Commit 221486b1 authored by theos's avatar theos
Browse files

Merge branch 'master' into NIFTy3_temp

# Conflicts:
#	lm/__init__.py
#	lm/nifty_lm.py
#	rg/nifty_fft.py
parents c65a30a8 45ec5251
......@@ -23,9 +23,20 @@ from sys import stdout as so
import os
import inspect
import d2o
import keepers
from nifty import __version__
MPI = d2o.config.dependency_injector[
keepers.get_Configuration('D2O')['mpi_module']]
comm = MPI.COMM_WORLD
size = comm.size
rank = comm.rank
class switch(object):
"""
.. __ __ __
......@@ -251,12 +262,12 @@ class notification(switch):
i = 2
current = inspect.stack()[i][3]
while current != '<module>':
result = '.' + current + result
result = '.' + current + result
i += 1
current = inspect.stack()[i][3]
return result[1:]
def cstring(self,subject):
def cstring(self, subject):
"""
Casts an object to a string and augments that with a colour code.
......@@ -272,10 +283,11 @@ class notification(switch):
String augmented with a color code.
"""
return self.ccode + str(self._get_caller()) + ':\n' + \
str(subject) + self._code + '\n'
if rank == 0:
return self.ccode + str(self._get_caller()) + ':\n' + \
str(subject) + self._code + '\n'
def cflush(self,subject):
def cflush(self, subject):
"""
Flushes an object in its colour coded sting representation to the
standard output (*without* line break).
......@@ -291,11 +303,11 @@ class notification(switch):
None
"""
if(self.status):
if self.status and rank == 0:
so.write(self.cstring(subject))
so.flush()
def cprint(self,subject):
def cprint(self, subject):
"""
Flushes an object in its colour coded sting representation to the
standard output (*with* line break).
......@@ -311,7 +323,7 @@ class notification(switch):
None
"""
if(self.status):
if self.status and rank == 0:
so.write(self.cstring(subject)+"\n")
so.flush()
......
......@@ -857,7 +857,11 @@ class quasi_newton_minimizer(object):
step_length = 0
for i in xrange(limii):
if self.callback is not None:
self.callback(self.x, i)
try:
self.callback(self.x, f_k, i)
except StopIteration:
self.note.cprint("\nCallback function stopped minization.")
break
# compute the the gradient for the current x
gradient = self.fprime(self.x)
......
......@@ -3383,8 +3383,8 @@ class propagator_operator(operator):
raise ValueError(about._errors.cstring(
"ERROR: At least M or N must be given."))
def _multiply(self, x, W=None, spam=None, reset=None, note=False,
x0=None, tol=1E-4, clevel=1, limii=None, **kwargs):
def _multiply(self, x, W=None, spam=None, reset=None, note=True,
x0=None, tol=1E-3, clevel=1, limii=1000, **kwargs):
if W is None:
W = self.S
......
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