in operator with dtype and set does not work as expected
See original GitHub issueWhen testing if the dtype of an array is present in a set of dtypes, the answer is unexpected.
Reproducing code example:
import numpy as np
f32_dtype = np.zeros(1, dtype=np.float32).dtype
# test with list of dtypes
print(f32_dtype in [np.float32, np.uint8]) # => True (as expected)
# test with set of dtypes
print(f32_dtype in {np.float32, np.uint8}) # => False (not as expected)
Error message:
none
Numpy/Python version information:
numpy 1.18.4 Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)]
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Sorting array of objects by row using custom dtype
In my case, str is a standin for arbitrary objects that support rich comparison. I noted that the sort works perfectly for integers,...
Read more >Working with text data — pandas 1.5.2 documentation
There are two ways to store text data in pandas: object -dtype NumPy array. StringDtype extension type. We recommend using StringDtype to store...
Read more >NumPy: Cast ndarray to a specific dtype with astype()
Basically, one dtype is set for one ndarray object, and all elements are of the same data type. This article describes the following ......
Read more >JAX Errors - JAX documentation - Read the Docs
This error can occur when a JAX Tracer object is used in a context where a Python integer is expected. It typically occurs...
Read more >pandas/base.py at main · pandas-dev/pandas - arrays - GitHub
The ExtensionArray interface does not impose any rules on how this data. is stored. ... Coercion : Most users will expect basic coercion...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Agreed that this is a bit unpleasant - we might be able to adjust
dtype.__hash__
to fix this.Going to close this as duplicate of gh-7242.