Commit dab8d7b9 authored by dboe's avatar dboe
Browse files

bugfix for empty template cutting

parent e227a907
......@@ -1408,10 +1408,8 @@ class Tensors(AbstractNdarray):
# 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)
template = tfields.TensorFields(np.empty((len(indices), 0)), indices)
return inst, template
def _cut_template(self, template):
......@@ -1449,7 +1447,7 @@ class Tensors(AbstractNdarray):
projected_field[nan_mask] = np.nan # correction for nan
fields.append(projected_field)
if dim(template) == 0:
tensors = self
tensors = np.array(self)[template.fields[0]]
else:
tensors = template
return type(self)(Tensors(tensors), *fields)
......@@ -2413,21 +2411,6 @@ class TensorMaps(TensorFields):
else:
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):
"""
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