-
-
Notifications
You must be signed in to change notification settings - Fork 386
override generated __eq__ to work with numpy fields #409
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
Comments
I’m afraid you’ll have to disable attrs’ eq and write it yourself. This is a super edgy edge case so I don’t think it makes a lot of sense to add special hooks for it. Are you aware of the reason why numpy arrays don't allow for comparison using |
Yes, there's a very explicit error message if you try do it and it makes sense: for the way they make use of python syntax, a == would be ambigous if used to compare 2 arrays, so they offer numpy.array_equal.
Can you explain me how? Just writing a eq method in my class doesn't work because I believe attrs eq is generated afterward. |
Your approach might work in the future (see #324) until then you'll have to pass |
Oh, perfect, thank you very much |
I would like to know how to override generated methods in attrs. From the documentation is not clear.
My problem is that if I put some numpy arrays as values, the regular "==" operator fails because
np.array_equal
should be used instead.The error is the following:
The text was updated successfully, but these errors were encountered: