Browse code

disallow infinite vectorized systems in operators

It is not clear how this will be implemented right now.

Joseph Weston authored on 10/12/2019 14:30:32
Showing 2 changed files
... ...
@@ -454,6 +454,11 @@ cdef class _LocalOperator:
454 454
                              'Declare the number of orbitals using the '
455 455
                              '`norbs` keyword argument when constructing '
456 456
                              'the site families (lattices).')
457
+        # TODO: Update this when it becomes clear how ND systems will be
458
+        #       implemented.
459
+        if is_vectorized(syst) and is_infinite(syst):
460
+            raise TypeError('Vectorized infinite systems cannot yet be '
461
+                            'used with operators.')
457 462
 
458 463
         self.syst = syst
459 464
         self.onsite, self._onsite_param_names = _normalize_onsite(
... ...
@@ -633,3 +633,12 @@ def test_vectorization(A):
633 633
     with pytest.raises(kwant._common.UserCodeError) as excinfo:
634 634
         bad_operator(wf)
635 635
     assert "did you remember to vectorize" in str(excinfo.value).lower()
636
+
637
+    # Infinite vectorized systems are incompatible with operators for now.
638
+    visyst = kwant.Builder(kwant.TranslationalSymmetry((-1, 0)), vectorize=True)
639
+    visyst[(lat(0, j) for j in range(5))] = sigmaz
640
+    visyst[lat.neighbors()] = sigmax
641
+    vifsyst = visyst.finalized()
642
+
643
+    with pytest.raises(TypeError):
644
+        A(vifsyst, vectorized_onsite, where=[(lat(1, 0), lat(0, 0))])