'Read array from unpickler file handle.
This function is an adaptation of the numpy read_array function
available in version 1.10.1 in numpy/lib/format.py.'

def read_array(self, unpickler):

    if (len(self.shape) == 0):
        count = 1
    else:
        count = unpickler.np.multiply.reduce(self.shape)
    if self.dtype.hasobject:
        array = pickle.load(unpickler.file_handle)
    else:
        if ((not PY3_OR_LATER) and unpickler.np.compat.isfileobj(unpickler.file_handle)):
            array = unpickler.np.fromfile(unpickler.file_handle, dtype=self.dtype, count=count)
        else:
            max_read_count = (BUFFER_SIZE // min(BUFFER_SIZE, self.dtype.itemsize))
            array = unpickler.np.empty(count, dtype=self.dtype)
            for i in range(0, count, max_read_count):
                read_count = min(max_read_count, (count - i))
                read_size = int((read_count * self.dtype.itemsize))
                data = _read_bytes(unpickler.file_handle, read_size, 'array    data')
                array[i:(i + read_count)] = unpickler.np.frombuffer(data, dtype=self.dtype, count=read_count)
                del data
        if (self.order == 'F'):
            array.shape = self.shape[::(-1)]
            array = array.transpose()
        else:
            array.shape = self.shape
    return array
