Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
kwant
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Joseph Weston
kwant
Commits
0ee95bfc
Commit
0ee95bfc
authored
12 years ago
by
Anton Akhmerov
Committed by
Christoph Groth
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
remove builder.Site.shifted
It only made sense for tinyarray tags, and was largely unused.
parent
e001ab42
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
kwant/builder.py
+0
-27
0 additions, 27 deletions
kwant/builder.py
kwant/tests/test_builder.py
+3
-4
3 additions, 4 deletions
kwant/tests/test_builder.py
kwant/tests/test_lattice.py
+6
-4
6 additions, 4 deletions
kwant/tests/test_lattice.py
with
9 additions
and
35 deletions
kwant/builder.py
+
0
−
27
View file @
0ee95bfc
...
...
@@ -74,33 +74,6 @@ class Site(tuple):
raise
t
(
msg
.
format
(
repr
(
tag
),
repr
(
group
),
v
))
return
tuple
.
__new__
(
cls
,
(
group
,
tag
))
def
shifted
(
self
,
delta
,
group
=
None
):
"""
Return a copy of the site, displaced by delta.
Parameters
----------
delta : sequence of integers
The vector by which to displace the site.
group : `SiteGroup`
Site group of the returned site. If no site group is provided, the
original one is kept.
Returns
-------
new_site : `Site`
A site shifted by `delta` with site group optionally set to
`group`.
Notes
-----
This method *works* only if the site for which it is called has a tag
which is a sequences of integers. It *makes sense* only when this
sites lives on a regular lattice, like one provided by `kwant.lattice`.
"""
if
group
is
None
:
group
=
self
.
group
return
Site
(
group
,
ta
.
add
(
self
.
tag
,
delta
))
def
__repr__
(
self
):
return
'
Site({0}, {1})
'
.
format
(
repr
(
self
.
group
),
repr
(
self
.
tag
))
...
...
This diff is collapsed.
Click to expand it.
kwant/tests/test_builder.py
+
3
−
4
View file @
0ee95bfc
...
...
@@ -32,8 +32,6 @@ def test_site_groups():
assert_equal
(
sys
[
sg
(
1
)],
123
)
assert_raises
(
KeyError
,
sys
.
__getitem__
,
osg
(
1
))
assert_equal
(
sg
(
-
5
).
shifted
((
-
2
,),
osg
),
osg
(
-
7
))
class
VerySimpleSymmetry
(
builder
.
Symmetry
):
def
__init__
(
self
,
period
):
...
...
@@ -47,11 +45,12 @@ class VerySimpleSymmetry(builder.Symmetry):
return
ta
.
array
((
site
.
tag
[
0
]
//
self
.
period
,),
int
)
def
act
(
self
,
element
,
a
,
b
=
None
):
shifted
=
lambda
site
,
delta
:
site
.
group
(
*
ta
.
add
(
site
.
tag
,
delta
))
delta
=
(
self
.
period
*
element
[
0
],)
+
(
len
(
a
.
tag
)
-
1
)
*
(
0
,)
if
b
is
None
:
return
a
.
shifted
(
delta
)
return
shifted
(
a
,
delta
)
else
:
return
a
.
shifted
(
delta
),
b
.
shifted
(
delta
)
return
shifted
(
a
,
delta
),
shifted
(
b
,
delta
)
# The hoppings have to form a ring. Some other implicit assumptions are also
...
...
This diff is collapsed.
Click to expand it.
kwant/tests/test_lattice.py
+
6
−
4
View file @
0ee95bfc
...
...
@@ -9,9 +9,10 @@
from
__future__
import
division
from
math
import
sqrt
import
numpy
as
np
import
tinyarray
as
ta
from
nose.tools
import
assert_raises
,
assert_not_equal
from
numpy.testing
import
assert_equal
from
kwant
import
lattice
,
builder
from
kwant
import
lattice
def
test_make_lattice
():
...
...
@@ -48,6 +49,7 @@ def test_translational_symmetry():
ts
=
lattice
.
TranslationalSymmetry
g2
=
lattice
.
make_lattice
(
np
.
identity
(
2
))
g3
=
lattice
.
make_lattice
(
np
.
identity
(
3
))
shifted
=
lambda
site
,
delta
:
site
.
group
(
*
ta
.
add
(
site
.
tag
,
delta
))
sym
=
ts
((
0
,
0
,
4
),
(
0
,
5
,
0
),
(
0
,
0
,
2
))
assert_raises
(
ValueError
,
sym
.
add_site_group
,
g3
)
...
...
@@ -81,7 +83,7 @@ def test_translational_symmetry():
assert_equal
(
sym
.
which
(
site
),
(
0
,
0
))
assert_equal
(
sym2
.
which
(
site
),
(
0
,))
for
v
in
[(
1
,
0
),
(
0
,
1
),
(
-
1
,
0
),
(
0
,
-
1
),
(
5
,
10
),
(
-
111
,
573
)]:
site2
=
site
.
shifted
(
np
.
dot
(
v
,
transl_vecs
))
site2
=
shifted
(
site
,
np
.
dot
(
v
,
transl_vecs
))
assert
not
sym
.
in_fd
(
site2
)
assert
(
v
[
0
]
!=
0
)
!=
sym2
.
in_fd
(
site2
)
assert_equal
(
sym
.
to_fd
(
site2
),
site
)
...
...
@@ -90,8 +92,8 @@ def test_translational_symmetry():
assert_equal
(
sym2
.
which
(
site2
),
v
[:
1
])
for
hop
in
[(
0
,
0
),
(
100
,
0
),
(
0
,
5
),
(
-
2134
,
3213
)]:
assert_equal
(
sym
.
to_fd
(
site2
,
site2
.
shifted
(
hop
)),
(
site
,
site
.
shifted
(
hop
)))
assert_equal
(
sym
.
to_fd
(
site2
,
shifted
(
site2
,
hop
)),
(
site
,
shifted
(
site
,
hop
)))
def
test_translational_symmetry_reversed
():
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment