Skip to content

Commit aa89735

Browse files
committed
refactor(templates): Apply review suggestions to hamiltonians.py
This commit addresses code review feedback on the new hamiltonians module. - Switched from absolute to relative imports for internal modules (`..cons`, `..quantum`) to improve modularity. - Cleaned up and unified `typing` imports for better code style and consistency.
1 parent 11f1162 commit aa89735

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

tensorcircuit/templates/hamiltonians.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import typing
21
from typing import Any, List, Tuple, Union
32
import numpy as np
4-
from tensorcircuit.cons import dtypestr, backend
3+
from ..cons import dtypestr, backend
54
from ..quantum import PauliStringSum2COO
65
from .lattice import AbstractLattice
76

@@ -53,8 +52,8 @@ def heisenberg_hamiltonian(
5352

5453
pauli_map = {"X": 1, "Y": 2, "Z": 3}
5554

56-
ls: typing.List[typing.List[int]] = []
57-
weights: typing.List[float] = []
55+
ls: List[List[int]] = []
56+
weights: List[float] = []
5857

5958
pauli_terms = ["X", "Y", "Z"]
6059
for i, j in neighbor_pairs:
@@ -102,8 +101,8 @@ def rydberg_hamiltonian(
102101
raise ValueError("Cannot generate a Hamiltonian for a lattice with zero sites.")
103102

104103
pauli_map = {"X": 1, "Y": 2, "Z": 3}
105-
ls: typing.List[typing.List[int]] = []
106-
weights: typing.List[float] = []
104+
ls: List[List[int]] = []
105+
weights: List[float] = []
107106

108107
for i in range(num_sites):
109108
x_string = [0] * num_sites

0 commit comments

Comments
 (0)