Skip to content

BUG: Fix ma coercion list-of-ma-arrays if they do not cast to bool#18605

Merged
charris merged 3 commits intonumpy:mainfrom
seberg:issue-18551
Mar 16, 2021
Merged

BUG: Fix ma coercion list-of-ma-arrays if they do not cast to bool#18605
charris merged 3 commits intonumpy:mainfrom
seberg:issue-18551

Conversation

@seberg
Copy link
Copy Markdown
Member

@seberg seberg commented Mar 12, 2021

There was a regression here due to force casting to bool, but if that
happens to fail (it does, but should not for strings). The mask
would just be dropped.

Of course masked arrays are held together by faith here, but its
a regression.

Closes gh-18551


This is a small regression introduced when the ragged warning was added. Apparently, this code runs into it (but I assume should not). So the dtype has to be passed to avoid a warning.

I tried to remove the inner asarray call, but it runs into the warnings. Replacing the dtype with the original (which is arguably right, since the result is definitely not masked) works. If that is too shady for a backport and we want one, I can try to look further.

There was a regression here due to force casting to bool, but if that
happens to fail (it does, but should not for strings). The mask
would just be dropped.

Of course masked arrays are held together by faith here, but its
a regression.

Closes numpygh-18551
@charris charris closed this Mar 16, 2021
@charris charris reopened this Mar 16, 2021
@charris charris added 06 - Regression 09 - Backport-Candidate PRs tagged should be backported labels Mar 16, 2021
@charris charris added this to the 1.20.2 release milestone Mar 16, 2021
@charris charris merged commit b1deaa0 into numpy:main Mar 16, 2021
@seberg seberg deleted the issue-18551 branch March 16, 2021 23:16
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Mar 17, 2021
@charris charris removed this from the 1.20.2 release milestone Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

np.ma.asarray looses mask for str array

2 participants