Skip to content

Commit 6ffb163

Browse files
timtreisclaude
andcommitted
Remove timing-based linearity test for _get_cs_contents
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 82f207d commit 6ffb163

1 file changed

Lines changed: 0 additions & 24 deletions

File tree

tests/pl/test_render.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import timeit
2-
31
import matplotlib.pyplot as plt
42
import numpy as np
53
import pytest
@@ -8,7 +6,6 @@
86
from spatialdata.transformations import Identity, set_transformation
97

108
import spatialdata_plot # noqa: F401
11-
from spatialdata_plot.pl.utils import _get_cs_contents
129

1310

1411
def test_render_images_can_plot_one_cyx_image(request):
@@ -118,24 +115,3 @@ def test_cs_name_with_apostrophe_does_not_crash():
118115
_, ax = plt.subplots()
119116
sdata.pl.render_images("img").pl.show(ax=ax, coordinate_systems="patient's_cs")
120117
plt.close("all")
121-
122-
123-
def test_get_cs_contents_is_linear():
124-
# Regression test for #602: pd.concat inside loop was O(n²).
125-
def build(n: int) -> SpatialData:
126-
data = np.zeros((1, 4, 4), dtype=np.float64)
127-
images = {}
128-
for i in range(n):
129-
img_i = Image2DModel.parse(data.copy(), dims=("c", "y", "x"))
130-
set_transformation(img_i, Identity(), to_coordinate_system=f"cs_{i}")
131-
images[f"img_{i}"] = img_i
132-
return SpatialData(images=images)
133-
134-
sd10 = build(10)
135-
sd50 = build(50)
136-
t10 = timeit.timeit(lambda: _get_cs_contents(sd10), number=20) / 20
137-
t50 = timeit.timeit(lambda: _get_cs_contents(sd50), number=20) / 20
138-
ratio = t50 / t10
139-
assert ratio < 15, (
140-
f"_get_cs_contents appears quadratic: n=10 {t10 * 1e3:.1f}ms, n=50 {t50 * 1e3:.1f}ms, ratio={ratio:.1f}x"
141-
)

0 commit comments

Comments
 (0)