Commit dab8d7b9 authored by dboe's avatar dboe
Browse files

bugfix for empty template cutting

parent e227a907
...@@ -1408,10 +1408,8 @@ class Tensors(AbstractNdarray): ...@@ -1408,10 +1408,8 @@ class Tensors(AbstractNdarray):
# template # template
indices = np.arange(len(self))[mask] indices = np.arange(len(self))[mask]
# TODO: maybe np.empty instead of inst below. Reason why i copy is
# that the template is such marked for where it comes from. template = tfields.TensorFields(np.empty((len(indices), 0)), indices)
# We have a trade-off with small memory consumpiton here.
template = tfields.TensorFields(inst, indices)
return inst, template return inst, template
def _cut_template(self, template): def _cut_template(self, template):
...@@ -1449,7 +1447,7 @@ class Tensors(AbstractNdarray): ...@@ -1449,7 +1447,7 @@ class Tensors(AbstractNdarray):
projected_field[nan_mask] = np.nan # correction for nan projected_field[nan_mask] = np.nan # correction for nan
fields.append(projected_field) fields.append(projected_field)
if dim(template) == 0: if dim(template) == 0:
tensors = self tensors = np.array(self)[template.fields[0]]
else: else:
tensors = template tensors = template
return type(self)(Tensors(tensors), *fields) return type(self)(Tensors(tensors), *fields)
...@@ -2413,21 +2411,6 @@ class TensorMaps(TensorFields): ...@@ -2413,21 +2411,6 @@ class TensorMaps(TensorFields):
else: else:
return inst return inst
def _cut_sympy(self, expression):
if len(self) == 0:
return self.copy()
mask = self.evalf(expression) # coord_sys is handled by tmp_transform
mask.astype(bool)
inst = self[mask].copy()
# template
indices = np.arange(len(self))[mask]
# TODO: maybe np.empty instead of inst below. Reason why i copy is
# that the template is such marked for where it comes from.
# We have a trade-off with small memory consumpiton here.
template = tfields.TensorFields(inst, indices)
return inst, template
def _cut_template(self, template): def _cut_template(self, template):
""" """
Args: Args:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment