Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions src/scippnexus/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,19 +217,7 @@ def __getitem__(self, select: ScippIndex) -> Any | sc.Variable:
if self.dataset.name.endswith('/depends_on') and variable.ndim == 0:
return DependsOn(parent=self.dataset.parent.name, value=variable.value)
elif variable.values.flags["C_CONTIGUOUS"]:
# On versions of h5py prior to 3.2, a TypeError occurs in some cases
# where h5py cannot broadcast data with e.g. shape (20, 1) to a buffer
# of shape (20,). Note that broadcasting (1, 20) -> (20,) does work
# (see https://github.com/h5py/h5py/pull/1796).
# Therefore, we manually squeeze here.
# A pin of h5py<3.2 is currently required by Mantid and hence scippneutron
# (see https://github.com/h5py/h5py/issues/1880#issuecomment-823223154)
# hence this workaround. Once we can use a more recent h5py with Mantid,
# this try/except can be removed.
try:
self.dataset.read_direct(variable.values, source_sel=index)
except TypeError:
variable.values = self.dataset[index].squeeze()
self.dataset.read_direct(variable.values, source_sel=index)
if self.errors is not None:
self._load_variances(variable, index)
else:
Expand Down
Loading