Repository navigation
fix(results): project NumPy scalar measurements as plain JSON values - #796
Closed
Abhishek-B-R wants to merge 1 commit into
Closed
Abhishek-B-R wants to merge 1 commit into
Abhishek-B-R wants to merge 1 commit into
Conversation
MeasuredCheck accepted a measurement only when its type was exactly str, bool, int or float, so project_results raised "selected measurement is not a finite JSON scalar" for a check that returned np.float64(0.5) or np.int64(3), values the catalog stores without complaint. NumPy scalars are now converted with .item() first, the same way the catalog does, and the existing type and finiteness checks run on the result.
|
👋 Hi @Abhishek-B-R — thanks for the contribution! To keep starter issues available You already have #795 open, so this one is being closed automatically. |
Contributor
[Medium impact] The PR appears safe to merge.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
project_resultsnow accepts measurements a check returned as NumPy scalars. Before, selecting a measurement whose value wasnp.float64(0.5)ornp.int64(3)raisedValueError: selected measurement is not a finite JSON scalar, even though the value is finite and the catalog stores it as0.5/3.Why
MeasuredCheck.__post_init__checkstype(value) not in (str, bool, int, float). That exact type test refuses every NumPy scalar,np.float64included, which is what a check gets from almost any NumPy reduction. The catalog boundary converts these with.item()(#126), so the same report records fine and only fails when it is projected for an external consumer.Repro:
MeasuredChecknow convertsnp.genericvalues with.item()before the existing checks, so the payload still holds only plainstr,bool,intandfloat, and a NumPy NaN is still refused as non-finite.Validation
test_result_projection_accepts_numpy_scalar_measurementsintests/test_result_projection.py: fails on main with theValueErrorabove, passes with the fix. It also checks thatnp.float32("nan")is still refused.uv run pytest -q tests/test_result_projection.py: 5 passed.pytest -q -n 4in theuv sync --lockedenvironment (macOS, Python 3.11): 2598 passed, 49 skipped.uv run ruff check,uv run ruff format --check,uv run ty check: clean.Checklist
uv run ruff check --fix,uv run ruff format, anduv run ty check.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.