-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
ValueError: low level cast function is for unequal type numbers for object types #2798
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
Conversation
… for object types
This There are really too many ways to create dtypes..... |
Reply by Andrew Collette, author of h5py, on the numpy discussion mailing list on 13 Dec 22:57: "
I am also seeing this problem; there was a change to how string types
Yes, this seems to be the cause of issue 217. |
@cgohlke, could you please write a test for this too? |
I am not very familiar with this part of numpy. But if Ralf or others are giving the patch +1, I am ok to merge this to 1.7. It seems simple enough that hopefully things will not break. |
@cgohlke either that, or maybe |
@rgommers, are you +1 with this patch? All tests pass (the only failure is the old python 3.1 which was removed from Travis and we fixed it in our .travis.yml in the meantime) and it looks ok to me. |
Backported in #2859. |
I'm not familiar with that code either, but it looks like the patch makes the object type special, just as datetime and timedelta are. That 'feels' like it might be the right thing but I can't say much more without a longer look at the code. @cgohlke It might be nice to have a comment in the code explaining the reason. That said, I tend to trust Christoph's judgement in these things. |
@cgohlke, or you can explain your reasoning in the commit log. For example to me, as somebody who is not familiar with this part of the code, I have no idea what your patch does, or is intending to do. All I can see is that it fixes some problem with astype(). |
The Travis failure is due to the missing Python 3.1 |
@cgohlke I would like to release rc1 today or early tomorrow. If you could please address the reviews, let's get it in and release. If not, then it will have to wait for rc2, or go into 1.8. |
Looking at the code some, this patch is definitely not a complete fix for whatever's going on here... there are only two call sites for I suspect the correct fix is to just delete the check and error message entirely. This function is just responsible for fixing up alignment/byte-order and delegating to the lower-level functions that actually know how to do casting for different types, so having a check on the types here is reaaally fishy. |
Well, stuck up the just-delete-the-check patch as #2863. |
At least, I hope it's spurious. Certainly it's creating a spurious error message, is unexpected by callers (one of whom specifically makes the *opposite* check before calling get_cast_transfer_function), and even if it is a useful check for some reason I can't see, it certainly doesn't belong in this function (which is otherwise just taking care of byte-swapping and alignment issues and doesn't know anything about dtypes). And worst case, we'll have turned an exception into a crash; even if I'm wrong, this shouldn't cause any code to go from working to not working, just from broken to slightly-more-broken. Test and original diagnosis by @cgohlke. Fixes gh-2798.
This was reported on the numpy-discussion mailing list.
The following code using np.object_ data types works with numpy 1.5.1 but fails with 1.6.2. Other data types, np.float64 for example, seem to work.
These downstream issues could be related:
I'm not entirely sure the proposed patch is correct/best, but it seems to fix this and the h5py issue.