Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type hint for CoordinateSpace axis #228

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python-spec/src/somacore/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CoordinateSpace(collections.abc.Sequence[Axis]):
Lifecycle: experimental
"""

axes: Tuple[Axis] = attrs.field(converter=tuple)
axes: Tuple[Axis, ...] = attrs.field(converter=tuple)

@axes.validator
def _validate(self, _, axes: Tuple[Axis, ...]) -> None:
Expand Down
11 changes: 11 additions & 0 deletions python-spec/testing/test_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import pytest

from somacore import AffineTransform
from somacore import Axis
from somacore import CoordinateSpace
from somacore import CoordinateTransform
from somacore import IdentityTransform
from somacore import ScaleTransform
Expand All @@ -28,6 +30,15 @@ def check_transform_is_equal(
assert False


def test_coordinate_space():
coord_space = CoordinateSpace(
(Axis("x", unit="nanometer"), Axis("y", unit="nanometer")) # type: ignore[arg-type]
)
assert len(coord_space) == 2
assert coord_space.axis_names == ("x", "y")
assert coord_space[0] == Axis("x", unit="nanometer")


@pytest.mark.parametrize(
("input", "expected"),
[
Expand Down
Loading