8000 BUG: Fix TestStringDiscovery float casting warning on FreeBSD by abhishek-iitmadras · Pull Request #28331 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fix TestStringDiscovery float casting warning on FreeBSD #28331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

abhishek-iitmadras
Copy link
Contributor
@abhishek-iitmadras abhishek-iitmadras commented Feb 13, 2025

Fixes #28329

The test_nested_arrays_stringlength test in test_array_coercion.py was failing on FreeBSD due to a platform-specific RuntimeWarning when casting float objects to string dtype. This PR modifies the test to properly handle and verify this warning.

Changes:

  • Add FreeBSD-specific warning handling for float-to-string dtype conversion
  • Only check for warning with float values, as other types don't trigger it
  • Keep original test behavior for non-float types and non-FreeBSD platforms
  • Add assertion to verify exactly one warning is raised, preventing multiple or unexpected warnings

cc: @ngoldbaum @rgommers @charris

@abhishek-iitmadras abhishek-iitmadras marked this pull request as ready for review February 13, 2025 17:16
@abhishek-iitmadras abhishek-iitmadras changed the title fix freebsd test failure [BUG]: Fix TestStringDiscovery float casting warning on FreeBSD Feb 13, 2025
@abhishek-iitmadras abhishek-iitmadras force-pushed the patch-2 branch 2 times, most recently from e9f1d98 to 31c0e1e Compare February 13, 2025 17:50
@abhishek-iitmadras abhishek-iitmadras changed the title [BUG]: Fix TestStringDiscovery float casting warning on FreeBSD BUG: Fix TestStringDiscovery float casting warning on FreeBSD Feb 13, 2025
@charris charris added 00 - Bug 09 - Backport-Candidate PRs tagged should be backported labels Feb 13, 2025
@ngoldbaum
Copy link
Member

Sorry to keep giving you pushback like this, but I want to strongly discourage you from "fixing" bugs by ignoring errors or warning in the tests without first doing some investigation to justify doing so.

This just started failing recently, it's likely due to a change in freebsd or in numpy. We should figure that out. If CI has a failing job for a little while that's OK.

@abhishek-iitmadras
Copy link
Contributor Author

Sorry to keep giving you pushback like this, but I want to strongly discourage you from "fixing" bugs by ignoring errors or warning in the tests without first doing some investigation to justify doing so.

This just started failing recently, it's likely due to a change in freebsd or in numpy. We should figure that out. If CI has a failing job for a little while that's OK.

Thanks @ngoldbaum , completely agree with your point.
Initial failure is regarding base image change fix i 8000 n PR #28328.

@abhishek-iitmadras abhishek-iitmadras force-pushed the patch-2 branch 10 times, most recently from ad0bdd9 to 80986de Compare February 17, 2025 10:47
@abhishek-iitmadras
Copy link
Contributor Author
abhishek-iitmadras commented Feb 17, 2025

Update patch and commit msg.
Please re-check this patch again.
@ngoldbaum @rgommers

The current CI failure Linux Qemu tests / loongarch64 (pull_request) has nothing to do with this patch.

@ngoldbaum
Copy link
Member

without first doing some investigation to justify doing so

Did you do the investigation to justify disabling the warning?

I’m reading into your motivations a bit in what follows so apologies if I’m assuming incorrectly.

Note that the CI does not need to be all green on your other PR to merge it, so pushing on this isn’t helping your other PR or helping to unblock turning on aarch64 CI. Please have some patience. Ignoring me is making me less likely to look at your PRs.

@abhishek-iitmadras
Copy link
Contributor Author

Hi @ngoldbaum

Did you do the investigation to justify disabling the warning?

Yes, I have tried to investigate the following part of the code, but based on my knowledge, I did not find any specific issues related to FreeBSD: https://github.com/numpy/numpy/blob/e20317a43d3714f9085ad959f68c1ba6bc998fcd/numpy/_core/src/multiarray/stringdtype/casts.cpp#L1191C1-L1256C3

Note that the CI does not need to be all green on your other PR to merge it, so pushing on this isn’t helping your other PR or helping to unblock turning on aarch64 CI. Please have some patience. Ignoring me is making me less likely to look at your PRs.

Agree with you on this.

Initially, I applied a patch to ignore runtime warnings across all platforms using the following code (which is not good at all):
@pytest.mark.filterwarnings("ignore:invalid value encountered in cast:RuntimeWarning")

Now, I have the patch to ignore warnings for a specific test on FreeBSD, focusing on a single warning related to float-to-string conversions only (may be a good improvement from the initial approach).

My purpose of this patch is not to unblock my other PRs. Instead, I am focused on understanding how the NumPy codebase operates, particularly how NumPy tests and handles warnings. I hope this clarifies my motivation for this patch.

@abhishek-iitmadras
Copy link
Contributor Author

I am going to close this patch. Further investigation may be required.

Thanks @ngoldbaum

@rgommers
Copy link
Member

@ngoldbaum checking the approach here: why wouldn't we merge this? It doesn't close the issue, but CI has been red for days, so merging this PR to turn it green and then defer detailed investigation of this pretty niche issue till later seems like the right approach to me.

@ngoldbaum
Copy link
Member

I was hoping someone would look more closely to understand what’s happening inside a freebsd VM. I’ll try to do that tomorrow.

I was asked to re-review the PR and didn’t see any response besides just rebasing the original commit and an ask to re-review.

I’m reopening and will merge this tomorrow if I can’t figure out a better explanation for what’s happening besides “freebsd changed something”.

@ngoldbaum ngoldbaum reopened this Feb 17, 2025
@mattip
Copy link
Member
mattip commented Feb 18, 2025

I think opening a new issue and merging this PR is the best way forward.

@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Feb 21, 2025
@charris
Copy link
Member
charris commented Feb 21, 2025

Closing this, #28358 fixes it.

@charris charris closed this Feb 21, 2025
@abhishek-iitmadras abhishek-iitmadras deleted the patch-2 branch February 24, 2025 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test_array_coercion.TestStringDiscovery test failure on FreeBSD 14.2
5 participants
0