Skip to content

cirq.unitary(…) can return a non-unitary in some cases #7572

@mhucka

Description

@mhucka

@pavoljuhas noted in a comment on PR quantumlib/qsim#857 that as things stand now, cirq.unitary(…) may return a non-unitary value, which means that it's possible for cirq_unitary(cirq.unitary(val)) to fail when cirq.unitary(val) works.

This became possible after PR #7419 added checks in the case of NumPy arrays. This is arguably the right behavior, in the sense that cirq.unitary(…) is supposed to return a unitary but previously would simply return the argument unverified when the argument was a NumPy array. Now it won't do that, but the other strategies used by cirq.unitary(…) don't do similar checks, and that leads to the possibility of new inconsistent behaviors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/protocolskind/healthFor CI/testing/release process/refactoring/technical debt itemstriage/discussNeeds decision / discussion, bring these up during Cirq Cynque

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions