コード例 #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
コード例 #5
0
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