`tb_to_builder` fails for 0-dimensional system
import numpy as np
import kwant
import meanfi
from meanfi.kwant_helper import utils
lat = kwant.lattice.chain()
sys = kwant.Builder()
for x in range(2):
sys[lat(x)] = 0
sys[lat.neighbors()] = 1.0
h_0, data = utils.builder_to_tb(sys, return_data=True)
utils.tb_to_builder(h_0, data["sites"], data["periods"])
fails with
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[1], line 15
12 sys[lat.neighbors()] = 1.0
14 h_0, data = utils.builder_to_tb(sys, return_data=True)
---> 15 utils.tb_to_builder(h_0, data["sites"], data["periods"])
File /opt/conda/lib/python3.12/site-packages/meanfi/kwant_helper/utils.py:123, in tb_to_builder(h_0, sites_list, periods)
102 def tb_to_builder(
103 h_0: _tb_type, sites_list: list[Site, ...], periods: np.ndarray
104 ) -> kwant.builder.Builder:
105 """
106 Construct a `kwant.builder.Builder` from a tight-binding dictionary.
107
(...)
120 `kwant.builder.Builder` that corresponds to the tight-binding dictionary.
121 """
--> 123 builder = kwant.Builder(kwant.TranslationalSymmetry(*periods))
124 onsite_idx = tuple([0] * len(list(h_0)[0]))
126 norbs_list = [site.family.norbs for site in sites_list]
File /opt/conda/lib/python3.12/site-packages/kwant/lattice.py:540, in TranslationalSymmetry.__init__(self, *periods)
535 if self.periods.ndim != 2:
536 # TODO: remove the second part of the following message once
537 # everybody got used to it.
538 msg = ("TranslationalSymmetry takes 1d sequences as parameters.\n"
539 "See What's new in Kwant 0.2 in the documentation.")
--> 540 raise ValueError(msg)
541 if np.linalg.matrix_rank(periods) < len(periods):
542 raise ValueError("Translational symmetry periods must be "
543 "linearly independent")
ValueError: TranslationalSymmetry takes 1d sequences as parameters.
See What's new in Kwant 0.2 in the documentation.