qp.testing.assert_eqn_matches_op¶
- assert_eqn_matches_op(eqn, expected_op)[source]¶
Assert that a jaxpr equation creates an operator of the expected type.
Subclasses of
Operator2are all captured with the sharedoperatorprimitive, so the operator class is read from the equation’s parameters. Other operators are captured with a primitive of their own.- Parameters:
eqn (jax.extend.core.JaxprEqn) – the equation to check
expected_op (type) – the expected operator class
- Raises:
AssertionError – if the equation does not create an
expected_op
Example
>>> qp.capture.enable() >>> plxpr = jax.make_jaxpr(lambda x: qp.RX(x, 0))(0.5) >>> qp.testing.assert_eqn_matches_op(plxpr.eqns[0], qp.RX)