How to use the klepto.keygen function in klepto

To help you get started, we’ve selected a few klepto examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uqfoundation / klepto / tests / test_rounding.py View on Github external
    @keygen('x',2,tol=2)
    def add(w,x,y,z):
        return x+y+z+w
github uqfoundation / klepto / tests / test_workflow.py View on Github external
  @keygen('self')
  def bar(self, x,y):
    return x+y
github uqfoundation / klepto / tests / test_ignore.py View on Github external
@keygen('x','**')
def foo(x,y,z=2):
    return x+y+z
github uqfoundation / klepto / tests / test_workflow.py View on Github external
_add(4,debug=True)
    _add(2,0,3)
    _add(2,0,4)

    _cache =  _add.__cache__()
    _func = _add.__wrapped__

    # do a lookup
    assert _add.lookup(2,0) == _func(2,0)

    # generate the key, and do a look-up
    key = _add.key(2,0)
    assert _cache[key] == _func(2,0)

    # look-up the key again, doing a little more work...
    lookup = keygen('self','**')(_func)
    lookup.register(hasher)
    key = lookup(2,0)
    assert _cache[key] == _func(2,0)

    # since we have the 'key lookup', let's play with lookup a bit
    assert lookup.valid()
    assert lookup.call() == _func(2,0)