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
02edf61d
Commit
02edf61d
authored
5 years ago
by
Christoph Groth
Browse files
Options
Downloads
Patches
Plain Diff
restore the functioning of args for wraparound-treated systems
parent
b1ce67b6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/source/pre/whatsnew/1.4.rst
+4
-0
4 additions, 0 deletions
doc/source/pre/whatsnew/1.4.rst
kwant/wraparound.py
+14
-11
14 additions, 11 deletions
kwant/wraparound.py
with
18 additions
and
11 deletions
doc/source/pre/whatsnew/1.4.rst
+
4
−
0
View file @
02edf61d
...
...
@@ -334,6 +334,10 @@ Changes in Kwant 1.4.1
mechanism is used, this restores most of the backwards compatibility with
previous Kwant versions: `Restrictions on value functions when named
parameters are given`_.
- The ``args`` parameter passing mechanism works again with
`~kwant.wraparound`-treated systems. Some restriction continue to appply,
notably it is not possible to use ``wraparound`` with value functions that
take ``*args`` or ``*kwargs``.
- Kwant no longer requires the existence of a `parameters` attribute for
low-level systems.
- A note about an :ref:`whatsnew13-params-api-change` that ocurred in Kwant
...
...
This diff is collapsed.
Click to expand it.
kwant/wraparound.py
+
14
−
11
View file @
02edf61d
...
...
@@ -165,42 +165,45 @@ def wraparound(builder, keep=None, *, coordinate_names='xyz'):
params
[
name
]
=
inspect
.
Parameter
(
name
,
inspect
.
Parameter
.
POSITIONAL_ONLY
)
# Add all the other parameters, except for the momenta.
# Add all the other parameters (except for the momenta). Setup the
# 'selections'.
selections
=
[]
for
val
in
vals
:
if
not
callable
(
val
):
selections
.
append
(())
continue
val_params
=
get_parameters
(
val
)[
num_sites
:]
assert
val_params
[
mnp
:]
==
momenta
val_params
=
val_params
[:
mnp
]
selections
.
append
((
*
site_params
,
*
val_params
))
for
p
in
val_params
:
# Skip parameters that exist in previously added functions,
# and the momenta, which will be placed at the end.
if
p
in
params
or
p
in
momenta
:
# Skip parameters that exist in previously added functions.
if
p
in
params
:
continue
params
[
p
]
=
inspect
.
Parameter
(
p
,
inspect
.
Parameter
.
POSITIONAL_ONLY
)
# Finally, add the momenta.
for
k
in
momenta
:
params
[
k
]
=
inspect
.
Parameter
(
k
,
inspect
.
Parameter
.
POSITIONAL_ONLY
)
# Sort values such that ones with the same arguments are bunched.
# Prepare 'val_selection_pairs' that is used in the function 'f' above.
params_keys
=
list
(
params
.
keys
())
val_selection_pairs
=
[]
prev_selection
=
None
argsort
=
sorted
(
range
(
len
(
selections
)),
key
=
selections
.
__getitem__
)
momenta_sel
=
tuple
(
range
(
mnp
,
0
,
1
))
for
i
in
argsort
:
selection
=
selections
[
i
]
if
selection
and
selection
!=
prev_selection
:
prev_selection
=
selection
=
tuple
(
params_keys
.
index
(
s
)
for
s
in
selection
)
params_keys
.
index
(
s
)
for
s
in
selection
)
+
momenta_sel
else
:
selection
=
()
val_selection_pairs
.
append
((
vals
[
i
],
selection
))
# Finally, add the momenta.
for
k
in
momenta
:
params
[
k
]
=
inspect
.
Parameter
(
k
,
inspect
.
Parameter
.
POSITIONAL_ONLY
)
f
.
__signature__
=
inspect
.
Signature
(
params
.
values
())
return
f
...
...
@@ -220,7 +223,7 @@ def wraparound(builder, keep=None, *, coordinate_names='xyz'):
sym
=
TranslationalSymmetry
(
*
periods
)
momenta
.
pop
(
keep
)
momenta
=
tuple
(
momenta
)
mnp
=
-
len
(
sym
.
periods
)
# Used by the bound functions above.
mnp
=
-
len
(
momenta
)
# Used by the bound functions above.
# Store the names of the momentum parameters and the symmetry of the
# old Builder (this will be needed for band structure plotting)
...
...
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