Exemplo n.º 1
0
    def __new__(cls, system, method=DEFAULT, name=DEFAULT, parameters=DEFAULT, **kwargs):
        name = cls.className() + system.className()

        if not parameters is DEFAULT:
            system = system.copy(parameters=parameters)

        parameters = system.parameters()

        if isinstance(system, AbstractRelaxed):
            relaxed_system = system
            cls = relaxed_system.__class__
        else:
            sub_parameters = system.subParameters(parameters)

            assert len(system.subSystems()) == len(sub_parameters)
            it = zip(system.subSystems(), sub_parameters)
            sub_systems = [sub if isinstance(sub, AbstractRelaxed)
                else Relaxed(sub.copy(parameters=p), method=method, parameters=p)
                for sub, p in it]

            relaxed_system = system.setSubSystems(sub_systems)
            cls = type(name,
                       (cls, relaxed_system.__class__),
                        relaxed_system.__dict__)

        instance = System.__new__(cls,)

        instance.__system = relaxed_system

        return instance
Exemplo n.º 2
0
    def __new__(cls, system, relaxation):
        name = 'Test' + system.className()
        cls = type(name,
                   (cls, system.__class__),
                    system.__dict__)

        instance = System.__new__(cls)

        return instance
Exemplo n.º 3
0
 def __init__(self):
     System.__init__(self, sub_systems=[TestSubSystem()])