Skip to content

Commit

Permalink
Preserve gcxs compression (#601)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamestwebber authored Jan 5, 2024
1 parent e1990b2 commit 790f6d5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sparse/_umath.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ def __init__(self, func, *args, **kwargs):

processed_args = []
out_type = GCXS
out_kwargs = {}

sparse_args = [arg for arg in args if isinstance(arg, SparseArray)]

Expand All @@ -421,6 +422,8 @@ def __init__(self, func, *args, **kwargs):
out_type = DOK
elif all(isinstance(arg, GCXS) for arg in sparse_args):
out_type = GCXS
if len({arg.compressed_axes for arg in sparse_args}) == 1:
out_kwargs["compressed_axes"] = sparse_args[0].compressed_axes
else:
out_type = COO

Expand All @@ -441,6 +444,7 @@ def __init__(self, func, *args, **kwargs):
return

self.out_type = out_type
self.out_kwargs = out_kwargs
self.args = tuple(processed_args)
self.func = func
self.dtype = kwargs.pop("dtype", None)
Expand Down Expand Up @@ -497,7 +501,7 @@ def get_result(self):
shape=self.shape,
has_duplicates=False,
fill_value=self.fill_value,
).asformat(self.out_type)
).asformat(self.out_type, **self.out_kwargs)

def _get_fill_value(self):
"""
Expand Down

0 comments on commit 790f6d5

Please sign in to comment.