Coverage for /usr/local/lib/python3.11/dist-packages/grond/optimisers/base.py: 91%
44 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-10-26 16:25 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2023-10-26 16:25 +0000
1import logging
3from pyrocko.guts import Object
4from grond.meta import GrondError, has_get_plot_classes
6guts_prefix = 'grond'
8logger = logging.getLogger('grond.optimisers.base')
11class BadProblem(GrondError):
12 pass
15@has_get_plot_classes
16class Optimiser(Object):
18 def __init__(self, **kwargs):
19 Object.__init__(self, **kwargs)
20 self.iiter = 0
22 def optimise(self, problem):
23 raise NotImplementedError
25 @property
26 def niterations(self):
27 raise NotImplementedError
29 def get_status(self, history):
30 pass
32 def init_bootstraps(self, problem):
33 raise NotImplementedError
35 @classmethod
36 def get_plot_classes(cls):
37 from . import plot
38 return plot.get_plot_classes()
41class OptimiserConfig(Object):
42 pass
45class OptimiserStatus(object):
46 __slots__ = ['row_names', 'column_data', 'extra_header', 'extra_footer']
48 def __init__(self, row_names, column_data,
49 extra_header=None, extra_footer=None):
50 self.row_names = row_names
51 self.column_data = column_data
52 self.extra_header = extra_header
53 self.extra_footer = extra_footer
55 @property
56 def column_names(self):
57 return self.column_data.keys()
59 @property
60 def ncolumns(self):
61 return len(self.column_data)
63 @property
64 def values(self):
65 return self.column_data.values()
68__all__ = '''
69 BadProblem
70 Optimiser
71 OptimiserConfig
72'''.split()