diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bab17ea2f7dcf0a4621b0c135d62d39efab145b3..b70e2396f2691eb07e0b97d6b98d2b7c43367613 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,9 +21,6 @@ variables: image: name: gcr.io/kaniko-project/executor:debug-v0.16.0 entrypoint: [""] - artifacts: - untracked: true - expire_in: 1 hour before_script: - mkdir -p /kaniko/.docker - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json @@ -219,7 +216,8 @@ build documentation: - build:latest stage: test script: - - make -C doc clean; make -C doc html SPHINXOPTS='-A website_deploy=True -n -W -D jupyter_execute_default_kernel=kwant-latest' SOURCE_LINK_TEMPLATE="$CI_PROJECT_URL"/blob/\$\$r/\$\$f + - python -c 'from matplotlib import pyplot' # Pre-generate font cache + - make -C doc clean; make -C doc html SPHINXOPTS='-A website_deploy=True -n -D jupyter_execute_default_kernel=kwant-latest' SOURCE_LINK_TEMPLATE="$CI_PROJECT_URL"/blob/\$\$r/\$\$f artifacts: paths: - doc/build/html/ @@ -231,7 +229,8 @@ build PDF documentation: - build:latest stage: test script: - - make -C doc latex SPHINXOPTS='-n -W -D jupyter_execute_default_kernel=kwant-latest' + - python -c 'from matplotlib import pyplot' # Pre-generate font cache + - make -C doc latex SPHINXOPTS='-n -D jupyter_execute_default_kernel=kwant-latest' - cd doc/build/latex - make all-pdf artifacts: diff --git a/AUTHORS.rst b/AUTHORS.rst index 07b31efed8e4582ac647c8a44330742f1e65bcb1..6be00d42c27480fcbd8750dc535bd26bd95ea3ab 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -8,8 +8,8 @@ The principal developers of Kwant are * `Christoph Groth <mailto:christoph.groth@cea.fr>`_ (CEA Grenoble) * `Michael Wimmer <https://michaelwimmer.org>`_ (TU Delft) -* `Anton Akhmerov <http://antonakhmerov.org>`_ (TU Delft) -* `Xavier Waintal <http://inac.cea.fr/Pisp/xavier.waintal>`_ (CEA Grenoble) +* `Anton Akhmerov <https://antonakhmerov.org>`_ (TU Delft) +* `Xavier Waintal <https://www.pheliqs.fr/en/Pages/Portrait/Xavier-Waintal.aspx>`_ (CEA Grenoble) * `Joseph Weston <https://joseph.weston.cloud>`_ (TU Delft) Contributors to Kwant include @@ -34,7 +34,7 @@ Contributors to Kwant include We thank Christoph Gohlke for the creation of installers for Microsoft Windows. -`CEA <http://www.cea.fr>`_ is the French Commissariat à l'énergie atomique et aux +`CEA <https://www.cea.fr>`_ is the French Commissariat à l'énergie atomique et aux énergies alternatives. The CEA is the copyright holder for the contributions of C. W. Groth, X. Waintal, and its other employees involved in Kwant. diff --git a/CITING.rst b/CITING.rst index c34a422fc95690b73a1cdc46ad1477a8afc29a3a..05a6b727d262185fb05becb0b2029e24a096901d 100644 --- a/CITING.rst +++ b/CITING.rst @@ -15,7 +15,7 @@ cite the main paper that introduces Kwant: C. W. Groth, M. Wimmer, A. R. Akhmerov, X. Waintal, *Kwant: a software package for quantum transport*, `New J. Phys. 16, 063065 (2014) - <https://iopscience.iop.org/1367-2630/16/6/063065/article>`_. + <https://doi.org/10.1088/1367-2630/16/6/063065>`_. Other references we ask you to consider @@ -26,7 +26,7 @@ also cite the upcoming paper that describes the relevant algorithms. The reference will also be added here once it is available. Kwant owes much of its current performance to the use of the `MUMPS -<http://graal.ens-lyon.fr/MUMPS/>`_ library for solving systems of sparse linear +<https://graal.ens-lyon.fr/MUMPS/>`_ library for solving systems of sparse linear equations. If you have done high-performance calculations, we suggest citing P. R. Amestoy, I. S. Duff, J. S. Koster, J. Y. L’Excellent, SIAM. J. Matrix diff --git a/INSTALL.rst b/INSTALL.rst index 460551c99e6eab92a92ad77f14304a78ec337ef4..6ba23e125606096ab44306ec61438979e6c5e1d7 100644 --- a/INSTALL.rst +++ b/INSTALL.rst @@ -20,7 +20,7 @@ Obtaining the source code Source distributions of Kwant (and Tinyarray) are available at the `downloads section of the Kwant website <https://downloads.kwant-project.org/kwant/>`_ as well -as `PyPI <https://pypi.python.org/pypi/kwant>`_. The sources may be also +as `PyPI <https://pypi.org/project/kwant>`_. The sources may be also cloned directly from the `official Kwant git repository <https://gitlab.kwant-project.org/kwant/kwant>`_. @@ -29,13 +29,12 @@ Prerequisites ============= Building Kwant requires - * `Python <https://www.python.org/>`_ 3.6 or above (Kwant 1.1 is the last - version to support Python 2), - * `NumPy <http://numpy.org/>`_ 1.13.3 or newer, - * `SciPy <https://www.scipy.org/>`_ 0.19.1 or newer, - * `LAPACK <http://netlib.org/lapack/>`_ and `BLAS <http://netlib.org/blas/>`_, + * `Python <https://www.python.org/>`_ 3.7 or above, + * `NumPy <https://numpy.org/>`_ 1.16.2 or newer, + * `SciPy <https://www.scipy.org/>`_ 1.1.0 or newer, + * `LAPACK <https://netlib.org/lapack/>`_ and `BLAS <https://netlib.org/blas/>`_, (For best performance we recommend the free `OpenBLAS - <http://www.openblas.net/>`_ or the nonfree `MKL + <https://www.openblas.net/>`_ or the nonfree `MKL <https://software.intel.com/en-us/intel-mkl>`_.) * `Tinyarray <https://gitlab.kwant-project.org/kwant/tinyarray>`_ 1.2 or newer, a NumPy-like Python package optimized for very small arrays, @@ -43,19 +42,20 @@ a NumPy-like Python package optimized for very small arrays, C++. The following software is highly recommended though not strictly required: - * `matplotlib <http://matplotlib.org/>`_ 2.1.1 or newer, for the module `kwant.plotter` and the tutorial, - * `SymPy <http://sympy.org/>`_ 1.1.1 or newer, for the subpackage `kwant.continuum`. - * `Qsymm <https://pypi.org/project/qsymm/>`_ 1.2.6 or newer, for the subpackage `kwant.qsymm`. - * `MUMPS <http://graal.ens-lyon.fr/MUMPS/>`_, a sparse linear algebra library + * `matplotlib <https://matplotlib.org/>`_ 3.0.2 or newer, for the module `kwant.plotter` and the tutorial, + * `plotly <https://plotly.com/>`_ 3.6.1 or newer, for the module `kwant.plotter` and the tutorial, + * `SymPy <https://sympy.org/>`_ 1.3.0 or newer, for the subpackage `kwant.continuum`. + * `Qsymm <https://pypi.org/project/qsymm/>`_ 1.3.0 or newer, for the subpackage `kwant.qsymm`. + * `MUMPS <https://graal.ens-lyon.fr/MUMPS/>`_, a sparse linear algebra library that will in many cases speed up Kwant several times and reduce the memory footprint. (Kwant uses only the sequential, single core version of MUMPS. The advantages due to MUMPS as used by Kwant are thus independent of the number of CPU cores of the machine on which Kwant runs.) - * The `py.test testing framework <http://pytest.org/>`_ 3.3.2 or newer for running the + * The `py.test testing framework <https://docs.pytest.org/>`_ 3.3.2 or newer for running the tests included with Kwant. In addition, to build a copy of Kwant that has been checked-out directly from -version control, you will also need `Cython <http://cython.org/>`_ 0.26.1 or +version control, you will also need `Cython <https://cython.org/>`_ 0.26.1 or newer. You do not need Cython to build Kwant that has been unpacked from a source .tar.gz-file. @@ -128,7 +128,7 @@ The section ``[kwant.linalg._mumps]`` may be used to adapt the build process. Example ``build.conf`` for linking Kwant against a self-compiled MUMPS, `SCOTCH -<http://www.labri.fr/perso/pelegrin/scotch/>`_ and `METIS +<https://www.labri.fr/perso/pelegrin/scotch/>`_ and `METIS <http://glaros.dtc.umn.edu/gkhome/metis/metis/overview>`_:: [mumps] @@ -143,7 +143,7 @@ Building the documentation ========================== To build the documentation, the `Sphinx documentation generator -<http://www.sphinx-doc.org/en/stable/>`_ is required with ``numpydoc`` extension +<https://www.sphinx-doc.org/en/stable/>`_ is required with ``numpydoc`` extension (version 0.5 or newer), as well as ``jupyter-sphinx`` (version 0.2 or newer). If PDF documentation is to be built, the tools from the `libRSVG <https://wiki.gnome.org/action/show/Projects/LibRsvg>`_ @@ -195,72 +195,6 @@ By default the package will be installed under ``/usr/local``. Run ``python3 setup.py --help install`` for installation options. -Mac OS X: MacPorts -================== - -The following instructions are valid for Kwant 1.1 with Python 2.7. They need -to be updated for Kwant 1.2. (Help is welcome.) - -The required dependencies of Kwant are best installed with one of the packaging -systems. Here we only consider the case of `MacPorts -<https://www.macports.org>`_ in detail. Some remarks for homebrew are given -below. - -1. Install a recent version of MacPorts, as explained in the `installation - instructions of MacPorts <https://www.macports.org/install.php>`_. - -2. Install the required dependencies:: - - sudo port install gcc47 python27 py27-numpy py27-scipy py27-matplotlib mumps_seq - sudo port select --set python python27 - -3. Unpack Tinyarray, enter its directory, build and install:: - - python setup.py build - sudo python setup.py install - -4. Unpack Kwant, go to the Kwant directory, and edit ``build.conf`` to read:: - - [mumps] - include_dirs = /opt/local/include - library_dirs = /opt/local/lib - libraries = zmumps_seq mumps_common_seq pord_seq esmumps scotch scotcherr mpiseq gfortran - -5. Then, build and install Kwant. :: - - CC=gcc-mp-4.7 LDSHARED='gcc-mp-4.7 -shared -undefined dynamic_lookup' python setup.py build - sudo python setup.py install - -You might note that installing Kwant on Mac OS X is somewhat more involved than -installing on Linux. Part of the reason is that we need to mix Fortran and C -code in Kwant: While C code is usually compiled using Apple compilers, -Fortran code must be compiled with the Gnu Fortran compiler (there is -no Apple Fortran compiler). For this reason we force the Gnu compiler suite -with the environment variables ``CC`` and ``LDSHARED`` as shown above. - - -Mac OS X: homebrew -================== - -The following instructions are valid for Kwant 1.1 with Python 2.7. They need -to be updated for Kwant 1.2. (Help is welcome.) - -It is also possible to build Kwant using homebrew. The dependencies can be -installed as :: - - brew install gcc python - brew tap homebrew/science - brew tap homebrew/python - brew tap kwant-project/kwant - pip install pytest pytest-runner six - brew install numpy scipy matplotlib - -Note that during the installation you will be told which paths to add when you -want to compile/link against scotch/metis/mumps; you need to add these to the -build.conf file. Also, when linking against MUMPS, one needs also to link -against METIS (in addition to the libraries needed for MacPorts). - - Microsoft Windows ================= diff --git a/README.rst b/README.rst index 3b6ec5805bc39b0329191d13d62c1e0119143a01..2695f356e76e984b639ca0861f696be95899bd03 100644 --- a/README.rst +++ b/README.rst @@ -28,12 +28,12 @@ Kwant can calculate Other computations involving tight-binding Hamiltonians can be implemented easily. -See the `Kwant web site <http://kwant-project.org/>`_ for the latest stable +See the `Kwant website <https://kwant-project.org/>`_ for the latest stable version. The current development version is available via the `Kwant gitlab instance <https://gitlab.kwant-project.org/kwant/kwant>`_. Contributions are welcome. -A `mailing list <http://kwant-project.org/community>`_ exists for general +A `mailing list <https://kwant-project.org/community>`_ exists for general discussions related to Kwant. Please report bugs and other issues using the `issue tracker <https://gitlab.kwant-project.org/kwant/kwant/issues>`_. diff --git a/RELEASE.rst b/RELEASE.rst index f6ae00fd3e61cc894cbfa3eef05b358fbebf5aed..05c493c95c584a54ed47ee9d49c041ca0cc85fea 100644 --- a/RELEASE.rst +++ b/RELEASE.rst @@ -338,7 +338,7 @@ Push the tag to the official Kwant repository:: PyPI ---- -Install `twine <https://pypi.python.org/pypi/twine>`_ and run the following +Install `twine <https://pypi.org/project/twine>`_ and run the following (this requires a file ~/.pypirc with a valid username and password: ask Christoph Groth to add you as a maintainer on PyPI, if you are not already):: @@ -382,7 +382,7 @@ sure to update the codenames and the versions):: Version: 9.0 Architectures: i386 amd64 source Components: main - Description: Unofficial Debian package repository of http://kwant-project.org/ + Description: Unofficial Debian package repository of https://kwant-project.org/ SignWith: C3F147F5980F3535 Origin: Kwant project @@ -391,7 +391,7 @@ sure to update the codenames and the versions):: Version: 10.0 Architectures: i386 amd64 source Components: main - Description: Unofficial Debian package repository of http://kwant-project.org/ + Description: Unofficial Debian package repository of https://kwant-project.org/ SignWith: C3F147F5980F3535 If the config had to be updated execute:: diff --git a/conftest.py b/conftest.py index cdf296dbd4dea8b1ec7762a85ef260badb1cd4b0..254de81f281204b77642ad85dd16449cd3bb9bf9 100644 --- a/conftest.py +++ b/conftest.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. """Pytest plugin to ignore packages that have uninstalled dependencies. This ignores packages on test collection, which is required when the diff --git a/doc/source/conf.py b/doc/source/conf.py index 891c06bc9c6c44d8848f014fd56bfbed85f97d12..180b47153729b389849d0525a4d28c4a687bc643 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -38,7 +38,7 @@ sys.path.insert(0, os.path.abspath('../sphinxext')) extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.todo', 'sphinx.ext.mathjax', 'numpydoc', - 'kwantdoc', 'sphinx.ext.linkcode', 'jupyter_sphinx.execute', + 'kwantdoc', 'sphinx.ext.linkcode', 'jupyter_sphinx', 'sphinxcontrib.rsvgconverter'] # Add any paths that contain templates here, relative to this directory. @@ -198,7 +198,6 @@ htmlhelp_basename = 'kwantdoc' # -- Options for LaTeX output -------------------------------------------------- -# http://thread.gmane.org/gmane.comp.python.sphinx.devel/4220/focus=4238 latex_elements = {'papersize': 'a4paper', 'release': '', 'releasename': '', @@ -271,7 +270,7 @@ class BoundMethodDocumenter(autodoc.FunctionDocumenter): @classmethod def can_document_member(cls, member, membername, isattr, parent): # Return True iff `member` is a bound method. Taken from - # <http://stackoverflow.com/a/1260881>. + # <https://stackoverflow.com/a/1260881>. return (isinstance(member, types.MethodType) and member.__self__ is not None and not issubclass(member.__self__.__class__, type) and diff --git a/doc/source/figure/ab_ring_sketch.svg b/doc/source/figure/ab_ring_sketch.svg index 0b2e94288c0eb404ff434ee596e5cbaf7230a032..b9166755bc3c521e7fed508a2cad300e52f5e8de 100644 --- a/doc/source/figure/ab_ring_sketch.svg +++ b/doc/source/figure/ab_ring_sketch.svg @@ -3,7 +3,7 @@ <svg xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" + xmlns:cc="https://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" diff --git a/doc/source/figure/ab_ring_sketch2.svg b/doc/source/figure/ab_ring_sketch2.svg index 2bf7bf06d8887295d88941f5cad2bfcbb026c50b..83fc495cc169618953d2849a0781f026f422ebaf 100644 --- a/doc/source/figure/ab_ring_sketch2.svg +++ b/doc/source/figure/ab_ring_sketch2.svg @@ -3,7 +3,7 @@ <svg xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" + xmlns:cc="https://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" diff --git a/doc/source/figure/superconductor_transport_sketch.svg b/doc/source/figure/superconductor_transport_sketch.svg index 35f087cd2bc17e04258920aeae4173f36d135ae4..6ab066de6207b46f4018ffa708a8afd39b95675a 100644 --- a/doc/source/figure/superconductor_transport_sketch.svg +++ b/doc/source/figure/superconductor_transport_sketch.svg @@ -3,7 +3,7 @@ <svg xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" + xmlns:cc="https://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" diff --git a/doc/source/pre/whatsnew/0.2.rst b/doc/source/pre/whatsnew/0.2.rst index 2022810f63e0c00d3df442d91ff1e772f45ba0d8..bebe32cc4aac9c9d003c48391532ed8ce05d8fc9 100644 --- a/doc/source/pre/whatsnew/0.2.rst +++ b/doc/source/pre/whatsnew/0.2.rst @@ -21,7 +21,7 @@ New MUMPS-based solver ---------------------- The code for sparse matrix solvers has been reorganized and a new solver has been added next to `kwant.solvers.sparse`: `kwant.solvers.mumps`. The new -solver uses the `MUMPS <http://graal.ens-lyon.fr/MUMPS/>`_ software package and +solver uses the `MUMPS <https://graal.ens-lyon.fr/MUMPS/>`_ software package and is much (typically several times) faster than the UMFPACK-based old solver. In addition, MUMPS uses considerably less memory for a given system while at the same time it is able to take advantage of more than 2 GiB of RAM. diff --git a/doc/source/pre/whatsnew/1.5.rst b/doc/source/pre/whatsnew/1.5.rst index 17b7b3bc2163e567d8cf4dff7732188148d38b96..ae1da8313acf0c1b1ed80336043290ef8391bd9f 100644 --- a/doc/source/pre/whatsnew/1.5.rst +++ b/doc/source/pre/whatsnew/1.5.rst @@ -122,7 +122,7 @@ Improving or adding to Kwant's tutorial is now much simpler. Now the text and code for each tutorial is kept in the same file, making it easy to see where changes need to be made, and images generated by the code are inserted directly into the document thanks to the magic of -`jupyter-sphinx <https://github.com/jupyter-widgets/jupyter-sphinx/>`_. +`jupyter-sphinx <https://github.com/jupyter/jupyter-sphinx/>`_. It has never been easier to get started contributing to Kwant by helping us improve our documentation. diff --git a/doc/source/reference/kwant.rst b/doc/source/reference/kwant.rst index e429f81d8fc7863a12f21b12b4c08e88f4378185..19ac87e42dcd7b20de963990299ff23a3dde6aba 100644 --- a/doc/source/reference/kwant.rst +++ b/doc/source/reference/kwant.rst @@ -9,21 +9,8 @@ Otherwise, this package has only very limited functionality of its own. Generic functionality --------------------- -.. - TODO: Once we depend on Sphinx 1.8, the documentation of __version__ can be - put into the "docstring": https://github.com/sphinx-doc/sphinx/issues/344 - -The version of Kwant is available under the name ``__version__``. -This string respects `PEP 440 <https://www.python.org/dev/peps/pep-0440/>`_ -and has the following format - -- Released version: '1.3.0', '1.3.1', etc. -- Alpha version: '1.2.0a0', '1.2.0a1', etc. -- Beta version: '1.1.0b0', '1.1.0b1', etc. -- Development version (derived from ``git describe --first-parent --dirty``): - '1.3.2.dev27+gdecf6893', '1.1.1.dev10+gabcd012.dirty', etc. -- Development version with incomplete information: 'unknown', - 'unknown+g0123abc', etc. + +.. autodata:: kwant.__version__ .. autosummary:: :toctree: generated/ diff --git a/doc/source/reference/kwant.solvers.mumps.rst b/doc/source/reference/kwant.solvers.mumps.rst index 3ccc92df1b1b9749022182538361c24c1d744d6c..83d9b05121eb6fa4e0a685e0958e868e3badade1 100644 --- a/doc/source/reference/kwant.solvers.mumps.rst +++ b/doc/source/reference/kwant.solvers.mumps.rst @@ -3,7 +3,7 @@ .. module:: kwant.solvers.mumps -This solver uses `MUMPS <http://graal.ens-lyon.fr/MUMPS/>`_. (Only the +This solver uses `MUMPS <https://graal.ens-lyon.fr/MUMPS/>`_. (Only the sequential, single core version of MUMPS is used.) MUMPS is a very efficient direct sparse solver that can take advantage of memory beyond 3GiB for the solution of large problems. Furthermore, it offers a choice of several diff --git a/doc/source/tutorial/discretize.rst b/doc/source/tutorial/discretize.rst index dabb96f7572c616e46c56b565e72a6f8c39ab248..6a1c0d2295ca4803cbd14781da648982a7496e74 100644 --- a/doc/source/tutorial/discretize.rst +++ b/doc/source/tutorial/discretize.rst @@ -150,7 +150,7 @@ Printing the Builder produced by ``discretize`` shows the source code of its ons When working interactively in `Jupyter notebooks <https://jupyter.org/>`_ it can be useful to use this to see a symbolic representation of the discretized Hamiltonian. This works best when combined with ``sympy`` - `Pretty Printing <http://docs.sympy.org/latest/tutorial/printing.html#setting-up-pretty-printing>`_. + `Pretty Printing <https://docs.sympy.org/latest/tutorial/printing.html#setting-up-pretty-printing>`_. - The symbolic result of discretization obtained with ``discretize_symbolic`` can be converted into a diff --git a/doc/source/tutorial/first_steps.rst b/doc/source/tutorial/first_steps.rst index b0760b6432e4d22003aa8bdfb9c18e5352999972..efff2f9cf43ce8d3f8d8eb47cc12e5328864f07f 100644 --- a/doc/source/tutorial/first_steps.rst +++ b/doc/source/tutorial/first_steps.rst @@ -750,7 +750,7 @@ Finally, we use the following standard Python construct [#]_ to execute .. jupyter-execute:: # Call the main function if the script gets executed (as opposed to imported). - # See <http://docs.python.org/library/__main__.html>. + # See <https://docs.python.org/library/__main__.html>. if __name__ == '__main__': main() diff --git a/doc/source/tutorial/spectrum.rst b/doc/source/tutorial/spectrum.rst index 2b6d86a0a92db6d9b709697b00bea6097e865b22..bfaaeabc51db29ede03195a535390733c92409ed 100644 --- a/doc/source/tutorial/spectrum.rst +++ b/doc/source/tutorial/spectrum.rst @@ -105,7 +105,7 @@ This gives the result: :hide-code: # Call the main function if the script gets executed (as opposed to imported). - # See <http://docs.python.org/library/__main__.html>. + # See <https://docs.python.org/library/__main__.html>. if __name__ == '__main__': main() diff --git a/doc/source/tutorial/spin_potential_shape.rst b/doc/source/tutorial/spin_potential_shape.rst index 23d90bf8bbf384af9d3644a34867c635c5eaf115..6a2a7f0700a11d5b14a59b982fdb4399f17e22ca 100644 --- a/doc/source/tutorial/spin_potential_shape.rst +++ b/doc/source/tutorial/spin_potential_shape.rst @@ -36,11 +36,11 @@ Here :math:`\sigma_{x,y,z}` denote the Pauli matrices. It turns out that this well studied Rashba-Hamiltonian has some peculiar properties in (ballistic) nanowires: It was first predicted theoretically in `Phys. Rev. Lett. 90, 256601 (2003) -<http://prl.aps.org/abstract/PRL/v90/i25/e256601>`_ that such a system should +<https://doi.org/10.1103/PhysRevLett.90.256601>`_ that such a system should exhibit non-monotonic conductance steps due to a spin-orbit gap. Only very recently, this non-monotonic behavior has been supposedly observed in experiment: `Nature Physics 6, 336 (2010) -<http://www.nature.com/nphys/journal/v6/n5/abs/nphys1626.html>`_. Here +<https://doi.org/10.1038/nphys1626>`_. Here we will show that a very simple extension of our previous examples will exactly show this behavior (Note though that no care was taken to choose realistic parameters). @@ -48,7 +48,7 @@ realistic parameters). The tight-binding model corresponding to the Rashba-Hamiltonian naturally exhibits a 2x2-matrix structure of onsite energies and hoppings. In order to use matrices in our program, we import the Tinyarray package. (`NumPy -<http://www.numpy.org/>`_ would work as well, but Tinyarray is much faster +<https://numpy.org/>`_ would work as well, but Tinyarray is much faster for small arrays.) .. jupyter-execute:: @@ -61,9 +61,9 @@ for small arrays.) # ------------------ # Gaps in quantum wires with spin-orbit coupling and Zeeman splititng, # as theoretically predicted in - # http://prl.aps.org/abstract/PRL/v90/i25/e256601 + # https://doi.org/10.1103/PhysRevLett.90.256601 # and (supposedly) experimentally oberved in - # http://www.nature.com/nphys/journal/v6/n5/abs/nphys1626.html + # https://doi.org/10.1038/nphys1626 # # Kwant features highlighted # -------------------------- diff --git a/doc/sphinxext/kwantdoc.py b/doc/sphinxext/kwantdoc.py index f7b1bed3ac5e4dedd0b905a2515c4e51b0822298..3ac5a1800b068bfb6f064ce2fc8e5bd0ba869887 100644 --- a/doc/sphinxext/kwantdoc.py +++ b/doc/sphinxext/kwantdoc.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. """Simple sphinx extension that allows for a section that can be hidden/shown on click using javascript""" diff --git a/doc/templates/layout.html b/doc/templates/layout.html index d197ece6481033e188868f2626e3e4ea468bb686..b6c8107072f8a37e6f7cbf8d7e0bd306431a258b 100644 --- a/doc/templates/layout.html +++ b/doc/templates/layout.html @@ -15,7 +15,7 @@ {%- block doctype -%} <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> {%- endblock %} {%- set reldelim1 = reldelim1 is not defined and ' »' or reldelim1 %} {%- set reldelim2 = reldelim2 is not defined and ' |' or reldelim2 %} @@ -41,7 +41,7 @@ {%- if not loop.first %}{{ reldelim2 }}{% endif %}</li> {%- endfor %} {%- block rootrellink %} - <li><a href="http://kwant-project.org/"> + <li><a href="https://kwant-project.org/"> <img src="{{ pathto('_static/kwant_logo.png', 1) }}" style="vertical-align: middle; margin-top: -4px" alt="Kwant logo"/></a> {{ reldelim1 }}</li> @@ -117,7 +117,7 @@ {%- endfor %} {%- endmacro %} -<html xmlns="http://www.w3.org/1999/xhtml" lang="en"> +<html xmlns="https://www.w3.org/1999/xhtml" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset={{ encoding }}" /> {{ metatags }} @@ -205,7 +205,7 @@ {% trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %} {%- endif %} {%- if show_sphinx %} - {% trans sphinx_version=sphinx_version|e %}Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> {{ sphinx_version }}.{% endtrans %} + {% trans sphinx_version=sphinx_version|e %}Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> {{ sphinx_version }}.{% endtrans %} {%- endif %} </div> {%- endblock %} @@ -226,7 +226,7 @@ g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s); })(); </script> - <noscript><img src="http://piwik.kwant-project.org/piwik.php?idsite=1&rec=1" style="border:0" alt="" /></noscript> + <noscript><img src="https://piwik.kwant-project.org/piwik.php?idsite=1&rec=1" style="border:0" alt="" /></noscript> <!-- End Piwik Code: Analytics are used by us to improve the site, and not sent to anyone. --> {%- endif %} </body> diff --git a/docker/Dockerfile.debian b/docker/Dockerfile.debian index ad235f066518144ebf33c28dd567c46f892acc3b..b9ce80209cae69b08e228b98103f5ae96e8437d8 100644 --- a/docker/Dockerfile.debian +++ b/docker/Dockerfile.debian @@ -1,4 +1,4 @@ -FROM debian:latest +FROM debian:buster ENV LANG C.UTF-8 ENV LC_ALL C.UTF-8 @@ -7,7 +7,7 @@ ENV DEBIAN_FRONTEND noninteractive RUN apt-get update && apt-get install -y --no-install-recommends \ gnupg dirmngr apt-transport-https ca-certificates curl software-properties-common -RUN echo "deb http://downloads.kwant-project.org/debian/ stable main" >> /etc/apt/sources.list && \ +RUN echo "deb https://downloads.kwant-project.org/debian/ stable main" >> /etc/apt/sources.list && \ apt-key adv --no-tty --keyserver pool.sks-keyservers.net --recv-key C3F147F5980F3535 && \ apt-get update && apt-get install -y --no-install-recommends \ # all the hard non-Python dependencies @@ -24,7 +24,7 @@ RUN echo "deb http://downloads.kwant-project.org/debian/ stable main" >> /etc/ap ### install optional dependencies not available from the Debian repositories RUN pip3 install \ - qsymm==1.2.6 + qsymm==1.3.0 ### install build and testing dependencies RUN pip3 install \ diff --git a/docker/Dockerfile.ubuntu b/docker/Dockerfile.ubuntu index 39789a7724ac9570d39a5ba94462eac635a5b4d8..4e6899fd9bd6fa59286e5688efa2cf8f72d57f09 100644 --- a/docker/Dockerfile.ubuntu +++ b/docker/Dockerfile.ubuntu @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:20.04 ENV LANG C.UTF-8 ENV LC_ALL C.UTF-8 @@ -22,7 +22,7 @@ RUN apt-add-repository -s ppa:kwant-project/ppa && \ ### install optional dependencies not available from the Debian repositories RUN pip3 install \ - qsymm==1.2.6 + qsymm==1.3.0 ### install build and testing dependencies RUN pip3 install \ diff --git a/docker/kwant-latest.yml b/docker/kwant-latest.yml index aa346581d61f2866d531129c1dfc3a0742b94e19..6285664b835ad2fa1c6ba44c69af68ca3ffff3a3 100644 --- a/docker/kwant-latest.yml +++ b/docker/kwant-latest.yml @@ -2,14 +2,14 @@ name: kwant-latest channels: - conda-forge dependencies: - - python=3.6 + - python=3.9 - numpy - scipy - tinyarray - sympy - - matplotlib - - qsymm + - matplotlib-base - plotly + - qsymm # Linear algebra libraraies - mumps-seq - mumps-include @@ -30,6 +30,3 @@ dependencies: - numpydoc - requests - jupyter_sphinx - - pip - - pip: - - sphinxcontrib-svg2pdfconverter diff --git a/docker/kwant-stable-no-extras.yml b/docker/kwant-stable-no-extras.yml index fd208eb56def218316bd97cc6e8813c6626fa03e..4dedb756135fd1cea56979b0225314144a56c8fb 100644 --- a/docker/kwant-stable-no-extras.yml +++ b/docker/kwant-stable-no-extras.yml @@ -2,10 +2,10 @@ name: kwant-stable-no-extras channels: - conda-forge dependencies: - - python=3.6 - - numpy=1.13.1 - - scipy=0.19.1 - - tinyarray=1.2.0 + - python=3.7 + - numpy=1.16.2 + - scipy=1.1.0 + - tinyarray=1.2 # Linear algebra libraraies - blas #=1.1 openblas - openblas #=0.2.20 diff --git a/docker/kwant-stable.yml b/docker/kwant-stable.yml index 00203b4d0b563ec0647aaa0f5bb6d38f28567e6a..f9cad32b05b00bdce7df51e22787fa3f8c8e6c1c 100644 --- a/docker/kwant-stable.yml +++ b/docker/kwant-stable.yml @@ -2,14 +2,14 @@ name: kwant-stable channels: - conda-forge dependencies: - - python=3.6 - - numpy=1.13.3 - - scipy=0.19.1 - - tinyarray=1.2.0 - - sympy=1.1.1 - - matplotlib=2.1.1 - - qsymm=1.2.6 - - plotly=2.2.2 + - python=3.7 + - numpy=1.16.2 + - scipy=1.1.0 + - tinyarray=1.2 + - sympy=1.3.0 + - matplotlib-base=3.0.2 + - plotly=3.6.1 + - qsymm=1.3.0 # Linear algebra libraraies - mumps-seq - mumps-include diff --git a/kwant/__init__.py b/kwant/__init__.py index d8c88ebf2b9c70ff3da0cfdf6d1e2e4c9e7029dc..399d8a09094f3ab0062ccd2d192d0663c8c1459b 100644 --- a/kwant/__init__.py +++ b/kwant/__init__.py @@ -2,15 +2,29 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. __all__ = [] from . import version version.ensure_python() __version__ = version.version +"""The version of Kwant is available under the name ``__version__``. + +This string respects `PEP 440 <https://www.python.org/dev/peps/pep-0440/>`_ +and has the following format + +- Released version: '1.3.0', '1.3.1', etc. +- Alpha version: '1.2.0a0', '1.2.0a1', etc. +- Beta version: '1.1.0b0', '1.1.0b1', etc. +- Development version (derived from ``git describe --first-parent --dirty``): + '1.3.2.dev27+gdecf6893', '1.1.1.dev10+gabcd012.dirty', etc. +- Development version with incomplete information: 'unknown', + 'unknown+g0123abc', etc. +""" + import numpy # Needed by C. Gohlke's Windows package. import warnings diff --git a/kwant/_colormaps.py b/kwant/_colormaps.py index d92e4ebf2682d8fa5ae4110ff68ce531b19ffe6a..a966b7182f7d5e7b825699e2d384a9b76a5d22b5 100644 --- a/kwant/_colormaps.py +++ b/kwant/_colormaps.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import numpy as np diff --git a/kwant/_common.py b/kwant/_common.py index 22acf3674cd953caa038c1c6601ddb165c62cf12..7673e05c042209ce2d06ef51c9a3233f02b23cd5 100644 --- a/kwant/_common.py +++ b/kwant/_common.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import sys import numpy as np diff --git a/kwant/_plotter.py b/kwant/_plotter.py index ba943851a9829c474d9b8808f9c627c038bba281..bdf71d830566eb79fc4472546a9bf819484f96f9 100644 --- a/kwant/_plotter.py +++ b/kwant/_plotter.py @@ -3,9 +3,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. # This module is imported by plotter.py. It contains all the expensive imports # that we want to remove from plotter.py @@ -269,11 +269,11 @@ if mpl_available: phi = np.linspace(0, pi, 21) xyz = np.c_[np.cos(phi), np.sin(phi), 0 * phi].T.reshape(-1, 1, 21) - # TODO: use np.block once we depend on numpy >= 1.13. - unit_sphere = np.vstack([ - np.hstack([xyz[0], xyz[2]]), - np.hstack([xyz[1], xyz[0]]), - np.hstack([xyz[2], xyz[1]]), + + unit_sphere = np.block([ + [xyz[0], xyz[2]], + [xyz[1], xyz[0]], + [xyz[2], xyz[1]], ]) def projected_length(ax, length): diff --git a/kwant/_system.pyx b/kwant/_system.pyx index ac7875b29dd77397102e5dde9b7967cf700312de..57731cc010b1de3c735ae13a87b319afe9336d7b 100644 --- a/kwant/_system.pyx +++ b/kwant/_system.pyx @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. cimport cython import tinyarray as ta @@ -90,16 +90,8 @@ def make_sparse(ham, args, params, CGraph gr, diag, rows_cols[1, k] = j + from_off[n_fs] k += 1 - # Hack around a bug in Scipy + Python 3 + memoryviews - # see https://github.com/scipy/scipy/issues/5123 for details. - # TODO: remove this once we depend on scipy >= 0.18. - np_data = np.asarray(data) - np_rows_cols = np.asarray(rows_cols) - np_to_off = np.asarray(to_off) - np_from_off = np.asarray(from_off) - - return sp.coo_matrix((np_data[:k], np_rows_cols[:, :k]), - shape=(np_to_off[-1], np_from_off[-1])) + return sp.coo_matrix((data[:k], rows_cols[:, :k]), + shape=(to_off[-1], from_off[-1])) @cython.boundscheck(False) @@ -161,16 +153,8 @@ def make_sparse_full(ham, args, params, CGraph gr, diag, rows_cols[0, k + 1] = rows_cols[1, k] = j + from_off[fs] k += 2 - # hack around a bug in Scipy + Python 3 + memoryviews - # see https://github.com/scipy/scipy/issues/5123 for details - # TODO: remove this once we depend on scipy >= 0.18. - np_data = np.asarray(data) - np_rows_cols = np.asarray(rows_cols) - np_to_off = np.asarray(to_off) - np_from_off = np.asarray(from_off) - - return sp.coo_matrix((np_data[:k], np_rows_cols[:, :k]), - shape=(np_to_off[-1], np_from_off[-1])) + return sp.coo_matrix((data[:k], rows_cols[:, :k]), + shape=(to_off[-1], from_off[-1])) @cython.boundscheck(False) diff --git a/kwant/builder.py b/kwant/builder.py index e122aa772668fe4cdf49494de9601ee68bf00a18..3ffdf09940f359bcdcccad1adf210a63761a2697 100644 --- a/kwant/builder.py +++ b/kwant/builder.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import abc import warnings diff --git a/kwant/continuum/__init__.py b/kwant/continuum/__init__.py index bf6da67bdf8861443851148a4f3c25bf99546429..3da986313a5c0217cfdd3a7ff9b6cf24851285ec 100644 --- a/kwant/continuum/__init__.py +++ b/kwant/continuum/__init__.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. try: from .discretizer import discretize, discretize_symbolic, build_discretized diff --git a/kwant/continuum/_common.py b/kwant/continuum/_common.py index a8ffa66a66a67849af74059e34874693e0009d1c..c51ebc255ceda9f9fb02bb545ffc923cab156966 100644 --- a/kwant/continuum/_common.py +++ b/kwant/continuum/_common.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import keyword from collections import defaultdict @@ -39,7 +39,7 @@ extra_ns.update({'kron': sympy.physics.quantum.TensorProduct, extra_ns.update({'sigma_{}'.format(c): p for c, p in zip('0xyz', pauli)}) -# workaroud for https://github.com/sympy/sympy/issues/12060 +# TODO: remove this once https://github.com/sympy/sympy/issues/12060 is fixed del extra_ns['I'] del extra_ns['pi'] diff --git a/kwant/continuum/discretizer.py b/kwant/continuum/discretizer.py index ce9e6fe2f65bffeed3da826b02f1618e474a1757..febe3312e4b4fc2063b77c78746de7fe07168d8a 100644 --- a/kwant/continuum/discretizer.py +++ b/kwant/continuum/discretizer.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. from keyword import iskeyword from collections import defaultdict @@ -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: @@ -328,7 +329,7 @@ def build_discretized(tb_hamiltonian, coords, *, grid=None, locals=None, is_diagonal = lambda m: np.allclose(m, np.diag(np.diagonal(m))) if not (lat.prim_vecs.shape[0] == grid_dim and is_diagonal(lat.prim_vecs)): - raise ValueError('"grid" is expected to by an orthogonal lattice ' + raise ValueError('"grid" has to be an orthogonal lattice ' 'of dimension matching number of "coords".') if (lat.norbs is not None) and (lat.norbs != norbs): @@ -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)) diff --git a/kwant/continuum/landau_levels.py b/kwant/continuum/landau_levels.py index b2b8fc802dfa03343c4d7d314d84203c7c581302..f267f624e894d8c14dd09e9c1efe1b2c8e934910 100644 --- a/kwant/continuum/landau_levels.py +++ b/kwant/continuum/landau_levels.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. from keyword import iskeyword import functools diff --git a/kwant/continuum/tests/test_common.py b/kwant/continuum/tests/test_common.py index 74d87746e242637a24a9fe1690962047e99081e5..f9c99a68075b64e93b60757c4a97aaba45b19dd5 100644 --- a/kwant/continuum/tests/test_common.py +++ b/kwant/continuum/tests/test_common.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import pytest import tinyarray as ta diff --git a/kwant/continuum/tests/test_discretizer.py b/kwant/continuum/tests/test_discretizer.py index 6307b1f7c9889cccef6e3b764b35fe782549d993..703b6790738a87721d8fef8b359b40fd1d81e041 100644 --- a/kwant/continuum/tests/test_discretizer.py +++ b/kwant/continuum/tests/test_discretizer.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import inspect import warnings diff --git a/kwant/continuum/tests/test_landau_levels.py b/kwant/continuum/tests/test_landau_levels.py index 5878724fbf997949d791dc33ae49a90e55b24a39..e31fdaf4bcf6360218b42996a16c98064d53f595 100644 --- a/kwant/continuum/tests/test_landau_levels.py +++ b/kwant/continuum/tests/test_landau_levels.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. from math import sqrt diff --git a/kwant/digest.py b/kwant/digest.py index 0181032ffdedf719f901ce4692828b5f21ea00bf..903b243089ced71f49d0f7576570f64d680a00e5 100644 --- a/kwant/digest.py +++ b/kwant/digest.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. """Random-access random numbers diff --git a/kwant/graph/__init__.py b/kwant/graph/__init__.py index 2ea8e96396789bb7627d199adce479806a6e416f..021b086a921b2f986385381289110a77f09fe97d 100644 --- a/kwant/graph/__init__.py +++ b/kwant/graph/__init__.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. """Functionality for graphs""" diff --git a/kwant/graph/c_scotch.pxd b/kwant/graph/c_scotch.pxd index 4920d31ad401af7405ef81a119fcd1286c871137..23d2436ed063c5da2719c0d1c85c408463a63271 100644 --- a/kwant/graph/c_scotch.pxd +++ b/kwant/graph/c_scotch.pxd @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. from libc.stdio cimport FILE diff --git a/kwant/graph/core.pxd b/kwant/graph/core.pxd index 52c851cc3ae944513db14bd4ff98b9bd2984fb33..df342e1f41f5a0e5f6cc27009a6fa61738c4c05d 100644 --- a/kwant/graph/core.pxd +++ b/kwant/graph/core.pxd @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. cimport numpy as np from cpython cimport array diff --git a/kwant/graph/core.pyx b/kwant/graph/core.pyx index a5175bee100b26328fc4fa8fd516799c5f0fa14b..e99acb1a6aa20baedad7a2b10655d1635cb82e41 100644 --- a/kwant/graph/core.pyx +++ b/kwant/graph/core.pyx @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. """Directed graphs optimized for storage and runtime efficiency.""" @@ -649,7 +649,7 @@ cdef class CGraph: Notes ----- That resulting file can be visualized with dot(1) or neato(1) form the - `graphviz <http://graphviz.org/>`_ package. + `graphviz <https://graphviz.org/>`_ package. """ cdef gint tail file.write("digraph g {\n") diff --git a/kwant/graph/defs.h b/kwant/graph/defs.h index a328fbc7f79b64a75215bfaffdbc7e9e0fac3868..25867287fd14e4b08870396a56c21f824ad4c961 100644 --- a/kwant/graph/defs.h +++ b/kwant/graph/defs.h @@ -2,9 +2,9 @@ // // This file is part of Kwant. It is subject to the license terms in the file // LICENSE.rst found in the top-level directory of this distribution and at -// http://kwant-project.org/license. A list of Kwant authors can be found in +// https://kwant-project.org/license. A list of Kwant authors can be found in // the file AUTHORS.rst at the top-level directory of this distribution and at -// http://kwant-project.org/authors. +// https://kwant-project.org/authors. #ifndef DEFS_H #define DEFS_H diff --git a/kwant/graph/defs.pxd b/kwant/graph/defs.pxd index 83aed41d2946d719b162ec33a1dd1b7024c8f758..5ff8c8c160184048064d16c7ef5f3ed18a6c2e4e 100644 --- a/kwant/graph/defs.pxd +++ b/kwant/graph/defs.pxd @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. cdef extern from "defs.h": ctypedef signed int gint diff --git a/kwant/graph/defs.py b/kwant/graph/defs.py index f9c44423686adb45510a0ea3b080c71ce6075a2c..fead2f9cb25f45bf9a6fe84d9b58db177f09118f 100644 --- a/kwant/graph/defs.py +++ b/kwant/graph/defs.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. __all__ = ['gint_dtype'] import numpy as np diff --git a/kwant/graph/scotch.pyx b/kwant/graph/scotch.pyx index b2ad0559143bb4695ddc87ecc7a7fc68af18368d..3be68504e19a5dd9da236d50f4f39e109309c186 100644 --- a/kwant/graph/scotch.pyx +++ b/kwant/graph/scotch.pyx @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. """Wrapper for the graph library SCOTCH""" diff --git a/kwant/graph/tests/test_core.py b/kwant/graph/tests/test_core.py index b52e6a104fef72b2d5d2e2af9fa89eaa5ac88506..64d2e833290c491be2077803b8cad67231e90413 100644 --- a/kwant/graph/tests/test_core.py +++ b/kwant/graph/tests/test_core.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import pickle from io import StringIO diff --git a/kwant/graph/tests/test_scotch.py b/kwant/graph/tests/test_scotch.py index 3f40364b045a5cc09d74ad937467e53a6ae58a38..5fde47b09bdd6850ec8e296b8323335031a9ed53 100644 --- a/kwant/graph/tests/test_scotch.py +++ b/kwant/graph/tests/test_scotch.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. from kwant.graph import Graph # from kwant.graph.scotch import bisect, reset diff --git a/kwant/kpm.py b/kwant/kpm.py index 44cf9758f4ddfff3f098be074ca929689c562f11..0961738f2b2879f91ae649477f1bc842b9b42717 100644 --- a/kwant/kpm.py +++ b/kwant/kpm.py @@ -3,9 +3,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import math from operator import add from collections.abc import Iterable @@ -326,8 +326,7 @@ class SpectralDensity: if energy_resolution: if energy_resolution <= 0: - raise ValueError("'energy_resolution' must be positive" - .format(energy_resolution)) + raise ValueError("'energy_resolution' must be positive") # factor of 1.6 comes from the fact that we use the # Jackson kernel when calculating the FFT, which has # maximal slope π/2. Rounding to 1.6 ensures that the @@ -1099,7 +1098,7 @@ def jackson_kernel(moments): <https://arxiv.org/abs/cond-mat/0504627>`_. """ - n_moments, *extra_shape = moments.shape + n_moments = len(moments) m = np.arange(n_moments) kernel_array = ((n_moments - m + 1) * np.cos(np.pi * m/(n_moments + 1)) + @@ -1121,7 +1120,7 @@ def lorentz_kernel(moments, l=4): The additional parameter ``l`` controls the decay of the kernel. """ - n_moments, *extra_shape = moments.shape + n_moments = len(moments) m = np.arange(n_moments) kernel_array = np.sinh(l * (1 - m / n_moments)) / np.sinh(l) diff --git a/kwant/lattice.py b/kwant/lattice.py index 16caa2c50a97d28f94d5459c462f95b018de605c..e58384cff6bb4529de9a9368eb8726506708703e 100644 --- a/kwant/lattice.py +++ b/kwant/lattice.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. __all__ = ['TranslationalSymmetry', 'general', 'Polyatomic', 'Monatomic', 'chain', 'square', 'cubic', 'triangular', 'honeycomb', 'kagome'] @@ -541,10 +541,7 @@ class TranslationalSymmetry(system.Symmetry): def __init__(self, *periods): self.periods = ta.array(periods) if self.periods.ndim != 2: - # TODO: remove the second part of the following message once - # everybody got used to it. - msg = ("TranslationalSymmetry takes 1d sequences as parameters.\n" - "See What's new in Kwant 0.2 in the documentation.") + msg = ("TranslationalSymmetry takes 1d sequences as parameters.") raise ValueError(msg) if np.linalg.matrix_rank(periods) < len(periods): raise ValueError("Translational symmetry periods must be " diff --git a/kwant/linalg/__init__.py b/kwant/linalg/__init__.py index 2456b350965ca6281e9418c1638a88e8445a005f..627ee8d1b8dbe85def3b5bdd6fbcc207fff14a11 100644 --- a/kwant/linalg/__init__.py +++ b/kwant/linalg/__init__.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. __all__ = ['lapack'] from . import lapack diff --git a/kwant/linalg/_mumps.pyx b/kwant/linalg/_mumps.pyx index 68b59aa053e04373ae2c706c609ede7e740eff8a..4b9ab2ab74f3845c1e664d1697a44b569d596980 100644 --- a/kwant/linalg/_mumps.pyx +++ b/kwant/linalg/_mumps.pyx @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. cimport numpy as np import numpy as np diff --git a/kwant/linalg/cmumps.pxd b/kwant/linalg/cmumps.pxd index 1d60a3eeeb1fd7c76b1878f5cd09a097071aa11b..55064e1e88636b7c9820656ceae027971eee1a75 100644 --- a/kwant/linalg/cmumps.pxd +++ b/kwant/linalg/cmumps.pxd @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. cdef extern from "mumps_c_types.h": ctypedef int MUMPS_INT diff --git a/kwant/linalg/cmumps.py b/kwant/linalg/cmumps.py index 33babe0071f3b09fe4959815d9598f4efa69803f..074590118a1453c2f86f50a61ad5df61290c60f5 100644 --- a/kwant/linalg/cmumps.py +++ b/kwant/linalg/cmumps.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import numpy as np diff --git a/kwant/linalg/decomp_ev.py b/kwant/linalg/decomp_ev.py index 8e7b95d68b0eae6701f3fe38a624653a5aa67f68..a90975f8c6c9d3f9d07cf4cd58aa693b61e2a509 100644 --- a/kwant/linalg/decomp_ev.py +++ b/kwant/linalg/decomp_ev.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. __all__ = ['gen_eig'] diff --git a/kwant/linalg/decomp_lu.py b/kwant/linalg/decomp_lu.py index 639b547bfdb082eb0e45df3180bb31ceeb67937f..b79c312fbe5e2c690fbf58f421be83048f79ab51 100644 --- a/kwant/linalg/decomp_lu.py +++ b/kwant/linalg/decomp_lu.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. __all__ = ['lu_factor', 'lu_solve', 'rcond_from_lu'] diff --git a/kwant/linalg/decomp_schur.py b/kwant/linalg/decomp_schur.py index d65432132efd3084e26a25643dbc36b82f48b39c..5faedc1cbdce7abeba2cdc5d9f9f16b89882b9a9 100644 --- a/kwant/linalg/decomp_schur.py +++ b/kwant/linalg/decomp_schur.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. __all__ = ['schur', 'convert_r2c_schur', 'order_schur', 'evecs_from_schur', 'gen_schur', 'order_gen_schur', 'convert_r2c_gen_schur', diff --git a/kwant/linalg/fortran_helpers.py b/kwant/linalg/fortran_helpers.py index 39ec639e606264e8dc14d85e06284c4aa51b86e6..ce44cca0a20142f3b7c3888df15912b5da3899be 100644 --- a/kwant/linalg/fortran_helpers.py +++ b/kwant/linalg/fortran_helpers.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import numpy as np diff --git a/kwant/linalg/lapack.pyx b/kwant/linalg/lapack.pyx index e173bc0ce28e860f93ee58d36c725d020fd95c72..81d6bb46703e81d91c094248c7f3941296e6a5a5 100644 --- a/kwant/linalg/lapack.pyx +++ b/kwant/linalg/lapack.pyx @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. """Low-level access to LAPACK functions. """ diff --git a/kwant/linalg/lll.py b/kwant/linalg/lll.py index b4cca6141460c22009425beb3116f8c8fcdd85f5..6a54b58eae460cfa04d4029ae607718d3b1b9576 100644 --- a/kwant/linalg/lll.py +++ b/kwant/linalg/lll.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. __all__ = ['lll', 'cvp', 'voronoi'] @@ -39,7 +39,7 @@ def lll(basis, c=1.34): Calculate a reduced lattice basis using LLL algorithm. Reduce a basis of a lattice to an almost orthonormal form. For details see - e.g. http://en.wikipedia.org/wiki/LLL-algorithm. + e.g. https://en.wikipedia.org/wiki/Lenstra–Lenstra–Lovász_lattice_basis_reduction_algorithm. Parameters ---------- @@ -101,8 +101,7 @@ def lll(basis, c=1.34): if abs(u[i+1, i]) > 0.5: ll_reduce(i+1) i = max(i-1, 0) - # TODO: change to rcond=None once we depend on numpy >= 1.14. - coefs = np.linalg.lstsq(vecs_orig.T, vecs.T, rcond=-1)[0] + coefs = np.linalg.lstsq(vecs_orig.T, vecs.T, rcond=None)[0] if not np.allclose(np.round(coefs), coefs, atol=1e-6): raise RuntimeError('LLL algorithm instability.') if not is_c_reduced(vecs, c): diff --git a/kwant/linalg/mumps.py b/kwant/linalg/mumps.py index c3bec6fddf6b45cf951351abe9b9dc7dd67db28e..754826fbd6934baf8aad36db5decbc9e706b5bec 100644 --- a/kwant/linalg/mumps.py +++ b/kwant/linalg/mumps.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. """Interface to the MUMPS sparse solver library""" diff --git a/kwant/linalg/tests/_test_utils.py b/kwant/linalg/tests/_test_utils.py index 5ada76379e8b6a42dc5f7ace060213384de5ed90..a354d7fbda83338c9f734627d31ea76179c6ae50 100644 --- a/kwant/linalg/tests/_test_utils.py +++ b/kwant/linalg/tests/_test_utils.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import numpy as np diff --git a/kwant/linalg/tests/test_linalg.py b/kwant/linalg/tests/test_linalg.py index c092f010210596fdbb95274e07ee2145fb3eb9c8..f568261de587458ff916c911f2064a41f0f519b2 100644 --- a/kwant/linalg/tests/test_linalg.py +++ b/kwant/linalg/tests/test_linalg.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. from kwant.linalg import ( lu_factor, lu_solve, rcond_from_lu, gen_eig, schur, diff --git a/kwant/linalg/tests/test_lll.py b/kwant/linalg/tests/test_lll.py index 0a4b2b350246144f733f32a640333772b85fa94d..697f45a59e5c07c6728a29e07c18627cae250cd0 100644 --- a/kwant/linalg/tests/test_lll.py +++ b/kwant/linalg/tests/test_lll.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import numpy as np diff --git a/kwant/linalg/tests/test_mumps.py b/kwant/linalg/tests/test_mumps.py index c2d3b56f157a5ee4bd76f5d800e0f4c012f8b100..fda96bc8ad1252b9c731f2a056689d759edc13d8 100644 --- a/kwant/linalg/tests/test_mumps.py +++ b/kwant/linalg/tests/test_mumps.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. try: from kwant.linalg.mumps import MUMPSContext, schur_complement diff --git a/kwant/operator.pyx b/kwant/operator.pyx index 69e5ca0831175fb3a93610f6d7ce3553004405ac..6f2ee0bbcb8c0d9617c5de94f809c9fa6edfdccb 100644 --- a/kwant/operator.pyx +++ b/kwant/operator.pyx @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. """Tools for working with operators for acting on wavefunctions.""" __all__ = ['Density', 'Current', 'Source'] diff --git a/kwant/physics/__init__.py b/kwant/physics/__init__.py index 199d68d230293f932f2ce82eeddfe60f69f90536..bfc019a79e34382380c7bf6f21092afa7403baef 100644 --- a/kwant/physics/__init__.py +++ b/kwant/physics/__init__.py @@ -1,9 +1,9 @@ # Copyright 2011-2018 Kwant authors. # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. """Physics-related algorithms""" diff --git a/kwant/physics/dispersion.py b/kwant/physics/dispersion.py index cfdbe1f5cc4c161be081459e0b3b43c2cea7a4f0..0a16e50ce5a807cc4ca50a3b59bea73d7dd70678 100644 --- a/kwant/physics/dispersion.py +++ b/kwant/physics/dispersion.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. """Band structure calculation for the leads""" diff --git a/kwant/physics/gauge.py b/kwant/physics/gauge.py index cfb927a6fb1e3397ad4d739160f0e4031b736060..672604b1c2cc42d94e1c52f08f330ede9c63bfe3 100644 --- a/kwant/physics/gauge.py +++ b/kwant/physics/gauge.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. """Functions for fixing the magnetic gauge automatically in a Kwant system. diff --git a/kwant/physics/leads.py b/kwant/physics/leads.py index b3c9132da448a26b0da5bf769182660b7e1f25ed..d27057d623d72b4c38cf0ff6ddb6500537871b09 100644 --- a/kwant/physics/leads.py +++ b/kwant/physics/leads.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. from math import sin, cos, sqrt, pi, copysign @@ -24,36 +24,6 @@ dot = np.dot __all__ = ['selfenergy', 'modes', 'PropagatingModes', 'StabilizedModes'] -# TODO: Use scipy block_diag once we depend on scipy>=0.19 -try: - # Throws ValueError, but if fixed ensure that works as intended - bdiag_broken = block_diag(np.zeros((1,1)), np.zeros((2,0))).shape != (3, 1) -except ValueError: # skip coverage - bdiag_broken = True -if bdiag_broken: # skip coverage - def block_diag(*matrices): - """Construct a block diagonal matrix out of the input matrices. - - Like scipy.linalg.block_diag, but works for zero size matrices.""" - rows, cols = np.sum([mat.shape for mat in matrices], axis=0) - b_mat = np.zeros((rows,cols), dtype='complex') - rows, cols = 0, 0 - for mat in matrices: - new_rows = rows + mat.shape[0] - new_cols = cols + mat.shape[1] - b_mat[rows:new_rows, cols:new_cols] = mat - rows, cols = new_rows, new_cols - return b_mat - - -# TODO: Remove the workaround once we depend on scipy >= 1.0 -def lstsq(a, b): - """Least squares version that works also with 0-shaped matrices.""" - if a.shape[1] == 0: - return np.empty((0, 0), dtype=np.common_type(a, b)) - return la.lstsq(a, b)[0] - - def nonzero_symm_projection(matrix): """Check whether a discrete symmetry relation between two blocks of the Hamiltonian vanishes or not. @@ -838,7 +808,7 @@ def make_proper_modes(lmbdainv, psi, extract, tol, particle_hole, # reverse the order of the product at the end. wf_neg_k = particle_hole.dot( (full_psi[:, :N][:, positive_k]).conj())[:, ::-1] - rot = lstsq(orig_neg_k, wf_neg_k) + rot = la.lstsq(orig_neg_k, wf_neg_k)[0] full_psi[:, :N][:, positive_k[::-1]] = wf_neg_k psi[:, :N][:, positive_k[::-1]] = \ psi[:, :N][:, positive_k[::-1]].dot(rot) @@ -853,7 +823,7 @@ def make_proper_modes(lmbdainv, psi, extract, tol, particle_hole, # Reverse order at the end to match momenta of opposite sign. wf_neg_k = particle_hole.dot( full_psi[:, N:][:, positive_k].conj())[:, ::-1] - rot = lstsq(orig_neg_k, wf_neg_k) + rot = la.lstsq(orig_neg_k, wf_neg_k)[0] full_psi[:, N:][:, positive_k[::-1]] = wf_neg_k psi[:, N:][:, positive_k[::-1]] = \ psi[:, N:][:, positive_k[::-1]].dot(rot) @@ -865,7 +835,7 @@ def make_proper_modes(lmbdainv, psi, extract, tol, particle_hole, # of propagating modes, not either left or right movers. out_orig = full_psi[:, nmodes//2:] out = time_reversal.dot(full_psi[:, :nmodes//2].conj()) - rot = lstsq(out_orig, out) + rot = la.lstsq(out_orig, out)[0] full_psi[:, nmodes//2:] = out psi[:, nmodes//2:] = psi[:, nmodes//2:].dot(rot) diff --git a/kwant/physics/noise.py b/kwant/physics/noise.py index b565885f056976d2077ce9c37a3b345ac7733455..0547ff8ab113f33907897372fe143f5615fe8e18 100644 --- a/kwant/physics/noise.py +++ b/kwant/physics/noise.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import numpy as np from ..solvers.common import SMatrix @@ -43,7 +43,7 @@ def two_terminal_shotnoise(smatrix): # A general multi-terminal routine for noise would need to also have the # voltages at various leads as input. (See -# http://arxiv.org/abs/cond-mat/9910158) It could still be based on +# https://arxiv.org/abs/cond-mat/9910158) It could still be based on # smatrix._a_ttdagger_a_inv, i.e. be also valid also for self-energy leads, # provided that only true transmission blocks are used. As long as nobody needs # it though, it does make little sense to make such a routine. diff --git a/kwant/physics/symmetry.py b/kwant/physics/symmetry.py index 6c648a95d1687acd2b4c6318277e635ae6e6171a..3c18495ac1cdad789ed0ffd9042c217a7da66f7e 100644 --- a/kwant/physics/symmetry.py +++ b/kwant/physics/symmetry.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. __all__ = ['DiscreteSymmetry'] diff --git a/kwant/physics/tests/test_dispersion.py b/kwant/physics/tests/test_dispersion.py index 745e58b842ca8d6d0119b0d7f79c8e907d7c8d23..e944c56ec6b2473c117479e9df8f5cc527135ddb 100644 --- a/kwant/physics/tests/test_dispersion.py +++ b/kwant/physics/tests/test_dispersion.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import numpy as np from numpy.testing import assert_array_almost_equal, assert_almost_equal diff --git a/kwant/physics/tests/test_gauge.py b/kwant/physics/tests/test_gauge.py index 40e5f66d7560ad8c6f70111ac1dd73c7b89411bb..f1744254c41afcd18fc9dbd30cf3b372d56fdae8 100644 --- a/kwant/physics/tests/test_gauge.py +++ b/kwant/physics/tests/test_gauge.py @@ -1,7 +1,9 @@ from collections import namedtuple, Counter import warnings from math import sqrt + import numpy as np +from scipy.stats import special_ortho_group import pytest import kwant @@ -13,31 +15,6 @@ from .. import gauge ## Utilities -# TODO: remove in favour of 'scipy.stats.special_ortho_group' once -# we depend on scipy 0.18 -class special_ortho_group_gen: - - def rvs(self, dim): - H = np.eye(dim) - D = np.empty((dim,)) - for n in range(dim-1): - x = np.random.normal(size=(dim-n,)) - D[n] = np.sign(x[0]) if x[0] != 0 else 1 - x[0] += D[n]*np.sqrt((x*x).sum()) - # Householder transformation - Hx = (np.eye(dim-n) - - 2.*np.outer(x, x)/(x*x).sum()) - mat = np.eye(dim) - mat[n:, n:] = Hx - H = np.dot(H, mat) - D[-1] = (-1)**(dim-1)*D[:-1].prod() - # Equivalent to np.dot(np.diag(D), H) but faster, apparently - H = (D*H.T).T - return H - -special_ortho_group = special_ortho_group_gen() - - square_lattice = lattice.square(norbs=1, name='square') honeycomb_lattice = lattice.honeycomb(norbs=1, name='honeycomb') cubic_lattice = lattice.cubic(norbs=1, name='cubic') diff --git a/kwant/physics/tests/test_leads.py b/kwant/physics/tests/test_leads.py index a3b795a27f1070db02db02c6d3fe54f5dad6ad9b..f7453f0364a1a77c1313eb38a7c4b6103ec13c19 100644 --- a/kwant/physics/tests/test_leads.py +++ b/kwant/physics/tests/test_leads.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import numpy as np diff --git a/kwant/physics/tests/test_noise.py b/kwant/physics/tests/test_noise.py index 1c3434035d2fad786bf7d543f27c73e9134217a0..c09cc8818b2fc75a5570e9481efe7ab93d56003d 100644 --- a/kwant/physics/tests/test_noise.py +++ b/kwant/physics/tests/test_noise.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import numpy as np from pytest import raises diff --git a/kwant/physics/tests/test_symmetry.py b/kwant/physics/tests/test_symmetry.py index 1fe225a905bec5fb6970b237e1bb8fb631014d12..7b70e131c8a1b59833d86e0bffa197b030cb0c8d 100644 --- a/kwant/physics/tests/test_symmetry.py +++ b/kwant/physics/tests/test_symmetry.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import numpy as np diff --git a/kwant/plotter.py b/kwant/plotter.py index b3dcc392328e0e4d15e88540dd94eaac15253fab..aee49474259d91401a3d523c46858835365a40be 100644 --- a/kwant/plotter.py +++ b/kwant/plotter.py @@ -3,9 +3,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. """Plotter module for Kwant. @@ -2179,9 +2179,11 @@ def _spectrum_matplotlib(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) @@ -2324,8 +2326,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] diff --git a/kwant/qsymm.py b/kwant/qsymm.py index fef2fd6438bd7028ad7dd22f3eaecf65dc2f300d..1ae2cb33ee4b28f39e9470cf51ed56d1e7acd6ac 100644 --- a/kwant/qsymm.py +++ b/kwant/qsymm.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. __all__ = ['builder_to_model', 'model_to_builder', 'find_builder_symmetries'] @@ -18,12 +18,15 @@ 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 from qsymm.symmetry_finder import bravais_point_group from qsymm.linalg import allclose from qsymm.hamiltonian_generator import hamiltonian_from_family + + one = sympy.S.One except ImportError as error: msg = ("'kwant.qsymm' is not available because one or more of its " "dependencies is not installed.") @@ -346,7 +349,7 @@ def model_to_builder(model, norbs, lat_vecs, atom_coords, *, coeffs=None): for atom in atoms: if atom not in onsites_dict: onsites_dict[atom] = Model( - {sympy.numbers.One(): np.zeros((norbs[atom], norbs[atom]))}, + {one: np.zeros((norbs[atom], norbs[atom]))}, momenta=momenta) # Make the Kwant system, and set all onsites and hoppings. diff --git a/kwant/rmt.py b/kwant/rmt.py index 239313b29cd12c915150c2318212929b8cf8efff..b337906b17f906a02431313fc886a552bf1705da 100644 --- a/kwant/rmt.py +++ b/kwant/rmt.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. __all__ = ['gaussian', 'circular'] @@ -134,8 +134,7 @@ def gaussian(n, sym='A', v=1., rng=None): h = randn(n, n) + 1j * randn(n, n) # Ensure Hermiticity. - # TODO: write this as h += h.T.conj() once we rely on numpy >= 1.13.0 - h = h + h.T.conj() + h += h.T.conj() # Ensure Chiral symmetry. if c(sym): diff --git a/kwant/solvers/__init__.py b/kwant/solvers/__init__.py index 6e8024668925b266f046cae51f296620f0e684f9..abf5ecd3f8599e59aa54488bbd3df4965f24279e 100644 --- a/kwant/solvers/__init__.py +++ b/kwant/solvers/__init__.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. """This package contains solvers in individual sub-packages. diff --git a/kwant/solvers/common.py b/kwant/solvers/common.py index 8f3fa2f97b37755c3c0e537adc82ed79040bc004..db4bc9b332457bae64d13fae5fd6567cde0f3373 100644 --- a/kwant/solvers/common.py +++ b/kwant/solvers/common.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. __all__ = ['SparseSolver', 'SMatrix', 'GreensFunction'] @@ -18,17 +18,6 @@ from .._common import ensure_isinstance, deprecate_args from .. import system, physics from functools import reduce -# Until v0.13.0, scipy.sparse did not support making block matrices out of -# matrices with one dimension being zero: -# https://github.com/scipy/scipy/issues/2127 Additionally, 'scipy.sparse.bmat' -# didn't support matrices with zero size until v0.18: -# https://github.com/scipy/scipy/issues/5976. For now we use NumPy dense -# matrices as a replacement. - -# TODO: Once we depend on scipy >= 0.18, code for the special cases can be -# removed from _make_linear_sys, _solve_linear_sys and possibly other places -# marked by the line "See comment about zero-shaped sparse matrices at the top -# of common.py". LinearSys = namedtuple('LinearSys', ['lhs', 'rhs', 'indices', 'num_orb']) @@ -296,11 +285,8 @@ class SparseSolver(metaclass=abc.ABCMeta): zero_rows = (lhs.shape[0] - mats[0].shape[0] - mats[1].shape[0]) - if zero_rows: - zero_mat = sprhsmat((zero_rows, mats[0].shape[1])) - bmat = [[mats[0]], [mats[1]], [zero_mat]] - else: - bmat = [[mats[0]], [mats[1]]] + zero_mat = sprhsmat((zero_rows, mats[0].shape[1])) + bmat = [[mats[0]], [mats[1]], [zero_mat]] rhs[i] = sp.bmat(bmat, format=self.rhsformat) elif mats is None: @@ -407,9 +393,7 @@ class SparseSolver(metaclass=abc.ABCMeta): return SMatrix(np.zeros((len_kv, len_rhs)), lead_info, out_leads, in_leads, check_hermiticity) - # See comment about zero-shaped sparse matrices at the top of common.py. - rhs = sp.bmat([[i for i in linsys.rhs if i.shape[1]]], - format=self.rhsformat) + rhs = sp.bmat([linsys.rhs], format=self.rhsformat) flhs = self._factorized(linsys.lhs) data = self._solve_linear_sys(flhs, rhs, kept_vars) @@ -505,9 +489,7 @@ class SparseSolver(metaclass=abc.ABCMeta): return GreensFunction(np.zeros((len_kv, len_rhs)), lead_info, out_leads, in_leads, check_hermiticity) - # See comment about zero-shaped sparse matrices at the top of common.py. - rhs = sp.bmat([[i for i in linsys.rhs if i.shape[1]]], - format=self.rhsformat) + rhs = sp.bmat([linsys.rhs], format=self.rhsformat) flhs = self._factorized(linsys.lhs) data = self._solve_linear_sys(flhs, rhs, kept_vars) @@ -569,9 +551,7 @@ class SparseSolver(metaclass=abc.ABCMeta): factored = self._factorized(linsys.lhs) - # See comment about zero-shaped sparse matrices at the top of common.py. - rhs = sp.bmat([[i for i in linsys.rhs if i.shape[1]]], - format=self.rhsformat) + rhs = sp.bmat([linsys.rhs], format=self.rhsformat) for j in range(0, rhs.shape[1], self.nrhs): jend = min(j + self.nrhs, rhs.shape[1]) psi = self._solve_linear_sys(factored, rhs[:, j:jend], @@ -861,12 +841,10 @@ 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 + 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)] - self.out_block_offsets = \ - np.array(self.block_offsets)[list(self.out_leads)] + self._in_block_offsets = block_offsets[list(self.in_leads)] + self._out_block_offsets = block_offsets[list(self.out_leads)] # Block j of in lead i starts at in_block_offsets[i][j] def out_block_coords(self, lead_out): @@ -880,9 +858,9 @@ class SMatrix(BlockResult): lead_ind, block_ind = lead_out lead_ind = self.out_leads.index(lead_ind) return slice(self.out_offsets[lead_ind] + - self.out_block_offsets[lead_ind][block_ind], + self._out_block_offsets[lead_ind][block_ind], self.out_offsets[lead_ind] + - self.out_block_offsets[lead_ind][block_ind + 1]) + self._out_block_offsets[lead_ind][block_ind + 1]) def in_block_coords(self, lead_in): """ @@ -896,9 +874,9 @@ class SMatrix(BlockResult): lead_ind, block_ind = lead_in lead_ind = self.in_leads.index(lead_ind) return slice(self.in_offsets[lead_ind] + - self.in_block_offsets[lead_ind][block_ind], + self._in_block_offsets[lead_ind][block_ind], self.in_offsets[lead_ind] + - self.in_block_offsets[lead_ind][block_ind + 1]) + self._in_block_offsets[lead_ind][block_ind + 1]) def _transmission(self, lead_out, lead_in): return np.linalg.norm(self.submatrix(lead_out, lead_in)) ** 2 diff --git a/kwant/solvers/default.py b/kwant/solvers/default.py index e07f19aa8896a6044261f6d7fac93f5dddfe3060..cc082308e13f9f5b8aadf368c875d42d73d476f6 100644 --- a/kwant/solvers/default.py +++ b/kwant/solvers/default.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. __all__ = ['smatrix', 'ldos', 'wave_function', 'greens_function'] diff --git a/kwant/solvers/mumps.py b/kwant/solvers/mumps.py index 7d0dec0be1652ec07bdedb18548a138f4cd1dcba..d662e3aeeec31b78eb153cbd9df332878df2d493 100644 --- a/kwant/solvers/mumps.py +++ b/kwant/solvers/mumps.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. __all__ = ['smatrix', 'ldos', 'wave_function', 'greens_function', 'options', 'Solver'] diff --git a/kwant/solvers/sparse.py b/kwant/solvers/sparse.py index 8b8feeff7775092bc2af403df7ae4c24569a908b..3f1a6732784248da727cf1e34a02a46faf0b799c 100644 --- a/kwant/solvers/sparse.py +++ b/kwant/solvers/sparse.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. __all__ = ['smatrix', 'greens_function', 'ldos', 'wave_function', 'Solver'] @@ -15,16 +15,7 @@ from . import common # Note: previous code would have failed if UMFPACK was provided by scikit import scipy.sparse.linalg.dsolve.linsolve as linsolve -# check if we are actually using UMFPACK or rather SuperLU -# TODO: remove the try (only using the except clause) once we depend on -# scipy >= 0.14.0. -try: - uses_umfpack = linsolve.isUmfpack -except AttributeError: - uses_umfpack = linsolve.useUmfpack - -if uses_umfpack: - umfpack = linsolve.umfpack +uses_umfpack = linsolve.useUmfpack if uses_umfpack: def factorized(A, piv_tol=1.0, sym_piv_tol=1.0): @@ -51,6 +42,7 @@ if uses_umfpack: x1 = solve(rhs1) # Uses the LU factors. x2 = solve(rhs2) # Uses again the LU factors. """ + umfpack = linsolve.umfpack if not sp.isspmatrix_csc(A): A = sp.csc_matrix(A) diff --git a/kwant/solvers/tests/test_solvers.py b/kwant/solvers/tests/test_solvers.py index b960e1cbe2486ce544637b409df71e4d7419aa81..ff27992e2759e37d6b61bcf853c1b21f6b957c4d 100644 --- a/kwant/solvers/tests/test_solvers.py +++ b/kwant/solvers/tests/test_solvers.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import itertools from math import cos, sin diff --git a/kwant/system.py b/kwant/system.py index 594f09be0f35a9661b006d1bc1541f182f9cf02a..7f7fc63bf2900f5c083983a14cba4590359c959f 100644 --- a/kwant/system.py +++ b/kwant/system.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. """Low-level interface of systems""" @@ -110,7 +110,7 @@ class SiteArray(collections.abc.Sequence): Raises ------ ValueError - If `tags` are not proper tags for `family`. + If ``tags`` are not proper tags for ``family``. See Also -------- @@ -557,23 +557,23 @@ class VectorizedSystem(System, metaclass=abc.ABCMeta): the site array, and the offset of the first orbital of the first site in the site array. In addition, the final row has the form ``(len(graph.num_nodes), 0, tot_norbs)`` where ``tot_norbs`` is the - total number of orbitals in the system. Note 'site_ranges' - is directly computable from 'site_arrays'. + total number of orbitals in the system. Note ``site_ranges`` + is directly computable from ``site_arrays``. graph : kwant.graph.CGraph The system graph. subgraphs : sequence of tuples - Each subgraph has the form '((idx1, idx2), (offsets1, offsets2))' - where 'offsets1' and 'offsets2' index sites within the site arrays - indexed by 'idx1' and 'idx2'. + Each subgraph has the form ``((idx1, idx2), (offsets1, offsets2))`` + where ``offsets1`` and ``offsets2`` index sites within the site arrays + indexed by ``idx1`` and ``idx2``. terms : sequence of tuples Each tuple has the following structure: (subgraph: int, symmetry_element: tuple, hermitian: bool, parameters: List(str)) - 'subgraph' indexes 'subgraphs' and supplies the to/from sites of this - term. 'symmetry_element' is the symmetry group element that should be - applied to the 'to-sites' of this term. - 'hermitian' is 'True' if the term needs its Hermitian - conjugate to be added when evaluating the Hamiltonian, and 'parameters' + ``subgraph`` indexes ``subgraphs`` and supplies the to/from sites of this + term. ``symmetry_element`` is the symmetry group element that should be + applied to the to-sites of this term. + ``hermitian`` is ``True`` if the term needs its Hermitian + conjugate to be added when evaluating the Hamiltonian, and ``parameters`` contains a list of parameter names used when evaluating this term. parameters : frozenset of strings The names of the parameters on which the system depends. This attribute @@ -588,6 +588,7 @@ class VectorizedSystem(System, metaclass=abc.ABCMeta): ``pos`` which is assumed to return the real-space position of a site given its index. """ + @abc.abstractmethod def hamiltonian_term(self, index, selector=slice(None), args=(), params=None): @@ -615,6 +616,7 @@ class VectorizedSystem(System, metaclass=abc.ABCMeta): Providing positional arguments via 'args' is deprecated, instead, provide named parameters as a dictionary via 'params'. """ + @property @lru_cache(1) def site_ranges(self): diff --git a/kwant/tests/test_builder.py b/kwant/tests/test_builder.py index 46b3faeed6a81ff53ab3073da269959e40ad33d9..ffaad2c7eb8c85676a8bace6c8f4e940b9c25987 100644 --- a/kwant/tests/test_builder.py +++ b/kwant/tests/test_builder.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import warnings import pickle diff --git a/kwant/tests/test_kpm.py b/kwant/tests/test_kpm.py index 524cc57d78a97434ed6605f36b72d5833c5fd410..4b2934309323b838f0e36f5d6bdd9ac0961425eb 100644 --- a/kwant/tests/test_kpm.py +++ b/kwant/tests/test_kpm.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. from copy import copy as copy from types import SimpleNamespace diff --git a/kwant/tests/test_lattice.py b/kwant/tests/test_lattice.py index a1648f4759b3d7173b27256a81dcf67c82a51832..c073ba223731f7179337f5d53224d266b4807ff7 100644 --- a/kwant/tests/test_lattice.py +++ b/kwant/tests/test_lattice.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import warnings from math import sqrt diff --git a/kwant/tests/test_operator.py b/kwant/tests/test_operator.py index 42df5fbe3b868ae12134559b750a6d8f82b6d4bc..5895aae55d0ee5a3e4cfe1176f09efa65ed88cbf 100644 --- a/kwant/tests/test_operator.py +++ b/kwant/tests/test_operator.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import warnings import functools as ft diff --git a/kwant/tests/test_plotter.py b/kwant/tests/test_plotter.py index ce1e669ae456b62019502a4e5389c7b8022202a1..f3b0ec297bc7b71b55bb84ccc35d101133ba91e2 100644 --- a/kwant/tests/test_plotter.py +++ b/kwant/tests/test_plotter.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import tempfile import warnings diff --git a/kwant/tests/test_qsymm.py b/kwant/tests/test_qsymm.py index 7714c1c397d49171c8c6699860752ba333ed444c..214d728944ff056d80a63509a21e0e37bcd8cedd 100644 --- a/kwant/tests/test_qsymm.py +++ b/kwant/tests/test_qsymm.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. from collections import OrderedDict @@ -180,7 +180,7 @@ def test_graphene_to_kwant(): assert allclose(hamiltonian2, hamiltonian3) # Include random onsites as well - one = sympy.numbers.One() + one = sympy.S.One onsites = [Model({one: np.array([[1, 0], [0, 0]])}, momenta=family[0].momenta), Model({one: np.array([[0, 0], [0, 1]])}, momenta=family[0].momenta)] family = family + onsites diff --git a/kwant/tests/test_rmt.py b/kwant/tests/test_rmt.py index b7e3e64fdfacb5c57c1c2951ecfb7697f80df949..eaa83b845331ea6be0adc228d0dce32452a64c01 100644 --- a/kwant/tests/test_rmt.py +++ b/kwant/tests/test_rmt.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import numpy as np from scipy import stats diff --git a/kwant/tests/test_system.py b/kwant/tests/test_system.py index bbd79f2bd8607ee63bfea046be9a955348773be4..1b20a1c4f0a236dfab1618c5da83994b920f349e 100644 --- a/kwant/tests/test_system.py +++ b/kwant/tests/test_system.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import pickle import copy diff --git a/kwant/tests/test_wraparound.py b/kwant/tests/test_wraparound.py index c56abd3d679228d935b29da71d17ba61a274e007..cc7a9428e13afabd3757ef9697a10140090642ce 100644 --- a/kwant/tests/test_wraparound.py +++ b/kwant/tests/test_wraparound.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import tempfile import itertools diff --git a/kwant/version.py b/kwant/version.py index 151bd03f63ee2a3aefcbde8d40a6098f0470337b..1f24f23f2e1c789fa45c5c4e10b03132175edf47 100644 --- a/kwant/version.py +++ b/kwant/version.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. # This module must also work with Python 2. from __future__ import print_function diff --git a/kwant/wraparound.py b/kwant/wraparound.py index e1a9e0c334a4295ce2a639f15621596539d1777d..630a6172128fe5868e0f61c1a70632dbabce7259 100644 --- a/kwant/wraparound.py +++ b/kwant/wraparound.py @@ -2,9 +2,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. import collections import inspect diff --git a/kwant_red.jscm b/kwant_red.jscm index fd1f6485331d743bf8d1a512ef5db1cd7881f251..913dcaa6f255d22b8ad569debdbf8ac99901308c 100644 --- a/kwant_red.jscm +++ b/kwant_red.jscm @@ -1,5 +1,5 @@ { - "license": "http://creativecommons.org/publicdomain/zero/1.0/", + "license": "https://creativecommons.org/publicdomain/zero/1.0/", "usage-hints": [ "red-green-colorblind-safe", "greyscale-safe", diff --git a/pytest.ini b/pytest.ini index ecac1a6fb78efcdfd9088f58b4f3727024b24530..8f600a57dbdf4708e59fcb0a36732983c1b26e51 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,5 +1,6 @@ [pytest] testpaths = kwant +junit_family = xunit2 flakes-ignore = __init__.py UnusedImport ImportStarUsed ImportStarUsage kwant/_plotter.py UnusedImport diff --git a/setup.py b/setup.py index 436592799691a938c2e0662f356928ea145e678d..52ef3afe4a0c8396729c597e9d5062ceb2f792bc 100755 --- a/setup.py +++ b/setup.py @@ -4,9 +4,9 @@ # # This file is part of Kwant. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution and at -# http://kwant-project.org/license. A list of Kwant authors can be found in +# https://kwant-project.org/license. A list of Kwant authors can be found in # the file AUTHORS.rst at the top-level directory of this distribution and at -# http://kwant-project.org/authors. +# https://kwant-project.org/authors. from __future__ import print_function @@ -315,7 +315,7 @@ class sdist(sdist_orig): # The following class is based on a recipe in -# http://doc.pytest.org/en/latest/goodpractices.html#manual-integration. +# https://doc.pytest.org/en/latest/goodpractices.html#manual-integration. class test(test_orig): user_options = [('pytest-args=', 'a', "Arguments to pass to pytest")] @@ -584,7 +584,7 @@ def main(): "(Python 3 version)"), long_description=long_description(), platforms=["Unix", "Linux", "Mac OS-X", "Windows"], - url="http://kwant-project.org/", + url="https://kwant-project.org/", license="BSD", packages=packages, package_data={p: ['*.pxd', '*.h'] for p in packages}, @@ -593,16 +593,16 @@ def main(): 'build_ext': build_ext, 'test': test}, ext_modules=exts, - python_requires='>=3.6', - install_requires=['numpy >= 1.13.3', 'scipy >= 0.19.1', + python_requires='>=3.7', + # The oldest versions between: Debian stable, Ubuntu LTS + install_requires=['numpy >= 1.16.2', 'scipy >= 1.1.0', 'tinyarray >= 1.2'], extras_require={ - # The oldest versions between: Debian stable, Ubuntu LTS - 'plotting': ['matplotlib >= 2.1.1', - 'plotly >= 2.2.2'], - 'continuum': 'sympy >= 1.1.1', + 'plotting': ['matplotlib >= 3.0.2', + 'plotly >= 3.6.1'], + 'continuum': 'sympy >= 1.3.0', # qsymm is only packaged on PyPI - 'qsymm': 'qsymm >= 1.2.6', + 'qsymm': 'qsymm >= 1.3.0', }, classifiers=[c.strip() for c in classifiers.split('\n')])