Skip to content

Commit

Permalink
inherit_attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
ddkohler committed Jul 10, 2024
1 parent b9b18d6 commit b159f6f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions WrightTools/data/_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1891,7 +1891,7 @@ def smooth(self, factors, channel=None, verbose=True) -> "Data":
print("smoothed data")

def split(
self, expression, positions, *, units=None, parent=None, verbose=True
self, expression, positions, *, units=None, parent=None, inherit_attrs=False, verbose=True,
) -> wt_collection.Collection:
"""
Split the data object along a given expression, in units.
Expand Down Expand Up @@ -1928,7 +1928,7 @@ def split(
# axis ------------------------------------------------------------------------------------
old_expr = self.axis_expressions
old_units = self.units
out = wt_collection.Collection(name="split", parent=parent)
out = wt_collection.Collection(name=f"{self.name}_split", parent=parent)
if isinstance(expression, int):
if units is None:
units = self._axes[expression].units
Expand Down Expand Up @@ -1962,8 +1962,11 @@ def split(
omasks.append(None)
cuts.append(None)
for i in range(len(positions) - 1):
out.create_data("split%03i" % i)

out.create_data(f"{self.name}_{i:0>3}")

if inherit_attrs:
for d in out.values():
{d.attrs[k] : self.attrs[k] for k in self.attrs.keys() if k not in d.attrs.keys()}
for var in self.variables:
for i, (imask, omask, cut) in enumerate(zip(masks, omasks, cuts)):
if omask is None:
Expand Down

0 comments on commit b159f6f

Please sign in to comment.