Skip to content

Commit 66459ea

Browse files
authored
Lazily load scipy.linalg (quantumlib#5461)
Keep import down by not importing scipy.
1 parent 10eeb37 commit 66459ea

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cirq/devices/thermal_noise_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from typing import TYPE_CHECKING, Dict, List, Optional, Sequence, Set, Tuple, Union
1818
import numpy as np
1919
import sympy
20-
import scipy.linalg
2120

2221
from cirq import devices, ops, protocols, qis
2322
from cirq._import import LazyLoader
@@ -26,6 +25,7 @@
2625
if TYPE_CHECKING:
2726
import cirq
2827

28+
linalg = LazyLoader("linalg", globals(), "scipy.linalg")
2929
moment_module = LazyLoader("moment_module", globals(), "cirq.circuits.moment")
3030

3131

@@ -95,7 +95,7 @@ def _kraus_ops_from_rates(
9595
# Lindbladian with three Lindblad ops for the three processes
9696
# Note: 'time' parameter already specified implicitly through rates
9797
L = _lindbladian(annihilation) + _lindbladian(creation) + 2 * _lindbladian(num_op)
98-
superop = scipy.linalg.expm(L.real)
98+
superop = linalg.expm(L.real)
9999
return qis.superoperator_to_kraus(superop)
100100

101101

0 commit comments

Comments
 (0)