GoLP-IST / nata

Python visualization and post-processing library for particle-in-cell codes
MIT License
33 stars 15 forks source link

Remove attrs from 'attrib_equality' and let it check only for custom dunder methods if available #47

Closed ahelm closed 4 years ago

ahelm commented 4 years ago

In the current implementation nata.utils.attrs.attrib_equality() uses a hack to check if equality of two objects based on attributes defined with attr. While it works out and fulfills it's purpose, it seems a little bit hacky. In particular, the part were attributes with attr.ib(..., eq=True, ...) are actually only considered. I think we should use a custom dunder method to specify how objects are checked. If this exist in an object, then this will be considered. Otherwise we check for equality between the objects.

ahelm commented 4 years ago

Also the name of the function is quite misleading. I think we might consider renaming it to something like equal_objects or objects_equiv.