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