Skip to content

Commit 6ee1013

Browse files
Reduce time cost of tests (#1116)
* perf: session-scope blobs fixtures to cut setup time by ~10s Cache `blobs(256, 300, 3)` and `BlobsDataset()._labels_blobs()` once per session via private session-scoped fixtures, then deepcopy into each function-scoped fixture. Cuts fixture setup from 44.8s to 35.0s (-9.8s) and total suite from 186s to 180s. All 1332 tests still pass. Benchmark CSVs committed for reference (pytest_*.csv). Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * perf: use blobs(length=128) in test_vectorize to cut to_circles cost to_circles() on labels scales linearly with pixel count. Dropping from 512×512 to 128×128 cuts test_labels_2d_to_circles from ~3.9s to ~1.0s per parametrized variant (−4.7s across the file). Updated hardcoded coordinate/radius assertions to match the new size. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * chore: remove benchmark CSVs from repo * chore: remove benchmark stats csv * perf: eliminate double-validation in __setitem__ and use fast fixture deepcopy Two orthogonal wins: 1. _elements.py: `get_model()` already calls `schema.validate()` internally; the explicit second validate() + get_axes_names() call in every __setitem__ was redundant. Removing it halves the DataTree (_to_dataset_view) overhead per element insertion — directly speeds up fixture setup. 2. conftest.py: introduce `_fast_deepcopy_sdata` (copy.deepcopy + manual attrs restoration for DaskDataFrame/#503 and GeoDataFrame/#286) that is ~13x faster than sd_deepcopy (7ms vs 93ms for full_sdata). Session-scope full_sdata, images, labels and the 'full' sdata parametrized fixture; each test gets a fresh 7ms copy instead of an 87ms full reconstruction. Also switch sdata_blobs from sd_deepcopy to fast_deepcopy_sdata (2ms vs 25ms). Full suite: 186s → 163s (~12% reduction, ~23s saved). Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * perf: add validate=False option to get_model, clarify setitem validation comment - get_model() now accepts validate=False to skip schema.validate() when the caller only needs to infer the element type without re-running validation - add comment to Elements.__setitem__ noting that subclass overrides call get_model() which performs the validation - drop Python 3.13 CI matrix entries (superseded by 3.14) Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * perf: skip re-validation when building SpatialData from already-valid elements Add skip_element_validation() context manager (backed by a ContextVar) that makes __setitem__ call get_model(validate=False) — type inference only, no schema.validate(). Use it in every code path that constructs a SpatialData from elements that originated from an existing SpatialData and were never externally mutated: bounding_box_query, polygon_query, query_by_coordinate_system, transform_to_coordinate_system, subset, and init_from_elements. test_query_spatial_data: 0.77s → 0.64s (the remaining time is the query work itself — filtering, shapely ops, raster cropping). Also inline a minimal 2-image SpatialData in test_transformations_between_coordinate_systems instead of relying on the full 8-element images fixture; the test only ever uses image2d and image2d_multiscale, so writing the other 6 to disk was pure waste. test_transformations_between_coordinate_systems: 0.61s → 0.44s. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * Revert "perf: skip re-validation when building SpatialData from already-valid elements" This reverts commit acb25b1. * perf: vectorize label centroid computation, 30x speedup Replace per-slice O(H+W) approach (512 dask compute() calls for a 256×256 array) with a single array materialization + np.bincount O(n_pixels) pass. This speeds up get_centroids() on labels from ~1.5s to ~50ms, cutting to_circles(labels) from ~1.6s to ~53ms. Affects test_validation dataloader variants (~2.5s → ~0.2s each, saving ~9s), test_labels_2d_to_circles, and any production call to get_centroids or to_circles on label arrays. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * perf: session-scope blobs fixtures in concatenate and get_attrs tests Add blobs_factory fixture that returns fast deepcopies of the session-scoped blobs dataset, and update test_concatenate_* and test_no_shared_transformations to use it instead of calling blobs() per test. Also update test_get_attrs.py sdata_attrs fixture and test_empty_attrs to use sdata_blobs. The concatenate parametrized tests (6 variants) drop from ~0.55s to ~0.02s each (~3s total savings); test_get_attrs drops from ~0.28s to ~0.02s per test. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * perf: reduce categories and partitions in test_categories_on_partitioned_dataframe Drop from 200 to 20 for both N_PARTITIONS and the number of gene categories. The test's assertions (round-trip values, category-order mismatch between pandas and dask, dtype) are all preserved at the smaller scale; the 200-partition stress test was over-specified for what's actually being verified. ~1.56s → ~0.95s (39% faster) for that test. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * perf: shrink test_categories_on_partitioned_dataframe to N=10, local seed Drop from 20 to 10 for both N_PARTITIONS and the number of gene categories, and replace the module-level RNG with a local default_rng(seed=0) so the test is independent of other tests' RNG consumption. With seed=0 and N=10, partition 0 is deterministically missing gene_4, which is sufficient to trigger the dask category-order mismatch being tested. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * ci: parallelize test suite with pytest-xdist worksteal Add pytest-xdist to test dependencies and pass -n auto --dist worksteal to pytest in CI. worksteal distributes tests dynamically across workers so slow IO tests don't block fast unit tests on a single worker. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * refactor: clean up _get_centroids_for_labels docstring and clarify indexing - Remove reference to the old per-slice implementation from the docstring - Add inline comment explaining why indexing="ij" is correct for any number of spatial dimensions (2D and 3D labels) Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * refactor: minor code swap for improved clarity * perf: speed up test suite — subset sdata, disable numba JIT, promote fixtures to session scope - test_delete_element_from_disk: subset full_sdata to [element_name, points_0_1] before writing, cutting the initial write from 19 elements to 2 (2–13× speedup per parametrize case) - conftest: set NUMBA_DISABLE_JIT=1 to avoid ~1.4s JIT overhead per worker on first datashader/rasterize call - test_partial_read: promote all module-scoped fixtures to session scope so the corrupted zarr stores are built once per session instead of once per module - test_transform: use small_translation=True to avoid out-of-bounds raster operations that trigger large dask computations - test_spatialdata_operations: reduce target_width 1000→100 in test_transform_to_data_extent to shrink the output raster Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * fix+perf: faster test suite — subset fixtures, disable numba JIT, fix napari plugin Napari registers a pytest11 entry point that loads (and breaks) numba before conftest.py runs. Fix: block it in pyproject.toml addopts with -p no:napari. datashader's @jit(cache=True) raises "no locator available" on Python 3.13 + numba. With napari blocked, conftest.py now runs before any plugin imports numba, so NUMBA_DISABLE_JIT=1 consistently disables all @jit decorators (datashader, xrspatial) and avoids the mixed JIT/non-JIT crash. Promote all module-scoped fixtures in test_partial_read to session scope so corrupted zarr stores are built once per session. For tests that write a full SpatialData object but only need a single element (or a small subset) to trigger the condition under test, subset the fixture before writing. The initial full write dominates test time (19 elements including 3-D multiscale rasters), so even subsetting to 1-6 elements gives 2-13× speedups per parametrize case: - test_delete_element_from_disk: subset to [element_name, points_0_1] - test_incremental_io_on_disk: subset to the 7 elements the loop accesses - test_overwrite_fails_when_zarr_store_present: use empty SpatialData() - test_element_already_on_disk_different_type: subset to [element_name] - test_self_contained: subset to [image2d, labels2d, points_0, circles] - test_change_path_of_subset: subset to the 5 elements + points_0_1 (needed so only_on_disk > 0 assertion passes) - test_validate_can_write_metadata_on_element: subset to [element_name] - test_save_transformations_incremental: subset to [element_name, image2d] (image2d anchors the non-self-contained assertion for the circles case) - test_consolidated_metadata: subset to one element per type - test_channel_names_raster_images_v1_to_v2_to_v3: subset to [image2d, image2d_multiscale] Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * refactor: update comments and refine test_consolidated_metadata subset Co-Authored-By: Claude Sonnet 4.6 <[email protected]> --------- Co-authored-by: Claude Sonnet 4.6 <[email protected]>
1 parent d0582ec commit 6ee1013

17 files changed

Lines changed: 215 additions & 147 deletions

‎.github/workflows/test.yaml‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@ jobs:
2020
matrix:
2121
include:
2222
- {os: windows-latest, python: "3.11", dask-version: "2025.12.0", name: "min dask"}
23-
- {os: windows-latest, python: "3.13", dask-version: "latest"}
2423
- {os: windows-latest, python: "3.14", dask-version: "latest"}
2524
- {os: ubuntu-latest, python: "3.11", dask-version: "latest"}
26-
- {os: ubuntu-latest, python: "3.13", dask-version: "latest"}
2725
- {os: ubuntu-latest, python: "3.14", dask-version: "latest"}
2826
- {os: macos-latest, python: "3.11", dask-version: "latest"}
29-
- {os: macos-latest, python: "3.13", prerelease: "allow", name: "prerelease"}
3027
- {os: macos-latest, python: "3.14", prerelease: "allow", name: "prerelease"}
3128
env:
3229
OS: ${{ matrix.os }}
@@ -62,7 +59,7 @@ jobs:
6259
PLATFORM: ${{ matrix.os }}
6360
DISPLAY: :42
6461
run: |
65-
uv run pytest --cov --color=yes --cov-report=xml
62+
uv run pytest --cov --color=yes --cov-report=xml -n auto --dist worksteal
6663
- name: Upload coverage to Codecov
6764
uses: codecov/codecov-action@v5
6865
with:

‎pyproject.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ test = [
6969
"pytest",
7070
"pytest-cov",
7171
"pytest-mock",
72+
"pytest-xdist",
7273
"torch",
7374
]
7475
docs = [
@@ -102,6 +103,7 @@ strict = true
102103
addopts = [
103104
"--import-mode=importlib", # allow using test files with same name
104105
"-s", # print output from tests
106+
"-p no:napari", # napari registers a pytest plugin via its entry point; disable it here since spatialdata tests don't need it
105107
]
106108
# These are all markers coming from xarray, dask or anndata. Added here to silence warnings.
107109
markers = [

‎src/spatialdata/_core/_elements.py‎

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
PointsModel,
2222
ShapesModel,
2323
TableModel,
24-
get_axes_names,
2524
get_model,
2625
)
2726

@@ -50,6 +49,7 @@ def _check_key(key: str, element_keys: Iterable[str], shared_keys: set[str | Non
5049
raise KeyError(*e.args) from e
5150

5251
def __setitem__(self, key: str, value: T) -> None:
52+
# note that each __setitem__ in the subclasses calls get_model(), which performs data validation
5353
self._add_shared_key(key)
5454
super().__setitem__(key, value)
5555

@@ -72,15 +72,7 @@ def __setitem__(self, key: str, value: Raster_T) -> None:
7272
schema = get_model(value)
7373
if schema not in (Image2DModel, Image3DModel):
7474
raise TypeError(f"Unknown element type with schema: {schema!r}.")
75-
ndim = len(get_axes_names(value))
76-
if ndim == 3:
77-
Image2DModel.validate(value)
78-
super().__setitem__(key, value)
79-
elif ndim == 4:
80-
Image3DModel.validate(value)
81-
super().__setitem__(key, value)
82-
else:
83-
NotImplementedError("TODO: implement for ndim > 4.")
75+
super().__setitem__(key, value)
8476

8577

8678
class Labels(Elements[DataArray | DataTree]):
@@ -89,15 +81,7 @@ def __setitem__(self, key: str, value: Raster_T) -> None:
8981
schema = get_model(value)
9082
if schema not in (Labels2DModel, Labels3DModel):
9183
raise TypeError(f"Unknown element type with schema: {schema!r}.")
92-
ndim = len(get_axes_names(value))
93-
if ndim == 2:
94-
Labels2DModel.validate(value)
95-
super().__setitem__(key, value)
96-
elif ndim == 3:
97-
Labels3DModel.validate(value)
98-
super().__setitem__(key, value)
99-
else:
100-
NotImplementedError("TODO: implement for ndim > 3.")
84+
super().__setitem__(key, value)
10185

10286

10387
class Shapes(Elements[GeoDataFrame]):
@@ -106,7 +90,6 @@ def __setitem__(self, key: str, value: GeoDataFrame) -> None:
10690
schema = get_model(value)
10791
if schema != ShapesModel:
10892
raise TypeError(f"Unknown element type with schema: {schema!r}.")
109-
ShapesModel.validate(value)
11093
super().__setitem__(key, value)
11194

11295

@@ -116,7 +99,6 @@ def __setitem__(self, key: str, value: DaskDataFrame) -> None:
11699
schema = get_model(value)
117100
if schema != PointsModel:
118101
raise TypeError(f"Unknown element type with schema: {schema!r}.")
119-
PointsModel.validate(value)
120102
super().__setitem__(key, value)
121103

122104

@@ -126,5 +108,4 @@ def __setitem__(self, key: str, value: AnnData) -> None:
126108
schema = get_model(value)
127109
if schema != TableModel:
128110
raise TypeError(f"Unknown element type with schema: {schema!r}.")
129-
TableModel.validate(value)
130111
super().__setitem__(key, value)

‎src/spatialdata/_core/centroids.py‎

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
from __future__ import annotations
22

3-
from collections import defaultdict
43
from functools import singledispatch
54

6-
import dask.array as da
5+
import numpy as np
76
import pandas as pd
87
import xarray as xr
98
from dask.dataframe import DataFrame as DaskDataFrame
@@ -56,40 +55,29 @@ def get_centroids(
5655
raise ValueError(f"The object type {type(e)} is not supported.")
5756

5857

59-
def _get_centroids_for_axis(xdata: xr.DataArray, axis: str) -> pd.DataFrame:
58+
def _get_centroids_for_labels(xdata: xr.DataArray) -> pd.DataFrame:
6059
"""
61-
Compute the component "axis" of the centroid of each label as a weighted average of the xarray coordinates.
60+
Compute centroids for all labels in a DataArray in a single O(n_voxels) pass.
6261
63-
Parameters
64-
----------
65-
xdata
66-
The xarray DataArray containing the labels.
67-
axis
68-
The axis for which the centroids are computed.
69-
70-
Returns
71-
-------
72-
pd.DataFrame
73-
A DataFrame containing one column, named after "axis", with the centroids of the labels along that axis.
74-
The index of the DataFrame is the collection of label values, sorted in ascending order.
62+
Works for any number of spatial dimensions (2D and 3D labels).
7563
"""
76-
centroids: dict[int, float] = defaultdict(float)
77-
for i in xdata[axis]:
78-
portion = xdata.sel(**{axis: i}).data
79-
u = da.unique(portion, return_counts=True)
80-
labels_values = u[0].compute()
81-
counts = u[1].compute()
82-
for j in range(len(labels_values)):
83-
label_value = labels_values[j]
84-
count = counts[j]
85-
centroids[label_value] += count * i.values.item()
86-
87-
all_labels_values, all_labels_counts = da.unique(xdata.data, return_counts=True)
88-
all_labels = dict(zip(all_labels_values.compute(), all_labels_counts.compute(), strict=True))
89-
for label_value in centroids:
90-
centroids[label_value] /= all_labels[label_value]
91-
centroids = dict(sorted(centroids.items(), key=lambda x: x[0]))
92-
return pd.DataFrame({axis: centroids.values()}, index=list(centroids.keys()))
64+
arr = xdata.data.compute()
65+
axes = list(xdata.dims)
66+
67+
# Map label values to a contiguous range for bincount efficiency.
68+
label_ids, inverse = np.unique(arr, return_inverse=True)
69+
flat_inverse = inverse.ravel()
70+
counts = np.bincount(flat_inverse) # per-label pixel counts
71+
72+
# indexing="ij" (matrix convention) ensures the i-th grid varies along the i-th
73+
# dimension of the output, correctly aligning with xdata.dims for any number of axes.
74+
coord_grids = np.meshgrid(*[xdata[ax].values for ax in axes], indexing="ij")
75+
data: dict[str, np.ndarray] = {}
76+
for ax, grid in zip(axes, coord_grids, strict=True):
77+
coord_sums = np.bincount(flat_inverse, weights=grid.ravel().astype(float))
78+
data[ax] = coord_sums / counts # counts > 0 by construction (unique guarantees this)
79+
80+
return pd.DataFrame(data, index=label_ids)
9381

9482

9583
@get_centroids.register(DataArray)
@@ -109,10 +97,7 @@ def _(
10997
assert len(e["scale0"]) == 1
11098
e = next(iter(e["scale0"].values()))
11199

112-
dfs = []
113-
for axis in get_axes_names(e):
114-
dfs.append(_get_centroids_for_axis(e, axis))
115-
df = pd.concat(dfs, axis=1)
100+
df = _get_centroids_for_labels(e)
116101
if not return_background and 0 in df.index:
117102
df = df.drop(index=0) # drop the background label
118103
t = get_transformation(e, coordinate_system)

‎src/spatialdata/models/models.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,14 +1250,17 @@ def parse(
12501250

12511251
def get_model(
12521252
e: SpatialElement,
1253+
validate: bool = True,
12531254
) -> Schema_t:
12541255
"""
1255-
Get the model for the given element.
1256+
Get the model for the given element. Validate using the model if `validate` is `True`.
12561257
12571258
Parameters
12581259
----------
12591260
e
12601261
The element.
1262+
validate
1263+
Whether to validate the element using the model.
12611264
12621265
Returns
12631266
-------
@@ -1268,7 +1271,8 @@ def _validate_and_return(
12681271
schema: Schema_t,
12691272
e: SpatialElement,
12701273
) -> Schema_t:
1271-
schema.validate(e)
1274+
if validate:
1275+
schema.validate(e)
12721276
return schema
12731277

12741278
if isinstance(e, DataArray | DataTree):

‎tests/conftest.py‎

Lines changed: 85 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
from __future__ import annotations
22

3-
from collections.abc import Sequence
3+
import os
4+
5+
# Disable numba JIT for the test suite (the test data is small so initializing the JIT is slower than using plain
6+
# Python)
7+
os.environ.setdefault("NUMBA_DISABLE_JIT", "1")
8+
9+
import copy as _copy
10+
from collections.abc import Callable, Sequence
411
from pathlib import Path
512
from typing import Any
613

@@ -33,6 +40,25 @@
3340
TableModel,
3441
)
3542

43+
44+
def _fast_deepcopy_sdata(sd: SpatialData) -> SpatialData:
45+
"""
46+
Fast deepcopy for SpatialData objects in tests.
47+
48+
Uses copy.deepcopy (which skips model re-validation) and manually restores
49+
the attrs that copy.deepcopy loses for DaskDataFrame (issue #503) and
50+
GeoDataFrame (issue #286).
51+
"""
52+
points_attrs = {k: _copy.deepcopy(v._attrs) for k, v in sd.points.items()}
53+
shapes_attrs = {k: _copy.deepcopy(v.attrs) for k, v in sd.shapes.items()}
54+
sd_copy = _copy.deepcopy(sd)
55+
for k, attrs in points_attrs.items():
56+
sd_copy.points[k]._attrs = attrs
57+
for k, attrs in shapes_attrs.items():
58+
sd_copy.shapes[k].attrs = attrs
59+
return sd_copy
60+
61+
3662
SEED = 0
3763
RNG = default_rng(seed=SEED)
3864

@@ -41,16 +67,26 @@
4167
POINT_PATH = Path(__file__).parent / "data/points.json"
4268

4369

44-
@pytest.fixture()
45-
def images() -> SpatialData:
70+
@pytest.fixture(scope="session")
71+
def _images_session() -> SpatialData:
4672
return SpatialData(images=_get_images())
4773

4874

4975
@pytest.fixture()
50-
def labels() -> SpatialData:
76+
def images(_images_session: SpatialData) -> SpatialData:
77+
return _fast_deepcopy_sdata(_images_session)
78+
79+
80+
@pytest.fixture(scope="session")
81+
def _labels_session() -> SpatialData:
5182
return SpatialData(labels=_get_labels())
5283

5384

85+
@pytest.fixture()
86+
def labels(_labels_session: SpatialData) -> SpatialData:
87+
return _fast_deepcopy_sdata(_labels_session)
88+
89+
5490
@pytest.fixture()
5591
def shapes() -> SpatialData:
5692
return SpatialData(shapes=_get_shapes())
@@ -87,8 +123,8 @@ def tables() -> list[AnnData]:
87123
return _tables
88124

89125

90-
@pytest.fixture()
91-
def full_sdata() -> SpatialData:
126+
@pytest.fixture(scope="session")
127+
def _full_sdata_session() -> SpatialData:
92128
return SpatialData(
93129
images=_get_images(),
94130
labels=_get_labels(),
@@ -98,6 +134,22 @@ def full_sdata() -> SpatialData:
98134
)
99135

100136

137+
@pytest.fixture()
138+
def full_sdata(_full_sdata_session: SpatialData) -> SpatialData:
139+
return _fast_deepcopy_sdata(_full_sdata_session)
140+
141+
142+
@pytest.fixture(scope="session")
143+
def _sdata_full_session() -> SpatialData:
144+
return SpatialData(
145+
images=_get_images(),
146+
labels=_get_labels(),
147+
shapes=_get_shapes(),
148+
points=_get_points(),
149+
tables=_get_tables(region="labels2d"),
150+
)
151+
152+
101153
@pytest.fixture(
102154
# params=["labels"]
103155
params=["full", "empty"]
@@ -110,15 +162,9 @@ def full_sdata() -> SpatialData:
110162
]
111163
# + ["empty_" + x for x in ["table"]] # TODO: empty table not supported yet
112164
)
113-
def sdata(request) -> SpatialData:
165+
def sdata(request, _sdata_full_session: SpatialData) -> SpatialData:
114166
if request.param == "full":
115-
return SpatialData(
116-
images=_get_images(),
117-
labels=_get_labels(),
118-
shapes=_get_shapes(),
119-
points=_get_points(),
120-
tables=_get_tables(region="labels2d"),
121-
)
167+
return _fast_deepcopy_sdata(_sdata_full_session)
122168
if request.param == "empty":
123169
return SpatialData()
124170
return request.getfixturevalue(request.param)
@@ -304,18 +350,38 @@ def _get_new_table(spatial_element: None | str | Sequence[str], instance_id: Non
304350
return TableModel.parse(adata=adata, spatial_element=spatial_element, instance_id=instance_id)
305351

306352

307-
@pytest.fixture()
308-
def labels_blobs() -> ArrayLike:
309-
"""Create a 2D labels."""
353+
@pytest.fixture(scope="session")
354+
def _labels_blobs_session() -> ArrayLike:
310355
return BlobsDataset()._labels_blobs()
311356

312357

313358
@pytest.fixture()
314-
def sdata_blobs() -> SpatialData:
359+
def labels_blobs(_labels_blobs_session: ArrayLike) -> ArrayLike:
315360
"""Create a 2D labels."""
361+
return deepcopy(_labels_blobs_session)
362+
363+
364+
@pytest.fixture(scope="session")
365+
def _sdata_blobs_session() -> SpatialData:
316366
from spatialdata.datasets import blobs
317367

318-
return deepcopy(blobs(256, 300, 3))
368+
return blobs(256, 300, 3)
369+
370+
371+
@pytest.fixture()
372+
def sdata_blobs(_sdata_blobs_session: SpatialData) -> SpatialData:
373+
"""Create a 2D labels."""
374+
return _fast_deepcopy_sdata(_sdata_blobs_session)
375+
376+
377+
@pytest.fixture()
378+
def blobs_factory(_sdata_blobs_session: SpatialData) -> Callable[[], SpatialData]:
379+
"""Return a factory that creates cheap fresh copies of the session-scoped blobs dataset."""
380+
381+
def _make() -> SpatialData:
382+
return _fast_deepcopy_sdata(_sdata_blobs_session)
383+
384+
return _make
319385

320386

321387
def _make_points(coordinates: np.ndarray) -> DaskDataFrame:

‎tests/core/operations/conftest.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from __future__ import annotations
2+
3+
import os
4+
5+
# Disable numba JIT compilation for rasterize tests. Datashader (used by rasterize) triggers
6+
# numba JIT on first call, costing ~1.4s per worker. Python-mode gives identical results for
7+
# the small test data here — unlike real data, there is no throughput advantage from JIT.
8+
os.environ.setdefault("NUMBA_DISABLE_JIT", "1")

0 commit comments

Comments
 (0)