Skip to content

Commit

Permalink
💄 ui(frames): improve Coordinate str repr (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
nstarman authored Dec 29, 2024
1 parent 0b31390 commit fc2e151
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/coordinax/_src/frames/coordinate.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ def __repr__(self) -> str:
"""
# NOTE: this is necessary because equinox __repr__ isn't great
str_fs = ",\n".join(indent(f"{k}={v}", " ") for k, v in field_items(self))
return f"{type(self).__name__}(\n{str_fs}\n)"
cls_name = type(self).__name__
str_fs = ",\n".join(indent(f"{k}={v!r}", " ") for k, v in field_items(self))
return f"{cls_name}(\n{str_fs}\n)"

_repr_latex_ = __repr__ # TODO: implement this

Expand All @@ -116,7 +117,9 @@ def __str__(self) -> str:
)
"""
return self.__repr__()
# NOTE: this is necessary because equinox __repr__ isn't great
str_fs = ",\n".join(indent(f"{k}={v}", " ") for k, v in field_items(self))
return f"{type(self).__name__}(\n{str_fs}\n)"


##############################################################################
Expand Down Expand Up @@ -202,6 +205,9 @@ class Coordinate(AbstractCoordinate):
converter=Unless(AbstractReferenceFrame, TransformedReferenceFrame.from_)
)

# ===============================================================
# Vector API

@override
def _dimensionality(self) -> int:
"""Dimensionality of the vector.
Expand All @@ -220,9 +226,6 @@ def _dimensionality(self) -> int:
# TODO: Space is currently not implemented.
return self.data._dimensionality() # noqa: SLF001

# ===============================================================
# Vector API

@dispatch
def __getitem__(self: "Coordinate", index: Any) -> "Coordinate":
"""Return Coordinate, with indexing applied to the data.
Expand Down

0 comments on commit fc2e151

Please sign in to comment.