diff --git a/SimPEG/Rules.py b/SimPEG/Directives.py similarity index 84% rename from SimPEG/Rules.py rename to SimPEG/Directives.py index aed5e9d2..5f26c022 100644 --- a/SimPEG/Rules.py +++ b/SimPEG/Directives.py @@ -1,7 +1,7 @@ import Utils, numpy as np -class InversionRule(object): - """InversionRule""" +class InversionDirective(object): + """InversionDirective""" debug = False #: Print debugging information @@ -12,12 +12,12 @@ class InversionRule(object): @property def inversion(self): - """This is the inversion of the InversionRule instance.""" + """This is the inversion of the InversionDirective instance.""" return getattr(self,'_inversion',None) @inversion.setter def inversion(self, i): if getattr(self,'_inversion',None) is not None: - print 'Warning: InversionRule %s has switched to a new inversion.' % self.__name__ + print 'Warning: InversionDirective %s has switched to a new inversion.' % self.__name__ self._inversion = i @property @@ -40,14 +40,14 @@ class InversionRule(object): def finish(self): pass -class RuleList(object): +class DirectiveList(object): - rList = None #: The list of Rules + rList = None #: The list of Directives def __init__(self, *rules, **kwargs): self.rList = [] for r in rules: - assert isinstance(r, InversionRule), 'All rules must be InversionRules not %s' % r.__name__ + assert isinstance(r, InversionDirective), 'All rules must be InversionDirectives not %s' % r.__name__ self.rList.append(r) Utils.setKwargs(self, **kwargs) @@ -62,7 +62,7 @@ class RuleList(object): @property def inversion(self): - """This is the inversion of the InversionRule instance.""" + """This is the inversion of the InversionDirective instance.""" return getattr(self,'_inversion',None) @inversion.setter def inversion(self, i): @@ -75,16 +75,16 @@ class RuleList(object): def call(self, ruleType): if self.rList is None: - if self.debug: 'RuleList is None, no rules to call!' + if self.debug: 'DirectiveList is None, no rules to call!' return rules = ['initialize', 'endIter', 'finish'] - assert ruleType in rules, 'Rule type must be in ["%s"]' % '", "'.join(rules) + assert ruleType in rules, 'Directive type must be in ["%s"]' % '", "'.join(rules) for r in self.rList: getattr(r, ruleType)() -class BetaEstimate_ByEig(InversionRule): +class BetaEstimate_ByEig(InversionDirective): """BetaEstimate""" beta0 = None #: The initial Beta (regularization parameter) @@ -133,7 +133,7 @@ class BetaEstimate_ByEig(InversionRule): self.objFunc.beta = self.beta0 -class BetaSchedule(InversionRule): +class BetaSchedule(InversionDirective): """BetaSchedule""" coolingFactor = 2. diff --git a/SimPEG/Inversion.py b/SimPEG/Inversion.py index fc541e59..3d96b4b4 100644 --- a/SimPEG/Inversion.py +++ b/SimPEG/Inversion.py @@ -1,7 +1,7 @@ import SimPEG from SimPEG import Utils, sp, np from Optimization import Remember, IterationPrinters, StoppingCriteria -import Rules +import Directives class BaseInversion(object): @@ -19,12 +19,12 @@ class BaseInversion(object): @property def ruleList(self): if getattr(self,'_ruleList', None) is None: - self._ruleList = Rules.RuleList(inversion=self) + self._ruleList = Directives.DirectiveList(inversion=self) return self._ruleList @ruleList.setter def ruleList(self, value): - assert isinstance(value, Rules.RuleList), 'Must be a RuleList' + assert isinstance(value, Directives.DirectiveList), 'Must be a RuleList' self._ruleList = value self._ruleList.inversion = self diff --git a/SimPEG/__init__.py b/SimPEG/__init__.py index aac0c7f8..ea317e3c 100644 --- a/SimPEG/__init__.py +++ b/SimPEG/__init__.py @@ -9,7 +9,7 @@ import Survey import Regularization import ObjFunction import Optimization -import Rules +import Directives import Inversion import Tests diff --git a/Tutorials/Linear.py b/Tutorials/Linear.py index 59f42cc0..6fcfd17c 100644 --- a/Tutorials/Linear.py +++ b/Tutorials/Linear.py @@ -60,9 +60,9 @@ if __name__ == '__main__': objFunc = ObjFunction.BaseObjFunction(survey, reg) opt = Optimization.InexactGaussNewton(maxIter=20) inv = Inversion.BaseInversion(objFunc, opt) - beta = Rules.BetaSchedule() - betaest = Rules.BetaEstimate_ByEig() - inv.ruleList = Rules.RuleList(betaest, beta) + beta = Directives.BetaSchedule() + betaest = Directives.BetaEstimate_ByEig() + inv.ruleList = Directives.DirectiveList(betaest, beta) m0 = np.zeros_like(survey.mtrue) mrec = inv.run(m0)