quantumlib / Cirq

A Python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
Apache License 2.0
4.28k stars 1.02k forks source link

Avoid DivisionByZero error when TensorNetwork simplifies to a scalar #6586

Closed pavoljuhas closed 6 months ago

pavoljuhas commented 6 months ago

Problem: Python 3.12 requires quimb-1.8.0, but quimb-1.8.0 cannot evaluate path-info for TensorNetwork consisting of a scalar Tensor.

Solution: Skip path-info evaluation for scalar TensorNetwork. Path-info is used for RAM estimation only which is not a problem for scalar TensorNetwork-s.

This fixes unit test failure for cirq-core/cirq/contrib/quimb/grid_circuits_test.py::test_tensor_expectation_value

Ref: https://github.com/jcmgray/quimb/issues/231

codecov[bot] commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 97.79%. Comparing base (69e3de1) to head (016b758).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #6586 +/- ## ======================================= Coverage 97.79% 97.79% ======================================= Files 1124 1124 Lines 95703 95705 +2 ======================================= + Hits 93589 93595 +6 + Misses 2114 2110 -4 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.