예제 #1
0
    def clone(self, debug=False, trace=False):
        """
        Copy the simulation just enough to be able to run the copy without modifying the original simulation
        """
        new = commons.empty_clone(self)
        new_dict = new.__dict__

        for key, value in self.__dict__.items():
            if key not in ('debug', 'trace', 'tracer'):
                new_dict[key] = value

        new.persons = self.persons.clone(new)
        setattr(new, new.persons.entity.key, new.persons)
        new.populations = {new.persons.entity.key: new.persons}

        for entity in self.tax_benefit_system.group_entities:
            population = self.populations[entity.key].clone(new)
            new.populations[entity.key] = population
            setattr(new, entity.key, population
                    )  # create shortcut simulation.household (for instance)

        new.debug = debug
        new.trace = trace

        return new
예제 #2
0
    def clone(self, debug = False, trace = False):
        """
            Copy the simulation just enough to be able to run the copy without modifying the original simulation
        """
        new = empty_clone(self)
        new_dict = new.__dict__

        for key, value in self.__dict__.items():
            if key not in ('debug', 'trace', 'tracer'):
                new_dict[key] = value

        new.persons = self.persons.clone(new)
        setattr(new, new.persons.key, new.persons)
        new.entities = {new.persons.key: new.persons}

        for entity_class in self.tax_benefit_system.group_entities:
            entity = self.entities[entity_class.key].clone(new)
            new.entities[entity.key] = entity
            setattr(new, entity_class.key, entity)  # create shortcut simulation.household (for instance)

        if debug:
            new_dict['debug'] = True
        if trace:
            new_dict['trace'] = True
        if debug or trace:
            if self.debug or self.trace:
                new_dict['tracer'] = self.tracer.clone()
            else:
                new_dict['tracer'] = Tracer()

        return new
예제 #3
0
def test_empty_clone():
    dummy_class = type("Dummmy", (), {})
    dummy = dummy_class()

    result = commons.empty_clone(dummy)

    assert type(result) == dummy_class
예제 #4
0
    def clone(self):
        clone = commons.empty_clone(self)
        clone.__dict__ = self.__dict__.copy()

        clone.metadata = copy.deepcopy(self.metadata)
        clone.values_list = [parameter_at_instant.clone() for parameter_at_instant in self.values_list]
        return clone
예제 #5
0
    def clone(self):
        clone = empty_clone(self)
        clone.__dict__ = self.__dict__.copy()

        clone.brackets = [bracket.clone() for bracket in self.brackets]
        clone.metadata = copy.deepcopy(self.metadata)

        return clone
예제 #6
0
    def clone(self):
        new = empty_clone(self)
        new_dict = new.__dict__

        for key, value in self.__dict__.items():
            if key not in ('children', 'metadata'):
                new_dict[key] = value

        new_dict['children'] = self.children.copy()
        new_dict['metadata'] = self.metadata.copy()
        return new
예제 #7
0
    def clone(self):
        new = empty_clone(self)
        new_dict = new.__dict__

        for key, value in self.__dict__.items():
            if key not in ('children', 'metadata'):
                new_dict[key] = value

        new_dict['children'] = self.children.copy()
        new_dict['metadata'] = self.metadata.copy()
        return new
예제 #8
0
    def clone(self):
        clone = commons.empty_clone(self)
        clone.__dict__ = self.__dict__.copy()

        clone.metadata = copy.deepcopy(self.metadata)
        clone.children = {
            key: child.clone()
            for key, child in self.children.items()
        }
        for child_key, child in clone.children.items():
            setattr(clone, child_key, child)

        return clone
    def clone(self):
        new = empty_clone(self)
        new_dict = new.__dict__

        for key, value in self.__dict__.items():
            if key not in ('parameters', '_parameters_at_instant_cache',
                           'variables', 'open_api_config'):
                new_dict[key] = value

        new_dict['parameters'] = self.parameters.clone()
        new_dict['_parameters_at_instant_cache'] = {}
        new_dict['variables'] = self.variables.copy()
        new_dict['open_api_config'] = self.open_api_config.copy()
        return new
예제 #10
0
    def clone(self, population):
        """
        Copy the holder just enough to be able to run a new simulation without modifying the original simulation.
        """
        new = commons.empty_clone(self)
        new_dict = new.__dict__

        for key, value in self.__dict__.items():
            if key not in ('population', 'formula', 'simulation'):
                new_dict[key] = value

        new_dict['population'] = population
        new_dict['simulation'] = population.simulation

        return new
예제 #11
0
    def clone(self):
        new = empty_clone(self)
        new_dict = new.__dict__

        for key, value in self.__dict__.items():
            if key not in ('parameters', '_parameters_at_instant_cache', 'variables', 'open_api_config'):
                new_dict[key] = value
        for entity in new_dict['entities']:
            entity.set_tax_benefit_system(new)

        new_dict['parameters'] = self.parameters.clone()
        new_dict['_parameters_at_instant_cache'] = {}
        new_dict['variables'] = self.variables.copy()
        new_dict['open_api_config'] = self.open_api_config.copy()
        return new
예제 #12
0
    def clone(self):
        new = commons.empty_clone(self)
        new_dict = new.__dict__

        for key, value in self.__dict__.items():
            if key not in ('parameters', '_parameters_at_instant_cache',
                           'variables', 'open_api_config'):
                new_dict[key] = value
        for entity in new_dict['entities']:
            entity.set_tax_benefit_system(new)

        new_dict['parameters'] = self.parameters.clone()
        new_dict['_parameters_at_instant_cache'] = {}
        new_dict['variables'] = self.variables.copy()
        new_dict['open_api_config'] = self.open_api_config.copy()
        return new
예제 #13
0
    def clone(self, debug = False, trace = False):
        """
            Copy the simulation just enough to be able to run the copy without modifying the original simulation
        """
        new = empty_clone(self)
        new_dict = new.__dict__

        for key, value in self.__dict__.items():
            if key not in ('debug', 'trace', 'tracer'):
                new_dict[key] = value

        new.persons = self.persons.clone(new)
        setattr(new, new.persons.entity.key, new.persons)
        new.populations = {new.persons.entity.key: new.persons}

        for entity in self.tax_benefit_system.group_entities:
            population = self.populations[entity.key].clone(new)
            new.populations[entity.key] = population
            setattr(new, entity.key, population)  # create shortcut simulation.household (for instance)

        new.debug = debug
        new.trace = trace

        return new
예제 #14
0
 def copy(self):
     new = empty_clone(self)
     new.__dict__ = copy.deepcopy(self.__dict__)
     return new
예제 #15
0
 def copy(self) -> Any:
     new = commons.empty_clone(self)
     new.__dict__ = copy.deepcopy(self.__dict__)
     return new
예제 #16
0
 def clone(self):
     clone = empty_clone(self)
     clone.__dict__ = self.__dict__.copy()
     clone.metadata = copy.deepcopy(self.metadata)
     return clone