Skip to content

Commit 78120ad

Browse files
committed
remove parse_key
1 parent 1c5e67e commit 78120ad

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

tensorcircuit/results/counts.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import numpy as np
88

9-
from ..cons import _ALPHABET
9+
from ..quantum import _decode_basis_label
1010

1111
Tensor = Any
1212
ct = Dict[str, int]
@@ -117,9 +117,6 @@ def count2vec(
117117
array([0.2, 0. , 0.3, 0.5])
118118
"""
119119

120-
def parse_key(_k: str) -> List[int]:
121-
return [_ALPHABET.index(_ch) for _ch in _k.upper()]
122-
123120
if not count:
124121
return np.array([], dtype=float)
125122

@@ -133,7 +130,7 @@ def parse_key(_k: str) -> List[int]:
133130

134131
powers = [dim**p for p in range(n)][::-1]
135132
for k, v in count.items():
136-
digits = parse_key(k)
133+
digits = _decode_basis_label(k, n, dim)
137134
idx = sum(dig * p for dig, p in zip(digits, powers))
138135
prob[idx] = (v / shots) if normalization else v
139136

0 commit comments

Comments
 (0)