示例#1
0
    def update_actions_deps(self):
        """
        Returns a list of update functions in :code:`update_actions` plus
        dependencies.
        """
        # recover the names of the method's update functions and operations
        names = remove_duplicates(
            get_strings(self.update_actions, remove=('exec', 'iter')))

        # recover the dependencies for in-place updates 'ud_...'
        for name in names:
            if name.startswith('ud_') and not name[3:] in names:
                names.append(name[3:])
        return names + ['dx', 'w', 'u', 'p']
示例#2
0
    def build(self):
        # init args values with 0
        setattr(self, 'args', numpy.array([0., ]*self.method.core.dims.args()))
        for name in self.method.args_names:
            self.build_arg(name)

        # recover the names of the method's update functions and operations
        self.names = remove_duplicates(get_strings(self.method.update_actions))
        for name in self.names:
            if name.startswith('ud_') and not name[3:] in self.names:
                self.names.append(name[3:])
        # build numerical evaluation for functions and operations
        for name in self.names:
            if name in self.method.funcs_names:
                self.build_func(name)
            elif name in self.method.ops_names:
                self.build_op(name)
示例#3
0
    def update_actions_deps(self):
        """
        Returns a list of update functions in :code:`update_actions` plus
        dependencies.
        """
        # recover the names of the method's update functions and operations
        names = remove_duplicates(
            get_strings(self.update_actions, remove=('exec', 'iter')))

        updates = list()

        def add_update(name):
            if name not in updates:
                if name in self.ops_names:
                    deps = getattr(self, name + '_deps')
                    for d in deps:
                        add_update(d)
                updates.append(name)

        # recover the dependencies for in-place updates 'ud_...'
        for name in names:
            add_update(name)

        return remove_duplicates(updates + ['dx', 'w', 'u', 'p'])