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
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
Michael Wimmer
kwant
Commits
b825d6c0
Commit
b825d6c0
authored
11 years ago
by
Anton Akhmerov
Committed by
Christoph Groth
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
make plotter tests run without DISPLAY set
parent
05ebc353
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
kwant/tests/test_plotter.py
+34
-32
34 additions, 32 deletions
kwant/tests/test_plotter.py
with
34 additions
and
32 deletions
kwant/tests/test_plotter.py
+
34
−
32
View file @
b825d6c0
...
...
@@ -96,47 +96,49 @@ def test_plot():
color_opts
=
[
'
k
'
,
(
lambda
site
:
site
.
tag
[
0
]),
lambda
site
:
(
abs
(
site
.
tag
[
0
]
/
100
),
abs
(
site
.
tag
[
1
]
/
100
),
0
)]
for
color
in
color_opts
:
for
sys
in
(
sys2d
,
sys3d
):
fig
=
plot
(
sys
,
site_color
=
color
,
cmap
=
'
binary
'
,
show
=
False
)
if
color
!=
'
k
'
and
isinstance
(
color
(
iter
(
sys2d
.
sites
()).
next
()),
float
):
assert
fig
.
axes
[
0
].
collections
[
0
].
get_array
()
is
not
None
assert
len
(
fig
.
axes
[
0
].
collections
)
==
(
8
if
sys
is
sys2d
else
6
)
color_opts
=
[
'
k
'
,
(
lambda
site
,
site2
:
site
.
tag
[
0
]),
lambda
site
,
site2
:
(
abs
(
site
.
tag
[
0
]
/
100
),
abs
(
site
.
tag
[
1
]
/
100
),
0
)]
for
color
in
color_opts
:
for
sys
in
(
sys2d
,
sys3d
):
fig
=
plot
(
sys2d
,
hop_color
=
color
,
cmap
=
'
binary
'
,
show
=
False
,
fig_size
=
(
2
,
10
),
dpi
=
30
)
if
color
!=
'
k
'
and
isinstance
(
color
(
iter
(
sys2d
.
sites
()).
next
(),
None
),
float
):
assert
fig
.
axes
[
0
].
collections
[
1
].
get_array
()
is
not
None
assert
isinstance
(
plot
(
sys3d
,
show
=
False
).
axes
[
0
],
mplot3d
.
axes3d
.
Axes3D
)
sys2d
.
leads
=
[]
plot
(
sys2d
,
show
=
False
)
del
sys2d
[
list
(
sys2d
.
hoppings
())]
plot
(
sys2d
,
show
=
False
)
with
tempfile
.
TemporaryFile
(
'
w+b
'
)
as
output
:
plot
(
sys3d
,
file
=
output
)
with
tempfile
.
TemporaryFile
(
'
w+b
'
)
as
out
:
for
color
in
color_opts
:
for
sys
in
(
sys2d
,
sys3d
):
fig
=
plot
(
sys
,
site_color
=
color
,
cmap
=
'
binary
'
,
file
=
out
)
if
color
!=
'
k
'
and
\
isinstance
(
color
(
iter
(
sys2d
.
sites
()).
next
()),
float
):
assert
fig
.
axes
[
0
].
collections
[
0
].
get_array
()
is
not
None
assert
len
(
fig
.
axes
[
0
].
collections
)
==
(
8
if
sys
is
sys2d
else
6
)
color_opts
=
[
'
k
'
,
(
lambda
site
,
site2
:
site
.
tag
[
0
]),
lambda
site
,
site2
:
(
abs
(
site
.
tag
[
0
]
/
100
),
abs
(
site
.
tag
[
1
]
/
100
),
0
)]
for
color
in
color_opts
:
for
sys
in
(
sys2d
,
sys3d
):
fig
=
plot
(
sys2d
,
hop_color
=
color
,
cmap
=
'
binary
'
,
file
=
out
,
fig_size
=
(
2
,
10
),
dpi
=
30
)
if
color
!=
'
k
'
and
isinstance
(
color
(
iter
(
sys2d
.
sites
()).
next
(),
None
),
float
):
assert
fig
.
axes
[
0
].
collections
[
1
].
get_array
()
is
not
None
assert
isinstance
(
plot
(
sys3d
,
file
=
out
).
axes
[
0
],
mplot3d
.
axes3d
.
Axes3D
)
sys2d
.
leads
=
[]
plot
(
sys2d
,
file
=
out
)
del
sys2d
[
list
(
sys2d
.
hoppings
())]
plot
(
sys2d
,
file
=
out
)
plot
(
sys3d
,
file
=
out
)
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
"
ignore
"
)
plot
(
sys2d
.
finalized
(),
file
=
out
put
)
plot
(
sys2d
.
finalized
(),
file
=
out
)
def
test_map
():
if
not
plotter
.
mpl_enabled
:
raise
nose
.
SkipTest
sys
=
sys_2d
()
with
tempfile
.
TemporaryFile
(
'
w+b
'
)
as
out
put
:
plotter
.
map
(
sys
,
lambda
site
:
site
.
tag
[
0
],
file
=
out
put
,
with
tempfile
.
TemporaryFile
(
'
w+b
'
)
as
out
:
plotter
.
map
(
sys
,
lambda
site
:
site
.
tag
[
0
],
file
=
out
,
method
=
'
linear
'
,
a
=
4
,
oversampling
=
4
,
cmap
=
'
flag
'
)
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
"
ignore
"
)
plotter
.
map
(
sys
.
finalized
(),
xrange
(
len
(
sys
.
sites
())),
file
=
out
put
)
nose
.
tools
.
assert_raises
(
ValueError
,
plotter
.
map
,
sys
,
xrange
(
len
(
sys
.
sites
())),
file
=
out
put
)
file
=
out
)
nose
.
tools
.
assert_raises
(
ValueError
,
plotter
.
map
,
sys
,
xrange
(
len
(
sys
.
sites
())),
file
=
out
)
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