|
19 | 19 | from typing import cast, Dict, Iterable, Iterator, List, overload, Tuple, Union |
20 | 20 |
|
21 | 21 | import attrs |
22 | | -import numpy as np |
23 | 22 | import sympy |
24 | 23 | from attrs import field, frozen |
25 | 24 |
|
26 | | -from qualtran.symbolics import is_symbolic, smax, SymbolicInt |
| 25 | +from qualtran.symbolics import is_symbolic, prod, smax, ssum, SymbolicInt |
27 | 26 |
|
28 | 27 | from .data_types import QAny, QBit, QDType |
29 | 28 |
|
@@ -99,7 +98,7 @@ def total_bits(self) -> int: |
99 | 98 |
|
100 | 99 | This is the product of bitsize and each of the dimensions in `shape`. |
101 | 100 | """ |
102 | | - return self.bitsize * int(np.prod(self.shape)) |
| 101 | + return self.bitsize * prod(self.shape_symbolic) |
103 | 102 |
|
104 | 103 | def adjoint(self) -> 'Register': |
105 | 104 | """Return the 'adjoint' of this register by switching RIGHT and LEFT registers.""" |
@@ -202,8 +201,8 @@ def n_qubits(self) -> int: |
202 | 201 | is taken to be the greater of the number of left or right qubits. A bloq with this |
203 | 202 | signature uses at least this many qubits. |
204 | 203 | """ |
205 | | - left_size = sum(reg.total_bits() for reg in self.lefts()) |
206 | | - right_size = sum(reg.total_bits() for reg in self.rights()) |
| 204 | + left_size = ssum(reg.total_bits() for reg in self.lefts()) |
| 205 | + right_size = ssum(reg.total_bits() for reg in self.rights()) |
207 | 206 | return smax(left_size, right_size) |
208 | 207 |
|
209 | 208 | def __repr__(self): |
|
0 commit comments