-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add a property to access vector dimensionality #174
base: main
Are you sure you want to change the base?
Conversation
@@ -183,7 +187,7 @@ class AbstractPositionTest(AbstractVectorTest): | |||
"""Test :class:`coordinax.AbstractPosition`.""" | |||
|
|||
@pytest.fixture(scope="class") | |||
def vector(self) -> AbstractPosition: # noqa: PT004 | |||
def vector(self) -> AbstractPosition: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rule is deprecated: https://docs.astral.sh/ruff/rules/pytest-missing-fixture-name-underscore/
I agree this would be a useful property!
|
👍
I thought about |
Actually won't this end up creating a lot of copy-pasted code? It would need to go on the position, velocity, acceleration, and need the docstring to follow for 1D, 2D, 3D, 4D. Isn't it cleaner to just compute it automatically as in the current implementation? |
@classproperty
@classmethod
def dims(cls) -> int: ... And I think @classproperty
@classmethod
def components(cls) -> tuple[str, ...]:
return tuple(f.name for f in fields(cls)) |
I thought it might be useful to add this shorthand.