def __new__(cls, *args, **kwargs): # construct our object future_self = super(Searcher, cls).__new__(cls, *args, **kwargs) name = cls.__name__ # initialize a dict with searcher's name # and the initialization time d = dict(searcher=name, initialized=datetime.now()) # if there are global options for this class or its bases in CONFIG for k in [k.__name__ for k in cls.__bases__] + [name]: if hasattr(CONFIG, k): # add them to the dict d.update(getattr(CONFIG, k).__dict__) # then, add the kwargs to the constructor call to the dict. # NB: this happens after adding options from The, so # call-specific options override the globals d.update(kwargs) # set our spec with the contents of the dict future_self.spec = memo(**d) return future_self
def test_string(self): m = base.memo(a=base.memo(a=1, b=2), b=2) s = '{\n b: 2\n a: {\n a: 1, b: 2\n }\n}' assert_equal(m.to_str(), s)
def test_nested(self): v = 1 m = base.memo(a=base.memo(a=v)) assert_equal(m.a.a, v)
def test_multiple(self): v1 = 't' v2 = 3 m = base.memo(a=v1, b=v2) assert_equal(m.a, v1) assert_equal(m.b, v2)
def _generate_report(self): return base.memo(median=self.median(), iqr=self.iqr(), lo=self.lo, hi=self.hi)
def test_basic(self): v = 1 m = base.memo(a=v) assert_equal(m.a, v)