qiskit/transpiler/passmanager.py
def _do_pass(self, pass_, dag, options):
        """Do a pass and its "requires".

        Args:
            pass_ (BasePass): Pass to do.
            dag (DAGCircuit): The dag on which the pass is ran.
            options (dict): PassManager options.
        Returns:
            DAGCircuit: The transformed dag in case of a transformation pass.
            The same input dag in case of an analysis pass.
        Raises:
            TranspilerError: If the pass is not a proper pass instance.
        """

        # First, do the requires of pass_
        if not options["ignore_requires"]:
            for required_pass in pass_.requires:
                dag = self._do_pass(required_pass, dag, options)

        # Run the pass itself, if not already run
        if pass_ not in self.valid_passes:
            if pass_.is_transformation_pass:
                pass_.property_set = self.fenced_property_set
                new_dag = pass_.run(dag)
                if not isinstance(new_dag, DAGCircuit):
                    raise TranspilerError("Transformation passes should return a transformed dag."
                                          "The pass %s is returning a %s" % (type(pass_).__name__,
                                                                             type(new_dag)))
                dag = new_dag
            elif pass_.is_analysis_pass:
                pass_.property_set = self.property_set
                pass_.run(FencedDAGCircuit(dag))
            else:
                raise TranspilerError("I dont know how to handle this type of pass")

            # update the valid_passes property
            self._update_valid_passes(pass_, options['ignore_preserves'])

        return dag
def _do_pass(self, pass_, dag, options):
        # First, do the requires of pass_
        if not options["ignore_requires"]:
            for required_pass in pass_.requires:
                dag = self._do_pass(required_pass, dag, options)

        # Run the pass itself, if not already run
        if pass_ not in self.valid_passes:
            if pass_.is_transformation_pass:
                pass_.property_set = self.fenced_property_set
                new_dag = pass_.run(dag)
                if not isinstance(new_dag, DAGCircuit):
                    raise TranspilerError("Transformation passes should return a transformed dag."
                                          "The pass %s is returning a %s" % (type(pass_).__name__,
                                                                             type(new_dag)))
                dag = new_dag
            elif pass_.is_analysis_pass:
                pass_.property_set = self.property_set
                pass_.run(FencedDAGCircuit(dag))
            else:
                raise TranspilerError("I dont know how to handle this type of pass")

            # update the valid_passes property
            self._update_valid_passes(pass_, options['ignore_preserves'])

        return dag
def _do_pass ( self , pass_ , dag , options ) : # First, do the requires of pass_ if not options [ "ignore_requires" ] : for required_pass in pass_ . requires : dag = self . _do_pass ( required_pass , dag , options ) # Run the pass itself, if not already run if pass_ not in self . valid_passes : if pass_ . is_transformation_pass : pass_ . property_set = self . fenced_property_set new_dag = pass_ . run ( dag ) if not isinstance ( new_dag , DAGCircuit ) : raise TranspilerError ( "Transformation passes should return a transformed dag." "The pass %s is returning a %s" % ( type ( pass_ ) . __name__ , type ( new_dag ) ) ) dag = new_dag elif pass_ . is_analysis_pass : pass_ . property_set = self . property_set pass_ . run ( FencedDAGCircuit ( dag ) ) else : raise TranspilerError ( "I dont know how to handle this type of pass" ) # update the valid_passes property self . _update_valid_passes ( pass_ , options [ 'ignore_preserves' ] ) return dag
Do a pass and its "requires".

        Args:
            pass_ (BasePass): Pass to do.
            dag (DAGCircuit): The dag on which the pass is ran.
            options (dict): PassManager options.
        Returns:
            DAGCircuit: The transformed dag in case of a transformation pass.
            The same input dag in case of an analysis pass.
        Raises:
            TranspilerError: If the pass is not a proper pass instance.
Do a pass and its requires .