コード例 #1
0
ファイル: test_params.py プロジェクト: ConorPQuinn/nengo
def test_iter_params_does_not_list_obsolete_params():
    class Test(object):
        p1 = params.IntParam('p1')
        p2 = params.IntParam('p2')
        obsolete = params.ObsoleteParam('obsolete', 'not included in params')

    assert set(params.iter_params(Test())) == {'p1', 'p2'}
コード例 #2
0
def test_iter_params_does_not_list_obsolete_params():
    class Test:
        p1 = params.IntParam("p1")
        p2 = params.IntParam("p2")
        obsolete = params.ObsoleteParam("obsolete", "not included in params")

    assert set(params.iter_params(Test())) == {"p1", "p2"}
コード例 #3
0
def test_iter_params_does_not_list_obsolete_params():
    class Test(object):
        p1 = params.IntParam('p1')
        p2 = params.IntParam('p2')
        obsolete = params.ObsoleteParam('obsolete', 'not included in params')

    assert set(params.iter_params(Test())) == {'p1', 'p2'}
コード例 #4
0
ファイル: config.py プロジェクト: tisana69/nengo
    def __getstate__(self):
        state = {}

        for key in iter_params(self._configures):
            param = self._clsparams.get_param(key)
            if self in param:
                state[key] = param.__get__(self, type(self))

        state.update(self.__dict__)
        return state
コード例 #5
0
ファイル: config.py プロジェクト: nengo/nengo
    def __getstate__(self):
        state = {}

        for key in iter_params(self._configures):
            param = self._clsparams.get_param(key)
            if self in param:
                state[key] = param.__get__(self, type(self))

        state.update(self.__dict__)
        return state
コード例 #6
0
ファイル: test_copy.py プロジェクト: NickleDave/nengo
def assert_is_deepcopy(cp, original):
    assert cp is not original  # ensures separate parameters
    for param in iter_params(cp):
        param_inst = getattr(cp, param)
        if isinstance(param_inst,
                      (nengo.solvers.Solver, nengo.base.NengoObject)):
            assert_is_copy(param_inst, getattr(original, param))
        elif is_array_like(param_inst):
            assert np.all(param_inst == getattr(original, param))
        else:
            assert param_inst == getattr(original, param)
コード例 #7
0
def assert_is_deepcopy(cp, original):
    assert cp is not original  # ensures separate parameters
    for param in iter_params(cp):
        param_inst = getattr(cp, param)
        if isinstance(param_inst, nengo.solvers.Solver) or isinstance(
                param_inst, nengo.base.NengoObject):
            assert_is_copy(param_inst, getattr(original, param))
        elif is_array_like(param_inst):
            assert np.all(param_inst == getattr(original, param))
        else:
            assert param_inst == getattr(original, param)
コード例 #8
0
def resolve_default(cls, param):
    if inspect.ismodule(param.default):
        return DisplayDefault(param.default.__name__)
    elif param.default is not Default:
        return param.default
    else:
        for cls_param in (getattr(cls, name) for name in iter_params(cls)):
            if cls_param.name == param.name:
                return DisplayDefault("Default<{!r}>".format(
                    cls_param.default))
        warnings.warn("Default value for argument {} of {} could not be "
                      "resolved.".format(param.name, cls))
        return param.default
コード例 #9
0
    def __init_subclass__(cls, backing_class, **kwargs):
        unsupported_params = []

        for param_name in p.iter_params(backing_class):
            param = getattr(backing_class, param_name)
            if (param.name not in vars(cls)
                    and type(param) in cls.paramTypeToGqlType):
                cls.bind_param(param)
            else:
                unsupported_params.append(param)

        setattr(cls, 'unsupported_params', tuple(unsupported_params))
        super().__init_subclass__(**kwargs)
コード例 #10
0
 def params(self):
     """Returns a list of parameter names that can be set."""
     return list(iter_params(self))
コード例 #11
0
 def params(self):
     """Returns a list of parameter names that can be set."""
     return list(iter_params(self))