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
e0da0419
Commit
e0da0419
authored
13 years ago
by
Anton Akhmerov
Committed by
Christoph Groth
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
improve an error message in system.py
parent
0691b46d
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/system.py
+5
-4
5 additions, 4 deletions
kwant/system.py
with
5 additions
and
4 deletions
kwant/system.py
+
5
−
4
View file @
e0da0419
...
...
@@ -55,6 +55,9 @@ class System(object):
in which they appear. If sparse is set to `True`, a
`scipy.sparse.coo_matrix` is returned, otherwise a dense one.
"""
msg
=
'
Hopping from site {0} to site {1} does not match the
'
+
\
'
dimensions of onsite Hamiltonians of these sites.
'
def
create_sparse
():
# Calculate the data size.
num_entries
=
0
...
...
@@ -76,8 +79,7 @@ class System(object):
# The shape check is here to prevent data corruption.
shape
=
(
1
,
1
)
if
np
.
isscalar
(
h
)
else
h
.
shape
if
shape
!=
(
b_norb
[
n_j
],
a_norb
[
n_i
]):
raise
ValueError
(
'
matrix element
'
'
dimensions mismatch
'
)
raise
ValueError
(
msg
.
format
(
i
,
j
))
if
np
.
isscalar
(
h
):
data
[
offset
]
=
h
ij
[
0
,
offset
]
=
n_j
...
...
@@ -107,8 +109,7 @@ class System(object):
h_sub
[
b_off
[
n_j
]
:
b_off
[
n_j
+
1
],
a_off
[
n_i
]
:
a_off
[
n_i
+
1
]]
=
ham
(
j
,
i
)
except
ValueError
:
raise
ValueError
(
'
matrix element
'
'
dimensions mismatch
'
)
raise
ValueError
(
msg
.
format
(
i
,
j
))
return
h_sub
gr
=
self
.
graph
...
...
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