From 9b78503b8434aba24bfdfeba253b2915f2e4aeef Mon Sep 17 00:00:00 2001 From: Mridul Seth Date: Mon, 4 Aug 2025 13:03:03 +0200 Subject: [PATCH] MAINT: remove try/except block required for old mantid/h5py pin --- src/scippnexus/field.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/scippnexus/field.py b/src/scippnexus/field.py index 183eb5d9..778c109f 100644 --- a/src/scippnexus/field.py +++ b/src/scippnexus/field.py @@ -218,19 +218,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: