Commit 7ee5221f authored by Joseph Weston's avatar Joseph Weston
Browse files

replace 'builder' with 'system' when referring to 'Symmetry'

Even though we currently import 'Symmetry' and 'NoSymmetry' in
'builder' (to maintain backwards compatibility), we should use
the canonical location within Kwant itself.
parent b008821f
......@@ -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:
......
......@@ -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)
......
......@@ -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(
......
......@@ -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.")
......
......@@ -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
......
......@@ -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
......
......@@ -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)
......
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