Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lee1043 committed Dec 2, 2024
1 parent 24ef26f commit 5e2929e
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
66 changes: 66 additions & 0 deletions tests/test_core_portrait_plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import unittest

import numpy as np
from bokeh.plotting import Figure

from ESMBenchmarkViz import portrait_plot


class TestPortraitPlot(unittest.TestCase):
def test_minimal_valid_input(self):
data = np.array([[1, 2], [3, 4]])
xaxis_labels = ["A", "B"]
yaxis_labels = ["C", "D"]
plot = portrait_plot(data, xaxis_labels, yaxis_labels, show_plot=False)
self.assertIsInstance(plot, Figure)

def test_3d_data_input(self):
data = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
xaxis_labels = ["A", "B"]
yaxis_labels = ["C", "D"]
plot = portrait_plot(data, xaxis_labels, yaxis_labels, show_plot=False)
self.assertIsInstance(plot, Figure)

def test_with_annotations(self):
data = np.array([[1, 2], [3, 4]])
annotate_data = np.array([[0.1, 0.2], [0.3, 0.4]])
xaxis_labels = ["A", "B"]
yaxis_labels = ["C", "D"]
plot = portrait_plot(
data,
xaxis_labels,
yaxis_labels,
annotate=True,
annotate_data=annotate_data,
show_plot=False,
)
self.assertIsInstance(plot, Figure)

def test_clickable_urls(self):
data = np.array([[1, 2], [3, 4]])
xaxis_labels = ["A", "B"]
yaxis_labels = ["C", "D"]
img_url = ["http://example.com/img1", "http://example.com/img2"]
plot = portrait_plot(
data,
xaxis_labels,
yaxis_labels,
clickable=True,
img_url=img_url,
show_plot=False,
)
self.assertIsInstance(plot, Figure)

def test_custom_color_map_bounds(self):
data = np.array([[1, 2], [3, 4]])
xaxis_labels = ["A", "B"]
yaxis_labels = ["C", "D"]
cmap_bounds = [0, 2, 4]
plot = portrait_plot(
data, xaxis_labels, yaxis_labels, cmap_bounds=cmap_bounds, show_plot=False
)
self.assertIsInstance(plot, Figure)


if __name__ == "__main__":
unittest.main()
2 changes: 1 addition & 1 deletion tests/test_core_scatter_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure

from ESMBenchmarkViz.core_scatter_plot import scatter_plot
from ESMBenchmarkViz import scatter_plot


class TestScatterPlot(unittest.TestCase):
Expand Down

0 comments on commit 5e2929e

Please sign in to comment.