diff --git a/kwant/builder.py b/kwant/builder.py index 05ee58f7398b8dec5ba3c712e20e656968962f70..156c97f65d3dd08833d5c66aaf7f1e93372f39c2 100644 --- a/kwant/builder.py +++ b/kwant/builder.py @@ -482,7 +482,7 @@ class Builder: Parameters ---------- - symmetry : `Symmetry` or `None` + symmetry : `~kwant.system.Symmetry` or `None` The spatial symmetry of the system. conservation_law : 2D array, dictionary, function, or `None` An onsite operator with integer eigenvalues that commutes with the @@ -531,8 +531,8 @@ class Builder: that if ``builder[a, b]`` has been set, there is no need to set ``builder[b, a]``. - Builder instances can be made to automatically respect a `Symmetry` that is - passed to them during creation. The behavior of builders with a symmetry + Builder instances can be made to automatically respect a `~kwant.system.Symmetry` + that is passed to them during creation. The behavior of builders with a symmetry is slightly more sophisticated: all keys are mapped to the fundamental domain of the symmetry before storing them. This may produce confusing results when neighbors of a site are queried. @@ -1481,7 +1481,7 @@ class Builder: system to be returned. Currently, only Builder instances without or with a 1D translational - `Symmetry` can be finalized. + `~kwant.system.Symmetry` can be finalized. """ if self.symmetry.num_directions == 0: if self.vectorize: diff --git a/kwant/continuum/landau_levels.py b/kwant/continuum/landau_levels.py index c653c55ef2634cd13e932f0c3f9c5fd026c10ff9..b2b8fc802dfa03343c4d7d314d84203c7c581302 100644 --- a/kwant/continuum/landau_levels.py +++ b/kwant/continuum/landau_levels.py @@ -18,6 +18,7 @@ import sympy import kwant.lattice import kwant.builder +import kwant.system import kwant.continuum import kwant.continuum._common @@ -144,7 +145,7 @@ def discretize_landau(hamiltonian, N, momenta=None, grid_spacing=1): if _has_coordinate(normal_coordinate, hamiltonian): sym = kwant.lattice.TranslationalSymmetry([grid_spacing, 0]) else: - sym = kwant.builder.NoSymmetry() + sym = kwant.system.NoSymmetry() lat = LandauLattice(grid_spacing, norbs=norbs) syst = kwant.Builder(sym) diff --git a/kwant/continuum/tests/test_landau_levels.py b/kwant/continuum/tests/test_landau_levels.py index 8a568e6f4a4a716f1daa2c82542f47ea237a0f9d..5878724fbf997949d791dc33ae49a90e55b24a39 100644 --- a/kwant/continuum/tests/test_landau_levels.py +++ b/kwant/continuum/tests/test_landau_levels.py @@ -13,8 +13,8 @@ import sympy import pytest import itertools -import kwant.builder import kwant.lattice +import kwant.system from .._common import position_operators, momentum_operators, sympify from ..landau_levels import ( @@ -118,7 +118,7 @@ def test_discretize_landau(): # test a basic Hamiltonian with no normal coordinate dependence syst = discretize_landau("k_x**2 + k_y**2", N=n_levels) lat = LandauLattice(1, norbs=1) - assert isinstance(syst.symmetry, kwant.builder.NoSymmetry) + assert isinstance(syst.symmetry, kwant.system.NoSymmetry) syst = syst.finalized() assert set(syst.sites) == {lat(0, j) for j in range(n_levels)} assert np.allclose( diff --git a/kwant/lattice.py b/kwant/lattice.py index 7e0d55905df3292b5e4eeee7812ed7649d952f77..976213d3578899a497e06da357aa512d8289f24d 100644 --- a/kwant/lattice.py +++ b/kwant/lattice.py @@ -153,7 +153,7 @@ class Polyatomic: algorithm finds and yields all the lattice sites inside the specified shape starting from the specified position. - A `~kwant.builder.Symmetry` or `~kwant.builder.Builder` may be passed as + A `~kwant.system.Symmetry` or `~kwant.builder.Builder` may be passed as sole argument when calling the function returned by this method. This will restrict the flood-fill to the fundamental domain of the symmetry (or the builder's symmetry). Note that unless the shape function has @@ -174,8 +174,8 @@ class Polyatomic: Site = system.Site if symmetry is None: - symmetry = builder.NoSymmetry() - elif not isinstance(symmetry, builder.Symmetry): + symmetry = system.NoSymmetry() + elif not isinstance(symmetry, system.Symmetry): symmetry = symmetry.symmetry def fd_site(lat, tag): @@ -259,7 +259,7 @@ class Polyatomic: center = ta.array(center, float) def wire_sites(sym): - if not isinstance(sym, builder.Symmetry): + if not isinstance(sym, system.Symmetry): sym = sym.symmetry if not isinstance(sym, TranslationalSymmetry): raise ValueError('wire shape only works with ' @@ -568,7 +568,7 @@ class TranslationalSymmetry(system.Symmetry): return TranslationalSymmetry(*ta.dot(generators, self.periods)) def has_subgroup(self, other): - if isinstance(other, builder.NoSymmetry): + if isinstance(other, system.NoSymmetry): return True elif not isinstance(other, TranslationalSymmetry): raise ValueError("Unknown symmetry type.") diff --git a/kwant/physics/tests/test_gauge.py b/kwant/physics/tests/test_gauge.py index 067c3244d44363ffcf6e9e4f993485b465e10e34..40e5f66d7560ad8c6f70111ac1dd73c7b89411bb 100644 --- a/kwant/physics/tests/test_gauge.py +++ b/kwant/physics/tests/test_gauge.py @@ -6,7 +6,8 @@ import pytest import kwant from ... import lattice -from ...builder import HoppingKind, Builder, NoSymmetry, Site +from ...builder import HoppingKind, Builder, Site +from ...system import NoSymmetry from .. import gauge diff --git a/kwant/tests/test_builder.py b/kwant/tests/test_builder.py index 3355a4ff0eacb4b68e7286961231051a7a858e47..f4a70985af7719a89693a5d0145f3a4b5ec24f6d 100644 --- a/kwant/tests/test_builder.py +++ b/kwant/tests/test_builder.py @@ -153,7 +153,7 @@ def test_site_families(): assert fam1 < fam2 # string '1' is lexicographically less than '2' -class VerySimpleSymmetry(builder.Symmetry): +class VerySimpleSymmetry(system.Symmetry): def __init__(self, period): self.period = period @@ -162,7 +162,7 @@ class VerySimpleSymmetry(builder.Symmetry): return 1 def has_subgroup(self, other): - if isinstance(other, builder.NoSymmetry): + if isinstance(other, system.NoSymmetry): return True elif isinstance(other, VerySimpleSymmetry): return not other.period % self.period @@ -809,7 +809,7 @@ def test_vectorized_value_normalization(): @pytest.mark.parametrize("sym", [ - builder.NoSymmetry(), + system.NoSymmetry(), kwant.TranslationalSymmetry([-1]), ]) def test_vectorized_requires_norbs(sym): @@ -918,7 +918,7 @@ def test_fill(): ## Test that copying a builder by "fill" preserves everything. for sym, func in [(kwant.TranslationalSymmetry(*np.diag([3, 4, 5])), lambda pos: True), - (builder.NoSymmetry(), + (system.NoSymmetry(), lambda pos: ta.dot(pos, pos) < 17)]: cubic = kwant.lattice.general(ta.identity(3), norbs=1) @@ -1639,7 +1639,7 @@ def test_subs(): lat = kwant.lattice.chain(norbs=1) - def make_system(sym=kwant.builder.NoSymmetry(), n=3): + def make_system(sym=system.NoSymmetry(), n=3): syst = kwant.Builder(sym) syst[(lat(i) for i in range(n))] = onsite syst[lat.neighbors()] = hopping diff --git a/kwant/tests/test_lattice.py b/kwant/tests/test_lattice.py index 5e7a9976ed74ef881ece72ada167c48c39f8ff13..4850e45137076dbe05615225530e2d8b1e671eed 100644 --- a/kwant/tests/test_lattice.py +++ b/kwant/tests/test_lattice.py @@ -11,7 +11,7 @@ from math import sqrt import numpy as np import tinyarray as ta from pytest import raises -from kwant import lattice, builder +from kwant import lattice, builder, system from kwant._common import ensure_rng import pytest @@ -285,7 +285,7 @@ def test_symmetry_has_subgroup(): ## test whether actual subgroups are detected as such vecs = rng.randn(3, 3) sym1 = lattice.TranslationalSymmetry(*vecs) - ns = builder.NoSymmetry() + ns = system.NoSymmetry() assert ns.has_subgroup(ns) assert sym1.has_subgroup(sym1) assert sym1.has_subgroup(ns)