|
1 | | -import timeit |
2 | | - |
3 | 1 | import matplotlib.pyplot as plt |
4 | 2 | import numpy as np |
5 | 3 | import pytest |
|
8 | 6 | from spatialdata.transformations import Identity, set_transformation |
9 | 7 |
|
10 | 8 | import spatialdata_plot # noqa: F401 |
11 | | -from spatialdata_plot.pl.utils import _get_cs_contents |
12 | 9 |
|
13 | 10 |
|
14 | 11 | def test_render_images_can_plot_one_cyx_image(request): |
@@ -118,24 +115,3 @@ def test_cs_name_with_apostrophe_does_not_crash(): |
118 | 115 | _, ax = plt.subplots() |
119 | 116 | sdata.pl.render_images("img").pl.show(ax=ax, coordinate_systems="patient's_cs") |
120 | 117 | 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