Skip to content

Commit

Permalink
Merge pull request #189 from cggh/zarr-upgrade-20180409
Browse files Browse the repository at this point in the history
Zarr upgrade 2.2
  • Loading branch information
alimanfoo committed Apr 11, 2018
2 parents 6f392ba + 77b7d46 commit 08f767b
Show file tree
Hide file tree
Showing 12 changed files with 505 additions and 501 deletions.
9 changes: 3 additions & 6 deletions allel/chunked/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,17 @@
>>> import numpy as np
>>> a = np.arange(10000000)
>>> chunked.copy(a)
Array((10000000,), int64, chunks=(39063,), order=C)
...
<zarr.core.Array (10000000,) int64>
>>> chunked.copy(a, storage='bcolzmem')
carray((10000000,), int64)
...
>>> chunked.copy(a, storage='bcolztmp')
carray((10000000,), int64)
...
>>> chunked.copy(a, storage='zarrmem')
Array((10000000,), int64, chunks=(39063,), order=C)
...
<zarr.core.Array (10000000,) int64>
>>> chunked.copy(a, storage='zarrtmp')
Array((10000000,), int64, chunks=(39063,), order=C)
...
<zarr.core.Array (10000000,) int64>
>>> chunked.copy(a, storage=chunked.BcolzStorage(cparams=bcolz.cparams(cname='lz4')))
carray((10000000,), int64)
...
Expand Down
16 changes: 8 additions & 8 deletions allel/chunked/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ def store(data, arr, start=0, stop=None, offset=0, blen=None):
raise ValueError('invalid stop/start')

# copy block-wise
for i in range(start, stop, blen):
j = min(i+blen, stop)
l = j-i
arr[offset:offset+l] = data[i:j]
offset += l
for bi in range(start, stop, blen):
bj = min(bi+blen, stop)
bl = bj - bi
arr[offset:offset+bl] = data[bi:bj]
offset += bl


def copy(data, start=0, stop=None, blen=None, storage=None, create='array',
Expand Down Expand Up @@ -900,13 +900,13 @@ def ndim(self):

@property
def dtype(self):
l = []
items = []
for n, c in zip(self._names, self._columns):
# need to account for multidimensional columns
t = (n, c.dtype) if len(c.shape) == 1 else \
(n, c.dtype, c.shape[1:])
l.append(t)
return np.dtype(l)
items.append(t)
return np.dtype(items)

@property
def nbytes(self):
Expand Down
4 changes: 2 additions & 2 deletions allel/io/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def recarray_from_hdf5_group(*args, **kwargs):
h5f = h5py.File(file_path, mode='r')
try:
group = h5f[node_path]
except:
except Exception as e:
h5f.close()
raise
raise e

else:
raise ValueError('bad arguments; expected group or (file_path, '
Expand Down
6 changes: 3 additions & 3 deletions allel/model/chunked.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,15 +792,15 @@ class VariantChunkedTable(ChunkedTableWrapper):
>>> vt.copy() # doctest: +ELLIPSIS
<VariantChunkedTable shape=(5,) dtype=[('CHROM', 'S4'), ('POS', '<i8'), ('AC', ...
nbytes=220 cbytes=1.7K cratio=0.1
nbytes=220 cbytes=... cratio=...
values=allel.chunked.storage_zarr.ZarrTable>
>>> vt.copy(storage='bcolzmem') # doctest: +ELLIPSIS
<VariantChunkedTable shape=(5,) dtype=[('CHROM', 'S4'), ('POS', '<i8'), ('AC', ...
nbytes=220 cbytes=80.0K cratio=0.0
nbytes=220 cbytes=... cratio=...
values=bcolz.ctable.ctable>
>>> vt.copy(storage='hdf5mem_zlib1') # doctest: +ELLIPSIS
<VariantChunkedTable shape=(5,) dtype=[('CHROM', 'S4'), ('POS', '<i8'), ('AC', ...
nbytes=220 cbytes=131 cratio=1.7
nbytes=220 cbytes=... cratio=...
values=h5py._hl.files.File>
"""
Expand Down
7 changes: 4 additions & 3 deletions allel/model/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,11 @@ def _check_condition_length(a, condition, axis):
# because numpy allows condition to be shorter than the axis under selection,
# however we've found this allows mistakes to creep through and so we'll be stricter here
if axis is not None:
l = a.shape[axis]
expected_length = a.shape[axis]
k = condition.shape[0]
if k != l:
raise ValueError('bad length of condition; expected %s, found %s' % (l, k))
if k != expected_length:
raise ValueError('bad length of condition; expected %s, found %s' %
(expected_length, k))


def compress_genotypes(g, condition, axis, wrap_axes, cls, compress, **kwargs):
Expand Down

0 comments on commit 08f767b

Please sign in to comment.