Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage to 90% #1198

Merged
merged 18 commits into from
Nov 14, 2024
24 changes: 1 addition & 23 deletions src/hdmf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,10 @@
from . import query
from .backends.hdf5.h5_utils import H5Dataset, H5RegionSlicer
from .backends.hdf5.h5_utils import H5Dataset
from .container import Container, Data, DataRegion, HERDManager
from .region import ListSlicer
from .utils import docval, getargs
from .term_set import TermSet, TermSetWrapper, TypeConfigurator


@docval(
{"name": "dataset", "type": None, "doc": "the HDF5 dataset to slice"},
{"name": "region", "type": None, "doc": "the region reference to use to slice"},
is_method=False,
)
def get_region_slicer(**kwargs):
import warnings # noqa: E402

warnings.warn(
"get_region_slicer is deprecated and will be removed in HDMF 3.0.",
DeprecationWarning,
)

dataset, region = getargs("dataset", "region", kwargs)
if isinstance(dataset, (list, tuple, Data)):
return ListSlicer(dataset, region)
elif isinstance(dataset, H5Dataset):
return H5RegionSlicer(dataset, region)
return None


try:
# see https://effigies.gitlab.io/posts/python-packaging-2023/
from ._version import __version__
Expand Down
197 changes: 0 additions & 197 deletions src/hdmf/array.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/hdmf/backends/hdf5/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from . import h5_utils, h5tools
from .h5_utils import H5RegionSlicer, H5DataIO
from .h5_utils import H5DataIO
from .h5tools import HDF5IO, H5SpecWriter, H5SpecReader
28 changes: 2 additions & 26 deletions src/hdmf/backends/hdf5/h5_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
import os
import logging

from ...array import Array
from ...data_utils import DataIO, AbstractDataChunkIterator, append_data
from ...query import HDMFDataset, ReferenceResolver, ContainerResolver, BuilderResolver
from ...region import RegionSlicer
from ...spec import SpecWriter, SpecReader
from ...utils import docval, getargs, popargs, get_docval, get_data_shape

Expand Down Expand Up @@ -85,7 +83,7 @@ def append(self, dataset, data):


class H5Dataset(HDMFDataset):
@docval({'name': 'dataset', 'type': (Dataset, Array), 'doc': 'the HDF5 file lazily evaluate'},
@docval({'name': 'dataset', 'type': (Dataset), 'doc': 'the HDF5 file lazily evaluate'},
rly marked this conversation as resolved.
Show resolved Hide resolved
{'name': 'io', 'type': 'hdmf.backends.hdf5.h5tools.HDF5IO',
'doc': 'the IO object that was used to read the underlying dataset'})
def __init__(self, **kwargs):
Expand Down Expand Up @@ -189,7 +187,7 @@ def get_object(self, h5obj):

class AbstractH5TableDataset(DatasetOfReferences):

@docval({'name': 'dataset', 'type': (Dataset, Array), 'doc': 'the HDF5 file lazily evaluate'},
@docval({'name': 'dataset', 'type': (Dataset), 'doc': 'the HDF5 file lazily evaluate'},
rly marked this conversation as resolved.
Show resolved Hide resolved
{'name': 'io', 'type': 'hdmf.backends.hdf5.h5tools.HDF5IO',
'doc': 'the IO object that was used to read the underlying dataset'},
{'name': 'types', 'type': (list, tuple),
Expand Down Expand Up @@ -420,28 +418,6 @@ def read_namespace(self, ns_path):
return ret


class H5RegionSlicer(RegionSlicer):

@docval({'name': 'dataset', 'type': (Dataset, H5Dataset), 'doc': 'the HDF5 dataset to slice'},
{'name': 'region', 'type': RegionReference, 'doc': 'the region reference to use to slice'})
def __init__(self, **kwargs):
self.__dataset = getargs('dataset', kwargs)
self.__regref = getargs('region', kwargs)
self.__len = self.__dataset.regionref.selection(self.__regref)[0]
self.__region = None

def __read_region(self):
if self.__region is None:
self.__region = self.__dataset[self.__regref]

def __getitem__(self, idx):
self.__read_region()
return self.__region[idx]

def __len__(self):
return self.__len


class H5DataIO(DataIO):
"""
Wrap data arrays for write via HDF5IO to customize I/O behavior, such as compression and chunking
Expand Down
Loading
Loading