Commit c4a8ae8b authored by Sebastian Heimann's avatar Sebastian Heimann
Browse files

restructuring ...

parent de113af3
......@@ -6,15 +6,15 @@ from ..targets import TargetAnalysisResult
from ..meta import Forbidden
guts_prefix = 'grond'
class Analyser(object):
def __init__(self, niter):
self.niter = niter
def set_notifier(self, notifier):
self.notifier = notifier
def analyse(self, problem):
def analyse(self, problem, notifier):
if self.niter == 0:
return
......@@ -37,7 +37,7 @@ class Analyser(object):
mss = num.zeros((self.niter, wproblem.ntargets))
rstate = num.random.RandomState(123)
self.notifier.emit('progress_start', 'analysing problem', self.niter)
notifier.emit('progress_start', 'analysing problem', self.niter)
isbad_mask = None
for iiter in xrange(self.niter):
......@@ -62,9 +62,9 @@ class Analyser(object):
mss[iiter, :] = ms
isbad_mask = num.isnan(ms)
self.notifier.emit('progress_update', 'analysing problem', iiter)
notifier.emit('progress_update', 'analysing problem', iiter)
self.notifier.emit('progress_finish', 'analysing problem')
notifier.emit('progress_finish', 'analysing problem')
mean_ms = num.mean(mss, axis=0)
weights = 1. / mean_ms
......
......@@ -16,7 +16,7 @@ from .problems.base import ProblemConfig, Problem
from .solvers.base import SolverConfig
from .analysers.base import AnalyserConfig
from .targets import TargetConfig
from .meta import Path, HasPaths, expand_template, xjoin, GrondError
from .meta import Path, HasPaths, expand_template, xjoin, GrondError, Notifier
logger = logging.getLogger('grond.core')
guts_prefix = 'grond'
......@@ -703,8 +703,10 @@ def process_event(ievent, g_data_id):
logger.info(
'start %i / %i' % (ievent+1, nevents))
solver = config.solver_config.get_solver()
solver.analyse(problem)
notifier = Notifier()
analyser = config.analyser_config.get_analyser()
analyser.analyse(problem, notifier=notifier)
basepath = config.get_basepath()
config.change_basepath(rundir)
......@@ -726,11 +728,14 @@ def process_event(ievent, g_data_id):
# update_every=10,
# movie_filename='grond_opt_time_magnitude.mp4')
solver.solve(problem,
solver = config.solver_config.get_solver()
solver.solve(
problem,
rundir=rundir,
status=status,
xs_inject=xs_inject)
# plot=splot,
xs_inject=xs_inject,
notifier=notifier)
harvest(rundir, problem, force=True)
......
......@@ -68,7 +68,8 @@ def solve(problem,
compensate_excentricity=True,
xs_inject=None,
status=(),
plot=None):
plot=None,
notifier=None):
xbounds = num.array(problem.get_parameter_bounds(), dtype=num.float)
npar = problem.nparameters
......@@ -417,12 +418,13 @@ def solve(problem,
class HighScoreSolver(Solver):
def __init__(self, analyser, kwargs):
Solver.__init__(self, analyser)
def __init__(self, kwargs):
Solver.__init__(self)
self._kwargs = kwargs
def solve(
self, problem, rundir=None, status=(), plot=None, xs_inject=None):
self, problem, rundir=None, status=(), plot=None, xs_inject=None,
notifier=None):
solve(
problem,
......@@ -430,7 +432,8 @@ class HighScoreSolver(Solver):
status=status,
plot=plot,
xs_inject=xs_inject,
**self.kwargs)
notifier=notifier,
**self._kwargs)
class SamplerDistributionChoice(StringChoice):
......@@ -472,7 +475,7 @@ class HighScoreSolverConfig(SolverConfig):
compensate_excentricity=self.compensate_excentricity)
def get_solver(self):
return HighScoreSolver(self.get_analyser(), self.get_solver_kwargs())
return HighScoreSolver(self.get_solver_kwargs())
__all__ = '''
......
Supports Markdown
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