k-wave-python icon indicating copy to clipboard operation
k-wave-python copied to clipboard

[ENHANCE] Element equality for numpy array attributes

Open precicely opened this issue 1 year ago • 0 comments

Description of the Enhancement

The Element class subclasses dataclass which comes inbuilt with various helper functions like __repr__, etc. However, comparisons between Elements will fail as the Element class has attributes that are numpy arrays which have ambiguous equality results unless using something like np.array_equal or similar.

This enhancement will extend the inbuilt __eq__ method provided by dataclass and ensure that numpy arrays are handled correctly.

Justification for the Enhancement

Due to the numpy arrays, it's currently not possible to do the following:

element_1 == element_2

By more intelligently handling the numpy arrays the above will be possible, it will simplify code testing, improve readability and be more pythonic.

Impact of Changes

Will simplify test suite and long term improve readability.

precicely avatar Aug 28 '24 07:08 precicely