From 544fe95519c542d375bbd553dba3771e62ea553f Mon Sep 17 00:00:00 2001 From: Niklas Netter Date: Mon, 21 Oct 2024 10:26:47 +0200 Subject: [PATCH] 2024-10-21 adding version 3.11 --- noxfile.py | 2 +- poetry.lock | 29 ++++---- pyproject.toml | 2 +- tests/test_naive_fusion.py | 146 ++++++++++++++----------------------- 4 files changed, 73 insertions(+), 106 deletions(-) diff --git a/noxfile.py b/noxfile.py index 5b1b610..4c1fca7 100644 --- a/noxfile.py +++ b/noxfile.py @@ -22,7 +22,7 @@ package = "merge_stardist_masks" -python_versions = ["3.10", "3.9", "3.8"] +python_versions = ["3.11", "3.10", "3.9", "3.8"] nox.needs_version = ">= 2021.6.6" nox.options.sessions = ( "pre-commit", diff --git a/poetry.lock b/poetry.lock index 63553e5..0c5b796 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1558,6 +1558,7 @@ files = [ [package.dependencies] numpy = [ {version = ">1.20", markers = "python_version <= \"3.9\""}, + {version = ">=1.23.3", markers = "python_version > \"3.10\""}, {version = ">=1.21.2", markers = "python_version > \"3.9\""}, ] @@ -3012,23 +3013,23 @@ files = [ [[package]] name = "tornado" -version = "6.3.2" +version = "6.3.3" description = "Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed." category = "dev" optional = false python-versions = ">= 3.8" files = [ - {file = "tornado-6.3.2-cp38-abi3-macosx_10_9_universal2.whl", hash = "sha256:c367ab6c0393d71171123ca5515c61ff62fe09024fa6bf299cd1339dc9456829"}, - {file = "tornado-6.3.2-cp38-abi3-macosx_10_9_x86_64.whl", hash = "sha256:b46a6ab20f5c7c1cb949c72c1994a4585d2eaa0be4853f50a03b5031e964fc7c"}, - {file = "tornado-6.3.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c2de14066c4a38b4ecbbcd55c5cc4b5340eb04f1c5e81da7451ef555859c833f"}, - {file = "tornado-6.3.2-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:05615096845cf50a895026f749195bf0b10b8909f9be672f50b0fe69cba368e4"}, - {file = "tornado-6.3.2-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5b17b1cf5f8354efa3d37c6e28fdfd9c1c1e5122f2cb56dac121ac61baa47cbe"}, - {file = "tornado-6.3.2-cp38-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:29e71c847a35f6e10ca3b5c2990a52ce38b233019d8e858b755ea6ce4dcdd19d"}, - {file = "tornado-6.3.2-cp38-abi3-musllinux_1_1_i686.whl", hash = "sha256:834ae7540ad3a83199a8da8f9f2d383e3c3d5130a328889e4cc991acc81e87a0"}, - {file = "tornado-6.3.2-cp38-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:6a0848f1aea0d196a7c4f6772197cbe2abc4266f836b0aac76947872cd29b411"}, - {file = "tornado-6.3.2-cp38-abi3-win32.whl", hash = "sha256:7efcbcc30b7c654eb6a8c9c9da787a851c18f8ccd4a5a3a95b05c7accfa068d2"}, - {file = "tornado-6.3.2-cp38-abi3-win_amd64.whl", hash = "sha256:0c325e66c8123c606eea33084976c832aa4e766b7dff8aedd7587ea44a604cdf"}, - {file = "tornado-6.3.2.tar.gz", hash = "sha256:4b927c4f19b71e627b13f3db2324e4ae660527143f9e1f2e2fb404f3a187e2ba"}, + {file = "tornado-6.3.3-cp38-abi3-macosx_10_9_universal2.whl", hash = "sha256:502fba735c84450974fec147340016ad928d29f1e91f49be168c0a4c18181e1d"}, + {file = "tornado-6.3.3-cp38-abi3-macosx_10_9_x86_64.whl", hash = "sha256:805d507b1f588320c26f7f097108eb4023bbaa984d63176d1652e184ba24270a"}, + {file = "tornado-6.3.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1bd19ca6c16882e4d37368e0152f99c099bad93e0950ce55e71daed74045908f"}, + {file = "tornado-6.3.3-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7ac51f42808cca9b3613f51ffe2a965c8525cb1b00b7b2d56828b8045354f76a"}, + {file = "tornado-6.3.3-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:71a8db65160a3c55d61839b7302a9a400074c9c753040455494e2af74e2501f2"}, + {file = "tornado-6.3.3-cp38-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:ceb917a50cd35882b57600709dd5421a418c29ddc852da8bcdab1f0db33406b0"}, + {file = "tornado-6.3.3-cp38-abi3-musllinux_1_1_i686.whl", hash = "sha256:7d01abc57ea0dbb51ddfed477dfe22719d376119844e33c661d873bf9c0e4a16"}, + {file = "tornado-6.3.3-cp38-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:9dc4444c0defcd3929d5c1eb5706cbe1b116e762ff3e0deca8b715d14bf6ec17"}, + {file = "tornado-6.3.3-cp38-abi3-win32.whl", hash = "sha256:65ceca9500383fbdf33a98c0087cb975b2ef3bfb874cb35b8de8740cf7f41bd3"}, + {file = "tornado-6.3.3-cp38-abi3-win_amd64.whl", hash = "sha256:22d3c2fa10b5793da13c807e6fc38ff49a4f6e1e3868b0a6f4164768bb8e20f5"}, + {file = "tornado-6.3.3.tar.gz", hash = "sha256:e7d8db41c0181c80d76c982aacc442c0783a2c54d6400fe028954201a2e032fe"}, ] [[package]] @@ -3273,5 +3274,5 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" -python-versions = ">=3.8,<3.11" -content-hash = "83476f42a3efac11cef8f0730009e5b6eaca6887a772cf5971b6fffb99cf4351" +python-versions = ">=3.8,<3.12" +content-hash = "4b561ec7082a2195c32d740bc851c1dd9a02659fbe688eed89c5b69f13781f8a" diff --git a/pyproject.toml b/pyproject.toml index 558ff58..e0d330c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ classifiers = [ Changelog = "https://github.com/gatoniel/merge-stardist-masks/releases" [tool.poetry.dependencies] -python = ">=3.8,<3.11" +python = ">=3.8,<3.12" stardist = ">=0.7.3,<0.9.0" numpy = ">=1.21.0" edt = "^2.3.0" diff --git a/tests/test_naive_fusion.py b/tests/test_naive_fusion.py index 965a434..8f7d32f 100644 --- a/tests/test_naive_fusion.py +++ b/tests/test_naive_fusion.py @@ -96,9 +96,7 @@ def test_values_of_points_from_grid(shape: IntTuple, grid: IntTuple) -> None: points = nf.points_from_grid(shape, grid) mesh = nf.mesh_from_shape(shape) - np.testing.assert_array_equal( # type: ignore [no-untyped-call] - mesh * np.array(grid), points - ) + np.testing.assert_array_equal(mesh * np.array(grid), points) def test_value_error_of_points_from_grid() -> None: @@ -137,16 +135,12 @@ def test_values_of_inflate_array( slices_list.append(slice(None)) slices = tuple(slices_list) # first test if values at grid points are correct - np.testing.assert_array_equal( # type: ignore [no-untyped-call] - inflated_array[slices], x - ) + np.testing.assert_array_equal(inflated_array[slices], x) # then test if default values are correct inds = np.ones_like(inflated_array, dtype=bool) inds[slices] = False - np.testing.assert_equal( # type: ignore [no-untyped-call] - inflated_array[inds], default_value - ) + np.testing.assert_equal(inflated_array[inds], default_value) def test_value_error_of_inflate_array() -> None: @@ -213,16 +207,14 @@ def test_my_polyhedron_to_label() -> None: assert my_label.shape == shape label = polyhedron_to_label( - np.expand_dims( # type: ignore [no-untyped-call] - np.clip(dists, 1e-3, None), axis=0 - ), - np.expand_dims(points, axis=0), # type: ignore [no-untyped-call] + np.expand_dims(np.clip(dists, 1e-3, None), axis=0), + np.expand_dims(points, axis=0), rays, shape, verbose=False, ) - np.testing.assert_array_equal(my_label, label) # type: ignore [no-untyped-call] + np.testing.assert_array_equal(my_label, label) def test_my_polygons_to_label() -> None: @@ -237,14 +229,12 @@ def test_my_polygons_to_label() -> None: assert my_label.shape == shape label = polygons_to_label( - np.expand_dims( # type: ignore [no-untyped-call] - np.clip(dists, 1e-3, None), axis=0 - ), - np.expand_dims(points, axis=0), # type: ignore [no-untyped-call] + np.expand_dims(np.clip(dists, 1e-3, None), axis=0), + np.expand_dims(points, axis=0), shape, ) - np.testing.assert_array_equal(my_label, label) # type: ignore [no-untyped-call] + np.testing.assert_array_equal(my_label, label) @pytest.fixture(params=[True, False]) @@ -348,9 +338,9 @@ def test_naive_fusion_3d( label[label == 2] = 2 label[label == 3] = 2 - np.testing.assert_array_equal(lbl, label) # type: ignore [no-untyped-call] - np.testing.assert_array_equal(lbl_iso, label) # type: ignore [no-untyped-call] - np.testing.assert_array_equal(lbl_aniso, label) # type: ignore [no-untyped-call] + np.testing.assert_array_equal(lbl, label) + np.testing.assert_array_equal(lbl_iso, label) + np.testing.assert_array_equal(lbl_aniso, label) @pytest.mark.filterwarnings( @@ -427,9 +417,9 @@ def test_naive_fusion_2d( print(lbl) print(label) - np.testing.assert_array_equal(lbl, label) # type: ignore [no-untyped-call] - np.testing.assert_array_equal(lbl_iso, label) # type: ignore [no-untyped-call] - np.testing.assert_array_equal(lbl_aniso, label) # type: ignore [no-untyped-call] + np.testing.assert_array_equal(lbl, label) + np.testing.assert_array_equal(lbl_iso, label) + np.testing.assert_array_equal(lbl_aniso, label) def test_naive_fusion_2d_with_overlaps() -> None: @@ -470,7 +460,7 @@ def test_naive_fusion_2d_with_overlaps() -> None: print(lbl) print(label) - np.testing.assert_array_equal(lbl, label) # type: ignore [no-untyped-call] + np.testing.assert_array_equal(lbl, label) def test_naive_fusion_2d_respect_probs() -> None: @@ -510,7 +500,7 @@ def test_naive_fusion_2d_respect_probs() -> None: print(lbl) print(label) - np.testing.assert_array_equal(lbl, label) # type: ignore [no-untyped-call] + np.testing.assert_array_equal(lbl, label) def test_naive_fusion_2d_anisotropic() -> None: @@ -563,7 +553,7 @@ def test_naive_fusion_2d_anisotropic() -> None: print(lbl) print(label) - np.testing.assert_array_equal(lbl, label) # type: ignore [no-untyped-call] + np.testing.assert_array_equal(lbl, label) def test_naive_fusion_2d_winding() -> None: @@ -626,17 +616,11 @@ def test_naive_fusion_2d_winding() -> None: print(label) # lbl without slicing should not work in this case - np.testing.assert_raises( # type: ignore [no-untyped-call] - AssertionError, np.testing.assert_array_equal, lbl, label - ) + np.testing.assert_raises(AssertionError, np.testing.assert_array_equal, lbl, label) # lbl with slicing should work - np.testing.assert_array_equal( # type: ignore [no-untyped-call] - lbl_no_slicing, label - ) + np.testing.assert_array_equal(lbl_no_slicing, label) # lbl with slicing and anisotropic version should also work - np.testing.assert_array_equal( # type: ignore [no-untyped-call] - lbl_no_slicing_anisotropic, label - ) + np.testing.assert_array_equal(lbl_no_slicing_anisotropic, label) def test_respect_probs_warning_in_naive_fusion() -> None: @@ -717,18 +701,14 @@ def test_paint_in_without_overlaps() -> None: lbl[1:, 1:] = True x = nf.paint_in_without_overlaps(np.zeros(shape), lbl, 1) - np.testing.assert_equal( # type: ignore [no-untyped-call] - x[1:, 1:], np.ones((2, 2)) - ) - np.testing.assert_equal(x[:, 0], np.zeros((3,))) # type: ignore [no-untyped-call] - np.testing.assert_equal(x[0, :], np.zeros((3,))) # type: ignore [no-untyped-call] + np.testing.assert_equal(x[1:, 1:], np.ones((2, 2))) + np.testing.assert_equal(x[:, 0], np.zeros((3,))) + np.testing.assert_equal(x[0, :], np.zeros((3,))) x = nf.paint_in_without_overlaps(np.ones(shape), lbl, 3) - np.testing.assert_equal( # type: ignore [no-untyped-call] - x[1:, 1:], 3 * np.ones((2, 2)) - ) - np.testing.assert_equal(x[:, 0], np.ones((3,))) # type: ignore [no-untyped-call] - np.testing.assert_equal(x[0, :], np.ones((3,))) # type: ignore [no-untyped-call] + np.testing.assert_equal(x[1:, 1:], 3 * np.ones((2, 2))) + np.testing.assert_equal(x[:, 0], np.ones((3,))) + np.testing.assert_equal(x[0, :], np.ones((3,))) def test_paint_in_with_overlaps() -> None: @@ -738,56 +718,46 @@ def test_paint_in_with_overlaps() -> None: lbl[1:, 1:] = True x = nf.paint_in_with_overlaps(np.zeros(shape), lbl, 1) - np.testing.assert_equal( # type: ignore [no-untyped-call] - x[1:, 1:], np.ones((2, 2)) - ) - np.testing.assert_equal(x[:, 0], np.zeros((3,))) # type: ignore [no-untyped-call] - np.testing.assert_equal(x[0, :], np.zeros((3,))) # type: ignore [no-untyped-call] + np.testing.assert_equal(x[1:, 1:], np.ones((2, 2))) + np.testing.assert_equal(x[:, 0], np.zeros((3,))) + np.testing.assert_equal(x[0, :], np.zeros((3,))) x = nf.paint_in_with_overlaps(np.ones(shape), lbl, 3) - np.testing.assert_equal( # type: ignore [no-untyped-call] - x[1:, 1:], -np.ones((2, 2)) - ) - np.testing.assert_equal(x[:, 0], np.ones((3,))) # type: ignore [no-untyped-call] - np.testing.assert_equal(x[0, :], np.ones((3,))) # type: ignore [no-untyped-call] + np.testing.assert_equal(x[1:, 1:], -np.ones((2, 2))) + np.testing.assert_equal(x[:, 0], np.ones((3,))) + np.testing.assert_equal(x[0, :], np.ones((3,))) y = np.zeros(shape) y[1, 1] = 2 x = nf.paint_in_with_overlaps(y, lbl, 3) assert x[1, 1] == -1 - np.testing.assert_equal( # type: ignore [no-untyped-call] - x[1:, 2], 3 * np.ones((2,)) - ) - np.testing.assert_equal( # type: ignore [no-untyped-call] - x[2, 1:], 3 * np.ones((2,)) - ) - np.testing.assert_equal(x[:, 0], np.zeros((3,))) # type: ignore [no-untyped-call] - np.testing.assert_equal(x[0, :], np.zeros((3,))) # type: ignore [no-untyped-call] + np.testing.assert_equal(x[1:, 2], 3 * np.ones((2,))) + np.testing.assert_equal(x[2, 1:], 3 * np.ones((2,))) + np.testing.assert_equal(x[:, 0], np.zeros((3,))) + np.testing.assert_equal(x[0, :], np.zeros((3,))) def test_paint_in_without_overlaps_check_probs() -> None: """Set values of an array and respect their probabilities function.""" shape = (3, 3) lbl = np.zeros(shape, dtype=bool) - new_probs = np.zeros(shape) + new_probs = np.zeros(shape, dtype=np.float32) lbl[1:, 1:] = True new_probs[1:, 1:] = 0.9 new_probs[2, 2] = 0.95 # nothing in paint_in paint_in = np.zeros(shape) - old_probs = np.zeros(shape) + old_probs = np.zeros(shape, np.float32) x, p = nf.paint_in_without_overlaps_check_probs( paint_in, lbl, old_probs, new_probs, 1 ) - np.testing.assert_equal( # type: ignore [no-untyped-call] - x[1:, 1:], np.ones((2, 2)) - ) - np.testing.assert_equal(x[:, 0], np.zeros((3,))) # type: ignore [no-untyped-call] - np.testing.assert_equal(x[0, :], np.zeros((3,))) # type: ignore [no-untyped-call] + np.testing.assert_equal(x[1:, 1:], np.ones((2, 2))) + np.testing.assert_equal(x[:, 0], np.zeros((3,))) + np.testing.assert_equal(x[0, :], np.zeros((3,))) - np.testing.assert_equal(p, new_probs) # type: ignore [no-untyped-call] + np.testing.assert_equal(p, new_probs) # too low probability in old_probs old_probs[1, 1] = 0.8 @@ -796,13 +766,11 @@ def test_paint_in_without_overlaps_check_probs() -> None: paint_in, lbl, old_probs, new_probs, 1 ) - np.testing.assert_equal( # type: ignore [no-untyped-call] - x[1:, 1:], np.ones((2, 2)) - ) - np.testing.assert_equal(x[:, 0], np.zeros((3,))) # type: ignore [no-untyped-call] - np.testing.assert_equal(x[0, :], np.zeros((3,))) # type: ignore [no-untyped-call] + np.testing.assert_equal(x[1:, 1:], np.ones((2, 2))) + np.testing.assert_equal(x[:, 0], np.zeros((3,))) + np.testing.assert_equal(x[0, :], np.zeros((3,))) - np.testing.assert_equal(p, new_probs) # type: ignore [no-untyped-call] + np.testing.assert_equal(p, new_probs) # too low probability in old_probs old_probs[2, 2] = 0.93 @@ -811,13 +779,11 @@ def test_paint_in_without_overlaps_check_probs() -> None: paint_in, lbl, old_probs, new_probs, 1 ) - np.testing.assert_equal( # type: ignore [no-untyped-call] - x[1:, 1:], np.ones((2, 2)) - ) - np.testing.assert_equal(x[:, 0], np.zeros((3,))) # type: ignore [no-untyped-call] - np.testing.assert_equal(x[0, :], np.zeros((3,))) # type: ignore [no-untyped-call] + np.testing.assert_equal(x[1:, 1:], np.ones((2, 2))) + np.testing.assert_equal(x[:, 0], np.zeros((3,))) + np.testing.assert_equal(x[0, :], np.zeros((3,))) - np.testing.assert_equal(p, new_probs) # type: ignore [no-untyped-call] + np.testing.assert_equal(p, new_probs) # too high probability in old_probs old_probs[1, 1] = 0.93 @@ -828,15 +794,15 @@ def test_paint_in_without_overlaps_check_probs() -> None: x_ = np.ones((2, 2)) x_[0, 0] = 3 - np.testing.assert_equal(x[1:, 1:], x_) # type: ignore [no-untyped-call] - np.testing.assert_equal(x[:, 0], np.zeros((3,))) # type: ignore [no-untyped-call] - np.testing.assert_equal(x[0, :], np.zeros((3,))) # type: ignore [no-untyped-call] + np.testing.assert_equal(x[1:, 1:], x_) + np.testing.assert_equal(x[:, 0], np.zeros((3,))) + np.testing.assert_equal(x[0, :], np.zeros((3,))) p_ = np.zeros(shape) p_[1:, 1:] = 0.9 p_[1, 1] = 0.93 p_[2, 2] = 0.95 - np.testing.assert_equal(p, p_) # type: ignore [no-untyped-call] + np.testing.assert_equal(p, p_) def test_polygon_list_with_probs_2d() -> None: @@ -879,4 +845,4 @@ def test_polygon_list_with_probs_2d() -> None: test_array[3:, 5:] = prob1 print(test_array) - np.testing.assert_equal(prob_array, test_array) # type: ignore [no-untyped-call] + np.testing.assert_equal(prob_array, test_array)