-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
109 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import bento as bt | ||
import pandas as pd | ||
|
||
|
||
def test_comp(small_data): | ||
# Set up test data | ||
shape_names = ["cell_boundaries", "nucleus_boundaries"] | ||
points_key = "transcripts" | ||
|
||
# Call the comp function | ||
bt.tl.comp(sdata=small_data, points_key=points_key, shape_names=shape_names) | ||
|
||
# Check if comp_stats is updated in sdata.table.uns | ||
assert "comp_stats" in small_data.table.uns | ||
|
||
# Check the type of comp_stats | ||
assert type(small_data.table.uns["comp_stats"]) == pd.DataFrame | ||
|
||
# Check if the shape_names are present in comp_stats | ||
assert all( | ||
shape_name in small_data.table.uns["comp_stats"] for shape_name in shape_names | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import bento as bt | ||
import pandas as pd | ||
import geopandas as gpd | ||
import spatialdata as sd | ||
import dask.dataframe as dd | ||
|
||
|
||
def test_sample_data(): | ||
sdata = bt.ds.sample_data() | ||
|
||
# Check if the returned object is an instance of `bento.SpatialData` | ||
assert isinstance(sdata, sd.SpatialData) | ||
|
||
# Check if the required keys are present in the `sdata` object | ||
assert "transcripts" in sdata.points | ||
assert "cell_boundaries" in sdata.shapes | ||
assert "nucleus_boundaries" in sdata.shapes | ||
|
||
# Check if the types of the keys are correct | ||
assert isinstance(sdata.points["transcripts"], dd.DataFrame) | ||
assert isinstance(sdata.shapes["cell_boundaries"], gpd.GeoDataFrame) | ||
assert isinstance(sdata.shapes["nucleus_boundaries"], gpd.GeoDataFrame) | ||
|
||
# Check if the `feature_name` column is present in the `transcripts` DataFrame | ||
assert "feature_name" in sdata.points["transcripts"] | ||
|
||
# Check if the `cell_boundaries` and `nucleus_boundaries` shapes are present | ||
assert "cell_boundaries" in sdata.shapes | ||
assert "nucleus_boundaries" in sdata.shapes | ||
assert isinstance(sdata.shapes["cell_boundaries"], gpd.GeoDataFrame) | ||
assert isinstance(sdata.shapes["nucleus_boundaries"], gpd.GeoDataFrame) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import bento as bt | ||
import geopandas as gpd | ||
|
||
|
||
def test_overlay_intersection(small_data): | ||
s1 = "nucleus_boundaries" | ||
s2 = "cell_boundaries" | ||
name = "overlay_result" | ||
|
||
# Perform overlay operation using GeoDataFrame.overlay() | ||
shape1 = small_data.shapes[s1] | ||
shape2 = small_data.shapes[s2] | ||
expected_result = shape1.overlay(shape2, how="intersection", make_valid=True) | ||
|
||
# Perform overlay operation using bento.geo.overlay() | ||
bt.geo.overlay(small_data, s1, s2, name, how="intersection") | ||
|
||
assert name in small_data.shapes | ||
assert isinstance(small_data.shapes[name], gpd.GeoDataFrame) | ||
assert ( | ||
small_data[name] | ||
.geom_almost_equals(expected_result, decimal=1, align=True) | ||
.all() | ||
) |