Commit 2efd9a7e authored by Joseph Weston's avatar Joseph Weston
Browse files

use vectorized system interface more idiomatically in tests

This is a pure refactor.
parent e9ea4e8c
......@@ -2025,7 +2025,7 @@ class _VectorizedFinalizedBuilderMixin(_FinalizedBuilderMixin):
"elements at once using 'hamiltonian_term'.",
KwantDeprecationWarning
)
site_offsets = np.cumsum([0] + [len(s) for s in self.site_arrays])
site_offsets, _, _ = self.site_ranges.transpose()
if i == j:
which_term = self._onsite_term_by_site_id[i]
(w, _), (off, _) = self.subgraphs[self.terms[which_term].subgraph]
......
......@@ -321,10 +321,10 @@ def random_hopping_integral(rng):
def check_onsite(fsyst, sites, subset=False, check_values=True):
vectorized = isinstance(fsyst, (system.FiniteVectorizedSystem, system.InfiniteVectorizedSystem))
vectorized = system.is_vectorized(fsyst)
if vectorized:
site_offsets = np.cumsum([0] + [len(s) for s in fsyst.site_arrays])
site_offsets, _, _ = fsyst.site_ranges.transpose()
freq = {}
for node in range(fsyst.graph.num_nodes):
......@@ -353,10 +353,10 @@ def check_onsite(fsyst, sites, subset=False, check_values=True):
def check_hoppings(fsyst, hops):
vectorized = isinstance(fsyst, (system.FiniteVectorizedSystem, system.InfiniteVectorizedSystem))
vectorized = system.is_vectorized(fsyst)
if vectorized:
site_offsets = np.cumsum([0] + [len(s) for s in fsyst.site_arrays])
site_offsets, _, _ = fsyst.site_ranges.transpose()
assert fsyst.graph.num_edges == 2 * len(hops)
for edge_id, edge in enumerate(fsyst.graph):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment