Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 def test_nested(self):
     v = 1
     m = base.memo(a=base.memo(a=v))
     assert_equal(m.a.a, v)
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
 def _generate_report(self):
     return base.memo(median=self.median(), iqr=self.iqr(),
                      lo=self.lo, hi=self.hi)
Exemplo n.º 7
0
 def test_basic(self):
     v = 1
     m = base.memo(a=v)
     assert_equal(m.a, v)
Exemplo n.º 8
0
 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)
Exemplo n.º 9
0
 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)
Exemplo n.º 10
0
 def test_nested(self):
     v = 1
     m = base.memo(a=base.memo(a=v))
     assert_equal(m.a.a, v)
Exemplo n.º 11
0
 def test_basic(self):
     v = 1
     m = base.memo(a=v)
     assert_equal(m.a, v)
Exemplo n.º 12
0
 def _generate_report(self):
     return base.memo(median=self.median(),
                      iqr=self.iqr(),
                      lo=self.lo,
                      hi=self.hi)