Skip to content

Commit 88900ac

Browse files
committed
fix unicode
1 parent a0fb4f3 commit 88900ac

File tree

9 files changed

+34
-26
lines changed

9 files changed

+34
-26
lines changed

tensorcircuit/applications/layers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
def _resolve(symbol: Union[Symbol, Tensor], i: int = 0) -> Tensor:
3737
"""
38-
Make sure the layer is compatible with both multi-param and single param requirements
38+
Make sure the layer is compatible with both multi-param and single param requirements
3939
4040
What could be the input: list/tuple of sympy.symbol, tf.tensor with 1D or 0D shape
4141
"""

tensorcircuit/backends/abstract_backend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,8 +1039,8 @@ def searchsorted(self: Any, a: Tensor, v: Tensor, side: str = "left") -> Tensor:
10391039
:type a: Tensor
10401040
:param v: value to inserted
10411041
:type v: Tensor
1042-
:param side: If left, the index of the first suitable location found is given.
1043-
If right, return the last such index.
1042+
:param side: If `left`, the index of the first suitable location found is given.
1043+
If `right`, return the last such index.
10441044
If there is no suitable index, return either 0 or N (where N is the length of a),
10451045
defaults to "left"
10461046
:type side: str, optional

tensorcircuit/densitymatrix.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ def _contract(self) -> None:
179179

180180
@staticmethod
181181
def check_kraus(kraus: Sequence[Gate]) -> bool:
182-
"""
182+
r"""
183183
Check if Kraus operators satisfy the completeness relation:
184-
sum_i K_i^ K_i = I
184+
:math:`\sum_i K_i^\dagger K_i = I`
185185
186186
:param kraus: Sequence of Kraus operators
187187
:type kraus: Sequence[Gate]

tensorcircuit/quantum.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def _decode_basis_label(label: str, n: int, dim: int) -> List[int]:
7979
"""
8080
Decode a string basis label into a list of integer digits.
8181
82-
The label is interpreted in base-``dim`` using characters ``0–9A–Z``.
82+
The label is interpreted in base-``dim`` using characters ``0-9A-Z``.
8383
Only dimensions up to 36 are supported.
8484
8585
:param label: basis label string, e.g. "010" or "A9F"
@@ -97,7 +97,7 @@ def _decode_basis_label(label: str, n: int, dim: int) -> List[int]:
9797
"""
9898
if dim > 36:
9999
raise NotImplementedError(
100-
f"String basis label supports d<=36 (0–9A–Z). Got dim={dim}. "
100+
f"String basis label supports d<=36 (0-9A-Z). Got dim={dim}. "
101101
"Use an integer array/tensor of length n instead."
102102
)
103103
s = label.upper()
@@ -107,7 +107,7 @@ def _decode_basis_label(label: str, n: int, dim: int) -> List[int]:
107107
for ch in s:
108108
if ch not in _ALPHABET:
109109
raise ValueError(
110-
f"Invalid character '{ch}' in basis label (allowed 0–9A–Z)."
110+
f"Invalid character '{ch}' in basis label (allowed 0-9A-Z)."
111111
)
112112
v = _ALPHABET.index(ch)
113113
if v >= dim:
@@ -751,7 +751,7 @@ def tensor_product(self, other: "QuOperator") -> "QuOperator":
751751
"""
752752
Tensor product with another operator.
753753
Given two operators `A` and `B`, produces a new operator `AB` representing
754-
:math:`A B`. The `out_edges` (`in_edges`) of `AB` is simply the
754+
:math:`A \otimes B`. The `out_edges` (`in_edges`) of `AB` is simply the
755755
concatenation of the `out_edges` (`in_edges`) of `A.copy()` with that of
756756
`B.copy()`:
757757
`new_out_edges = [*out_edges_A_copy, *out_edges_B_copy]`
@@ -2403,13 +2403,13 @@ def free_energy(
24032403

24042404
def renyi_entropy(rho: Union[Tensor, QuOperator], k: int = 2) -> Tensor:
24052405
"""
2406-
Compute the Rényi entropy of order :math:`k` by given density matrix.
2406+
Compute the Renyi entropy of order :math:`k` by given density matrix.
24072407
24082408
:param rho: The density matrix in form of Tensor or QuOperator.
24092409
:type rho: Union[Tensor, QuOperator]
2410-
:param k: The order of Rényi entropy, default is 2.
2410+
:param k: The order of Renyi entropy, default is 2.
24112411
:type k: int, optional
2412-
:return: The :math:`k` th order of Rényi entropy.
2412+
:return: The :math:`k` th order of Renyi entropy.
24132413
:rtype: Tensor
24142414
"""
24152415
s = 1 / (1 - k) * backend.real(backend.log(trace_product(*[rho for _ in range(k)])))
@@ -2423,7 +2423,7 @@ def renyi_free_energy(
24232423
k: int = 2,
24242424
) -> Tensor:
24252425
"""
2426-
Compute the Rényi free energy of the corresponding density matrix and Hamiltonian.
2426+
Compute the Renyi free energy of the corresponding density matrix and Hamiltonian.
24272427
24282428
:Example:
24292429
@@ -2440,9 +2440,9 @@ def renyi_free_energy(
24402440
:type h: Union[Tensor, QuOperator]
24412441
:param beta: Constant for the optimization, default is 1.
24422442
:type beta: float, optional
2443-
:param k: The order of Rényi entropy, default is 2.
2443+
:param k: The order of Renyi entropy, default is 2.
24442444
:type k: int, optional
2445-
:return: The :math:`k` th order of Rényi entropy.
2445+
:return: The :math:`k` th order of Renyi entropy.
24462446
:rtype: Tensor
24472447
"""
24482448
energy = backend.real(trace_product(rho, h))

tensorcircuit/results/counts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def count2vec(
140140
def vec2count(vec: Tensor, prune: bool = False, dim: Optional[int] = None) -> ct:
141141
"""
142142
Map a count/probability vector of length D to a dictionary with base-d string keys (0-9A-Z).
143-
Only generate string keys when d 36; if d is inferred to be > 36, raise a NotImplementedError.
143+
Only generate string keys when d <= 36; if d is inferred to be > 36, raise a NotImplementedError.
144144
145145
:param vec: A one-dimensional vector of length D = d**n
146146
:param prune: Whether to prune near-zero elements (threshold 1e-8)

tensorcircuit/shadows.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def entropy_shadow(
334334

335335
def renyi_entropy_2(snapshots: Tensor, sub: Optional[Sequence[int]] = None) -> Tensor:
336336
r"""To calculate the second order Renyi entropy of a subsystem from snapshot, please refer to
337-
Brydges, T. et al. Science 364, 260263 (2019). This function is not jitable.
337+
Brydges, T. et al. Science 364, 260-263 (2019). This function is not jitable.
338338
339339
:param snapshots: shape = (ns, repeat, nq)
340340
:type: Tensor

tensorcircuit/templates/hamiltonians.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ def heisenberg_hamiltonian(
1919
j_coupling: Union[float, List[float], Tuple[float, ...]] = 1.0,
2020
interaction_scope: str = "neighbors",
2121
) -> Any:
22-
"""
22+
r"""
2323
Generates the sparse matrix of the Heisenberg Hamiltonian for a given lattice.
2424
2525
The Heisenberg Hamiltonian is defined as:
26-
H = J * Σ_{i,j} (X_i X_j + Y_i Y_j + Z_i Z_j)
26+
:math:`H = J\sum_{i,j} (X_i X_j + Y_i Y_j + Z_i Z_j)`
2727
where the sum is over a specified set of interacting pairs {i,j}.
2828
2929
:param lattice: An instance of a class derived from AbstractLattice,
@@ -86,13 +86,21 @@ def heisenberg_hamiltonian(
8686
def rydberg_hamiltonian(
8787
lattice: AbstractLattice, omega: float, delta: float, c6: float
8888
) -> Any:
89-
"""
89+
r"""
9090
Generates the sparse matrix of the Rydberg atom array Hamiltonian.
9191
9292
The Hamiltonian is defined as:
93-
H = Σ_i (Ω/2)X_i - Σ_i δ(1 - Z_i)/2 + Σ_{i<j} V_ij (1-Z_i)/2 (1-Z_j)/2
94-
= Σ_i (Ω/2)X_i + Σ_i (δ/2)Z_i + Σ_{i<j} (V_ij/4)(Z_iZ_j - Z_i - Z_j)
95-
where V_ij = C6 / |r_i - r_j|^6.
93+
.. math::
94+
95+
H = \sum_i \frac{\Omega}{2} X_i
96+
- \sum_i \frac{\delta}{2} \bigl(1 - Z_i \bigr)
97+
+ \sum_{i<j} \frac{V_{ij}}{4} \bigl(1 - Z_i \bigr)\bigl(1 - Z_j \bigr)
98+
99+
= \sum_i \frac{\Omega}{2} X_i
100+
+ \sum_i \frac{\delta}{2} Z_i
101+
+ \sum_{i<j} \frac{V_{ij}}{4}\,\bigl(Z_i Z_j - Z_i - Z_j \bigr)
102+
103+
where :math:`V_{ij} = C6 / |r_i - r_j|^6`.
96104
97105
Note: Constant energy offset terms (proportional to the identity operator)
98106
are ignored in this implementation.

tensorcircuit/templates/lattice.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,7 @@ def _build_neighbors(self, max_k: int = 1, **kwargs: Any) -> None:
14361436
This method supports two modes:
14371437
1. KDTree mode (use_kdtree=True): Fast, O(N log N) performance for large lattices
14381438
but breaks differentiability due to scipy dependency
1439-
2. Distance matrix mode (use_kdtree=False): Slower O(N²) but fully differentiable
1439+
2. Distance matrix mode (use_kdtree=False): Slower O(N^2) but fully differentiable
14401440
and backend-agnostic
14411441
14421442
:param max_k: Maximum number of neighbor shells to compute

tensorcircuit/timeevol.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def hamiltonian_evol(
387387
... [0.0, 2.0, -1.0, 0.0],
388388
... [0.0, 0.0, 0.0, 1.0]
389389
... ])
390-
>>> # Initial state |00
390+
>>> # Initial state |00>
391391
>>> psi0 = tc.array_to_tensor([1.0, 0.0, 0.0, 0.0])
392392
>>> # Evolution times
393393
>>> times = tc.array_to_tensor([0.0, 0.5, 1.0])
@@ -843,7 +843,7 @@ def estimate_spectral_bounds(
843843
:type n_iter: int
844844
:param psi0: Optional initial state.
845845
:type psi0: Optional[Any]
846-
:return: (E_max, E_min)
846+
:return: (E_max, E_min)
847847
"""
848848
shape = h.shape
849849
D = shape[-1]

0 commit comments

Comments
 (0)