Repository navigation
fix(statistics): accept finite NumPy scalar measurements #651
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,8 +6,12 @@ | |
| from dataclasses import dataclass | ||
| from itertools import pairwise | ||
|
|
||
| import numpy as np | ||
|
|
||
|
|
||
| def _finite_number(value: float, name: str) -> float: | ||
| if isinstance(value, np.generic): | ||
| value = value.item() | ||
| if isinstance(value, bool) or not isinstance(value, (int, float)): | ||
|
Comment on lines
+13
to
15
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| raise ValueError(f"{name} must be a finite number") | ||
| try: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing utility test runs Python without site-packages and imports
hflow.statistics. This newnumpyimport raisesModuleNotFoundError, so the test fails before its checks run. Keep that import working without site-packages, or change the test and the documented standard-library-only promise together.