Skip to content

Commit

Permalink
Merge pull request #51 from fkroeber/fix_II
Browse files Browse the repository at this point in the history
fix: keep attrs during reduce 🔧
  • Loading branch information
luukvdmeer authored Jul 1, 2024
2 parents ee59d61 + ffb80fd commit 4b79cb8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions semantique/processor/arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,14 @@ def fix(x, y):
out = Collection(groups)
return out

def reduce(self, reducer, dimension = None, track_types = True, **kwargs):
def reduce(
self,
reducer,
dimension = None,
track_types = True,
keep_attrs = True,
**kwargs
):
"""Apply the reduce verb to the array.
The reduce verb reduces the dimensionality of an array.
Expand All @@ -508,6 +515,9 @@ def reduce(self, reducer, dimension = None, track_types = True, **kwargs):
track_types : :obj:`bool`
Should the reducer promote the value type of the output object, based
on the value type of the input object?
keep_attrs: :obj:`bool`
Should the variable's attributes (attrs) be copied from the
original object to the new one?
**kwargs:
Additional keyword arguments passed on to the reducer function. These
should not include a keyword argument "dim", which is reserved for
Expand Down Expand Up @@ -539,7 +549,7 @@ def reduce(self, reducer, dimension = None, track_types = True, **kwargs):
)
kwargs["dim"] = dimension
# Reduce.
out = reducer(obj, track_types = track_types, **kwargs)
out = reducer(obj, track_types = track_types, keep_attrs = keep_attrs, **kwargs)
return out

def shift(self, dimension, steps, **kwargs):
Expand Down

0 comments on commit 4b79cb8

Please sign in to comment.