Commit aa4e0f38 authored by Martin Reinecke's avatar Martin Reinecke
Browse files


parent 7f8c4fdf
Pipeline #43706 passed with stages
in 8 minutes and 8 seconds
......@@ -636,10 +636,8 @@ class Field(object):
return 0.5*(1.+self.tanh())
def clip(self, min=None, max=None):
if isinstance(min, Field):
min = min.local_data
if isinstance(max, Field):
max = max.local_data
min = min.local_data if isinstance(min, Field) else min
max = max.local_data if isinstance(max, Field) else max
return Field(self._domain, dobj.clip(self._val, min, max))
def one_over(self):
......@@ -192,18 +192,12 @@ class MultiField(object):
return self._transform(lambda x: x.conjugate())
def clip(self, min=None, max=None):
fields = []
for i in range(len(self._val)):
if isinstance(min, MultiField):
this_min = min._val[i]
this_min = min
if isinstance(max, MultiField):
this_max = max._val[i]
this_max = max
fields += [self._val[i].clip(this_min, this_max)]
return MultiField(self._domain, tuple(fields))
ncomp = len(self._val)
lmin = min._val if isinstance(min, MultiField) else (min,)*ncomp
lmax = max._val if isinstance(max, MultiField) else (max,)*ncomp
return MultiField(
tuple(self._val[i].clip(lmin[i], lmax[i]) for i in range(ncomp)))
def all(self):
for v in self._val:
Supports Markdown
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