-
Notifications
You must be signed in to change notification settings - Fork 20
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
deep_type throws error on list of numpy ints #27
Comments
Are you using the latest release or the repository version? |
I am using the latest from the repository. The error occurs even if there is no repeated element.
|
Okay, confirmed. However this boils down to strange behavior with
yields the same error, completely independent of We can add a workaround like this:
I'm a bit concerned to become bug-compatible with numpy. However in favor of workability and robustness I would add this workaround. Opinions? |
It is the intended behavior, however I am not sure if it is sane or not. With numpy you can compare a number against a list.
Having a workaround for robustness is good. With numpy the
Perhaps, something like this:
|
Then maybe an actual numpy-specific workaround would be best:
I'm not sure if we should also catch the |
This third version |
There is another similar issue with numpy and type checking with this package. import numpy
from pytypes import type_util
type_util._isinstance(numpy.array([1,2,3]), numpy.ndarray)
Why is there |
Empty lists, sets, dicts and other containers are specially problematic for That said, I did not test with numpy types so far. I didn't expect them to be specifically problematic. |
Also: Sorry that I currently have no time to work much on these issues. I'm rather bound by another project. A soon as I can I will wrap things up for a new release, including this issue. |
I opened: numpy/numpy#10399 and numpy/numpy#10400 I think that the crazy conversion of int64s to numpy array is really a bug in numpy. But probably it is something magical they like and will probably not change. So we should think about how to support that. |
Yes, this fixes the issue for me. |
The issue @kyao reported above, is in fact coming from type checking as well: import numpy
import typing
from pytypes import type_util
type_util._isinstance({'mapping': [numpy.int64(1), numpy.int64(1)]}, typing.Dict)
It seems |
One idea. In |
I made #29 which fixes all of the issues mentioned here. |
The following code causes deep_type to throw a ValueError:
The text was updated successfully, but these errors were encountered: