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

Method parameters: single quantity versus sbpy DataClass #405

Open
mkelley opened this issue Aug 19, 2024 · 0 comments
Open

Method parameters: single quantity versus sbpy DataClass #405

mkelley opened this issue Aug 19, 2024 · 0 comments

Comments

@mkelley
Copy link
Member

mkelley commented Aug 19, 2024

When a method uses a single quantity that may be found in an sbpy DataClass, sbpy's coding guidelines recommends internally transforming that quantity into a DataClass object. From the docs:

@quantity_to_dataclass(eph=(Ephem, 'phase'))
def phase_func(eph):
    ...

This buries the physical dependency of the method (although that can be addressed in the docstring), and it also makes the code slightly harder to read, with references to eph["phase"] versus just phase.

Following the Zen of Python, where it is stated that "Simple is better than complex," and "Flat is better than nested," perhaps we should reverse the rule and instead transform DataClass to Quantity?

@dataclass_to_quantity(phase=(Ephem, "phase"))
def phase_func(phase):
    ...

This approach would still validate the parameter's dimensions. I think we would deprecate quantity_to_dataclass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant