From 5cf2462c8f459774599983445c54b7960e229bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96yk=C3=BC=20S=C3=BCoglu?= Date: Thu, 25 Jun 2026 07:30:16 +0200 Subject: [PATCH 1/6] plotting tests tolerance increased, submodule pointer --- submodules/ehrdata | 2 +- tests/conftest.py | 4 ++- tests/plot/test_missingno_pl_api.py | 8 +++--- tests/plot/test_sankey.py | 2 -- tests/plot/test_scanpy_pl_api.py | 25 ++++++++----------- .../cohort_tracking/test_cohort_tracking.py | 11 ++++---- 6 files changed, 23 insertions(+), 29 deletions(-) diff --git a/submodules/ehrdata b/submodules/ehrdata index c96d7311..ed47643b 160000 --- a/submodules/ehrdata +++ b/submodules/ehrdata @@ -1 +1 @@ -Subproject commit c96d7311508feaad2c22fbb115aead86a8e11e19 +Subproject commit ed47643b9116226b178c8675a4b46e0853bf511f diff --git a/tests/conftest.py b/tests/conftest.py index 84c8bbdc..51e5d8a0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -486,7 +486,9 @@ def check_same_image( fig: Figure | hv.core.overlay.Overlay | hv.element.chart.Scatter | hv.Element, base_path: Path | os.PathLike, *, - tol: float, + # default mirrors scanpy's most common image-comparison tolerance (RMS on a + # 0-255 scale); individual tests bump this where rendering legitimately differs more. + tol: float = 15, ) -> None: expected = Path(base_path).parent / (Path(base_path).name + "_expected.png") if not Path(expected).is_file(): diff --git a/tests/plot/test_missingno_pl_api.py b/tests/plot/test_missingno_pl_api.py index 50a27fda..d596dffa 100644 --- a/tests/plot/test_missingno_pl_api.py +++ b/tests/plot/test_missingno_pl_api.py @@ -23,7 +23,7 @@ def test_missing_values_barplot(mimic_2, check_same_image, layer, clean_up_plots check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/missing_values_barplot", - tol=5, + tol=25, ) @@ -43,7 +43,7 @@ def test_missing_values_matrixplot(mimic_2, check_same_image, layer, clean_up_pl check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/missing_values_matrix", - tol=2e-1, + tol=25, ) @@ -63,7 +63,7 @@ def test_missing_values_heatmap(mimic_2, check_same_image, layer, clean_up_plots check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/missing_values_heatmap", - tol=2e-1, + tol=25, ) @@ -83,7 +83,7 @@ def test_missing_values_dendogram(mimic_2, check_same_image, layer): check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/missing_values_dendogram", - tol=2e-1, + tol=25, ) diff --git a/tests/plot/test_sankey.py b/tests/plot/test_sankey.py index 4ad1a00f..bafae648 100644 --- a/tests/plot/test_sankey.py +++ b/tests/plot/test_sankey.py @@ -21,7 +21,6 @@ def test_sankey_plot(diabetes_130_fairlearn_sample_100, check_same_image, hv_bac check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/sankey", - tol=2e-1, ) @@ -41,7 +40,6 @@ def test_sankey_time_plot(check_same_image, hv_backend): check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/sankey_time", - tol=2e-1, ) diff --git a/tests/plot/test_scanpy_pl_api.py b/tests/plot/test_scanpy_pl_api.py index f7c84a2e..8e452e13 100644 --- a/tests/plot/test_scanpy_pl_api.py +++ b/tests/plot/test_scanpy_pl_api.py @@ -26,7 +26,6 @@ def test_scatter_plot(mimic_2, check_same_image): check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/scatter_scanpy_plt", - tol=2e-1, ) plt.close("all") @@ -51,7 +50,7 @@ def test_heatmap_plot(edata_mini, check_same_image): check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/heatmap_scanpy_plt", - tol=2e-1, + tol=25, ) plt.close("all") @@ -149,7 +148,7 @@ def test_dotplot_plot_image(mimic_2, check_same_image): check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/dotplot_scanpy_plt", - tol=2e-1, + tol=25, ) plt.close("all") @@ -181,7 +180,7 @@ def test_tracks_plot(mimic_2, check_same_image): check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/tracksplot_scanpy_plt", - tol=2e-1, + tol=25, ) plt.close("all") @@ -206,7 +205,6 @@ def test_violin_plot(mimic_2, check_same_image): check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/violin_scanpy_plt", - tol=2e-1, ) plt.close("all") @@ -255,7 +253,7 @@ def test_matrix_plot(mimic_2, check_same_image): check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/matrix_scanpy_plot", - tol=2e-1, + tol=25, ) plt.close("all") @@ -287,7 +285,7 @@ def test_stacked_violin_plot(mimic_2, check_same_image): check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/stacked_violin_scanpy_plt", - tol=2e-1, + tol=25, ) plt.close("all") @@ -313,7 +311,6 @@ def test_clustermap(mimic_2_encoded, check_same_image): check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/clustermap_scanpy", - tol=2e-1, ) plt.close("all") @@ -424,7 +421,7 @@ def test_rank_features_groups_heatmap(mimic_2_encoded, check_same_image): check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/rank_features_groups_heatmap_scanpy", - tol=2e-1, + tol=25, ) plt.close("all") @@ -482,7 +479,7 @@ def test_rank_features_groups_dotplot_image(mimic_2_encoded, check_same_image): check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/rank_features_groups_dotplot_scanpy", - tol=2e-1, + tol=25, ) plt.close("all") @@ -505,7 +502,6 @@ def test_pca(mimic_2_sample_serv_unit_day_icu, check_same_image): check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/pca", - tol=2e-1, ) plt.close("all") @@ -527,7 +523,7 @@ def test_pca_loadings(mimic_2_sample_serv_unit_day_icu, check_same_image): check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/pca_loadings", - tol=2e-1, + tol=40, ) plt.close("all") @@ -550,7 +546,7 @@ def test_pca_variance_ration(mimic_2_sample_serv_unit_day_icu, check_same_image) check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/pca_variance_ratio", - tol=2e-1, + tol=25, ) plt.close("all") @@ -578,7 +574,6 @@ def test_pca_overview(mimic_2_sample_serv_unit_day_icu, check_same_image, clean_ check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/pca_overview_{id}", - tol=2e-1, ) @@ -671,5 +666,5 @@ def test_dpt_timeseries(mimic_2_encoded, check_same_image): check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/dpt_timeseries", - tol=2e-1, + tol=35, ) diff --git a/tests/tools/cohort_tracking/test_cohort_tracking.py b/tests/tools/cohort_tracking/test_cohort_tracking.py index 9f1e86ab..3889f118 100644 --- a/tests/tools/cohort_tracking/test_cohort_tracking.py +++ b/tests/tools/cohort_tracking/test_cohort_tracking.py @@ -91,7 +91,7 @@ def test_CohortTracker_plot_cohort_barplot_vanilla(edata_mini, check_same_image) check_same_image( fig=fig1, base_path=f"{_TEST_IMAGE_PATH}/cohorttracker_edata_mini_step1_vanilla", - tol=1e-1, + tol=35, ) ct(edata_mini, label="Second step", operations_done="Some other operations") @@ -100,7 +100,7 @@ def test_CohortTracker_plot_cohort_barplot_vanilla(edata_mini, check_same_image) check_same_image( fig=fig2, base_path=f"{_TEST_IMAGE_PATH}/cohorttracker_edata_mini_step2_vanilla", - tol=1e-1, + tol=35, ) @@ -117,7 +117,7 @@ def test_CohortTracker_plot_cohort_barplot_use_settings(edata_mini, check_same_i check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/cohorttracker_edata_mini_step1_use_settings", - tol=1e-1, + tol=35, ) @@ -136,7 +136,7 @@ def test_CohortTracker_plot_cohort_barplot_use_settings_big(edata_mini, check_sa check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/cohorttracker_edata_mini_step1_use_settings_big", - tol=1e-1, + tol=35, ) @@ -154,7 +154,7 @@ def test_CohortTracker_plot_cohort_barplot_loosing_category(edata_mini, check_sa check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/cohorttracker_edata_mini_step2_loose_category", - tol=1e-1, + tol=35, ) @@ -234,7 +234,6 @@ def test_CohortTracker_flowchart_image(edata_mini, check_same_image): check_same_image( fig=plot, base_path=f"{_TEST_IMAGE_PATH}/cohorttracker_edata_mini_flowchart", - tol=1e-1, ) From e5d9214f0368b3a37447236a46bf5c5a6ecf0278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96yk=C3=BC=20S=C3=BCoglu?= Date: Thu, 25 Jun 2026 11:44:52 +0200 Subject: [PATCH 2/6] tolerance increased in the plots of pca_overview and ncp --- tests/plot/test_ncp.py | 4 ++-- tests/plot/test_scanpy_pl_api.py | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/plot/test_ncp.py b/tests/plot/test_ncp.py index caa7c9ed..5b6eabe6 100644 --- a/tests/plot/test_ncp.py +++ b/tests/plot/test_ncp.py @@ -76,7 +76,7 @@ def test_pl_ncp_image(edata_with_ncp: ed.EHRData, check_same_image, hv_backend) check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/ncp", - tol=2e-1, + tol=30, ) @@ -152,5 +152,5 @@ def test_pl_ncp_cluster_trajectories_image(edata_with_ncp: ed.EHRData, check_sam check_same_image( fig=fig, base_path=f"{_TEST_IMAGE_PATH}/ncp_cluster_trajectories", - tol=2e-1, + tol=35, ) diff --git a/tests/plot/test_scanpy_pl_api.py b/tests/plot/test_scanpy_pl_api.py index 8e452e13..eb11db41 100644 --- a/tests/plot/test_scanpy_pl_api.py +++ b/tests/plot/test_scanpy_pl_api.py @@ -571,10 +571,7 @@ def test_pca_overview(mimic_2_sample_serv_unit_day_icu, check_same_image, clean_ fig.set_size_inches(8, 6) fig.subplots_adjust(left=0.2, right=0.8, bottom=0.2, top=0.8) - check_same_image( - fig=fig, - base_path=f"{_TEST_IMAGE_PATH}/pca_overview_{id}", - ) + check_same_image(fig=fig, base_path=f"{_TEST_IMAGE_PATH}/pca_overview_{id}", tol=40) def test_umap_functionality(mimic_2_sample_serv_unit_day_icu): From daace6900351cf1f24cf5ed98b2b276efb121bfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96yk=C3=BC=20S=C3=BCoglu?= Date: Thu, 25 Jun 2026 15:45:59 +0200 Subject: [PATCH 3/6] exclude matplotlib 3.11 (temporarily) --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 601e2b33..5154df82 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,6 +48,8 @@ classifiers = [ dependencies = [ "ehrdata", "scanpy", + # mirroring scanpy: skip 3.11.0 series for now: https://github.com/matplotlib/matplotlib/issues/31575 + "matplotlib>=3.10,!=3.11.0rc1,!=3.11.0rc2,!=3.11", "scverse-misc[settings]>=0.0.7", "requests", "miceforest", From be9ac5b97d7bf54877fac87a677e7b49fac5616b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96yk=C3=BC=20S=C3=BCoglu?= Date: Wed, 1 Jul 2026 12:06:01 +0200 Subject: [PATCH 4/6] Update tests/conftest.py Co-authored-by: Eljas Roellin <65244425+eroell@users.noreply.github.com> --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 51e5d8a0..8139a753 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -486,7 +486,7 @@ def check_same_image( fig: Figure | hv.core.overlay.Overlay | hv.element.chart.Scatter | hv.Element, base_path: Path | os.PathLike, *, - # default mirrors scanpy's most common image-comparison tolerance (RMS on a + # default mirrors scanpy's most common image-comparison tolerance 15 (RMS on a 0-255 scale). https://github.com/scverse/scanpy/blob/ee7707bc208132cca8387e542d0532f6967f68cc/tests/test_plotting.py#L567. Individual tests bump this where rendering legitimately differs more. # 0-255 scale); individual tests bump this where rendering legitimately differs more. tol: float = 15, ) -> None: From 24f53fa99d6972c4e1c6dfc888087b62455065a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96yk=C3=BC=20S=C3=BCoglu?= Date: Wed, 1 Jul 2026 12:06:09 +0200 Subject: [PATCH 5/6] Update tests/conftest.py Co-authored-by: Eljas Roellin <65244425+eroell@users.noreply.github.com> --- tests/conftest.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 8139a753..45a64c3c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -487,7 +487,6 @@ def check_same_image( base_path: Path | os.PathLike, *, # default mirrors scanpy's most common image-comparison tolerance 15 (RMS on a 0-255 scale). https://github.com/scverse/scanpy/blob/ee7707bc208132cca8387e542d0532f6967f68cc/tests/test_plotting.py#L567. Individual tests bump this where rendering legitimately differs more. - # 0-255 scale); individual tests bump this where rendering legitimately differs more. tol: float = 15, ) -> None: expected = Path(base_path).parent / (Path(base_path).name + "_expected.png") From 7ac16fc80d3f26f5f52df935642c64fbda3dfeac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96yk=C3=BC=20S=C3=BCoglu?= Date: Wed, 1 Jul 2026 12:38:18 +0200 Subject: [PATCH 6/6] permalinked the line in scanpy pyproject.toml as ref --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 607a7490..e3bce450 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,7 @@ dependencies = [ "ehrdata", "pooch", # required by the ehrdata submodule, which is installed with --no-deps "scanpy", - # mirroring scanpy: skip 3.11.0 series for now: https://github.com/matplotlib/matplotlib/issues/31575 + # mirroring scanpy, skip 3.11.0 series for now: https://github.com/matplotlib/matplotlib/issues/31575https://github.com/scverse/scanpy/blob/d5a745e1258f5ca6a23c6a790f27b40d7ad05418/pyproject.toml#L60 "matplotlib>=3.10,!=3.11.0rc1,!=3.11.0rc2,!=3.11", "scverse-misc[settings]>=0.0.7", "requests",