Skip to content

Commit bef3a35

Browse files
committed
Rename variables
1 parent 18fc0c3 commit bef3a35

2 files changed

Lines changed: 29 additions & 29 deletions

File tree

src/spatialdata/datasets.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232

3333
def blobs(
34-
length: int = 512, n_points: int = 200, n_shapes: int = 5, extra_coord_space: Optional[str] = None
34+
length: int = 512, n_points: int = 200, n_shapes: int = 5, extra_coord_system: Optional[str] = None
3535
) -> SpatialData:
3636
"""
3737
Blobs dataset.
@@ -45,7 +45,7 @@ def blobs(
4545
n_shapes
4646
Number of max shapes to generate.
4747
At most, as if overlapping they will be discarded
48-
extra_coord_space
48+
extra_coord_system
4949
Extra coordinate space on top of the standard global coordinate space. Will have only identity transform.
5050
5151
@@ -55,7 +55,7 @@ def blobs(
5555
SpatialData object with blobs dataset.
5656
"""
5757
return BlobsDataset(
58-
length=length, n_points=n_points, n_shapes=n_shapes, extra_coord_space=extra_coord_space
58+
length=length, n_points=n_points, n_shapes=n_shapes, extra_coord_system=extra_coord_system
5959
).blobs()
6060

6161

@@ -87,7 +87,7 @@ class BlobsDataset:
8787
"""Blobs dataset."""
8888

8989
def __init__(
90-
self, length: int = 512, n_points: int = 200, n_shapes: int = 5, extra_coord_space: Optional[str] = None
90+
self, length: int = 512, n_points: int = 200, n_shapes: int = 5, extra_coord_system: Optional[str] = None
9191
) -> None:
9292
"""
9393
Blobs dataset.
@@ -101,28 +101,28 @@ def __init__(
101101
n_shapes
102102
Number of max shapes to generate.
103103
At most, as if overlapping they will be discarded
104-
extra_coord_space
104+
extra_coord_system
105105
Extra coordinate space on top of the standard global coordinate space. Will have only identity transform.
106106
"""
107107
self.length = length
108108
self.n_points = n_points
109109
self.n_shapes = n_shapes
110-
self.transforms = {"global": Identity()}
111-
if extra_coord_space:
112-
self.transforms[extra_coord_space] = Identity()
110+
self.transformations = {"global": Identity()}
111+
if extra_coord_system:
112+
self.transformations[extra_coord_system] = Identity()
113113

114114
def blobs(
115115
self,
116116
) -> SpatialData:
117117
"""Blobs dataset."""
118-
image = self._image_blobs(self.transforms, self.length)
119-
multiscale_image = self._image_blobs(self.transforms, self.length, multiscale=True)
120-
labels = self._labels_blobs(self.transforms, self.length)
121-
multiscale_labels = self._labels_blobs(self.transforms, self.length, multiscale=True)
122-
points = self._points_blobs(self.transforms, self.length, self.n_points)
123-
circles = self._circles_blobs(self.transforms, self.length, self.n_shapes)
124-
polygons = self._polygons_blobs(self.transforms, self.length, self.n_shapes)
125-
multipolygons = self._polygons_blobs(self.transforms, self.length, self.n_shapes, multipolygons=True)
118+
image = self._image_blobs(self.transformations, self.length)
119+
multiscale_image = self._image_blobs(self.transformations, self.length, multiscale=True)
120+
labels = self._labels_blobs(self.transformations, self.length)
121+
multiscale_labels = self._labels_blobs(self.transformations, self.length, multiscale=True)
122+
points = self._points_blobs(self.transformations, self.length, self.n_points)
123+
circles = self._circles_blobs(self.transformations, self.length, self.n_shapes)
124+
polygons = self._polygons_blobs(self.transformations, self.length, self.n_shapes)
125+
multipolygons = self._polygons_blobs(self.transformations, self.length, self.n_shapes, multipolygons=True)
126126
adata = aggregate(image, labels)
127127
adata.obs["region"] = pd.Categorical(["blobs_labels"] * len(adata))
128128
adata.obs["instance_id"] = adata.obs_names.astype(int)
@@ -138,7 +138,7 @@ def blobs(
138138

139139
def _image_blobs(
140140
self,
141-
transforms: Optional[dict[str, Any]] = None,
141+
transformations: Optional[dict[str, Any]] = None,
142142
length: int = 512,
143143
multiscale: bool = False,
144144
) -> Union[SpatialImage, MultiscaleSpatialImage]:
@@ -151,11 +151,11 @@ def _image_blobs(
151151
x = np.stack(masks, axis=0)
152152
dims = ["c", "y", "x"]
153153
if not multiscale:
154-
return Image2DModel.parse(x, transformations=transforms, dims=dims)
155-
return Image2DModel.parse(x, transformations=transforms, dims=dims, scale_factors=[2, 2])
154+
return Image2DModel.parse(x, transformations=transformations, dims=dims)
155+
return Image2DModel.parse(x, transformations=transformations, dims=dims, scale_factors=[2, 2])
156156

157157
def _labels_blobs(
158-
self, transforms: Optional[dict[str, Any]] = None, length: int = 512, multiscale: bool = False
158+
self, transformations: Optional[dict[str, Any]] = None, length: int = 512, multiscale: bool = False
159159
) -> Union[SpatialImage, MultiscaleSpatialImage]:
160160
"""Create a 2D labels."""
161161
from scipy.ndimage import watershed_ift
@@ -180,8 +180,8 @@ def _labels_blobs(
180180
out[out == val[idx]] = i
181181
dims = ["y", "x"]
182182
if not multiscale:
183-
return Labels2DModel.parse(out, transformations=transforms, dims=dims)
184-
return Labels2DModel.parse(out, transformations=transforms, dims=dims, scale_factors=[2, 2])
183+
return Labels2DModel.parse(out, transformations=transformations, dims=dims)
184+
return Labels2DModel.parse(out, transformations=transformations, dims=dims, scale_factors=[2, 2])
185185

186186
def _generate_blobs(self, length: int = 512, seed: Optional[int] = None) -> ArrayLike:
187187
from scipy.ndimage import gaussian_filter
@@ -197,7 +197,7 @@ def _generate_blobs(self, length: int = 512, seed: Optional[int] = None) -> Arra
197197
return mask
198198

199199
def _points_blobs(
200-
self, transforms: Optional[dict[str, Any]] = None, length: int = 512, n_points: int = 200
200+
self, transformations: Optional[dict[str, Any]] = None, length: int = 512, n_points: int = 200
201201
) -> DaskDataFrame:
202202
rng = default_rng(42)
203203
arr = rng.integers(10, length - 10, size=(n_points, 2)).astype(np.int64)
@@ -211,11 +211,11 @@ def _points_blobs(
211211
},
212212
)
213213
return PointsModel.parse(
214-
arr, transformations=transforms, annotation=annotation, feature_key="genes", instance_key="instance_id"
214+
arr, transformations=transformations, annotation=annotation, feature_key="genes", instance_key="instance_id"
215215
)
216216

217217
def _circles_blobs(
218-
self, transforms: Optional[dict[str, Any]] = None, length: int = 512, n_shapes: int = 5
218+
self, transformations: Optional[dict[str, Any]] = None, length: int = 512, n_shapes: int = 5
219219
) -> GeoDataFrame:
220220
midpoint = length // 2
221221
halfmidpoint = midpoint // 2
@@ -226,11 +226,11 @@ def _circles_blobs(
226226
"radius": radius,
227227
}
228228
)
229-
return ShapesModel.parse(circles, transformations=transforms)
229+
return ShapesModel.parse(circles, transformations=transformations)
230230

231231
def _polygons_blobs(
232232
self,
233-
transforms: Optional[dict[str, Any]] = None,
233+
transformations: Optional[dict[str, Any]] = None,
234234
length: int = 512,
235235
n_shapes: int = 5,
236236
multipolygons: bool = False,
@@ -244,7 +244,7 @@ def _polygons_blobs(
244244
)
245245
}
246246
)
247-
return ShapesModel.parse(poly, transformations=transforms)
247+
return ShapesModel.parse(poly, transformations=transformations)
248248

249249
# function that generates random shapely polygons given a bounding box
250250
def _generate_random_polygons(

tests/datasets/test_datasets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
def test_datasets() -> None:
55
extra_cs = "test"
6-
sdata_blobs = blobs(extra_coord_space=extra_cs)
6+
sdata_blobs = blobs(extra_coord_system=extra_cs)
77

88
assert len(sdata_blobs.table) == 26
99
assert len(sdata_blobs.shapes["blobs_circles"]) == 5

0 commit comments

Comments
 (0)