Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
kwant
kwant
Commits
7f5a7dc0
Commit
7f5a7dc0
authored
Jun 17, 2021
by
Anton Akhmerov
Browse files
check for input length in Monatomic.n_closest
parent
32259813
Pipeline
#74782
passed with stages
in 8 minutes and 3 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
kwant/lattice.py
View file @
7f5a7dc0
...
...
@@ -484,6 +484,9 @@ class Monatomic(builder.SiteFamily, Polyatomic):
sites : numpy array
An array with sites coordinates.
"""
if
len
(
pos
)
!=
len
(
self
.
offset
):
raise
ValueError
(
"Incorrect dimensionality of 'pos'."
)
# TODO (Anton): transform to tinyarrays, once ta indexing is better.
return
np
.
dot
(
lll
.
cvp
(
pos
-
self
.
offset
,
self
.
reduced_vecs
,
n
=
n
,
group_by_length
=
group_by_length
,
rtol
=
rtol
),
...
...
kwant/tests/test_lattice.py
View file @
7f5a7dc0
...
...
@@ -27,6 +27,9 @@ def test_closest():
tag
=
rng
.
randint
(
10
,
size
=
(
3
,))
assert
lat
.
closest
(
lat
(
*
tag
).
pos
)
==
tag
# Closest should raise if input has a wrong dimensionality
raises
(
ValueError
,
lattice
.
square
().
closest
,
[
0
])
def
test_general
():
for
lat
in
(
lattice
.
general
(((
1
,
0
),
(
0.5
,
0.5
))),
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment