Skip to content

Method parameters: single quantity versus sbpy DataClass #405

@mkelley

Description

@mkelley

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions