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

Fix for dask to_allele_counts #266

Merged
merged 4 commits into from May 31, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions allel/model/dask.py
Expand Up @@ -318,7 +318,7 @@ def __getitem__(self, item):
return index_genotype_array(self, item, array_cls=type(self),
vector_cls=GenotypeDaskVector)

def _method(self, method_name, chunks=None, drop_axis=None, dtype=None, **kwargs):
def _method(self, method_name, chunks=None, drop_axis=None, new_axis=None, dtype=None, **kwargs):
if chunks is None:
# no shape change
chunks = self.chunks
Expand All @@ -330,7 +330,7 @@ def f(block):
g = array_cls(block)
method = getattr(g, method_name)
return method(**kwargs)
out = da.map_blocks(f, self.values, drop_axis=drop_axis, dtype=dtype)
out = da.map_blocks(f, self.values, chunks=chunks, drop_axis=drop_axis, new_axis=new_axis, dtype=dtype)

else:
# map with mask
Expand All @@ -340,7 +340,7 @@ def f(block, bmask):
method = getattr(g, method_name)
return method(**kwargs)
m = self.mask[:, :, np.newaxis]
out = da.map_blocks(f, self.values, m, drop_axis=drop_axis, dtype=dtype)
out = da.map_blocks(f, self.values, m, chunks=chunks, drop_axis=drop_axis, new_axis=new_axis, dtype=dtype)

return out

Expand Down Expand Up @@ -439,8 +439,9 @@ def to_allele_counts(self, max_allele=None):
if max_allele is None:
max_allele = self.max().compute()[()]

chunks = (self.chunks[0], self.chunks[1], (max_allele + 1,))
out = self._method('to_allele_counts', chunks=chunks, max_allele=max_allele)
chunks = (self.chunks[0], self.chunks[1], (max_allele + 1, ))

out = self._method('to_allele_counts', chunks=chunks, max_allele=max_allele, drop_axis=2, new_axis=2)
out = GenotypeAlleleCountsDaskArray(out)
return out

Expand Down