Skip to content

Fix bug in cfdm.netcdf_indexer that sometimes caused a failure with a np.newaxis index#400

Merged
davidhassell merged 9 commits intoNCAS-CMS:mainfrom
davidhassell:h5py-newaxis
Mar 25, 2026
Merged

Fix bug in cfdm.netcdf_indexer that sometimes caused a failure with a np.newaxis index#400
davidhassell merged 9 commits intoNCAS-CMS:mainfrom
davidhassell:h5py-newaxis

Conversation

@davidhassell
Copy link
Contributor

Fixes #395

@davidhassell davidhassell added bug Something isn't working cf-python labels Mar 22, 2026
@davidhassell davidhassell added this to the NEXTVERSION milestone Mar 22, 2026
Copy link
Member

@sadielbartholomew sadielbartholomew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes the fix and adds suitable testing. I've also recreated the original issue using the MRE in #395 (comment) and confirmed this PR fixes it.

Some typos (see in-line) but other than that all good, so please merge once those are in.

Comment on lines -85 to -86
self.close(dataset0)
del dataset, dataset0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you intend to remove these cleanup calls? If so what's the justification - were they redundant or made so?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes - I did mean to move these :) It was a bug to have them higher because once closed, the self._attributes(variable) call a few lines below wouldn't work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry - a bit confused. The correct close is lower down in the code - these deleted lines crept in, somewhere down the line and needed to be booted out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK sure - so it's all good then? I can mark this as resolved or go for it if you want to.

davidhassell and others added 4 commits March 24, 2026 16:51
Co-authored-by: Sadie L. Bartholomew <sadie.bartholomew@ncas.ac.uk>
Co-authored-by: Sadie L. Bartholomew <sadie.bartholomew@ncas.ac.uk>
Co-authored-by: Sadie L. Bartholomew <sadie.bartholomew@ncas.ac.uk>
Co-authored-by: Sadie L. Bartholomew <sadie.bartholomew@ncas.ac.uk>
@davidhassell davidhassell merged commit e6ebddb into NCAS-CMS:main Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Coordinate array materialization can fail with h5netcdf/h5py (TypeError: Indexing with None (or np.newaxis) is not supported)

2 participants