build kwant under archlinux (Manjaro)
Hello,
Unfortunately, I do not manage to build kwant under archlinux (Manjaro). Neither with the normal AUR version nor with an updated git version.
There seem to be some mumps-related unit-test failing. I've installed mumps-seq-shared from the AUR but I'm not getting any further because I do not really understand why the unit-test fail.
~/.../AUR/python-kwant-git >>> makepkg ±[●][master]
==> Making package: python-kwant-git v1.5.0a0.r51.gd77f742-1 (Di 28 Mai 2019 10:34:52 CEST)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
-> Updating kwant git repo...
Fetching origin
-> Found build.conf
==> Validating source files with sha256sums...
kwant ... Skipped
build.conf ... Passed
==> Extracting sources...
-> Creating working copy of kwant git repo...
Reset branch 'makepkg'
==> Starting prepare()...
==> Starting pkgver()...
==> Removing existing $pkgdir/ directory...
==> Starting check()...
running test
running egg_info
writing kwant.egg-info/PKG-INFO
writing dependency_links to kwant.egg-info/dependency_links.txt
writing requirements to kwant.egg-info/requires.txt
writing top-level names to kwant.egg-info/top_level.txt
reading manifest file 'kwant.egg-info/SOURCES.txt'
writing manifest file 'kwant.egg-info/SOURCES.txt'
running build_ext
building 'kwant._system' extension
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -D_FORTIFY_SOURCE=2 -fPIC -I./kwant/graph -Ikwant/graph -I/usr/lib/python3.7/site-packages/numpy/core/include -I/usr/include/python3.7m -c kwant/_system.c -o build/temp.linux-x86_64-3.7/kwant/_system.o
In file included from /usr/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1822,
from /usr/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
from /usr/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
from kwant/_system.c:616:
/usr/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it with " \
^~~~~~~
gcc -pthread -shared -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.7/kwant/_system.o -L/usr/lib -lpython3.7m -o build/lib.linux-x86_64-3.7/kwant/_system.cpython-37m-x86_64-linux-gnu.so
building 'kwant.operator' extension
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -D_FORTIFY_SOURCE=2 -fPIC -I./kwant/graph -Ikwant/graph -I/usr/lib/python3.7/site-packages/numpy/core/include -I/usr/include/python3.7m -c kwant/operator.c -o build/temp.linux-x86_64-3.7/kwant/operator.o
In file included from /usr/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1822,
from /usr/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
from /usr/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
from kwant/operator.c:618:
/usr/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it with " \
^~~~~~~
gcc -pthread -shared -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.7/kwant/operator.o -L/usr/lib -lpython3.7m -o build/lib.linux-x86_64-3.7/kwant/operator.cpython-37m-x86_64-linux-gnu.so
building 'kwant.graph.core' extension
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -D_FORTIFY_SOURCE=2 -fPIC -I./kwant/graph -I/usr/lib/python3.7/site-packages/numpy/core/include -I/usr/include/python3.7m -c kwant/graph/core.c -o build/temp.linux-x86_64-3.7/kwant/graph/core.o
In file included from /usr/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1822,
from /usr/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
from /usr/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
from kwant/graph/core.c:617:
/usr/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it with " \
^~~~~~~
gcc -pthread -shared -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.7/kwant/graph/core.o -L/usr/lib -lpython3.7m -o build/lib.linux-x86_64-3.7/kwant/graph/core.cpython-37m-x86_64-linux-gnu.so
building 'kwant.graph.dijkstra' extension
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -D_FORTIFY_SOURCE=2 -fPIC -I/usr/lib/python3.7/site-packages/numpy/core/include -I/usr/include/python3.7m -c kwant/graph/dijkstra.c -o build/temp.linux-x86_64-3.7/kwant/graph/dijkstra.o
In file included from /usr/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1822,
from /usr/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
from /usr/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
from kwant/graph/dijkstra.c:614:
/usr/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it with " \
^~~~~~~
gcc -pthread -shared -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.7/kwant/graph/dijkstra.o -L/usr/lib -lpython3.7m -o build/lib.linux-x86_64-3.7/kwant/graph/dijkstra.cpython-37m-x86_64-linux-gnu.so
building 'kwant.linalg.lapack' extension
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -D_FORTIFY_SOURCE=2 -fPIC -I/usr/lib/python3.7/site-packages/numpy/core/include -I/usr/include/python3.7m -c kwant/linalg/lapack.c -o build/temp.linux-x86_64-3.7/kwant/linalg/lapack.o
In file included from /usr/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1822,
from /usr/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
from /usr/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
from kwant/linalg/lapack.c:613:
/usr/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it with " \
^~~~~~~
gcc -pthread -shared -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.7/kwant/linalg/lapack.o -L/usr/lib -lpython3.7m -o build/lib.linux-x86_64-3.7/kwant/linalg/lapack.cpython-37m-x86_64-linux-gnu.so
building 'kwant.linalg._mumps' extension
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/mumps-seq-shared -I/usr/lib/python3.7/site-packages/numpy/core/include -I/usr/include/python3.7m -c kwant/linalg/_mumps.c -o build/temp.linux-x86_64-3.7/kwant/linalg/_mumps.o
In file included from /usr/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1822,
from /usr/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
from /usr/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
from kwant/linalg/_mumps.c:623:
/usr/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it with " \
^~~~~~~
kwant/linalg/_mumps.c:3748:18: warning: ‘__pyx_f_5kwant_6linalg_6_mumps_make_cmumps_real_array’ defined but not used [-Wunused-function]
static PyObject *__pyx_f_5kwant_6linalg_6_mumps_make_cmumps_real_array(CMUMPS_REAL *__pyx_v_array) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kwant/linalg/_mumps.c:3362:18: warning: ‘__pyx_f_5kwant_6linalg_6_mumps_make_dmumps_real_array’ defined but not used [-Wunused-function]
static PyObject *__pyx_f_5kwant_6linalg_6_mumps_make_dmumps_real_array(DMUMPS_REAL *__pyx_v_array) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kwant/linalg/_mumps.c:2976:18: warning: ‘__pyx_f_5kwant_6linalg_6_mumps_make_smumps_real_array’ defined but not used [-Wunused-function]
static PyObject *__pyx_f_5kwant_6linalg_6_mumps_make_smumps_real_array(SMUMPS_REAL *__pyx_v_array) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gcc -pthread -shared -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.7/kwant/linalg/_mumps.o -L/usr/lib -lzmumps -lmumps_common -lpord -lmetis -lmpiseq -lgfortran -lpython3.7m -o build/lib.linux-x86_64-3.7/kwant/linalg/_mumps.cpython-37m-x86_64-linux-gnu.so
copying build/lib.linux-x86_64-3.7/kwant/_system.cpython-37m-x86_64-linux-gnu.so -> kwant
copying build/lib.linux-x86_64-3.7/kwant/operator.cpython-37m-x86_64-linux-gnu.so -> kwant
copying build/lib.linux-x86_64-3.7/kwant/graph/core.cpython-37m-x86_64-linux-gnu.so -> kwant/graph
copying build/lib.linux-x86_64-3.7/kwant/graph/dijkstra.cpython-37m-x86_64-linux-gnu.so -> kwant/graph
copying build/lib.linux-x86_64-3.7/kwant/linalg/lapack.cpython-37m-x86_64-linux-gnu.so -> kwant/linalg
copying build/lib.linux-x86_64-3.7/kwant/linalg/_mumps.cpython-37m-x86_64-linux-gnu.so -> kwant/linalg
******************************** Build summary ********************************
User-configured MUMPS
*******************************************************************************
==================================================================================== test session starts =====================================================================================
platform linux -- Python 3.7.3, pytest-4.4.1, py-1.8.0, pluggy-0.9.0
rootdir: /home/dennis/Downloads/AUR/python-kwant-git/src/kwant, inifile: pytest.ini, testpaths: kwant
plugins: cov-2.6.1
collecting ... ignoring kwant/continuum because the following dependencies are not installed: sympy
collected 252 items
kwant/graph/tests/test_core.py ........ [ 3%]
kwant/linalg/tests/test_linalg.py ........... [ 7%]
kwant/linalg/tests/test_lll.py .. [ 8%]
kwant/linalg/tests/test_mumps.py .... [ 9%]
kwant/physics/tests/test_dispersion.py ....... [ 12%]
kwant/physics/tests/test_gauge.py .................................................... [ 33%]
kwant/physics/tests/test_leads.py ..........F............. [ 42%]
kwant/physics/tests/test_noise.py .. [ 43%]
kwant/physics/tests/test_symmetry.py ..... [ 45%]
kwant/solvers/tests/test_mumps.py .............. [ 51%]
kwant/solvers/tests/test_sparse.py .............. [ 56%]
kwant/tests/test_builder.py ........................... [ 67%]
kwant/tests/test_comprehensive.py . [ 67%]
kwant/tests/test_kpm.py .......................... [ 78%]
kwant/tests/test_lattice.py .................. [ 85%]
kwant/tests/test_operator.py ............. [ 90%]
kwant/tests/test_plotter.py ........... [ 94%]
kwant/tests/test_rmt.py ... [ 96%]
kwant/tests/test_system.py .. [ 96%]
kwant/tests/test_wraparound.py ........ [100%]
========================================================================================== FAILURES ==========================================================================================
______________________________________________________________________________ test_symm_algorithm_equivalence _______________________________________________________________________________
actual = array([[ 1.64970764e+00+0.00000000e+00j, 0.00000000e+00+0.00000000e+00j,
2.83937131e+00+0.00000000e+00j, 0....9823e+00j, 4.92542169e-01-1.09220532e-01j,
-3.07201321e-01+3.15407999e-01j, 2.33922022e-01-3.19561381e-01j]])
desired = array([[ 1.64970764e+00+0.00000000e+00j, 0.00000000e+00+0.00000000e+00j,
0.00000000e+00+0.00000000e+00j, 2....9823e+00j, 2.93590121e-01+4.10282529e-01j,
-3.07201321e-01+3.15407999e-01j, -1.36851265e-02-3.95792503e-01j]])
decimal = 7, err_msg = '', verbose = True
def assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=True):
"""
Raises an AssertionError if two items are not equal up to desired
precision.
.. note:: It is recommended to use one of `assert_allclose`,
`assert_array_almost_equal_nulp` or `assert_array_max_ulp`
instead of this function for more consistent floating point
comparisons.
The test verifies that the elements of ``actual`` and ``desired`` satisfy.
``abs(desired-actual) < 1.5 * 10**(-decimal)``
That is a looser test than originally documented, but agrees with what the
actual implementation in `assert_array_almost_equal` did up to rounding
vagaries. An exception is raised at conflicting values. For ndarrays this
delegates to assert_array_almost_equal
Parameters
----------
actual : array_like
The object to check.
desired : array_like
The expected object.
decimal : int, optional
Desired precision, default is 7.
err_msg : str, optional
The error message to be printed in case of failure.
verbose : bool, optional
If True, the conflicting values are appended to the error message.
Raises
------
AssertionError
If actual and desired are not equal up to specified precision.
See Also
--------
assert_allclose: Compare two array_like objects for equality with desired
relative and/or absolute precision.
assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal
Examples
--------
>>> import numpy.testing as npt
>>> npt.assert_almost_equal(2.3333333333333, 2.33333334)
>>> npt.assert_almost_equal(2.3333333333333, 2.33333334, decimal=10)
Traceback (most recent call last):
...
AssertionError:
Arrays are not almost equal to 10 decimals
ACTUAL: 2.3333333333333
DESIRED: 2.33333334
>>> npt.assert_almost_equal(np.array([1.0,2.3333333333333]),
... np.array([1.0,2.33333334]), decimal=9)
Traceback (most recent call last):
...
AssertionError:
Arrays are not almost equal to 9 decimals
Mismatch: 50%
Max absolute difference: 6.66669964e-09
Max relative difference: 2.85715698e-09
x: array([1. , 2.333333333])
y: array([1. , 2.33333334])
"""
__tracebackhide__ = True # Hide traceback for py.test
from numpy.core import ndarray
from numpy.lib import iscomplexobj, real, imag
# Handle complex numbers: separate into real/imag to handle
# nan/inf/negative zero correctly
# XXX: catch ValueError for subclasses of ndarray where iscomplex fail
try:
usecomplex = iscomplexobj(actual) or iscomplexobj(desired)
except ValueError:
usecomplex = False
def _build_err_msg():
header = ('Arrays are not almost equal to %d decimals' % decimal)
return build_err_msg([actual, desired], err_msg, verbose=verbose,
header=header)
if usecomplex:
if iscomplexobj(actual):
actualr = real(actual)
actuali = imag(actual)
else:
actualr = actual
actuali = 0
if iscomplexobj(desired):
desiredr = real(desired)
desiredi = imag(desired)
else:
desiredr = desired
desiredi = 0
try:
> assert_almost_equal(actualr, desiredr, decimal=decimal)
/usr/lib/python3.7/site-packages/numpy/testing/_private/utils.py:565:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
actual = array([[ 1.64970764e+00, 0.00000000e+00, 2.83937131e+00,
0.00000000e+00, -2.95366293e+00, 0.00000000e+00,
... 9.17722770e-01,
-1.36336032e+00, 8.30538928e-01, 4.92542169e-01,
-3.07201321e-01, 2.33922022e-01]])
desired = array([[ 1.64970764e+00, 0.00000000e+00, 0.00000000e+00,
2.83937131e+00, -2.95366293e+00, 0.00000000e+00,
... 1.87439449e+00,
9.17722770e-01, 8.30538928e-01, 2.93590121e-01,
-3.07201321e-01, -1.36851265e-02]])
decimal = 7, err_msg = '', verbose = True
def assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=True):
"""
Raises an AssertionError if two items are not equal up to desired
precision.
.. note:: It is recommended to use one of `assert_allclose`,
`assert_array_almost_equal_nulp` or `assert_array_max_ulp`
instead of this function for more consistent floating point
comparisons.
The test verifies that the elements of ``actual`` and ``desired`` satisfy.
``abs(desired-actual) < 1.5 * 10**(-decimal)``
That is a looser test than originally documented, but agrees with what the
actual implementation in `assert_array_almost_equal` did up to rounding
vagaries. An exception is raised at conflicting values. For ndarrays this
delegates to assert_array_almost_equal
Parameters
----------
actual : array_like
The object to check.
desired : array_like
The expected object.
decimal : int, optional
Desired precision, default is 7.
err_msg : str, optional
The error message to be printed in case of failure.
verbose : bool, optional
If True, the conflicting values are appended to the error message.
Raises
------
AssertionError
If actual and desired are not equal up to specified precision.
See Also
--------
assert_allclose: Compare two array_like objects for equality with desired
relative and/or absolute precision.
assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal
Examples
--------
>>> import numpy.testing as npt
>>> npt.assert_almost_equal(2.3333333333333, 2.33333334)
>>> npt.assert_almost_equal(2.3333333333333, 2.33333334, decimal=10)
Traceback (most recent call last):
...
AssertionError:
Arrays are not almost equal to 10 decimals
ACTUAL: 2.3333333333333
DESIRED: 2.33333334
>>> npt.assert_almost_equal(np.array([1.0,2.3333333333333]),
... np.array([1.0,2.33333334]), decimal=9)
Traceback (most recent call last):
...
AssertionError:
Arrays are not almost equal to 9 decimals
Mismatch: 50%
Max absolute difference: 6.66669964e-09
Max relative difference: 2.85715698e-09
x: array([1. , 2.333333333])
y: array([1. , 2.33333334])
"""
__tracebackhide__ = True # Hide traceback for py.test
from numpy.core import ndarray
from numpy.lib import iscomplexobj, real, imag
# Handle complex numbers: separate into real/imag to handle
# nan/inf/negative zero correctly
# XXX: catch ValueError for subclasses of ndarray where iscomplex fail
try:
usecomplex = iscomplexobj(actual) or iscomplexobj(desired)
except ValueError:
usecomplex = False
def _build_err_msg():
header = ('Arrays are not almost equal to %d decimals' % decimal)
return build_err_msg([actual, desired], err_msg, verbose=verbose,
header=header)
if usecomplex:
if iscomplexobj(actual):
actualr = real(actual)
actuali = imag(actual)
else:
actualr = actual
actuali = 0
if iscomplexobj(desired):
desiredr = real(desired)
desiredi = imag(desired)
else:
desiredr = desired
desiredi = 0
try:
assert_almost_equal(actualr, desiredr, decimal=decimal)
assert_almost_equal(actuali, desiredi, decimal=decimal)
except AssertionError:
raise AssertionError(_build_err_msg())
if isinstance(actual, (ndarray, tuple, list)) \
or isinstance(desired, (ndarray, tuple, list)):
> return assert_array_almost_equal(actual, desired, decimal, err_msg)
/usr/lib/python3.7/site-packages/numpy/testing/_private/utils.py:572:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = array([[ 1.64970764e+00, 0.00000000e+00, 2.83937131e+00,
0.00000000e+00, -2.95366293e+00, 0.00000000e+00,
... 9.17722770e-01,
-1.36336032e+00, 8.30538928e-01, 4.92542169e-01,
-3.07201321e-01, 2.33922022e-01]])
y = array([[ 1.64970764e+00, 0.00000000e+00, 0.00000000e+00,
2.83937131e+00, -2.95366293e+00, 0.00000000e+00,
... 1.87439449e+00,
9.17722770e-01, 8.30538928e-01, 2.93590121e-01,
-3.07201321e-01, -1.36851265e-02]])
decimal = 7, err_msg = '', verbose = True
def assert_array_almost_equal(x, y, decimal=6, err_msg='', verbose=True):
"""
Raises an AssertionError if two objects are not equal up to desired
precision.
.. note:: It is recommended to use one of `assert_allclose`,
`assert_array_almost_equal_nulp` or `assert_array_max_ulp`
instead of this function for more consistent floating point
comparisons.
The test verifies identical shapes and that the elements of ``actual`` and
``desired`` satisfy.
``abs(desired-actual) < 1.5 * 10**(-decimal)``
That is a looser test than originally documented, but agrees with what the
actual implementation did up to rounding vagaries. An exception is raised
at shape mismatch or conflicting values. In contrast to the standard usage
in numpy, NaNs are compared like numbers, no assertion is raised if both
objects have NaNs in the same positions.
Parameters
----------
x : array_like
The actual object to check.
y : array_like
The desired, expected object.
decimal : int, optional
Desired precision, default is 6.
err_msg : str, optional
The error message to be printed in case of failure.
verbose : bool, optional
If True, the conflicting values are appended to the error message.
Raises
------
AssertionError
If actual and desired are not equal up to specified precision.
See Also
--------
assert_allclose: Compare two array_like objects for equality with desired
relative and/or absolute precision.
assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal
Examples
--------
the first assert does not raise an exception
>>> np.testing.assert_array_almost_equal([1.0,2.333,np.nan],
... [1.0,2.333,np.nan])
>>> np.testing.assert_array_almost_equal([1.0,2.33333,np.nan],
... [1.0,2.33339,np.nan], decimal=5)
Traceback (most recent call last):
...
AssertionError:
Arrays are not almost equal to 5 decimals
Mismatch: 33.3%
Max absolute difference: 6.e-05
Max relative difference: 2.57136612e-05
x: array([1. , 2.33333, nan])
y: array([1. , 2.33339, nan])
>>> np.testing.assert_array_almost_equal([1.0,2.33333,np.nan],
... [1.0,2.33333, 5], decimal=5)
Traceback (most recent call last):
...
AssertionError:
Arrays are not almost equal to 5 decimals
x and y nan location mismatch:
x: array([1. , 2.33333, nan])
y: array([1. , 2.33333, 5. ])
"""
__tracebackhide__ = True # Hide traceback for py.test
from numpy.core import number, float_, result_type, array
from numpy.core.numerictypes import issubdtype
from numpy.core.fromnumeric import any as npany
def compare(x, y):
try:
if npany(gisinf(x)) or npany( gisinf(y)):
xinfid = gisinf(x)
yinfid = gisinf(y)
if not (xinfid == yinfid).all():
return False
# if one item, x and y is +- inf
if x.size == y.size == 1:
return x == y
x = x[~xinfid]
y = y[~yinfid]
except (TypeError, NotImplementedError):
pass
# make sure y is an inexact type to avoid abs(MIN_INT); will cause
# casting of x later.
dtype = result_type(y, 1.)
y = array(y, dtype=dtype, copy=False, subok=True)
z = abs(x - y)
if not issubdtype(z.dtype, number):
z = z.astype(float_) # handle object arrays
return z < 1.5 * 10.0**(-decimal)
assert_array_compare(compare, x, y, err_msg=err_msg, verbose=verbose,
header=('Arrays are not almost equal to %d decimals' % decimal),
> precision=decimal)
/usr/lib/python3.7/site-packages/numpy/testing/_private/utils.py:1007:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
comparison = <function assert_array_almost_equal.<locals>.compare at 0x7f5fe9177d90>
x = array([ 1.64970764e+00, 0.00000000e+00, 2.83937131e+00, 0.00000000e+00,
-2.95366293e+00, 0.00000000e+00, -1...1051e+00, 9.17722770e-01, -1.36336032e+00,
8.30538928e-01, 4.92542169e-01, -3.07201321e-01, 2.33922022e-01])
y = array([ 1.64970764e+00, 0.00000000e+00, 0.00000000e+00, 2.83937131e+00,
-2.95366293e+00, 0.00000000e+00, -1...4256e+00, 1.87439449e+00, 9.17722770e-01,
8.30538928e-01, 2.93590121e-01, -3.07201321e-01, -1.36851265e-02])
err_msg = '\nMismatch: 57.8%\nMax absolute difference: 6.65909781\nMax relative difference: nan', verbose = True, header = 'Arrays are not almost equal to 7 decimals', precision = 7
equal_nan = True, equal_inf = True
def assert_array_compare(comparison, x, y, err_msg='', verbose=True,
header='', precision=6, equal_nan=True,
equal_inf=True):
__tracebackhide__ = True # Hide traceback for py.test
from numpy.core import array, array2string, isnan, inf, bool_, errstate
x = array(x, copy=False, subok=True)
y = array(y, copy=False, subok=True)
# original array for output formating
ox, oy = x, y
def isnumber(x):
return x.dtype.char in '?bhilqpBHILQPefdgFDG'
def istime(x):
return x.dtype.char in "Mm"
def func_assert_same_pos(x, y, func=isnan, hasval='nan'):
"""Handling nan/inf.
Combine results of running func on x and y, checking that they are True
at the same locations.
"""
x_id = func(x)
y_id = func(y)
# We include work-arounds here to handle three types of slightly
# pathological ndarray subclasses:
# (1) all() on `masked` array scalars can return masked arrays, so we
# use != True
# (2) __eq__ on some ndarray subclasses returns Python booleans
# instead of element-wise comparisons, so we cast to bool_() and
# use isinstance(..., bool) checks
# (3) subclasses with bare-bones __array_function__ implemenations may
# not implement np.all(), so favor using the .all() method
# We are not committed to supporting such subclasses, but it's nice to
# support them if possible.
if bool_(x_id == y_id).all() != True:
msg = build_err_msg([x, y],
err_msg + '\nx and y %s location mismatch:'
% (hasval), verbose=verbose, header=header,
names=('x', 'y'), precision=precision)
raise AssertionError(msg)
# If there is a scalar, then here we know the array has the same
# flag as it everywhere, so we should return the scalar flag.
if isinstance(x_id, bool) or x_id.ndim == 0:
return bool_(x_id)
elif isinstance(x_id, bool) or y_id.ndim == 0:
return bool_(y_id)
else:
return y_id
try:
cond = (x.shape == () or y.shape == ()) or x.shape == y.shape
if not cond:
msg = build_err_msg([x, y],
err_msg
+ '\n(shapes %s, %s mismatch)' % (x.shape,
y.shape),
verbose=verbose, header=header,
names=('x', 'y'), precision=precision)
raise AssertionError(msg)
flagged = bool_(False)
if isnumber(x) and isnumber(y):
if equal_nan:
flagged = func_assert_same_pos(x, y, func=isnan, hasval='nan')
if equal_inf:
flagged |= func_assert_same_pos(x, y,
func=lambda xy: xy == +inf,
hasval='+inf')
flagged |= func_assert_same_pos(x, y,
func=lambda xy: xy == -inf,
hasval='-inf')
elif istime(x) and istime(y):
# If one is datetime64 and the other timedelta64 there is no point
if equal_nan and x.dtype.type == y.dtype.type:
flagged = func_assert_same_pos(x, y, func=isnat, hasval="NaT")
if flagged.ndim > 0:
x, y = x[~flagged], y[~flagged]
# Only do the comparison if actual values are left
if x.size == 0:
return
elif flagged:
# no sense doing comparison if everything is flagged.
return
val = comparison(x, y)
if isinstance(val, bool):
cond = val
reduced = [0]
else:
reduced = val.ravel()
cond = reduced.all()
reduced = reduced.tolist()
# The below comparison is a hack to ensure that fully masked
# results, for which val.ravel().all() returns np.ma.masked,
# do not trigger a failure (np.ma.masked != True evaluates as
# np.ma.masked, which is falsy).
if cond != True:
mismatch = 100.0 * reduced.count(0) / ox.size
remarks = ['Mismatch: {:.3g}%'.format(mismatch)]
with errstate(invalid='ignore', divide='ignore'):
# ignore errors for non-numeric types
try:
error = abs(x - y)
max_abs_error = error.max()
remarks.append('Max absolute difference: '
+ array2string(max_abs_error))
# note: this definition of relative error matches that one
# used by assert_allclose (found in np.isclose)
max_rel_error = (error / abs(y)).max()
remarks.append('Max relative difference: '
+ array2string(max_rel_error))
except TypeError:
pass
err_msg += '\n' + '\n'.join(remarks)
msg = build_err_msg([ox, oy], err_msg,
verbose=verbose, header=header,
names=('x', 'y'), precision=precision)
> raise AssertionError(msg)
E AssertionError:
E Arrays are not almost equal to 7 decimals
E
E Mismatch: 57.8%
E Max absolute difference: 6.65909781
E Max relative difference: nan
E x: array([[ 1.6497076e+00, 0.0000000e+00, 2.8393713e+00, 0.0000000e+00,
E -2.9536629e+00, 0.0000000e+00, -1.8651713e+00, 0.0000000e+00],
E [ 0.0000000e+00, 8.4896667e-02, -7.0418045e-16, -1.3029077e+00,...
E y: array([[ 1.6497076e+00, 0.0000000e+00, 0.0000000e+00, 2.8393713e+00,
E -2.9536629e+00, 0.0000000e+00, -1.8651713e+00, 0.0000000e+00],
E [ 1.6396453e-15, 1.0427744e+00, -1.8781606e+00, -7.0418045e-16,...
/usr/lib/python3.7/site-packages/numpy/testing/_private/utils.py:819: AssertionError
During handling of the above exception, another exception occurred:
def test_symm_algorithm_equivalence():
"""Test different stabilization methods in the computation of modes,
in the presence and/or absence of the discrete symmetries."""
rng = ensure_rng(400)
n = 8
for sym in kwant.rmt.sym_list:
# Random onsite and hopping matrices in symmetry class
h_cell = kwant.rmt.gaussian(n, sym, rng=rng)
# Hopping is an offdiagonal block of a Hamiltonian. We rescale it
# to ensure that there are modes at the Fermi level.
h_hop = 10 * kwant.rmt.gaussian(2*n, sym, rng=rng)[:n, n:]
if kwant.rmt.p(sym):
p_mat = np.array(kwant.rmt.h_p_matrix[sym])
p_mat = np.kron(np.identity(n // len(p_mat)), p_mat)
else:
p_mat = None
if kwant.rmt.t(sym):
t_mat = np.array(kwant.rmt.h_t_matrix[sym])
t_mat = np.kron(np.identity(n // len(t_mat)), t_mat)
else:
t_mat = None
if kwant.rmt.c(sym):
c_mat = np.kron(np.identity(n // 2), np.diag([1, -1]))
else:
c_mat = None
check_equivalence(h_cell, h_hop, n, sym=sym, particle_hole=p_mat,
> chiral=c_mat, time_reversal=t_mat)
kwant/physics/tests/test_leads.py:359:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
h = array([[-0.02409897+0.j , 0. +0.j ,
0.24687387-0.79521522j, 0.83376623+0.58754129j,
...,
-1.63525969-0.7636217j , -1.23041264+1.60728359j,
0. +0.j , -0.43236374+0.j ]])
t = array([[-13.17020304-10.42006278j, 0.44193901 +3.40061213j,
-16.59240987 +3.75460755j, 11.09807319 +1.37459... 19.48497876 -1.8739094j , -0.63500809 -4.30766849j,
8.07136882+11.85712573j, -9.83221525+11.75435028j]])
n = 8, sym = 'AII', particle_hole = None, chiral = None
time_reversal = array([[0.+0.j, 0.+1.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
[0.-1.j, 0.+0.j, 0.-0.j, 0.+0.j, 0.-0....0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+1.j],
[0.-0.j, 0.+0.j, 0.-0.j, 0.+0.j, 0.-0.j, 0.+0.j, 0.-1.j, 0.+0.j]])
def check_equivalence(h, t, n, sym='', particle_hole=None, chiral=None,
time_reversal=None):
"""Compare modes stabilization algorithms for a given Hamiltonian."""
u, s, vh = np.linalg.svd(t)
u, v = u * np.sqrt(s), vh.T.conj() * np.sqrt(s)
prop_vecs = []
evan_vecs = []
algos = [None, (True, True), (True, False), (False, True), (False, False)]
for algo in algos:
result = leads.modes(h, t, stabilization=algo, chiral=chiral,
particle_hole=particle_hole,
time_reversal=time_reversal)[1]
current_conserving(result, (sym, algo, n))
vecs, vecslmbdainv = result.vecs, result.vecslmbdainv
# Bring the calculated vectors to real space
if algo is not None:
vecs = np.dot(v, vecs)
> np.testing.assert_almost_equal(result.sqrt_hop, v)
E AssertionError:
E Arrays are not almost equal to 7 decimals
E ACTUAL: array([[ 1.64970764e+00+0.00000000e+00j, 0.00000000e+00+0.00000000e+00j,
E 2.83937131e+00+0.00000000e+00j, 0.00000000e+00+0.00000000e+00j,
E -2.95366293e+00+0.00000000e+00j, 0.00000000e+00+0.00000000e+00j,...
E DESIRED: array([[ 1.64970764e+00+0.00000000e+00j, 0.00000000e+00+0.00000000e+00j,
E 0.00000000e+00+0.00000000e+00j, 2.83937131e+00+0.00000000e+00j,
E -2.95366293e+00-0.00000000e+00j, 0.00000000e+00+0.00000000e+00j,...
kwant/physics/tests/test_leads.py:299: AssertionError
=========================================================================== 1 failed, 251 passed in 46.96 seconds ============================================================================
==> ERROR: A failure occurred in check().
Aborting...
Kind regards quaeritis