View source on GitHub

Strips comp's placement, returning a single call to map, apply or value.

For this purpose it is necessary to assume that all processing under comp is happening at a single placement.

The other assumptions on inputs of unwrap_placement are enumerated as follows:

  1. There is at most one unbound reference under comp, which is of federated type.
  2. The only intrinsics present here are apply or map, zip, and federated_valueat*.
  3. The type signature of comp is federated.
  4. There are no instances of building_blocks.Data of federated type under comp; how these would be handled by a function such as this is not entirely clear.

Under these conditions, unwrap_placement will produce a single call to federated_map, federated_apply or federated_value, depending on the placement and type signature of comp. Other than this single map or apply, no intrinsics will remain under comp.

comp Instance of building_blocks.ComputationBuildingBlock satisfying the assumptions above.

A modified version of comp, whose root is a single called intrinsic, and containing no other intrinsics. Equivalent to comp.

TypeError If the lone unbound reference under comp is not of federated type, comp itself is not of federated type, or comp is not a building block.
ValueError If we encounter a placement other than the one declared by comp.type_signature, an intrinsic not present in the whitelist above, or comp contains more than one unbound reference.