Commit aa4e0f38 authored by Martin Reinecke's avatar Martin Reinecke

tweaks

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