def test_get_keyword_defaults(self): self.assertEqual(utils.get_keyword_defaults(self.f1), {}) d = {'b': 1, 'c': 2, 'd': 3, 'e': 4} self.assertEqual(utils.get_keyword_defaults(self.f2), d) del d['b'] del d['c'] self.assertEqual(utils.get_keyword_defaults(self.f2, 2), d)
def test_get_keyword_defaults_f3(): d = {'a': None, 'b': 1, 'c': 2, 'd': 3, 'e': 4} assert utils.get_keyword_defaults(f3) == d del d['a'] assert utils.get_keyword_defaults(f3, 1) == d assert utils.get_keyword_defaults(f3, 7) == {}
def test_get_keyword_defaults_f2(): d = {'b': 1, 'c': 2, 'd': 3, 'e': 4} assert utils.get_keyword_defaults(f2) == d del d['b'] del d['c'] assert utils.get_keyword_defaults(f2, 2) == d assert utils.get_keyword_defaults(f2, 7) == {}
def __init__(self): self.priors = {} self._walker = Walk self._sampler = MetropolisMH self._sampler_opt = get_keyword_defaults(MetropolisMH.init) self.sample = None self.walk = lambda: None NoNewAttributesAfterInit.__init__(self)
def __init__(self): self.priors = {} # default sampler self.sampler = 'MetropolisMH' self.samplers = { 'MH': { 'class': MH, 'opts': get_keyword_defaults(MH.init) }, 'MetropolisMH': { 'class': MetropolisMH, 'opts': get_keyword_defaults(MetropolisMH.init) }, } self.walk = 'Walk' self.walks = { 'Walk': { 'class': Walk, }, }
def __init__(self): self.priors = {} # default sampler self.sampler = 'MetropolisMH' self.samplers = { 'MH' : { 'class' : MH, 'opts' : get_keyword_defaults(MH.init) }, 'MetropolisMH' : { 'class' : MetropolisMH, 'opts' : get_keyword_defaults(MetropolisMH.init) }, } self.walk = 'Walk' self.walks = { 'Walk' : { 'class' : Walk, }, }
def __setstate__(self, state): new_config = get_keyword_defaults(state.get('_optfunc')) old_config = state.get('config', {}) # remove old kw args from opt method dict for key in old_config.keys(): if key not in new_config: old_config.pop(key) # add new kw args with defaults for key, val in new_config.items(): if key not in old_config: old_config[key] = val self.__dict__.update(state)
def test_get_keyword_defaults_f1(): assert utils.get_keyword_defaults(f1) == {}
def get_histo_defaults(): return get_keyword_defaults(histo, 6)
def get_contour_defaults(): return get_keyword_defaults(contour, 6)
def get_point_defaults(): return get_keyword_defaults(point, 2)
def get_plot_defaults(): return get_keyword_defaults(plot, 7)
def get_split_plot_defaults(): return get_keyword_defaults(set_subplot, 3)
def get_split_plot_defaults(): return get_keyword_defaults(set_subplot, 1)
def _set_sampler(self, sampler): self._sampler = sampler self._sampler_opt = get_keyword_defaults(sampler.init)
def _get_default_config(self): args = get_keyword_defaults(self._optfunc) return args
def get_histo_defaults(): return get_keyword_defaults(_histogram, 6)
pylab.draw() def exceptions(): pass def _choose(test, iftrue, iffalse=None): if test: return iftrue return iffalse # In matplotlib 1.5RC1 the kwargs to pylab.Axes.errorbar are not # explictit, but they appear to be set for pybal.errorbar, so # switch to that. # _errorbar_defaults = get_keyword_defaults(pylab.Axes.errorbar) _errorbar_defaults = get_keyword_defaults(pylab.errorbar) def clear_window(): pylab.clf() def set_window_redraw(redraw): if redraw: pylab.draw() def point(x, y, overplot=True, clearwindow=False, symbol=None, color=None): if overplot:
def begin(): pass def end(): set_window_redraw(True) if plt.isinteractive(): plt.draw() def exceptions(): pass _errorbar_defaults = get_keyword_defaults(plt.errorbar) def clear_window(): plt.clf() def set_window_redraw(redraw): if redraw: plt.draw() def setup_axes(overplot, clearwindow): """Return the axes object, creating it if necessary. Parameters
def exceptions(): pass def _choose(test, iftrue, iffalse=None): if test: return iftrue return iffalse # In matplotlib 1.5RC1 the kwargs to pylab.Axes.errorbar are not # explictit, but they appear to be set for pybal.errorbar, so # switch to that. # _errorbar_defaults = get_keyword_defaults(pylab.Axes.errorbar) _errorbar_defaults = get_keyword_defaults(pylab.errorbar) def clear_window(): pylab.clf() def set_window_redraw(redraw): if redraw: pylab.draw() def point(x, y, overplot=True, clearwindow=False, symbol=None, color=None): if overplot: axes = pylab.gca()