10000 Selectors do not raise a warning, if input values are NaN by padix-key · Pull Request #26 · aivant/peppr · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Selectors do not raise a warning, if input values are NaN #26

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 1 commit into from
May 5, 2025

Conversation

padix-key
Copy link
Collaborator

No description provided.

@padix-key padix-key requested a review from cisert May 5, 2025 14:38
Copy link
@cisert cisert left a comment

Choose a reason for hiding this comment

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

Just had one small clarifying question, otherwise LGTM! 👍

Comment on lines +31 to +54
@pytest.mark.filterwarnings("error")
@pytest.mark.parametrize("smaller_is_better", [False, True])
@pytest.mark.parametrize(
"selector",
[
peppr.MeanSelector(),
peppr.OracleSelector(),
peppr.TopSelector(5),
peppr.TopSelector(1),
peppr.RandomSelector(5, seed=0),
],
ids=lambda selector: selector.name,
)
def test_nan_values(selector, smaller_is_better):
"""
Check that :meth:`Selector.select()` returns NaN if all values are NaN, without
raising a warnings.
If any value is not NaN, the selector should return an actual value.
"""
values = np.full(10, np.nan)
assert np.isnan(selector.select(values, smaller_is_better))
# Expect a non-NaN value if the input contains any non-NaN value
values = np.concatenate([np.arange(9), [np.nan]])
assert not np.isnan(selector.select(values, smaller_is_better))
Copy link

Choose a reason for hiding this comment

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

@pytest.mark.filterwarnings("error")

Would this fail if we raised a warning? 🤔

Copy link
Collaborator Author
@padix-key padix-key May 5, 2025

Choose a reason for hiding this comment

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

Yes

@cisert cisert self-requested a review May 5, 2025 16:09
@padix-key padix-key merged commit ae7b6a8 into main May 5, 2025
6 checks passed
@padix-key padix-key deleted the nan-selector branch May 5, 2025 16:12
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
0