division operator
This commit is contained in:
parent
1ca85cd7c2
commit
09eafc78a9
15
field.py
15
field.py
|
|
@ -39,6 +39,13 @@ class Field3d:
|
||||||
else:
|
else:
|
||||||
return Field3d(self.data*other,self.origin,self.spacing)
|
return Field3d(self.data*other,self.origin,self.spacing)
|
||||||
|
|
||||||
|
def __truediv__(self,other):
|
||||||
|
if isinstance(other,Field3d):
|
||||||
|
assert self.has_same_grid(other), "Grid mismatch."
|
||||||
|
return Field3d(self.data/other.data,self.origin,self.spacing)
|
||||||
|
else:
|
||||||
|
return Field3d(self.data/other,self.origin,self.spacing)
|
||||||
|
|
||||||
def __radd__(self,other):
|
def __radd__(self,other):
|
||||||
return Field3d(other+self.data,self.origin,self.spacing)
|
return Field3d(other+self.data,self.origin,self.spacing)
|
||||||
|
|
||||||
|
|
@ -72,6 +79,14 @@ class Field3d:
|
||||||
self.data *= other
|
self.data *= other
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
def __itruediv__(self,other):
|
||||||
|
if isinstance(other,Field3d):
|
||||||
|
assert self.has_same_grid(other), "Grid mismatch."
|
||||||
|
self.data /= other.data
|
||||||
|
else:
|
||||||
|
self.data /= other
|
||||||
|
return self
|
||||||
|
|
||||||
# TBD: this should return another Field3d object
|
# TBD: this should return another Field3d object
|
||||||
# def __getitem__(self,val):
|
# def __getitem__(self,val):
|
||||||
# assert isinstance(val,tuple) and len(val)==3, "Field3d must be indexed by [ii,jj,kk]."
|
# assert isinstance(val,tuple) and len(val)==3, "Field3d must be indexed by [ii,jj,kk]."
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue