-
Notifications
You must be signed in to change notification settings - Fork 2
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
Dimension: missing dunder methods #2
Comments
I am very unclear what less or greater means in context of a dimension |
I was thinking of set containment, but yeah, looking again, it'd be confusing for users. |
I agree less than etc aren't needed. I also don't think add or sub are worth including - I don't see when you'd need to do that. I think users should only need to multiply/divide/pow and eq/ne. |
pint's UnitsContainer has: pint's UnitsContainer's attributes```python3 ['__abstractmethods__', '__annotations__', '__class__', '__class_getitem__', '__contains__', '__copy__', '__delattr__', '__dir__', '__doc__', '__eq__', '__firstlineno__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__module__', '__mul__', '__ne__', '__new__', '__orig_bases__', '__pow__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__rtruediv__', '__setattr__', '__setstate__', '__sizeof__', '__slots__', '__static_attributes__', '__str__', '__subclasshook__', '__truediv__', '_abc_impl', '_d', '_hash', '_non_int_type', '_normalize_nonfloat_value', '_one', 'add', 'copy', 'format_babel', 'get', 'items', 'keys', 'remove', 'rename', 'unit_items', 'values'] ```from that list I think we'd want '__contains__',
'__eq__',
'__getitem__',
'__iter__',
'__len__',
'__mul__',
'__ne__',
'__pow__',
'__rmul__',
'__rtruediv__',
'__truediv__', |
actually I'm not sure on whether the dict methods should be included |
what would the semantics be for |
Many pint methods are to support pint's specific structure where everything is composed and it computes via an internal state dict. |
I personally like having the full set of arithmetic operators because then you can write elegant code where an operator callable can be applied to the dimension the same as the higher-level object.
|
There are more dunder methods that are / might be relevant:
Rich relations:
__eq__
__ne__
__lt__
__le__
__gt__
__ge__
Binary operations:
__add__
(where L+L = L)__sub__
(where L-L = L)Thoughts?
The text was updated successfully, but these errors were encountered: