Repository navigation
Allow passing a h5py file when opening a file - #238
Conversation
| Parameters | ||
| ---------- | ||
| name: | ||
| Path, Bytes object, or h5py.Group. |
There was a problem hiding this comment.
Can we leave this line out if it's already specified in the type hints? Would avoid it accidentally becoming out of date if we change something in the future...
| class File(AbstractContextManager, Group): | ||
| def __init__( | ||
| self, | ||
| name: str | os.PathLike[str] | io.BytesIO | h5py.Group, |
There was a problem hiding this comment.
If the file is open, is it a h5py.Group or a h5py.File?
There was a problem hiding this comment.
h5py.File. But that is a subclass of h5py.group. So this annotation is enough and also supports passing in a subgroup.
|
|
||
|
|
||
| @pytest.mark.parametrize('path_type', [str, Path]) | ||
| def test_load_entry_from_filename(tmp_path, path_type): |
There was a problem hiding this comment.
tmp_path: I hate pytest and all its hidden conventions/pre-defined objects. It took me a while to figure out where tmp_path was defined... :-(
|
|
||
|
|
||
| def test_load_entry_from_h5py_group_toor(tmp_path): | ||
| with h5.File('test.nxs', 'w', driver='core', backing_store=False) as h5_file: |
There was a problem hiding this comment.
I can't quite figure out if this is creating a file on disk or not. From the h5py docs for backing_store, it says "If False, any changes are discarded when the file is closed."
Does this mean that if the file did not exist, and you did not make changes to it, then no file will be created, or will an empty file be created?
There was a problem hiding this comment.
I don't actually know. This is used everywhere else in the tests. I just copied it from there.
Co-authored-by: Neil Vaytet <[email protected]>
Co-authored-by: Neil Vaytet <[email protected]>
Fixes #236