Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
kwant
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
113
Issues
113
List
Boards
Labels
Milestones
Merge Requests
14
Merge Requests
14
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kwant
kwant
Commits
3a02cc2f
Commit
3a02cc2f
authored
Sep 20, 2018
by
Joseph Weston
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder.fill: add tests for empty template and starting site outside
parent
4732c59d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
kwant/tests/test_builder.py
kwant/tests/test_builder.py
+17
-3
No files found.
kwant/tests/test_builder.py
View file @
3a02cc2f
...
...
@@ -684,7 +684,7 @@ def test_fill():
assert
(
set
(
clone
.
hopping_value_pairs
())
==
set
(
orig
.
hopping_value_pairs
()))
## Test for warning when "start" is out.
## Test for warning when "start" is out
side the filling shape
.
target
=
builder
.
Builder
()
for
start
in
[(
-
101
,
0
),
(
101
,
0
)]:
with
warns
(
RuntimeWarning
):
...
...
@@ -732,7 +732,6 @@ def test_fill():
assert
sorted
(
target
.
sites
())
==
sorted
(
should_be_syst
.
sites
())
assert
sorted
(
target
.
hoppings
())
==
sorted
(
should_be_syst
.
hoppings
())
## test multiplying unit cell size in 2D
template_2d
=
builder
.
Builder
(
sym_xy
)
template_2d
[
g
(
0
,
0
)]
=
None
...
...
@@ -752,7 +751,6 @@ def test_fill():
assert
sorted
(
target
.
sites
())
==
sorted
(
should_be_syst
.
sites
())
assert
sorted
(
target
.
hoppings
())
==
sorted
(
should_be_syst
.
hoppings
())
## test filling 0D builder with 2D builder
def
square_shape
(
site
):
x
,
y
=
site
.
tag
...
...
@@ -790,6 +788,22 @@ def test_fill():
assert
len
(
new_sites
)
==
1
assert
to_target_fd
(
new_sites
[
0
])
==
to_target_fd
(
lat
(
-
1
))
# Test for warning with an empty template
template
=
builder
.
Builder
(
kwant
.
TranslationalSymmetry
((
-
1
,)))
target
=
builder
.
Builder
()
with
warns
(
RuntimeWarning
):
target
.
fill
(
template
,
lambda
x
:
True
,
lat
(
0
))
# Test for warning when one of the starting sites is outside the template
lat
=
kwant
.
lattice
.
square
()
template
=
builder
.
Builder
(
kwant
.
TranslationalSymmetry
((
-
1
,
0
)))
template
[
lat
(
0
,
0
)]
=
None
template
[
lat
.
neighbors
()]
=
None
target
=
builder
.
Builder
()
with
warns
(
RuntimeWarning
):
target
.
fill
(
template
,
lambda
x
:
-
1
<
x
.
pos
[
0
]
<
1
,
[
lat
(
0
,
0
),
lat
(
0
,
1
)])
def
test_fill_sticky
():
"""Test that adjacent regions are properly interconnected when filled
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment