-
Notifications
You must be signed in to change notification settings - Fork 4
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
Save errors in create_field #167
Conversation
9ca8837
to
c2ae457
Compare
values_dataset.attrs.update(attrs) | ||
if errors is not None: | ||
errors_dataset = group.create_dataset(name + '_errors', data=errors, **kwargs) | ||
errors_dataset.attrs.update(attrs) |
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.
I am not sure the units
attribute (or any others) should we written here?
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.
On the other hand... I can't see any harm, even if the standard does not require it?
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.
I think the standard is silent on this. I did it just in case they are useful. But I'm fine with not writing them.
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.
Can you check with Tobias? If the standard does not specify them, maybe we should not write them either. Otherwise we may end up in situations where our reading code (which uses this for testing) only works with files that where written using ScippNexus.
76c9035
to
5230d5b
Compare
src/scippnexus/base.py
Outdated
@@ -235,13 +235,14 @@ def _make_child(obj: Union[H5Dataset, H5Group]) -> Union[Field, Group]: | |||
items = {k: v for k, v in items.items() if not k.startswith('cue_')} | |||
for suffix in ('_errors', '_error'): | |||
field_with_errors = [name for name in items if f'{name}{suffix}' in items] | |||
print(suffix, field_with_errors) |
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.
print(suffix, field_with_errors) |
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.
Oops. We should use https://pypi.org/project/flake8-print/. Or switch to Ruff like Scitacean: https://docs.astral.sh/ruff/rules/#flake8-print-t20
9eafdaa
to
55d6ff3
Compare
@@ -434,6 +434,24 @@ def test_errors_read_as_variances(h5root): | |||
assert np.array_equal(dg['time'].variances, np.arange(5.0) ** 2) | |||
|
|||
|
|||
def test_does_not_require_unit_of_errors(h5root): |
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.
With the latest change, is there a test that checks behavior for mismatching error units?
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.
Yes:
scippnexus/tests/nexus_test.py
Line 215 in 54642fe
def test_field_errors_with_different_unit_handles_them_individually(nxroot): |
Fixes #105