From d12d7b35be9a8bdce9611760fcb37d22b11d4583 Mon Sep 17 00:00:00 2001 From: Davis Vann Bennett Date: Mon, 20 Oct 2025 14:17:37 +0200 Subject: [PATCH 1/4] trim down test configuration to reduce runtime --- tests/conftest.py | 2 +- tests/test_indexing.py | 74 +++++++++++++----------------------------- 2 files changed, 23 insertions(+), 53 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 63c8950cff..7213cc9ca7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -231,7 +231,7 @@ def pytest_collection_modifyitems(config: Any, items: Any) -> None: settings.register_profile( "default", parent=settings.get_profile("default"), - max_examples=300, + max_examples=50, # Reduced from 300 for faster local testing suppress_health_check=[HealthCheck.filter_too_much, HealthCheck.too_slow], deadline=None, verbosity=Verbosity.verbose, diff --git a/tests/test_indexing.py b/tests/test_indexing.py index 609db6cdce..d8c48b7871 100644 --- a/tests/test_indexing.py +++ b/tests/test_indexing.py @@ -605,17 +605,12 @@ def test_get_orthogonal_selection_1d_int(store: StorePath) -> None: z = zarr_array_from_numpy_array(store, a, chunk_shape=(100,)) np.random.seed(42) - # test with different degrees of sparseness - for p in 2, 0.5, 0.1, 0.01: - # unordered + # test with different degrees of sparseness (reduced from 4 to 2 levels) + for p in 0.5, 0.01: + # sorted increasing (combined unordered, sorted, and reversed) ix = np.random.choice(a.shape[0], size=int(a.shape[0] * p), replace=True) - _test_get_orthogonal_selection(a, z, ix) - # increasing ix.sort() _test_get_orthogonal_selection(a, z, ix) - # decreasing - ix = ix[::-1] - _test_get_orthogonal_selection(a, z, ix) selections = basic_selections_1d + [ # test wraparound @@ -664,8 +659,8 @@ def test_get_orthogonal_selection_2d(store: StorePath) -> None: z = zarr_array_from_numpy_array(store, a, chunk_shape=(300, 3)) np.random.seed(42) - # test with different degrees of sparseness - for p in 0.5, 0.1, 0.01: + # test with different degrees of sparseness (reduced from 3 to 2 levels) + for p in 0.5, 0.01: # boolean arrays ix0 = np.random.binomial(1, p, size=a.shape[0]).astype(bool) ix1 = np.random.binomial(1, 0.5, size=a.shape[1]).astype(bool) @@ -679,16 +674,12 @@ def test_get_orthogonal_selection_2d(store: StorePath) -> None: for selection in selections: _test_get_orthogonal_selection(a, z, selection) - # integer arrays + # integer arrays with sorted increasing (combined two tests) ix0 = np.random.choice(a.shape[0], size=int(a.shape[0] * p), replace=True) ix1 = np.random.choice(a.shape[1], size=int(a.shape[1] * 0.5), replace=True) - _test_get_orthogonal_selection_2d(a, z, ix0, ix1) ix0.sort() ix1.sort() _test_get_orthogonal_selection_2d(a, z, ix0, ix1) - ix0 = ix0[::-1] - ix1 = ix1[::-1] - _test_get_orthogonal_selection_2d(a, z, ix0, ix1) for selection_2d in basic_selections_2d: _test_get_orthogonal_selection(a, z, selection_2d) @@ -747,27 +738,22 @@ def test_get_orthogonal_selection_3d(store: StorePath) -> None: z = zarr_array_from_numpy_array(store, a, chunk_shape=(60, 20, 3)) np.random.seed(42) - # test with different degrees of sparseness - for p in 0.5, 0.1, 0.01: + # test with different degrees of sparseness (reduced from 3 to 2 levels) + for p in 0.5, 0.01: # boolean arrays ix0 = np.random.binomial(1, p, size=a.shape[0]).astype(bool) ix1 = np.random.binomial(1, 0.5, size=a.shape[1]).astype(bool) ix2 = np.random.binomial(1, 0.5, size=a.shape[2]).astype(bool) _test_get_orthogonal_selection_3d(a, z, ix0, ix1, ix2) - # integer arrays + # integer arrays with sorted increasing (combined two tests) ix0 = np.random.choice(a.shape[0], size=int(a.shape[0] * p), replace=True) ix1 = np.random.choice(a.shape[1], size=int(a.shape[1] * 0.5), replace=True) ix2 = np.random.choice(a.shape[2], size=int(a.shape[2] * 0.5), replace=True) - _test_get_orthogonal_selection_3d(a, z, ix0, ix1, ix2) ix0.sort() ix1.sort() ix2.sort() _test_get_orthogonal_selection_3d(a, z, ix0, ix1, ix2) - ix0 = ix0[::-1] - ix1 = ix1[::-1] - ix2 = ix2[::-1] - _test_get_orthogonal_selection_3d(a, z, ix0, ix1, ix2) def test_orthogonal_indexing_edge_cases(store: StorePath) -> None: @@ -809,20 +795,17 @@ def test_set_orthogonal_selection_1d(store: StorePath) -> None: a = np.empty(v.shape, dtype=int) z = zarr_array_from_numpy_array(store, a, chunk_shape=(100,)) - # test with different degrees of sparseness + # test with different degrees of sparseness (reduced from 3 to 2 levels) np.random.seed(42) - for p in 0.5, 0.1, 0.01: + for p in 0.5, 0.01: # boolean arrays ix = np.random.binomial(1, p, size=a.shape[0]).astype(bool) _test_set_orthogonal_selection(v, a, z, ix) - # integer arrays + # integer arrays with sorted increasing (combined two tests) ix = np.random.choice(a.shape[0], size=int(a.shape[0] * p), replace=True) - _test_set_orthogonal_selection(v, a, z, ix) ix.sort() _test_set_orthogonal_selection(v, a, z, ix) - ix = ix[::-1] - _test_set_orthogonal_selection(v, a, z, ix) # basic selections for selection in basic_selections_1d: @@ -875,23 +858,19 @@ def test_set_orthogonal_selection_2d(store: StorePath) -> None: z = zarr_array_from_numpy_array(store, a, chunk_shape=(300, 3)) np.random.seed(42) - # test with different degrees of sparseness - for p in 0.5, 0.1, 0.01: + # test with different degrees of sparseness (reduced from 3 to 2 levels) + for p in 0.5, 0.01: # boolean arrays ix0 = np.random.binomial(1, p, size=a.shape[0]).astype(bool) ix1 = np.random.binomial(1, 0.5, size=a.shape[1]).astype(bool) _test_set_orthogonal_selection_2d(v, a, z, ix0, ix1) - # integer arrays + # integer arrays with sorted increasing (combined two tests) ix0 = np.random.choice(a.shape[0], size=int(a.shape[0] * p), replace=True) ix1 = np.random.choice(a.shape[1], size=int(a.shape[1] * 0.5), replace=True) - _test_set_orthogonal_selection_2d(v, a, z, ix0, ix1) ix0.sort() ix1.sort() _test_set_orthogonal_selection_2d(v, a, z, ix0, ix1) - ix0 = ix0[::-1] - ix1 = ix1[::-1] - _test_set_orthogonal_selection_2d(v, a, z, ix0, ix1) for selection in basic_selections_2d: _test_set_orthogonal_selection(v, a, z, selection) @@ -937,32 +916,23 @@ def test_set_orthogonal_selection_3d(store: StorePath) -> None: z = zarr_array_from_numpy_array(store, a, chunk_shape=(60, 20, 3)) np.random.seed(42) - # test with different degrees of sparseness - for p in 0.5, 0.1, 0.01: + # test with different degrees of sparseness (reduced from 3 to 2 levels) + for p in 0.5, 0.01: # boolean arrays ix0 = np.random.binomial(1, p, size=a.shape[0]).astype(bool) ix1 = np.random.binomial(1, 0.5, size=a.shape[1]).astype(bool) ix2 = np.random.binomial(1, 0.5, size=a.shape[2]).astype(bool) _test_set_orthogonal_selection_3d(v, a, z, ix0, ix1, ix2) - # integer arrays + # integer arrays with sorted increasing (combined two tests) ix0 = np.random.choice(a.shape[0], size=int(a.shape[0] * p), replace=True) ix1 = np.random.choice(a.shape[1], size=int(a.shape[1] * 0.5), replace=True) ix2 = np.random.choice(a.shape[2], size=int(a.shape[2] * 0.5), replace=True) - _test_set_orthogonal_selection_3d(v, a, z, ix0, ix1, ix2) - - # sorted increasing ix0.sort() ix1.sort() ix2.sort() _test_set_orthogonal_selection_3d(v, a, z, ix0, ix1, ix2) - # sorted decreasing - ix0 = ix0[::-1] - ix1 = ix1[::-1] - ix2 = ix2[::-1] - _test_set_orthogonal_selection_3d(v, a, z, ix0, ix1, ix2) - def test_orthogonal_indexing_fallback_on_get_setitem(store: StorePath) -> None: z = zarr_array_from_numpy_array(store, np.zeros((20, 20))) @@ -1133,8 +1103,8 @@ def test_set_coordinate_selection_1d(store: StorePath) -> None: z = zarr_array_from_numpy_array(store, a, chunk_shape=(100,)) np.random.seed(42) - # test with different degrees of sparseness - for p in 2, 0.5, 0.1, 0.01: + # test with different degrees of sparseness (reduced from 4 to 2 levels) + for p in 0.5, 0.01: n = int(a.size * p) ix = np.random.choice(a.shape[0], size=n, replace=True) _test_set_coordinate_selection(v, a, z, ix) @@ -1157,8 +1127,8 @@ def test_set_coordinate_selection_2d(store: StorePath) -> None: z = zarr_array_from_numpy_array(store, a, chunk_shape=(300, 3)) np.random.seed(42) - # test with different degrees of sparseness - for p in 2, 0.5, 0.1, 0.01: + # test with different degrees of sparseness (reduced from 4 to 2 levels) + for p in 0.5, 0.01: n = int(a.size * p) ix0 = np.random.choice(a.shape[0], size=n, replace=True) ix1 = np.random.choice(a.shape[1], size=n, replace=True) From 3ebd32946870151e56907d21e79129dea207f7c1 Mon Sep 17 00:00:00 2001 From: Davis Vann Bennett Date: Mon, 20 Oct 2025 14:27:57 +0200 Subject: [PATCH 2/4] adjust comments and squeeze arrays to a smaller size --- tests/conftest.py | 2 +- tests/test_indexing.py | 98 +++++++++++++++++++++--------------------- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 7213cc9ca7..63e246c3ee 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -231,7 +231,7 @@ def pytest_collection_modifyitems(config: Any, items: Any) -> None: settings.register_profile( "default", parent=settings.get_profile("default"), - max_examples=50, # Reduced from 300 for faster local testing + max_examples=50, suppress_health_check=[HealthCheck.filter_too_much, HealthCheck.too_slow], deadline=None, verbosity=Verbosity.verbose, diff --git a/tests/test_indexing.py b/tests/test_indexing.py index d8c48b7871..c0bf7dd270 100644 --- a/tests/test_indexing.py +++ b/tests/test_indexing.py @@ -601,13 +601,13 @@ def test_get_orthogonal_selection_1d_bool(store: StorePath) -> None: # noinspection PyStatementEffect def test_get_orthogonal_selection_1d_int(store: StorePath) -> None: # setup - a = np.arange(1050, dtype=int) + a = np.arange(550, dtype=int) z = zarr_array_from_numpy_array(store, a, chunk_shape=(100,)) np.random.seed(42) - # test with different degrees of sparseness (reduced from 4 to 2 levels) + # test with different degrees of sparseness for p in 0.5, 0.01: - # sorted increasing (combined unordered, sorted, and reversed) + # sorted integer arrays ix = np.random.choice(a.shape[0], size=int(a.shape[0] * p), replace=True) ix.sort() _test_get_orthogonal_selection(a, z, ix) @@ -655,11 +655,11 @@ def _test_get_orthogonal_selection_2d( # noinspection PyStatementEffect def test_get_orthogonal_selection_2d(store: StorePath) -> None: # setup - a = np.arange(10000, dtype=int).reshape(1000, 10) + a = np.arange(5400, dtype=int).reshape(600, 9) z = zarr_array_from_numpy_array(store, a, chunk_shape=(300, 3)) np.random.seed(42) - # test with different degrees of sparseness (reduced from 3 to 2 levels) + # test with different degrees of sparseness for p in 0.5, 0.01: # boolean arrays ix0 = np.random.binomial(1, p, size=a.shape[0]).astype(bool) @@ -674,7 +674,7 @@ def test_get_orthogonal_selection_2d(store: StorePath) -> None: for selection in selections: _test_get_orthogonal_selection(a, z, selection) - # integer arrays with sorted increasing (combined two tests) + # sorted integer arrays ix0 = np.random.choice(a.shape[0], size=int(a.shape[0] * p), replace=True) ix1 = np.random.choice(a.shape[1], size=int(a.shape[1] * 0.5), replace=True) ix0.sort() @@ -700,33 +700,33 @@ def _test_get_orthogonal_selection_3d( ) -> None: selections = [ # single value - (84, 42, 4), + (60, 15, 4), (-1, -1, -1), # index all axes with array (ix0, ix1, ix2), # mixed indexing with single array / slices - (ix0, slice(15, 25), slice(1, 5)), - (slice(50, 70), ix1, slice(1, 5)), - (slice(50, 70), slice(15, 25), ix2), - (ix0, slice(15, 25, 5), slice(1, 5, 2)), - (slice(50, 70, 3), ix1, slice(1, 5, 2)), - (slice(50, 70, 3), slice(15, 25, 5), ix2), + (ix0, slice(10, 20), slice(1, 5)), + (slice(30, 50), ix1, slice(1, 5)), + (slice(30, 50), slice(10, 20), ix2), + (ix0, slice(10, 20, 5), slice(1, 5, 2)), + (slice(30, 50, 3), ix1, slice(1, 5, 2)), + (slice(30, 50, 3), slice(10, 20, 5), ix2), # mixed indexing with single array / ints - (ix0, 42, 4), - (84, ix1, 4), - (84, 42, ix2), + (ix0, 15, 4), + (60, ix1, 4), + (60, 15, ix2), # mixed indexing with single array / slice / int - (ix0, slice(15, 25), 4), - (42, ix1, slice(1, 5)), - (slice(50, 70), 42, ix2), + (ix0, slice(10, 20), 4), + (15, ix1, slice(1, 5)), + (slice(30, 50), 15, ix2), # mixed indexing with two array / slice (ix0, ix1, slice(1, 5)), - (slice(50, 70), ix1, ix2), - (ix0, slice(15, 25), ix2), + (slice(30, 50), ix1, ix2), + (ix0, slice(10, 20), ix2), # mixed indexing with two array / integer (ix0, ix1, 4), - (42, ix1, ix2), - (ix0, 42, ix2), + (15, ix1, ix2), + (ix0, 15, ix2), ] for selection in selections: _test_get_orthogonal_selection(a, z, selection) @@ -734,11 +734,11 @@ def _test_get_orthogonal_selection_3d( def test_get_orthogonal_selection_3d(store: StorePath) -> None: # setup - a = np.arange(100000, dtype=int).reshape(200, 50, 10) + a = np.arange(32400, dtype=int).reshape(120, 30, 9) z = zarr_array_from_numpy_array(store, a, chunk_shape=(60, 20, 3)) np.random.seed(42) - # test with different degrees of sparseness (reduced from 3 to 2 levels) + # test with different degrees of sparseness for p in 0.5, 0.01: # boolean arrays ix0 = np.random.binomial(1, p, size=a.shape[0]).astype(bool) @@ -746,7 +746,7 @@ def test_get_orthogonal_selection_3d(store: StorePath) -> None: ix2 = np.random.binomial(1, 0.5, size=a.shape[2]).astype(bool) _test_get_orthogonal_selection_3d(a, z, ix0, ix1, ix2) - # integer arrays with sorted increasing (combined two tests) + # sorted integer arrays ix0 = np.random.choice(a.shape[0], size=int(a.shape[0] * p), replace=True) ix1 = np.random.choice(a.shape[1], size=int(a.shape[1] * 0.5), replace=True) ix2 = np.random.choice(a.shape[2], size=int(a.shape[2] * 0.5), replace=True) @@ -791,18 +791,18 @@ def _test_set_orthogonal_selection( def test_set_orthogonal_selection_1d(store: StorePath) -> None: # setup - v = np.arange(1050, dtype=int) + v = np.arange(550, dtype=int) a = np.empty(v.shape, dtype=int) z = zarr_array_from_numpy_array(store, a, chunk_shape=(100,)) - # test with different degrees of sparseness (reduced from 3 to 2 levels) + # test with different degrees of sparseness np.random.seed(42) for p in 0.5, 0.01: # boolean arrays ix = np.random.binomial(1, p, size=a.shape[0]).astype(bool) _test_set_orthogonal_selection(v, a, z, ix) - # integer arrays with sorted increasing (combined two tests) + # sorted integer arrays ix = np.random.choice(a.shape[0], size=int(a.shape[0] * p), replace=True) ix.sort() _test_set_orthogonal_selection(v, a, z, ix) @@ -853,19 +853,19 @@ def _test_set_orthogonal_selection_2d( def test_set_orthogonal_selection_2d(store: StorePath) -> None: # setup - v = np.arange(10000, dtype=int).reshape(1000, 10) + v = np.arange(5400, dtype=int).reshape(600, 9) a = np.empty_like(v) z = zarr_array_from_numpy_array(store, a, chunk_shape=(300, 3)) np.random.seed(42) - # test with different degrees of sparseness (reduced from 3 to 2 levels) + # test with different degrees of sparseness for p in 0.5, 0.01: # boolean arrays ix0 = np.random.binomial(1, p, size=a.shape[0]).astype(bool) ix1 = np.random.binomial(1, 0.5, size=a.shape[1]).astype(bool) _test_set_orthogonal_selection_2d(v, a, z, ix0, ix1) - # integer arrays with sorted increasing (combined two tests) + # sorted integer arrays ix0 = np.random.choice(a.shape[0], size=int(a.shape[0] * p), replace=True) ix1 = np.random.choice(a.shape[1], size=int(a.shape[1] * 0.5), replace=True) ix0.sort() @@ -886,20 +886,20 @@ def _test_set_orthogonal_selection_3d( ) -> None: selections = ( # single value - (84, 42, 4), + (60, 15, 4), (-1, -1, -1), # index all axes with bool array (ix0, ix1, ix2), # mixed indexing with single bool array / slice or int - (ix0, slice(15, 25), slice(1, 5)), - (slice(50, 70), ix1, slice(1, 5)), - (slice(50, 70), slice(15, 25), ix2), - (ix0, 42, 4), - (84, ix1, 4), - (84, 42, ix2), - (ix0, slice(15, 25), 4), - (slice(50, 70), ix1, 4), - (slice(50, 70), 42, ix2), + (ix0, slice(10, 20), slice(1, 5)), + (slice(30, 50), ix1, slice(1, 5)), + (slice(30, 50), slice(10, 20), ix2), + (ix0, 15, 4), + (60, ix1, 4), + (60, 15, ix2), + (ix0, slice(10, 20), 4), + (slice(30, 50), ix1, 4), + (slice(30, 50), 15, ix2), # indexing with two arrays / slice (ix0, ix1, slice(1, 5)), # indexing with two arrays / integer @@ -911,12 +911,12 @@ def _test_set_orthogonal_selection_3d( def test_set_orthogonal_selection_3d(store: StorePath) -> None: # setup - v = np.arange(100000, dtype=int).reshape(200, 50, 10) + v = np.arange(32400, dtype=int).reshape(120, 30, 9) a = np.empty_like(v) z = zarr_array_from_numpy_array(store, a, chunk_shape=(60, 20, 3)) np.random.seed(42) - # test with different degrees of sparseness (reduced from 3 to 2 levels) + # test with different degrees of sparseness for p in 0.5, 0.01: # boolean arrays ix0 = np.random.binomial(1, p, size=a.shape[0]).astype(bool) @@ -924,7 +924,7 @@ def test_set_orthogonal_selection_3d(store: StorePath) -> None: ix2 = np.random.binomial(1, 0.5, size=a.shape[2]).astype(bool) _test_set_orthogonal_selection_3d(v, a, z, ix0, ix1, ix2) - # integer arrays with sorted increasing (combined two tests) + # sorted integer arrays ix0 = np.random.choice(a.shape[0], size=int(a.shape[0] * p), replace=True) ix1 = np.random.choice(a.shape[1], size=int(a.shape[1] * 0.5), replace=True) ix2 = np.random.choice(a.shape[2], size=int(a.shape[2] * 0.5), replace=True) @@ -1098,12 +1098,12 @@ def _test_set_coordinate_selection( def test_set_coordinate_selection_1d(store: StorePath) -> None: # setup - v = np.arange(1050, dtype=int) + v = np.arange(550, dtype=int) a = np.empty(v.shape, dtype=v.dtype) z = zarr_array_from_numpy_array(store, a, chunk_shape=(100,)) np.random.seed(42) - # test with different degrees of sparseness (reduced from 4 to 2 levels) + # test with different degrees of sparseness for p in 0.5, 0.01: n = int(a.size * p) ix = np.random.choice(a.shape[0], size=n, replace=True) @@ -1122,12 +1122,12 @@ def test_set_coordinate_selection_1d(store: StorePath) -> None: def test_set_coordinate_selection_2d(store: StorePath) -> None: # setup - v = np.arange(10000, dtype=int).reshape(1000, 10) + v = np.arange(5400, dtype=int).reshape(600, 9) a = np.empty_like(v) z = zarr_array_from_numpy_array(store, a, chunk_shape=(300, 3)) np.random.seed(42) - # test with different degrees of sparseness (reduced from 4 to 2 levels) + # test with different degrees of sparseness for p in 0.5, 0.01: n = int(a.size * p) ix0 = np.random.choice(a.shape[0], size=n, replace=True) From 4e431810449f730c21371792910020c4498483d7 Mon Sep 17 00:00:00 2001 From: Davis Vann Bennett Date: Mon, 20 Oct 2025 15:02:07 +0200 Subject: [PATCH 3/4] changelog --- changes/3533.misc.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/3533.misc.md diff --git a/changes/3533.misc.md b/changes/3533.misc.md new file mode 100644 index 0000000000..237efc9b5b --- /dev/null +++ b/changes/3533.misc.md @@ -0,0 +1 @@ +Reduced the runtime of the test suite by simplifying test cases. \ No newline at end of file From bde752d7eb8f65e191d3328ad8a436ecb0aa60f7 Mon Sep 17 00:00:00 2001 From: Davis Vann Bennett Date: Wed, 22 Oct 2025 14:15:34 +0200 Subject: [PATCH 4/4] revert to 300 max_examples --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 63e246c3ee..63c8950cff 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -231,7 +231,7 @@ def pytest_collection_modifyitems(config: Any, items: Any) -> None: settings.register_profile( "default", parent=settings.get_profile("default"), - max_examples=50, + max_examples=300, suppress_health_check=[HealthCheck.filter_too_much, HealthCheck.too_slow], deadline=None, verbosity=Verbosity.verbose,