ComposablePass

class hugr.passes.composable.ComposablePass(*args, **kwargs)[source]

Bases: Protocol

A Protocol which represents a composable Hugr transformation.

Methods

run

Run the pass to transform a HUGR, returning a PassResult.

then

Perform another composable pass after this pass.

with_scope

Set the scope configuration for the pass.

Attributes

name

Returns the name of the pass.

property name: str

Returns the name of the pass.

run(hugr: Hugr, *, inplace: bool = True) PassResult[source]

Run the pass to transform a HUGR, returning a PassResult.

See implement_pass_run() for a helper function to implement this method.

then(other: ComposablePass) ComposablePass[source]

Perform another composable pass after this pass.

with_scope(scope: PassScope) ComposablePass[source]

Set the scope configuration for the pass.

As of hugr 0.14.*, this configuration is only guidance, and may be ignored by the pass.

In the future, passes will be required to respect the scope configuration.