Skip to content

Commit

Permalink
test configs and minor bugs introed from doc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ckmah committed Dec 17, 2024
1 parent 82c454b commit 3a24735
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 9 deletions.
8 changes: 6 additions & 2 deletions bento/io/_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def _sjoin_shapes(sdata: SpatialData, instance_key: str, shape_keys: List[str]):
if len(shape_keys) == 0:
return sdata

parent_shape = gpd.GeoDataFrame(geometry=sdata.shapes[instance_key])
parent_shape = gpd.GeoDataFrame(geometry=sdata.shapes[instance_key].geometry)

# sjoin shapes to instance_key shape
for shape_key in shape_keys:
Expand All @@ -118,10 +118,14 @@ def _sjoin_shapes(sdata: SpatialData, instance_key: str, shape_keys: List[str]):
]
.fillna("")
.astype("category")
.cat.add_categories([""])
)
.rename(columns={"index_right": shape_key})
)

# Add empty category to shape_key if not already present
if "" not in parent_shape[shape_key].cat.categories:
parent_shape[shape_key] = parent_shape[shape_key].cat.add_categories([""])

parent_shape[shape_key] = parent_shape[shape_key].fillna("")

# Save shape index as column in instance_key shape
Expand Down
4 changes: 2 additions & 2 deletions bento/tools/_point_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def extract(self, df: pd.DataFrame) -> Dict[str, float]:
Dict[str, float]
Computed feature values
"""
return df.to_dict("list")
return df


class ShapeProximity(PointFeature):
Expand Down Expand Up @@ -914,7 +914,7 @@ def _second_moment(centroid: np.ndarray, pts: np.ndarray) -> float:
float
Second moment value
"""
if type(centroid) is np.ndarray:
if type(centroid) is not np.ndarray:
centroid = centroid.coords
centroid = np.array(centroid).reshape(1, 2)
radii = distance.cdist(centroid, pts)
Expand Down
5 changes: 5 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import os
import sys

# Add the parent directory to the Python path
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
2 changes: 1 addition & 1 deletion tests/test_flux.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


import bento as bt
from . import conftest
from tests import conftest


@pytest.fixture(scope="module")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_io.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from . import conftest
from tests import conftest


def test_points_indexing(small_data):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import bento as bt

from . import conftest
from tests import conftest


@pytest.fixture(scope="module")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_point_features.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
import bento as bt

from . import conftest
from tests import conftest


@pytest.fixture(scope="module")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_shape_features.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
import bento as bt

from . import conftest
from tests import conftest


@pytest.fixture(scope="module")
Expand Down

0 comments on commit 3a24735

Please sign in to comment.