|
65 | 65 | from spatialdata._core.query.relational_query import _locate_value
|
66 | 66 | from spatialdata._types import ArrayLike
|
67 | 67 | from spatialdata.models import Image2DModel, Labels2DModel, SpatialElement
|
68 |
| - |
69 |
| -# from spatialdata.transformations.transformations import Scale |
70 |
| -from spatialdata.transformations import Affine, Identity, MapAxis, Scale, Translation |
71 |
| -from spatialdata.transformations import Sequence as SDSequence |
72 | 68 | from spatialdata.transformations.operations import get_transformation
|
| 69 | +from spatialdata.transformations.transformations import Scale |
73 | 70 | from xarray import DataArray, DataTree
|
74 | 71 |
|
75 | 72 | from spatialdata_plot._logging import logger
|
@@ -2381,39 +2378,6 @@ def _prepare_transformation(
|
2381 | 2378 | return trans, trans_data
|
2382 | 2379 |
|
2383 | 2380 |
|
2384 |
| -def _get_datashader_trans_matrix_of_single_element( |
2385 |
| - trans: Identity | Scale | Affine | MapAxis | Translation, |
2386 |
| -) -> npt.NDArray[Any]: |
2387 |
| - flip_matrix = np.array([[1, 0, 0], [0, -1, 0], [0, 0, 1]]) |
2388 |
| - tm: npt.NDArray[Any] = trans.to_affine_matrix(("x", "y"), ("x", "y")) |
2389 |
| - |
2390 |
| - if isinstance(trans, Identity): |
2391 |
| - return np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) |
2392 |
| - if isinstance(trans, (Scale | Affine)): |
2393 |
| - # idea: "flip the y-axis", apply transformation, flip back |
2394 |
| - flip_and_transform: npt.NDArray[Any] = flip_matrix @ tm @ flip_matrix |
2395 |
| - return flip_and_transform |
2396 |
| - if isinstance(trans, MapAxis): |
2397 |
| - # no flipping needed |
2398 |
| - return tm |
2399 |
| - # for a Translation, we need the transposed transformation matrix |
2400 |
| - tm_T = tm.T |
2401 |
| - assert isinstance(tm_T, np.ndarray) |
2402 |
| - return tm_T |
2403 |
| - |
2404 |
| - |
2405 |
| -def _get_transformation_matrix_for_datashader( |
2406 |
| - trans: Scale | Identity | Affine | MapAxis | Translation | SDSequence, |
2407 |
| -) -> npt.NDArray[Any]: |
2408 |
| - """Get the affine matrix needed to transform shapes for rendering with datashader.""" |
2409 |
| - if isinstance(trans, SDSequence): |
2410 |
| - tm = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) |
2411 |
| - for x in trans.transformations: |
2412 |
| - tm = tm @ _get_datashader_trans_matrix_of_single_element(x) |
2413 |
| - return tm |
2414 |
| - return _get_datashader_trans_matrix_of_single_element(trans) |
2415 |
| - |
2416 |
| - |
2417 | 2381 | def _datashader_map_aggregate_to_color(
|
2418 | 2382 | agg: DataArray,
|
2419 | 2383 | cmap: str | list[str] | ListedColormap,
|
|
0 commit comments