-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
np.testing.assert_almost_equal Issue in Python 3.5 for numpy==1.15.0 #11743
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
Weird. But your suggestion should work. (I'm on holidays so won't be able to check too much or make a PR; @foohyfooh - if you can, that would be great!) |
@foohyfooh Can you come up with simpler code that triggers the problem? |
import numpy as np
from pyrr.objects import Vector3
np.testing.assert_almost_equal(Vector3(), Vector3()) |
@foohyfooh I'm looking for something without outside dependencies so it can be added to numpy as a test. |
@charris Sorry I didn't recognize that is what you were looking for. I don't think I have a test other than what is happening in the Pyrr library. |
What is special about Vector3? We can make a testing class if needed. |
Nothing is special about it. It is just that the classes in Pyrr allow for positional element access just like numpy arrays. |
So this is a Python change, not a NumPy 1.15 thing? Now you have me wondering why it should work. Are the Vector3 classes instances of list or some other sequence type? |
But the test worked fine with NumPy 1.14.5 when using Python 3.5. |
A quick look says that they are ndarray subclasses.
…On Wed, Aug 15, 2018 at 7:51 PM Jonathan Herbert ***@***.***> wrote:
But the test worked fine with NumPy 1.14.5 when using Python 3.5.
Is there any change that was made between 1.14.5 and 1.15.0 that a
specific effect in Python 3.5 only?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#11743 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACNRkWR9LkkdjHZo_X6AOSQWipcWU7NWks5uRLPpgaJpZM4V-Ap6>
.
|
It looks like Vector3 subclasses ndarray, but the
Note that comparing arrays returns an array, but I suspect you have overloaded that operator and Vector3 no longer behaves like an array. That, in combination with the changes in testing, where it checks that it is working with an array and wrongly assumes that Vector3 acts like one -- it is an instance of ndarray after all -- and calls a method that the comparison result should have. So, we can work around that maybe, but the base class you are using maybe should not inherit from ndarray. |
@ewmoore Thanks for pointing that out. I can't believe that I missed that. |
Thank you for helping me sort out this issue. I will attempt to resolve the issue in Pyrr and verify that everything is working as it should. |
If you are looking for other ways to do things, the mailing list is a good resource. There have been recent additions to numpy, |
I'm thinking we should still make the suggested change on our end, as the dos and don'ts of subclassing are probably not as clearly set out as might be desired. In particular, scalars vs 1-D array returns can be a problem with a lot of functions. |
Implement fix suggested by @charris See numpy#11743
@foohyfooh - definitely don't worry about making a bug report if we break something, even if it turns out to be something that really one shouldn't have relied upon! |
Use np.all instead of the *.all method to be a bit more robust against bad subclasses of ndarray that may change the behavior of the method. Closes numpy#11743.
Use np.all instead of the *.all method to be a bit more robust against bad subclasses of ndarray that may change the behavior of the method. Closes numpy#11743.
The issues seems to be that in numpy/testing/_private/utils.py
(x_id == y_id).all()
on Line 707 is returning abool
in Python 3.5 and thus calling all on it is giving anAttributeError
.This is causing errors when testing the Pyrr package.
Note: This issue occurs with numpy==1.15.0 but not numpy==1.14.5
Reproducing code example:
This is one of the four code snippets that has the error is occurring.
Error message:
The errors can be found at https://travis-ci.org/adamlwgriffiths/Pyrr/jobs/415907003
Lines: 486, 502, 518, 534
The following is the Traceback from Travis CI
Numpy/Python version information:
1.15.0 3.5.5 |Anaconda, Inc.| (default, Apr 7 2018, 04:52:34) [MSC v.1900 64 bit (AMD64)]
The text was updated successfully, but these errors were encountered:
8000