GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — BUG: MaskedArray.__array_wrap__ propagates a stale, dtype-invalid fill_value across dtype-changing ufuncs · Issue #32401 · numpy/numpy Closed Labels DescriptionDescribe the issue:When a ufunc changes the dtype of a MaskedArray's output relative to its input (e.g. This happens in The stale fill_value does not raise an error immediately -- printing the result, indexing it, etc. all appear to work fine. It only surfaces later, the next time something calls This has been broken since numpy 2.0. Before that, this Reproduce the code example:import numpy as np col = np.ma.MaskedArray(['foo', 'bar', 'baz'], mask=False, fill_value='N/A') result = np.strings.find(col, 'foo') # dtype changes from string to int64 print(type(result), result.dtype) # result silently carries over col's *string* fill_value even though its # own dtype is now int64 -- not validated yet, so this all looks fine: print(result._fill_value) # 'N/A' print(result) # repr works fine print(result[0]) # indexing works fine # But an explicit .view() re-runs numpy's internal fill_value/dtype # consistency check, and that raises an exception: result.view(np.ma.MaskedArray) Error message:Traceback (most recent call last): File ".../numpy/ma/core.py", line 510, in _check_fill_value fill_value = np.asarray(fill_value, dtype=ndtype) ValueError: invalid literal for int() with base 10: np.str_('N/A') The above exception was the direct cause of the following exception: Traceback (most recent call last): File "<string>", line 16, in <module> result.view(np.ma.MaskedArray) File ".../numpy/ma/core.py", line 3264, in view output = super().view(*[a for a in (dtype, type) if a is not None]) File ".../numpy/ma/core.py", line 3138, in __array_finalize__ self._fill_value = _check_fill_value(self._fill_value, self.dtype) File ".../numpy/ma/core.py", line 516, in _check_fill_value raise TypeError(err_msg % (fill_value, ndtype)) from e TypeError: Cannot convert fill_value N/A to dtype int64 Python and NumPy Versions:NumPy 2.5.2 Runtime Environment:How does this issue affect you or how did you find it:This was originally noticed as a downstream bug in astropy's Plain Expected behavior: either Reacted by P. L. Lim ActivityMetadataMetadataAssigneesLabelsTypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |