Commit 148e6fbc authored by Ultima's avatar Ultima
Browse files

Started rework of operators. operator finished. diagonal_operator started.

parent df30d59c
......@@ -1728,6 +1728,11 @@ class point_space(space):
"""
raise AttributeError(about._errors.cstring("ERROR: power spectra ill-defined for (unstructured) point space."))
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def calc_real_Q(self, x):
return np.all(np.isreal(x))
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def get_plot(self,x,title="",vmin=None,vmax=None,unit="",norm=None,other=None,legend=False,**kwargs):
......
......@@ -23,8 +23,9 @@
##initialize the 'found-packages'-dictionary
found = {}
found = {}
import numpy as np
from nifty_about import about
......@@ -50,8 +51,6 @@ except(ImportError):
found['h5py_parallel'] = False
class distributed_data_object(object):
"""
......@@ -217,7 +216,7 @@ class distributed_data_object(object):
return False
## Case 4: 'other' is something different
## -> make a numpy casting and make a recursion
## -> make a numpy casting and make a recursive call
else:
temp_other = np.array(other)
return self.__eq__(temp_other)
......@@ -543,10 +542,22 @@ class distributed_data_object(object):
return temp_d2o
def is_completely_real(self):
local_realiness = np.all(self.isreal())
local_realiness = np.all(self.isreal().get_local_data())
global_realiness = self.distributor._allgather(local_realiness)
return np.all(global_realiness)
def all(self):
local_all = np.all(self.get_local_data())
global_all = self.distributor._allgather(local_all)
return np.all(global_all)
def any(self):
local_any = np.any(self.get_local_data())
global_any = self.distributor._allgather(local_any)
return np.all(global_any)
def set_local_data(self, data, hermitian=False, copy=False):
"""
Stores data directly in the local data attribute. No distribution
......@@ -1464,8 +1475,10 @@ class _not_distributor(object):
return np.array(data).astype(self.dtype, copy=False).\
reshape(self.global_shape)
def disperse_data(self, data, data_update, key, **kwargs):
data[key] = np.array(data_update, copy=False).astype(self.dtype)
def disperse_data(self, data, to_slices, data_update, from_slices=None,
**kwargs):
data[to_slices] = np.array(data_update[from_slices],
copy=False).astype(self.dtype)
def collect_data(self, data, slice_objects, **kwargs):
return data[slice_objects]
......
This diff is collapsed.
......@@ -1162,12 +1162,10 @@ class rg_space(point_space):
Weighted array.
"""
#x = self.cast(x)
if isinstance(x, distributed_data_object):
is_hermitianQ = x.hermitian
## weight
x = x * self.get_weight(power = power)
if isinstance(x, distributed_data_object):
x.hermitian = is_hermitianQ
return x
def get_weight(self, power = 1):
......@@ -1452,6 +1450,12 @@ class rg_space(point_space):
power_spectrum /= rho
return power_spectrum
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def calc_real_Q(self, x):
try:
return x.is_completely_real()
except(AttributeError):
return np.all(np.isreal(x))
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
......
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