Skip to content

Silence NonInteractiveExampleWarning in test_unary #318

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

Merged
merged 2 commits into from
Nov 20, 2024

Conversation

jakevdp
Copy link
Contributor

@jakevdp jakevdp commented Nov 20, 2024

The .example() call leads to a number of warnings in the test suite:

/.../array-api-tests/array_api_tests/test_special_cases.py:1253: NonInteractiveExampleWarning: The `.example()` method is good for exploring strategies, but should only be used interactively.  We recommend using `@given` for tests - it performs better, saves and replays failures to avoid flakiness, and reports minimal examples. (strategy: from_dtype(float64, min_value=0.0, max_value=13_407_807_929_942_595_611_008_317_640_802_934_282_464_207_265_959_107_021_466_054_756_094_376_573_581_619_054_852_612_241_927_956_455_650_759_996_398_703_782_412_109_633_178_814_162_067_569_513_603_268_608, exclude_min=True))
    in_value = case.cond_from_dtype(xp.float64).example()

I don't see an easy way for @given to be used here, but silencing the warning will make it more friendly to downstream CI jobs.

@asmeurer
Copy link
Member

These special case tests are doing some strange things with hypothesis. It's not clear to me if there aren't other downsides to using example here, or even if we can be sure that just drawing one example is going to definitely do what we want. IMO we should either draw multiple examples normally, like we used to, or just hard-code a specific example, rather than just assuming that a single hypothesis draw is going to work.

At any rate, we do need to clear all the annoying warnings that are currently printed. I will add a comment to the code here and merge this.

@asmeurer asmeurer enabled auto-merge November 20, 2024 22:36
@asmeurer asmeurer merged commit ad81cf6 into data-apis:master Nov 20, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants