8000 ENH: Add mask comparison support to `assert_array_equal` and `assert_equal` by Prtm2110 · Pull Request #30617 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@Prtm2110
Copy link
@Prtm2110 Prtm2110 commented Jan 9, 2026

Fixes: #30564

I added equal_mask keyword arg to assert_array_compare allowing it to be passed in assert_array_equal and assert_equal. I believe this should be done for other functions like assert_array_almost_equal which uses assert_array_compare internally, please let me know if this is required.

Apologies in advance, I haven’t read the contribution guidelines yet. I’ll read them ASAP and make the necessary changes.

@Prtm2110 Prtm2110 changed the title Add mask comparison support to assert_array_equal and assert_equal ENH: Add mask comparison support to assert_array_equal and assert_equal Jan 9, 2026
@Prtm2110
Copy link
Author

Please have a look at this PR and let me know the changes required.

Copy link
Member
@jorenham jorenham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gave this a quick look and left some preliminary review suggestions. There's quite a lot of code, and reviewing this thoroughly is going to be pretty time consuming, so it might take us a while to get to it.

But it's important to note that we've been trying to move away from masked arrays lately, rather than add more support for it, as that would make it even more difficult. And seeing as this might send of the wrong signal in that aspect, So although this seems like a useful feature in isolation, I'm just not sure if this is actually something that we should add, given the context.

@Prtm2110
Copy link
Author

But it's important to note that we've been trying to move away from masked arrays lately, rather than add more support for it, as that would make it even more difficult. And seeing as this might send of the wrong signal in that aspect, So although this seems like a useful feature in isolation, I'm just not sure if this is actually something that we should add, given the context.

That makes sense, it works for me.

@mattip
Copy link
Member
mattip commented Jan 26, 2026

Is there a reason not to use np.ma.allclose or np.ma.allequal?

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.

ENH: equal_mask flag for assert_array_equal

3 participants

0