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
0e398ff4
Commit
0e398ff4
authored
Jun 22, 2021
by
Viacheslav Ostroukh
🚲
Browse files
Merge branch 'fix/ndarray_deprecation_warnings' into 'stable'
Fix Numpy-related deprecation warnings See merge request
!397
parents
9e1361b8
640e17fc
Pipeline
#97276
passed with stages
in 42 minutes and 33 seconds
Changes
4
Pipelines
41
Hide whitespace changes
Inline
Side-by-side
kwant/continuum/discretizer.py
View file @
0e398ff4
...
...
@@ -15,6 +15,7 @@ import numpy as np
import
tinyarray
as
ta
import
sympy
from
sympy.matrices.matrices
import
MatrixBase
from
sympy.utilities.lambdify
import
lambdastr
from
sympy.printing.lambdarepr
import
LambdaPrinter
from
sympy.printing.precedence
import
precedence
...
...
@@ -211,7 +212,7 @@ def discretize_symbolic(hamiltonian, coords=None, *, locals=None):
onsite_zeros
=
(
0
,)
*
len
(
coords
)
if
not
isinstance
(
hamiltonian
,
sympy
.
matrices
.
MatrixBase
):
if
not
isinstance
(
hamiltonian
,
MatrixBase
):
hamiltonian
=
sympy
.
Matrix
([
hamiltonian
])
_input_format
=
'expression'
else
:
...
...
@@ -574,7 +575,7 @@ def _return_string(expr, coords):
expr
=
expr
.
subs
(
map_func_calls
)
if
isinstance
(
expr
,
sympy
.
matrices
.
MatrixBase
):
if
isinstance
(
expr
,
MatrixBase
):
# express matrix return values in terms of sums of known matrices,
# which will be assigned to '_cache_n' in the function body.
mons
=
monomials
(
expr
,
expr
.
atoms
(
sympy
.
Symbol
))
...
...
kwant/plotter.py
View file @
0e398ff4
...
...
@@ -1498,8 +1498,8 @@ def spectrum(syst, x, y=None, params=None, mask=None, file=None,
h_p
=
np
.
atleast_2d
(
bound_ham
(
**
p
))
spectrum
.
append
(
np
.
linalg
.
eigvalsh
(
h_p
))
# massage masked grid points into a list of NaNs of the appropriate length
n
_eigvals
=
len
(
next
(
filter
(
lambda
s
:
s
is
not
None
,
spectrum
))
)
nan_list
=
[
np
.
nan
]
*
n_eigvals
shape
_eigvals
=
next
(
filter
(
lambda
s
:
s
is
not
None
,
spectrum
))
.
shape
nan_list
=
np
.
full
(
shape_eigvals
,
np
.
nan
)
spectrum
=
[
nan_list
if
s
is
None
else
s
for
s
in
spectrum
]
# make into a numpy array and reshape
new_shape
=
[
len
(
v
)
for
v
in
array_values
]
+
[
-
1
]
...
...
@@ -1542,9 +1542,11 @@ def spectrum(syst, x, y=None, params=None, mask=None, file=None,
# plot_surface cannot directly handle rank-3 values, so we
# explicitly loop over the last axis
grid
=
np
.
meshgrid
(
*
array_values
)
for
i
in
range
(
spectrum
.
shape
[
-
1
]):
spec
=
spectrum
[:,
:,
i
].
transpose
()
# row-major to x-y ordering
ax
.
plot_surface
(
*
(
grid
+
[
spec
]),
cstride
=
1
,
rstride
=
1
)
with
warnings
.
catch_warnings
():
warnings
.
filterwarnings
(
'ignore'
,
message
=
'Z contains NaN values'
)
for
i
in
range
(
spectrum
.
shape
[
-
1
]):
spec
=
spectrum
[:,
:,
i
].
transpose
()
# row-major to x-y ordering
ax
.
plot_surface
(
*
(
grid
+
[
spec
]),
cstride
=
1
,
rstride
=
1
)
_maybe_output_fig
(
fig
,
file
=
file
,
show
=
show
)
...
...
@@ -1687,8 +1689,13 @@ def _interpolate_field(dim, elements, discrete_field, bbox, width,
# Coordinates of the grid points that are within range of the current
# hopping.
coords
=
np
.
meshgrid
(
*
[
region
[
d
][
field_slice
[
d
]]
for
d
in
range
(
dim
)],
sparse
=
True
,
indexing
=
'ij'
)
coords
=
np
.
array
(
np
.
meshgrid
(
*
[
region
[
d
][
field_slice
[
d
]]
for
d
in
range
(
dim
)],
sparse
=
True
,
indexing
=
'ij'
),
dtype
=
object
)
# Convert "coords" into scaled distances from pos_offset
coords
-=
pos_offsets
[
i
]
...
...
kwant/qsymm.py
View file @
0e398ff4
...
...
@@ -18,6 +18,7 @@ import scipy.linalg as la
try
:
import
sympy
import
sympy.matrices.matrices
import
qsymm
from
qsymm.model
import
Model
,
BlochModel
,
BlochCoeff
from
qsymm.groups
import
PointGroupElement
,
ContinuousGroupGenerator
...
...
kwant/solvers/common.py
View file @
0e398ff4
...
...
@@ -814,7 +814,7 @@ class SMatrix(BlockResult):
block_offsets
.
append
(
block_offset
)
# Symmetry block offsets for all leads - or None if lead does not have
# blocks.
self
.
block_offsets
=
block_offsets
self
.
block_offsets
=
np
.
array
(
block_offsets
,
dtype
=
object
)
# Pick out symmetry block offsets for in and out leads
self
.
in_block_offsets
=
\
np
.
array
(
self
.
block_offsets
)[
list
(
self
.
in_leads
)]
...
...
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