Skip to content

Commit 120d11d

Browse files
committed
fix: address pre-commit linting issues
- Simplify if/return pattern in _is_lazy_anndata (SIM103) - Add missing TableModel import in test fixture (F821) - Use modern np.random.Generator instead of np.random.rand (NPY002)
1 parent 44d4f45 commit 120d11d

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/spatialdata/models/models.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ def _is_lazy_anndata(adata: AnnData) -> bool:
6767
True if the AnnData is lazily loaded, False otherwise.
6868
"""
6969
# Check if obs is not a pandas DataFrame (lazy AnnData uses xarray Dataset2D)
70-
if not isinstance(adata.obs, pd.DataFrame):
71-
return True
72-
return False
70+
return not isinstance(adata.obs, pd.DataFrame)
7371

7472

7573
def _parse_transformations(element: SpatialElement, transformations: MappingToCoordinateSystem_t | None = None) -> None:

tests/io/test_readwrite.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,9 +1124,12 @@ class TestLazyTableLoading:
11241124
@pytest.fixture
11251125
def sdata_with_table(self) -> SpatialData:
11261126
"""Create a SpatialData object with a simple table for testing."""
1127+
from spatialdata.models import TableModel
1128+
1129+
rng = default_rng(42)
11271130
table = TableModel.parse(
11281131
AnnData(
1129-
X=np.random.rand(100, 50),
1132+
X=rng.random((100, 50)),
11301133
obs=pd.DataFrame(
11311134
{
11321135
"region": pd.Categorical(["region1"] * 100),

0 commit comments

Comments
 (0)