예제 #1
0
    def _lazyprop(self):
        if scopes.dpp_scope_active():
            attr_name = '_lazy_dpp_' + func.__name__
        else:
            attr_name = '_lazy_' + func.__name__

        try:
            return getattr(self, attr_name)
        except AttributeError:
            setattr(self, attr_name, func(self))
        return getattr(self, attr_name)
예제 #2
0
    def _compute_once(self, *args, **kwargs):
        if scopes.dpp_scope_active():
            attr_name = '_compute_once_dpp_' + func.__name__
        else:
            attr_name = '_compute_once_' + func.__name__

        try:
            return getattr(self, attr_name)
        except AttributeError:
            setattr(self, attr_name, func(self, *args, **kwargs))
        return getattr(self, attr_name)
예제 #3
0
def _cache_key(args, kwargs):
    key = args + tuple(list(kwargs.items()))
    if scopes.dpp_scope_active():
        key = ('__dpp_scope_active__', ) + key
    return key
예제 #4
0
파일: parameter.py 프로젝트: zxuen/cvxpy
 def is_constant(self) -> bool:
     if scopes.dpp_scope_active():
         return False
     return True
def _cache_key(args, kwargs):
    key = args + tuple([(key, item) for key, item in kwargs.items()])
    if scopes.dpp_scope_active():
        key = ('__dpp_scope_active__', ) + key
    return key