From 5e2929edfff73af760a2f16608a32d1eaeef7556 Mon Sep 17 00:00:00 2001 From: Jiwoo Lee Date: Sun, 1 Dec 2024 18:50:01 -0800 Subject: [PATCH 1/4] initial commit --- tests/test_core_portrait_plot.py | 66 ++++++++++++++++++++++++++++++++ tests/test_core_scatter_plot.py | 2 +- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 tests/test_core_portrait_plot.py diff --git a/tests/test_core_portrait_plot.py b/tests/test_core_portrait_plot.py new file mode 100644 index 0000000..da152c7 --- /dev/null +++ b/tests/test_core_portrait_plot.py @@ -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() diff --git a/tests/test_core_scatter_plot.py b/tests/test_core_scatter_plot.py index 31ef8ae..3ab7ac0 100644 --- a/tests/test_core_scatter_plot.py +++ b/tests/test_core_scatter_plot.py @@ -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): From ded75b1bb4df9a3a5b62d59573b2ce0178913dd2 Mon Sep 17 00:00:00 2001 From: Jiwoo Lee Date: Sun, 1 Dec 2024 18:56:50 -0800 Subject: [PATCH 2/4] typo fix --- tests/test_core_portrait_plot.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/test_core_portrait_plot.py b/tests/test_core_portrait_plot.py index da152c7..4e18703 100644 --- a/tests/test_core_portrait_plot.py +++ b/tests/test_core_portrait_plot.py @@ -1,7 +1,7 @@ import unittest import numpy as np -from bokeh.plotting import Figure +from bokeh.plotting import figure from ESMBenchmarkViz import portrait_plot @@ -12,14 +12,14 @@ def test_minimal_valid_input(self): xaxis_labels = ["A", "B"] yaxis_labels = ["C", "D"] plot = portrait_plot(data, xaxis_labels, yaxis_labels, show_plot=False) - self.assertIsInstance(plot, Figure) + 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) + self.assertIsInstance(plot, figure) def test_with_annotations(self): data = np.array([[1, 2], [3, 4]]) @@ -34,13 +34,13 @@ def test_with_annotations(self): annotate_data=annotate_data, show_plot=False, ) - self.assertIsInstance(plot, Figure) + 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"] + img_url = ["http://example.com/img1", "http://example.com/img2", "http://example.com/img3", "http://example.com/img4"] plot = portrait_plot( data, xaxis_labels, @@ -49,7 +49,7 @@ def test_clickable_urls(self): img_url=img_url, show_plot=False, ) - self.assertIsInstance(plot, Figure) + self.assertIsInstance(plot, figure) def test_custom_color_map_bounds(self): data = np.array([[1, 2], [3, 4]]) @@ -59,7 +59,7 @@ def test_custom_color_map_bounds(self): plot = portrait_plot( data, xaxis_labels, yaxis_labels, cmap_bounds=cmap_bounds, show_plot=False ) - self.assertIsInstance(plot, Figure) + self.assertIsInstance(plot, figure) if __name__ == "__main__": From e31f18521208e27e2b016e8c936f4990617d321e Mon Sep 17 00:00:00 2001 From: Jiwoo Lee Date: Sun, 1 Dec 2024 18:59:57 -0800 Subject: [PATCH 3/4] Update build_workflow.yml --- .github/workflows/build_workflow.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_workflow.yml b/.github/workflows/build_workflow.yml index f8cbda8..a4c4e10 100644 --- a/.github/workflows/build_workflow.yml +++ b/.github/workflows/build_workflow.yml @@ -6,7 +6,6 @@ on: pull_request: branches: [main] - types: [ready_for_review] workflow_dispatch: @@ -16,7 +15,6 @@ env: jobs: check-jobs-to-skip: - if: ${{ github.event.pull_request.draft != true }} runs-on: ubuntu-latest outputs: should_skip: ${{ steps.skip_check.outputs.should_skip }} @@ -29,7 +27,7 @@ jobs: pre-commit-hooks: needs: check-jobs-to-skip - if: ${{ (needs.check-jobs-to-skip.outputs.should_skip != 'true' || github.event_name == 'push') && github.event.pull_request.draft != true }} + if: ${{ needs.check-jobs-to-skip.outputs.should_skip != 'true' }} || ${{ github.event_name == 'push' }} runs-on: ubuntu-latest timeout-minutes: 10 steps: @@ -46,7 +44,7 @@ jobs: build: needs: check-jobs-to-skip - if: ${{ (needs.check-jobs-to-skip.outputs.should_skip != 'true' || github.event_name == 'push') && github.event.pull_request.draft != true }} + if: ${{ needs.check-jobs-to-skip.outputs.should_skip != 'true' }} || ${{ github.event_name == 'push' }} runs-on: ubuntu-latest defaults: run: @@ -100,7 +98,7 @@ jobs: publish-docs: - if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request') && github.event.pull_request.draft != true }} + if: ${{ github.event_name == 'push' }} || ${{ github.event_name == 'pull_request' }} runs-on: ubuntu-latest defaults: run: From 4e689838767a9eabb2adf266999d6d7919c8f1f7 Mon Sep 17 00:00:00 2001 From: Jiwoo Lee Date: Sun, 1 Dec 2024 19:01:47 -0800 Subject: [PATCH 4/4] pre-commit fix --- tests/test_core_portrait_plot.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_core_portrait_plot.py b/tests/test_core_portrait_plot.py index 4e18703..dbbf8d2 100644 --- a/tests/test_core_portrait_plot.py +++ b/tests/test_core_portrait_plot.py @@ -40,7 +40,12 @@ 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", "http://example.com/img3", "http://example.com/img4"] + img_url = [ + "http://example.com/img1", + "http://example.com/img2", + "http://example.com/img3", + "http://example.com/img4", + ] plot = portrait_plot( data, xaxis_labels,