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
60b7356d
Verified
Commit
60b7356d
authored
6 years ago
by
Anton Akhmerov
Browse files
Options
Downloads
Patches
Plain Diff
internal function formatting cleanup
parent
8bd421b6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
kwant/builder.py
+16
-14
16 additions, 14 deletions
kwant/builder.py
with
16 additions
and
14 deletions
kwant/builder.py
+
16
−
14
View file @
60b7356d
...
@@ -599,21 +599,23 @@ class BuilderLead(Lead):
...
@@ -599,21 +599,23 @@ class BuilderLead(Lead):
return
InfiniteSystem
(
self
.
builder
,
self
.
interface
)
return
InfiniteSystem
(
self
.
builder
,
self
.
interface
)
# Check that a modes/selfenergy function has a keyword-only parameter
# 'params', or takes '**kwargs'. If not, we wrap it
def
_ensure_signature
(
func
):
def
_ensure_signature
(
func
):
parameters
=
inspect
.
signature
(
func
).
parameters
"""
has_params
=
bool
(
parameters
.
get
(
'
params
'
))
Ensure that a modes/selfenergy function has a keyword-only parameter
has_kwargs
=
any
(
p
.
kind
==
inspect
.
Parameter
.
VAR_KEYWORD
``params``, or takes ``**kwargs`` by potentially wrapping it.
for
p
in
parameters
.
values
())
"""
if
has_params
or
has_kwargs
:
parameters
=
inspect
.
signature
(
func
).
parameters
return
func
has_params
=
bool
(
parameters
.
get
(
'
params
'
))
else
:
# function conforming to old API: needs wrapping
has_kwargs
=
any
(
p
.
kind
==
inspect
.
Parameter
.
VAR_KEYWORD
for
p
in
parameters
.
values
())
def
wrapper
(
energy
,
args
=
(),
*
,
params
=
None
):
if
has_params
or
has_kwargs
:
return
func
(
energy
,
args
)
return
func
return
wrapper
# function conforming to old API: needs wrapping
def
wrapper
(
energy
,
args
=
(),
*
,
params
=
None
):
return
func
(
energy
,
args
)
return
wrapper
class
SelfEnergyLead
(
Lead
):
class
SelfEnergyLead
(
Lead
):
...
...
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