Masked ``_array2string`` doesn't work on some structured arrays
See original GitHub issueDescription
The dispatch function _array2string
in masked.function_helpers
doesn’t work on arrays with strutcured dtypes.
Expected behavior
Masked arrays with structured dtypes can be printed no prob, like their non-masked counterparts.
Actual behavior
It errors because of the structured dtype.
Steps to Reproduce
Here’s an example:
from astropy.utils.masked import Masked
from astropy.uncertainty import Distribution
arr = np.array(Distribution(((np.random.beta(2,5, 10000)-(2/7))/2 + 3))) # just for convenience.
x = Masked(arr, mask=False)
repr(x)
While the following works:
repr(arr)
System Details
macOS-10.16-x86_64-i386-64bit Python 3.9.12 (main, Jun 1 2022, 06:36:29) [Clang 12.0.0 ] Numpy 1.22.3 pyerfa 2.0.0.1 astropy 5.2.dev131+ga2da0589eb.d20220607 Scipy 1.8.1 Matplotlib 3.5.2
Issue Analytics
- State:
- Created a year ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Strange Error when adding 2 numpy masked arrays
This isn't a masked array issue; it's a string dtype one. In [254]: a = np.arange(4) In [255]: a Out[255]: array([0, 1, 2,...
Read more >structured arrays slow to mask · Issue #17850 - GitHub
Fitting the data into one (n, 5) array works, and masking is equally fast with a (5, n) array. I'd love to use...
Read more >NumPy 1.14.0 Release Notes
In short, it is now the case that, when changing a view of a masked array, ... If you experience an unexpected import...
Read more >Numpy manual contents
Numpy manual contents¶ · Ones and zeros · numpy.empty · numpy.empty_like · From existing data · numpy.array · numpy.asarray · Creating record arrays...
Read more >Source code for numpy.ma.core - Astropy
OverflowError is seldom used, and the real problem here is # that the passed ... a : structured array Returns ------- output :...
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 FreeTop 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
Top GitHub Comments
Fix in #13404!
The problem is the array-valued field. It is clear I never tested that…