scipp / scippnexus

h5py-like utility for NeXus files with seamless scipp integration
https://scipp.github.io/scippnexus/
BSD 3-Clause "New" or "Revised" License
3 stars 3 forks source link

`NXobject.create_field` and `__setitem__` ignoring variances when passing `scipp.Variable`? #105

Closed SimonHeybrock closed 11 months ago

SimonHeybrock commented 1 year ago

Check the code, and add a test.

jl-wynen commented 11 months ago

There is a conceptual problem: What is a Field exactly? Does it contain errors or is it simply a HDF5 dataset? In the former case, the current interface of returning a H5Dataset from create_field and co. no longer works. In the latter, it create_field cannot save variances.

If we go with the latter, we could check for variances in create_field and raise if there are any. But this would mean that users would always have to extract the values: create_field(data=sc.values(var), ...)

SimonHeybrock commented 11 months ago

For reading, we treat a field as the combination of the value and error datasets. We should do the same for writing.

the current interface of returning a H5Dataset from create_field and co. no longer works

We could return the value dataset only? Or a tuple? I think the utility of the return value is mainly to be able to set additional attributes. In NeXus this is mostly (or even exclusively?) defined for the values dataset. Therefore I think we would be fine by simply returning that.