Skip to content

Interface/decorator for ValueType class #38

@capsulecorplab

Description

@capsulecorplab

The ValueType class (in parametrics.py module) should inherit the UnitRegistry behavior from pint and astropy and still be a subclass of ModelElement. ValueType can be implemented as either a decorated class or subclass that inherits from both UnitRegistry objects/classes.

e.g.,

>>> kesselrun = 12*ValueType('parsecs')
>>> kesselrun
<ValueType(12, 'parsec')>
>>> kesselrun.magnitude
12
>>> str(kesselrun.units)
'parsec'
>>> kesselrun.to('lightyear')
<ValueType(39.138799173399406, 'light_year')>
>>> 2*kesselrun
<ValueType(24, 'parsec')>
>>> type(kesselrun)
ValueType
>>> isinstance(kesselrun, ModelElement)
True

Additional unit tests welcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    HacktoberfestIn celebration of open sourcehelp wantedExtra attention is neededneeds design feedbackDesign implementation needs feedback

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions