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
185c70bd
Commit
185c70bd
authored
12 years ago
by
Christoph Groth
Browse files
Options
Downloads
Plain Diff
merge bugfix release 0.2.1 into 0.3 development branch
parents
c4e1859d
e7077783
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/lattice.py
+5
-3
5 additions, 3 deletions
kwant/lattice.py
kwant/plotter.py
+7
-11
7 additions, 11 deletions
kwant/plotter.py
kwant/tests/test_lattice.py
+5
-0
5 additions, 0 deletions
kwant/tests/test_lattice.py
with
17 additions
and
14 deletions
kwant/lattice.py
+
5
−
3
View file @
185c70bd
...
...
@@ -118,12 +118,13 @@ class PolyatomicLattice(object):
Site
=
builder
.
Site
dim
=
len
(
start
)
num_vecs
=
len
(
self
.
prim_vecs
)
if
dim
!=
self
.
prim_vecs
.
shape
[
1
]:
raise
ValueError
(
'
Dimensionality of start position does not match
'
'
the space dimensionality.
'
)
sls
=
self
.
sublattices
deltas
=
[
ta
.
array
(
i
*
(
0
,)
+
(
1
,)
+
(
dim
-
1
-
i
)
*
(
0
,))
for
i
in
xrange
(
dim
)]
deltas
=
[
ta
.
array
(
i
*
(
0
,)
+
(
1
,)
+
(
num_vecs
-
1
-
i
)
*
(
0
,))
for
i
in
xrange
(
num_vecs
)]
deltas
+=
[
-
delta
for
delta
in
deltas
]
# Check if no sites are going to be added, to catch a common error.
...
...
@@ -218,6 +219,7 @@ class MonatomicLattice(builder.SiteGroup, PolyatomicLattice):
repr
(
self
.
name
))
intern
(
self
.
canonical_repr
)
self
.
dim
=
dim
self
.
_lattice_dim
=
len
(
prim_vecs
)
def
short_array_str
(
array
):
full
=
'
,
'
.
join
([
i
.
lstrip
()
for
i
in
str
(
array
).
split
(
'
\n
'
)])
...
...
@@ -238,7 +240,7 @@ class MonatomicLattice(builder.SiteGroup, PolyatomicLattice):
def
normalize_tag
(
self
,
tag
):
tag
=
ta
.
array
(
tag
,
int
)
if
len
(
tag
)
!=
self
.
dim
:
if
len
(
tag
)
!=
self
.
_lattice_
dim
:
raise
ValueError
(
"
Dimensionality mismatch.
"
)
return
tag
...
...
This diff is collapsed.
Click to expand it.
kwant/plotter.py
+
7
−
11
View file @
185c70bd
...
...
@@ -201,7 +201,7 @@ def lines3d(axes, x0, x1, y0, y1, z0, z1,
if
len
(
x0
)
==
0
:
coll
=
mplot3d
.
art3d
.
Line3DCollection
([],
linestyles
=
linestyles
)
axes
.
add_collection
(
coll
)
axes
.
add_collection
3d
(
coll
)
return
coll
segments
=
[(
i
[:
3
],
i
[
3
:])
for
...
...
@@ -209,7 +209,7 @@ def lines3d(axes, x0, x1, y0, y1, z0, z1,
coll
=
mplot3d
.
art3d
.
Line3DCollection
(
segments
,
linestyles
=
linestyles
)
set_edge_colors
(
colors
,
coll
,
cmap
,
norm
)
coll
.
update
(
kwargs
)
axes
.
add_collection
(
coll
)
axes
.
add_collection
3d
(
coll
)
min_max
=
lambda
a
,
b
:
np
.
array
(
min
(
a
.
min
(),
b
.
min
()),
max
(
a
.
max
(),
b
.
max
()))
...
...
@@ -249,9 +249,6 @@ def output_fig(fig, output_mode='auto', file=None, savefile_opts=None,
Notes
-----
For IPython with inline plotting, automatic mode selects
'
return
'
, since
there is a better way to show a figure by just calling `display(figure)`.
The behavior of this function producing a file is different from that of
matplotlib in that the `dpi` attribute of the figure is used by defaul
instead of the matplotlib config setting.
...
...
@@ -263,11 +260,8 @@ def output_fig(fig, output_mode='auto', file=None, savefile_opts=None,
output_mode
=
'
file
'
else
:
try
:
if
matplotlib
.
pyplot
.
get_backend
()
!=
\
'
module://IPython.zmq.pylab.backend_inline
'
:
output_mode
=
'
pyplot
'
else
:
output_mode
=
'
return
'
matplotlib
.
pyplot
.
get_backend
()
output_mode
=
'
pyplot
'
except
AttributeError
:
output_mode
=
'
pyplot
'
if
output_mode
==
'
pyplot
'
:
...
...
@@ -670,7 +664,9 @@ def plot(sys, n_lead_copies=2, site_color='b', hop_color='b', cmap='gray',
cmap
=
'
gist_yarg_r
'
,
s
=
size
**
2
,
norm
=
matplotlib
.
colors
.
Normalize
(
-
1
,
n_lead_copies
+
1
))
else
:
ax
.
add_collection
(
mplot3d
.
art3d
.
Patch3DCollection
([]))
col
=
mplot3d
.
art3d
.
Patch3DCollection
([])
col
.
set_3d_properties
([],
'
z
'
)
ax
.
add_collection3d
(
col
)
lead_hop_colors
=
np
.
array
([
i
[
2
]
for
i
in
hops
if
i
[
1
]
is
not
None
],
dtype
=
float
)
lead_hop_colors
=
1
/
np
.
sqrt
(
1.
+
lead_hop_colors
)
...
...
This diff is collapsed.
Click to expand it.
kwant/tests/test_lattice.py
+
5
−
0
View file @
185c70bd
...
...
@@ -24,6 +24,11 @@ def test_general():
site
=
sl
(
*
tag
)
assert_equal
(
tag
,
sl
.
closest
(
site
.
pos
))
# Test 2D lattice with 1 vector.
lat
=
lattice
.
make_lattice
([[
1
,
0
]])
site
=
lat
(
0
)
assert_raises
(
ValueError
,
lat
,
0
,
1
)
def
test_shape
():
def
in_circle
(
pos
):
...
...
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