Skip to content

Commit

Permalink
renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaMarconato committed Jan 13, 2025
1 parent e646e69 commit 0246011
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ I/O for the `spatialdata` project.
.. autosummary::
:toctree: generated
read_generic
read_image
read_geojson
generic
image
geojson
```

### Conversion functions
Expand Down
2 changes: 1 addition & 1 deletion src/spatialdata_io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from spatialdata_io.readers.cosmx import cosmx
from spatialdata_io.readers.curio import curio
from spatialdata_io.readers.dbit import dbit
from spatialdata_io.readers.generic import read_generic, read_geojson, read_image
from spatialdata_io.readers.generic import generic, geojson, image
from spatialdata_io.readers.macsima import macsima
from spatialdata_io.readers.mcmicro import mcmicro
from spatialdata_io.readers.merscope import merscope
Expand Down
4 changes: 2 additions & 2 deletions src/spatialdata_io/converters/generic_to_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def generic_to_zarr(
using the `SpatialData` class. It handles both existing and new zarr stores, ensuring that data is appropriately
appended or initialized.
"""
from spatialdata_io.readers.generic import read_generic
from spatialdata_io.readers.generic import generic

input = Path(input)
output = Path(output)
Expand All @@ -64,7 +64,7 @@ def generic_to_zarr(
if not coordinate_system:
coordinate_system = "global"

element = read_generic(
element = generic(
input=input, data_axes=list(data_axes) if data_axes is not None else None, coordinate_system=coordinate_system
)

Expand Down
12 changes: 6 additions & 6 deletions src/spatialdata_io/readers/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
VALID_IMAGE_TYPES = [".tif", ".tiff", ".png", ".jpg", ".jpeg"]
VALID_SHAPE_TYPES = [".geojson"]

__all__ = ["read_generic", "read_geojson", "read_image", "VALID_IMAGE_TYPES", "VALID_SHAPE_TYPES"]
__all__ = ["generic", "geojson", "image", "VALID_IMAGE_TYPES", "VALID_SHAPE_TYPES"]


@docstring_parameter(
valid_image_types=", ".join(VALID_IMAGE_TYPES),
valid_shape_types=", ".join(VALID_SHAPE_TYPES),
default_coordinate_system=DEFAULT_COORDINATE_SYSTEM,
)
def read_generic(
def generic(
input: Path,
data_axes: Sequence[str] | None = None,
coordinate_system: str | None = None,
Expand Down Expand Up @@ -54,21 +54,21 @@ def read_generic(
if input.suffix in VALID_SHAPE_TYPES:
if data_axes is not None:
warnings.warn("data_axes is not used for geojson files", UserWarning, stacklevel=2)
return read_geojson(input, coordinate_system=coordinate_system)
return geojson(input, coordinate_system=coordinate_system)
elif input.suffix in VALID_IMAGE_TYPES:
if data_axes is None:
raise ValueError("data_axes must be provided for image files")
return read_image(input, data_axes=data_axes, coordinate_system=coordinate_system)
return image(input, data_axes=data_axes, coordinate_system=coordinate_system)
else:
raise ValueError(f"Invalid file type. Must be one of {VALID_SHAPE_TYPES + VALID_IMAGE_TYPES}")


def read_geojson(input: Path, coordinate_system: str) -> GeoDataFrame:
def geojson(input: Path, coordinate_system: str) -> GeoDataFrame:
"""Reads a GeoJSON file and returns a parsed GeoDataFrame spatial element"""
return ShapesModel.parse(input, transformations={coordinate_system: Identity()})


def read_image(input: Path, data_axes: Sequence[str], coordinate_system: str) -> DataArray:
def image(input: Path, data_axes: Sequence[str], coordinate_system: str) -> DataArray:
"""Reads an image file and returns a parsed Image2D spatial element"""
# this function is just a draft, the more general one will be available when
# https://github.com/scverse/spatialdata-io/pull/234 is merged
Expand Down

0 comments on commit 0246011

Please sign in to comment.