Skip to content

Commit db3c4c5

Browse files
committed
Lint
1 parent 351f1dc commit db3c4c5

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

tests/create_xenium_filtered_points.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
if not isfile(zip_filepath):
1818
os.makedirs(data_dir, exist_ok=True)
1919
urlretrieve('https://s3.embl.de/spatialdata/spatialdata-sandbox/xenium_rep1_io.zip', zip_filepath)
20-
with zipfile.ZipFile(zip_filepath,"r") as zip_ref:
20+
with zipfile.ZipFile(zip_filepath, "r") as zip_ref:
2121
zip_ref.extractall(data_dir)
2222
os.rename(join(data_dir, "data.zarr"), spatialdata_filepath)
23-
23+
2424
# This Xenium dataset has an AnnData "raw" element.
2525
# Reference: https://github.com/giovp/spatialdata-sandbox/issues/55
2626
raw_dir = join(spatialdata_filepath, "tables", "table", "raw")
@@ -32,17 +32,20 @@
3232
ddf = sdata.points["transcripts"]
3333

3434
# 2. Define a function to take every 100th row from a partition
35+
36+
3537
def select_every_200th(partition):
3638
# Each 'partition' is a Pandas DataFrame
3739
# .iloc[::100] is the efficient pandas way to get every 100th row
3840
return partition.iloc[::200]
3941

42+
4043
# 3. Apply this function to every partition in the Dask DataFrame
4144
result = ddf.map_partitions(select_every_200th)
4245

4346
# 4. Compute the result to see it
4447
filtered_ddf = result[["x", "y", "z", "feature_name", "cell_id"]]
4548

46-
small_sdata = SpatialData(points={ "transcripts": filtered_ddf })
49+
small_sdata = SpatialData(points={"transcripts": filtered_ddf})
4750

48-
small_sdata.write("xenium_rep1_io.points_only.spatialdata.zarr", overwrite=True)
51+
small_sdata.write("xenium_rep1_io.points_only.spatialdata.zarr", overwrite=True)

tests/test_sdata_points_zorder.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@
1515
MORTON_CODE_VALUE_MAX,
1616
)
1717

18+
1819
def is_sorted(l):
1920
return all(l[i] <= l[i + 1] for i in range(len(l) - 1))
2021

22+
2123
data_path = Path('tests/data')
2224

25+
2326
@pytest.fixture
2427
def sdata_with_points():
2528
sdata = read_zarr(data_path / "xenium_rep1_io.points_only.spatialdata.zarr")
@@ -59,7 +62,7 @@ def test_zorder_query(sdata_with_points):
5962
sdata_morton_sort_points(sdata, "transcripts")
6063

6164
# Query a rectangle that should return some points
62-
orig_rect = [[50.0, 50.0], [100.0, 150.0]] # x0, y0, x1, y1
65+
orig_rect = [[50.0, 50.0], [100.0, 150.0]] # x0, y0, x1, y1
6366
matching_row_ranges, rows_checked = sdata_morton_query_rect_debug(sdata, "transcripts", orig_rect)
6467
rect_row_indices = row_ranges_to_row_indices(matching_row_ranges)
6568

@@ -98,7 +101,7 @@ def test_zorder_query(sdata_with_points):
98101

99102
# Check that the number of rows checked is less than the total number of points
100103
assert len(rows_checked) <= 19858
101-
assert len(matching_row_ranges) == 2 # Kind of an implementation detail.
104+
assert len(matching_row_ranges) == 2 # Kind of an implementation detail.
102105

103106
# Do a second check, this time against x_uint/y_uint (the normalized coordinates)
104107
# TODO: does this ensure that estimated == exact?
@@ -130,9 +133,9 @@ def test_zorder_query(sdata_with_points):
130133

131134
assert len(exact_row_indices_norm) == 4
132135
assert len(estimated_row_indices) <= 4
133-
136+
134137
# ========= Another query ==========
135-
orig_rect = [[500.0, 500.0], [600.0, 600.0]] # x0, y0, x1, y1
138+
orig_rect = [[500.0, 500.0], [600.0, 600.0]] # x0, y0, x1, y1
136139

137140
# Query using z-order
138141
matching_row_ranges, rows_checked = sdata_morton_query_rect_debug(sdata, "transcripts", orig_rect)
@@ -159,7 +162,7 @@ def test_zorder_query(sdata_with_points):
159162

160163
# Check that the number of rows checked is less than the total number of points
161164
assert len(rows_checked) <= 71675
162-
assert len(matching_row_ranges) == 13 # Kind of an implementation detail.
165+
assert len(matching_row_ranges) == 13 # Kind of an implementation detail.
163166

164167
# Do the same query the "dumb" way, by checking all points
165168
in_rect = (
@@ -197,5 +200,3 @@ def test_zorder_query(sdata_with_points):
197200
# Check that the estimated rows contain all of the exact rows.
198201
assert len(exact_row_indices_norm) == 91
199202
assert len(estimated_row_indices) <= 95
200-
201-

0 commit comments

Comments
 (0)