# Path: pyfive/core.py
# def _padded_size(size, padding_multipe=8):
#     """ Return the size of a field padded to be a multiple a give value. """
#     return int(ceil(size / padding_multipe) * padding_multipe)
# 
# Path: pyfive/core.py
# def _unpack_struct_from_file(structure, fh):
#     """ Unpack a structure into an OrderedDict from an open file. """
#     size = _structure_size(structure)
#     buf = fh.read(size)
#     return _unpack_struct_from(structure, buf)
# 
# Path: pyfive/core.py
# class Reference(object):
#     """
#     HDF5 Reference.
#     """
# 
#     def __init__(self, address_of_reference):
#         self.address_of_reference = address_of_reference
# 
#     def __bool__(self):
#         # False for null references (address of 0) True otherwise
#         return bool(self.address_of_reference)
# 
#     __nonzero__ = __bool__  # Python 2.x requires __nonzero__ for truth value


from collections import OrderedDict
from .core import _padded_size
from .core import _unpack_struct_from_file
from .core import Reference
import struct
import zlib
import numpy as np
                raise NotImplementedError('datatype not implemented')
        else:
            true_dtype = None

        # create array to store data
        shape = [_padded_size(i, j) for i, j in zip(data_shape, chunk_shape)]
        data = np.zeros(shape, dtype=dtype)

        # loop over chunks reading each into the full data array
        count = np.prod(chunk_shape)
        itemsize = np.dtype(dtype).itemsize
        chunk_buffer_size = count * itemsize
        for node in self.all_nodes[0]:
            for node_key, addr in zip(node['keys'], node['addresses']):
                self.fh.seek(addr)
                if filter_pipeline is None:
                    chunk_buffer = self.fh.read(chunk_buffer_size)
                else:
                    chunk_buffer = self.fh.read(node_key['chunk_size'])
                    filter_mask = node_key['filter_mask']
                    chunk_buffer = self._filter_chunk(
                        chunk_buffer, filter_mask, filter_pipeline, itemsize)

                chunk_data = np.frombuffer(chunk_buffer, dtype=dtype)
                start = node_key['chunk_offset'][:-1]
                region = [slice(i, i+j) for i, j in zip(start, chunk_shape)]
                data[tuple(region)] = chunk_data.reshape(chunk_shape)

        if isinstance(true_dtype, tuple):
            if dtype_class == 'REFERENCE':

# Path: pyfive/core.py
# def _padded_size(size, padding_multipe=8):
#     """ Return the size of a field padded to be a multiple a give value. """
#     return int(ceil(size / padding_multipe) * padding_multipe)
# 
# Path: pyfive/core.py
# def _unpack_struct_from_file(structure, fh):
#     """ Unpack a structure into an OrderedDict from an open file. """
#     size = _structure_size(structure)
#     buf = fh.read(size)
#     return _unpack_struct_from(structure, buf)
# 
# Path: pyfive/core.py
# class Reference(object):
#     """
#     HDF5 Reference.
#     """
# 
#     def __init__(self, address_of_reference):
#         self.address_of_reference = address_of_reference
# 
#     def __bool__(self):
#         # False for null references (address of 0) True otherwise
#         return bool(self.address_of_reference)
# 
#     __nonzero__ = __bool__  # Python 2.x requires __nonzero__ for truth value


# Path: pyfive/btree.py
from collections import OrderedDict
from .core import _padded_size
from .core import _unpack_struct_from_file
from .core import Reference
import struct
import zlib
import numpy as np

                raise NotImplementedError('datatype not implemented')
        else:
            true_dtype = None

        # create array to store data
        shape = [_padded_size(i, j) for i, j in zip(data_shape, chunk_shape)]
        data = np.zeros(shape, dtype=dtype)

        # loop over chunks reading each into the full data array
        count = np.prod(chunk_shape)
        itemsize = np.dtype(dtype).itemsize
        chunk_buffer_size = count * itemsize
        for node in self.all_nodes[0]:
            for node_key, addr in zip(node['keys'], node['addresses']):
                self.fh.seek(addr)
                if filter_pipeline is None:
                    chunk_buffer = self.fh.read(chunk_buffer_size)
                else:
                    chunk_buffer = self.fh.read(node_key['chunk_size'])
                    filter_mask = node_key['filter_mask']
                    chunk_buffer = self._filter_chunk(
                        chunk_buffer, filter_mask, filter_pipeline, itemsize)

                chunk_data = np.frombuffer(chunk_buffer, dtype=dtype)
                start = node_key['chunk_offset'][:-1]
                region = [slice(i, i+j) for i, j in zip(start, chunk_shape)]
                data[tuple(region)] = chunk_data.reshape(chunk_shape)

        if isinstance(true_dtype, tuple):
            if dtype_class == 'REFERENCE':

                to_reference = np.vectorize(Reference)