Skip to content

Commit

Permalink
Merge pull request #270 from alimanfoo/upgrade_deps_20190614
Browse files Browse the repository at this point in the history
Upgrade requirements 20190614
  • Loading branch information
alimanfoo committed Jun 17, 2019
2 parents 961254b + ed9d522 commit 0fa09dd
Show file tree
Hide file tree
Showing 12 changed files with 780 additions and 217 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -9,7 +9,6 @@ sudo: true
dist: xenial

python:
- "3.5"
- "3.6"
- "3.7"

Expand Down
46 changes: 40 additions & 6 deletions allel/model/dask.py
Expand Up @@ -97,6 +97,40 @@ def da_subset(d, sel0, sel1):
return out


def da_compress(condition, a, axis=None):
"""Temporary workaround for https://github.com/dask/dask/issues/4940"""
from dask.array.core import asarray
from dask.array.utils import validate_axis
from dask.utils import is_arraylike

if not is_arraylike(condition):
# Allow `condition` to be anything array-like, otherwise ensure `condition`
# is a dask array.
condition = asarray(condition)
condition = condition.astype(bool)
a = asarray(a)

if condition.ndim != 1:
raise ValueError("Condition must be one dimensional")

if axis is None:
a = a.ravel()
axis = 0
axis = validate_axis(axis, a.ndim)

# Treat `condition` as filled with `False` (if it is too short)
a = a[tuple(slice(None, len(condition))
if i == axis else slice(None)
for i in range(a.ndim))]

# Use `condition` to select along 1 dimension
a = a[tuple(condition
if i == axis else slice(None)
for i in range(a.ndim))]

return a


class DaskArrayWrapper(ArrayWrapper):

def __init__(self, data, chunks=None, name=None, lock=False):
Expand Down Expand Up @@ -287,7 +321,7 @@ def compress(self, condition, axis=0, out=None):
# argument is only there for numpy API compatibility
raise NotImplementedError('out argument is not supported')
return compress_genotypes(self, condition, axis=axis, wrap_axes={0},
cls=type(self), compress=da.compress)
cls=type(self), compress=da_compress)

def take(self, indices, axis=0, out=None, mode='raise'):
if out is not None:
Expand Down Expand Up @@ -465,7 +499,7 @@ def compress(self, condition, axis=0, out=None):
# argument is only there for numpy API compatibility
raise NotImplementedError('out argument is not supported')
return compress_genotypes(self, condition, axis=axis, wrap_axes={0, 1},
cls=type(self), compress=da.compress)
cls=type(self), compress=da_compress)

def take(self, indices, axis=0, out=None, mode='raise'):
if out is not None:
Expand Down Expand Up @@ -635,7 +669,7 @@ def compress(self, condition, axis=0, out=None):
# argument is only there for numpy API compatibility
raise NotImplementedError('out argument is not supported')
return compress_haplotype_array(self, condition, axis=axis, cls=type(self),
compress=da.compress)
compress=da_compress)

def take(self, indices, axis=0, out=None, mode='raise'):
if out is not None:
Expand Down Expand Up @@ -794,7 +828,7 @@ def compress(self, condition, axis=0, out=None):
# argument is only there for numpy API compatibility
raise NotImplementedError('out argument is not supported')
return compress_allele_counts_array(self, condition, axis=axis, cls=type(self),
compress=da.compress)
compress=da_compress)

def take(self, indices, axis=0, out=None, mode='raise'):
if out is not None:
Expand Down Expand Up @@ -906,7 +940,7 @@ def compress(self, condition, axis=0, out=None):
# argument is only there for numpy API compatibility
raise NotImplementedError('out argument is not supported')
return compress_genotype_ac(self, condition, axis=axis, wrap_axes={0},
cls=type(self), compress=da.compress)
cls=type(self), compress=da_compress)

def take(self, indices, axis=0, out=None, mode='raise'):
if out is not None:
Expand Down Expand Up @@ -989,7 +1023,7 @@ def compress(self, condition, axis=0, out=None):
# argument is only there for numpy API compatibility
raise NotImplementedError('out argument is not supported')
return compress_genotype_ac(self, condition=condition, axis=axis, wrap_axes={0, 1},
cls=type(self), compress=da.compress)
cls=type(self), compress=da_compress)

def take(self, indices, axis=0, out=None, mode='raise'):
if out is not None:
Expand Down
2 changes: 1 addition & 1 deletion allel/model/ndarray.py
Expand Up @@ -4463,7 +4463,7 @@ class VariantTable(NumpyRecArrayWrapper):
Access multiple columns::
>>> vt[['DP', 'QD']]
<VariantTable shape=(5,) dtype=(numpy.record, [('DP', '<i8'), ('QD', '<f8')])>
<VariantTable shape=(5,) dtype=(numpy.record, {'names':['DP','QD'], ...
[(35, 4.5) (12, 6.7) (78, 1.2) (22, 4.4) (99, 2.8)]
Access a row::
Expand Down

0 comments on commit 0fa09dd

Please sign in to comment.