Commit 083f6433 authored by Theo Steininger's avatar Theo Steininger

Ported to keepers.Logging.

parent 8c7d198b
Pipeline #11901 passed with stage
in 7 minutes and 9 seconds
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import numpy as np import numpy as np
from keepers import Versionable from keepers import Versionable,\
Loggable
from d2o.config import configuration as gc,\ from d2o.config import configuration as gc,\
dependency_injector as gdi dependency_injector as gdi
...@@ -29,13 +30,8 @@ from strategies import STRATEGIES ...@@ -29,13 +30,8 @@ from strategies import STRATEGIES
MPI = gdi[gc['mpi_module']] MPI = gdi[gc['mpi_module']]
about_cstring = lambda z: z
from sys import stdout
about_warnings_cprint = lambda z: stdout.write(z + "\n"); stdout.flush()
about_infos_cprint = lambda z: stdout.write(z + "\n"); stdout.flush()
class distributed_data_object(Loggable, Versionable, object):
class distributed_data_object(Versionable, object):
"""A multidimensional array with modular MPI-based distribution schemes. """A multidimensional array with modular MPI-based distribution schemes.
The purpose of a distributed_data_object (d2o) is to provide the user The purpose of a distributed_data_object (d2o) is to provide the user
...@@ -429,8 +425,7 @@ class distributed_data_object(Versionable, object): ...@@ -429,8 +425,7 @@ class distributed_data_object(Versionable, object):
try: try:
result_data = function(local_data) result_data = function(local_data)
except: except:
about_warnings_cprint( self.logger.warn("Trying to use np.vectorize!")
"WARNING: Trying to use np.vectorize!")
result_data = np.vectorize(function, result_data = np.vectorize(function,
otypes=[local_data.dtype])(local_data) otypes=[local_data.dtype])(local_data)
...@@ -1221,11 +1216,9 @@ class distributed_data_object(Versionable, object): ...@@ -1221,11 +1216,9 @@ class distributed_data_object(Versionable, object):
""" """
if 0 in self.shape: if 0 in self.shape:
raise ValueError( raise ValueError("Attempt to get argmin of an empty object")
"ERROR: attempt to get argmin of an empty object")
if axis is not None: if axis is not None:
raise NotImplementedError("ERROR: argmin doesn't support axis " raise NotImplementedError("argmin doesn't support axis keyword")
"keyword")
if self.shape == (): if self.shape == ():
return 0 return 0
...@@ -1259,9 +1252,9 @@ class distributed_data_object(Versionable, object): ...@@ -1259,9 +1252,9 @@ class distributed_data_object(Versionable, object):
if 0 in self.shape: if 0 in self.shape:
raise ValueError( raise ValueError(
"ERROR: attempt to get argmax of an empty object") "Attempt to get argmax of an empty object")
if axis is not None: if axis is not None:
raise NotImplementedError("ERROR: argmax doesn't support axis " raise NotImplementedError("argmax doesn't support axis "
"keyword") "keyword")
if self.shape == (): if self.shape == ():
return 0 return 0
...@@ -1337,8 +1330,8 @@ class distributed_data_object(Versionable, object): ...@@ -1337,8 +1330,8 @@ class distributed_data_object(Versionable, object):
expensive. expensive.
""" """
about_warnings_cprint( self.logger.warn("The current implementation of median is very "
"WARNING: The current implementation of median is very expensive!") "expensive!")
median = np.median(self.get_full_data(), axis=axis, **kwargs) median = np.median(self.get_full_data(), axis=axis, **kwargs)
if np.isscalar(median): if np.isscalar(median):
return median return median
...@@ -1473,8 +1466,8 @@ class distributed_data_object(Versionable, object): ...@@ -1473,8 +1466,8 @@ class distributed_data_object(Versionable, object):
if self.dtype not in [np.dtype('int16'), np.dtype('int32'), if self.dtype not in [np.dtype('int16'), np.dtype('int32'),
np.dtype('int64'), np.dtype('uint16'), np.dtype('int64'), np.dtype('uint16'),
np.dtype('uint32'), np.dtype('uint64')]: np.dtype('uint32'), np.dtype('uint64')]:
raise TypeError(about_cstring( raise TypeError("Distributed-data-object must be of integer "
"ERROR: Distributed-data-object must be of integer datatype!")) "datatype!")
if axis is (): if axis is ():
return self.copy() return self.copy()
......
This diff is collapsed.
...@@ -20,4 +20,4 @@ ...@@ -20,4 +20,4 @@
# 1) we don't load dependencies by storing it in __init__.py # 1) we don't load dependencies by storing it in __init__.py
# 2) we can import it in setup.py for the same reason # 2) we can import it in setup.py for the same reason
# 3) we can import it into your module module # 3) we can import it into your module module
__version__ = '1.0.8' __version__ = '1.1.0'
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