Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 378-support-finalization-and-attaching-of-nd-systems
  • backup/210414_randomly_failing_test
  • bands_backport
  • bugfix/tests-without-dependencies
  • cleanup
  • doc/execute
  • document_peierls
  • enh/ci_performance
  • enh/vectorized_evaluation
  • enh/vectorized_finalization
  • enh/vectorized_refactoring
  • feat/stable-testing-images
  • feature/378-nd-finalization
  • feature/no-show
  • feature/plot-hopping-by-length
  • feature/vectorized_finalization
  • feature/vectorized_interface
  • fix/ban_scipy_1_6_1
  • fix/finish_bumping_py37
  • fix/matplotlib_3.4_deprecations
  • fix/remove_future_print_function
  • fix/sympy_numbers
  • fixup/docs
  • fixup/testing-env
  • image_update
  • issue-409-lattice-closest
  • main
  • master
  • oldstable_1.2
  • oldstable_1.3
  • pixi
  • plotter_current_fix
  • pretty-print-fix
  • sparse-modes
  • spec-0000
  • stable
  • stable_py2
  • test
  • vect_adv_constr
  • vect_args
  • vect_eval
  • latest-1.1
  • latest-1.2
  • latest-1.3
  • v0.0.0
  • v0.1.0
  • v0.1.5
  • v0.2.0
  • v0.2.4
  • v1.0.0
  • v1.0.1
  • v1.0.2
  • v1.0.3
  • v1.0.4
  • v1.0.5
  • v1.1.0
  • v1.1.0b0
  • v1.1.0pre0
  • v1.1.1
  • v1.1.2
  • v1.1.3
  • v1.2.0a0
  • v1.2.2
  • v1.2.3
  • v1.3.0
  • v1.3.0a0
  • v1.3.0a1
  • v1.3.1
  • v1.3.2
  • v1.3.3
  • v1.4.0
  • v1.4.0a0
  • v1.4.0a1
  • v1.4.0rc0
  • v1.4.0rc1
  • v1.4.1
  • v1.4.2
  • v1.4.3
  • v1.4.4
  • v1.5.0
  • v1.5.0a0
81 results

Target

Select target project
  • kwant/kwant
  • jbweston/kwant
  • anton-akhmerov/kwant
  • cwg/kwant
  • Mathieu/kwant
  • slavoutich/kwant
  • pacome/kwant
  • behrmann/kwant
  • michaelwimmer/kwant
  • albeercik/kwant
  • eunjongkim/kwant
  • basnijholt/kwant
  • r-j-skolasinski/kwant
  • sahmed95/kwant
  • pablopiskunow/kwant
  • mare/kwant
  • dvarjas/kwant
  • Paul/kwant
  • bbuijtendorp/kwant
  • tkloss/kwant
  • torosdahl/kwant
  • kel85uk/kwant
  • kpoyhonen/kwant
  • Fromeworld/kwant
  • quaeritis/kwant
  • marwahaha/kwant
  • fernandodfufrpe/kwant
  • oly/kwant
  • jiamingh/kwant
  • mehdi2369/kwant
  • ValFadeev/kwant
  • Kostas/kwant
  • chelseabaptiste03/kwant
33 results
Select Git revision
  • boundstate
  • feature/#250/plotly_backend_selection
  • feature/#252/scalarplot_plotly
  • feature/#253/streamplot_plotly
  • feature/boundstate
  • feature/indexable
  • fixup/testing-env
  • kwant2-system
  • master
  • setup-argparse
  • stable
  • stable_py2
  • system2
  • version/pin-sympy
  • latest-1.1
  • latest-1.2
  • latest-1.3
  • v0.0.0
  • v0.1.0
  • v0.1.5
  • v0.2.0
  • v0.2.4
  • v1.0.0
  • v1.0.1
  • v1.0.2
  • v1.0.3
  • v1.0.4
  • v1.0.5
  • v1.1.0
  • v1.1.0b0
  • v1.1.0pre0
  • v1.1.1
  • v1.1.2
  • v1.1.3
  • v1.2.0a0
  • v1.2.2
  • v1.2.3
  • v1.3.0
  • v1.3.0a0
  • v1.3.0a1
  • v1.3.1
  • v1.4.0a0
42 results
Show changes
Showing
with 178 additions and 981 deletions
# 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
# 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
# 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
tests reside in a package that itself requires the dependency to be
installed.
"""
import importlib
# map from subpackage to sequence of dependency module names
subpackage_dependencies = {
'kwant/continuum': ['sympy'],
'kwant/tests/test_qsymm': ['qsymm', 'sympy'],
}
# map from subpackage to sequence of dependency modules that are not installed
dependencies_not_installed = {}
for package, dependencies in subpackage_dependencies.items():
not_installed = []
for dep in dependencies:
try:
importlib.import_module(dep)
except ImportError:
not_installed.append(dep)
if len(not_installed) != 0:
dependencies_not_installed[package] = not_installed
def pytest_ignore_collect(path, config):
for subpackage, not_installed in dependencies_not_installed.items():
if subpackage in path.strpath:
print('ignoring {} because the following dependencies are not '
'installed: {}'.format(subpackage, ', '.join(not_installed)))
return True
# Makefile for Sphinx documentation
# Copyright 2011-2013 Kwant authors.
# Minimal makefile for Sphinx documentation
#
# This file is part of Kwant. It is subject to the license terms in the
# LICENSE file 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
# the AUTHORS file at the top-level directory of this distribution and at
# http://kwant-project.org/authors.
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
SOURCEDIR = source
BUILDDIR = build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
# We convert all SVG files to PDF for LaTeX output. For HTML output, we don't
# create PNGs but rather use the SVG files directly.
IMAGESOURCES = $(shell find source -name "*.svg")
GENERATEDPDF = $(patsubst %.svg,%.pdf,$(IMAGESOURCES))
# Image generation from patched tutorial scripts
#
# As make does not support the generation of multiple targets by a single
# invocation of a (non-implicit) rule, we use a trick: We pretend to be
# generating a single (empty) flag file per invocation. The image files are
# generated as well, but only as side-effects. Each flag file is used to
# remember the time at which the corresponding image-generating script was run.
# This works perfectly unless the actual output files are deleted without
# deleting the corresponding flag file.
SCRIPTS = $(patsubst source/images/%.diff,%,$(wildcard source/images/*.py.diff))
FLAGS = $(patsubst %.py,source/images/.%_flag,$(SCRIPTS))
.PHONY: help clean realclean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
# Put it first so that "make" without argument is like "make help".
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
-rm -rf $(BUILDDIR)/* $(GENERATEDPDF)
-rm -rf source/reference/generated
realclean: clean
-rm -f $(FLAGS)
-rm -f $(patsubst %,source/images/%,$(SCRIPTS))
-rm -f $(patsubst %.py,source/images/%_*.png,$(SCRIPTS))
-rm -f $(patsubst %.py,source/images/%_*.pdf,$(SCRIPTS))
html: $(FLAGS)
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
dirhtml: $(FLAGS)
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
.PHONY: help Makefile
pickle: $(FLAGS)
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json: $(FLAGS)
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp: $(FLAGS)
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp: $(FLAGS)
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/kwant.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/kwant.qhc"
latex: $(GENERATEDPDF) $(FLAGS)
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
"run these through (pdf)latex."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
%.pdf: %.svg
rsvg-convert -f pdf -o $@ $<
# Make the image generation scripts by patching tutorial scipts.
.SECONDARY:
%.py: %.py.diff
@grep -v '^#HIDDEN' source/tutorial/$(notdir $@) >$@
@patch $@ $<
clean:
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
# The image generation scripts depend on their unpatched originals
define makedep
source/images/$(1): source/tutorial/$(1)
endef
$(foreach name,$(SCRIPTS),$(eval $(call makedep,$(name))))
latex:
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
# Generation of images
.%_flag: %.py
cd $(dir $<) && python $(notdir $<)
@touch $@
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
/* This theme is based on pydoctheme by Georg Brandl. */
@import url("default.css");
body {
background-color: white;
margin-left: 1em;
margin-right: 1em;
}
/* Disable typewriter font in headings. */
h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
font-family: "Bitstream Vera Sans", Verdana, sans-serif;
font-size: 100%;
}
div.body p, div.body dd, div.body li {
-webkit-hyphens: auto;
-moz-hyphens: auto;
-ms-hyphens: auto;
-o-hyphens: auto;
hyphens: auto;
}
div.related {
margin-bottom: 1.2em;
padding: 0.5em 0;
border-top: 1px solid #ccc;
margin-top: 0.5em;
}
dt:target, .highlighted {
background-color: #fbf1aa;
}
div.related:first-child {
border-top: 0;
border-bottom: 1px solid #ccc;
}
div.sphinxsidebar {
background-color: #eeeeee;
border-radius: 5px;
line-height: 130%;
font-size: smaller;
overflow: hidden;
}
div.sphinxsidebar h3, div.sphinxsidebar h4 {
margin-top: 1.5em;
}
div.sphinxsidebarwrapper > h3:first-child {
margin-top: 0.2em;
}
div.sphinxsidebarwrapper > ul > li > ul > li {
margin-bottom: 0.4em;
}
div.sphinxsidebar input {
font-family: 'Bitstream Vera Serif', Georgia, serif
border: 1px solid #999999;
font-size: smaller;
border-radius: 3px;
}
div.sphinxsidebar input[type=text] {
max-width: 220px;
}
div.body {
padding: 0 0 0 1.2em;
}
div.body p {
line-height: 140%;
}
div.body h1, div.body h2, div.body h3, div.body h4, div.body h5, div.body h6 {
margin: 0;
border: 0;
padding: 0.3em 0;
}
div.body hr {
border: 0;
background-color: #ccc;
height: 1px;
}
div.body pre {
border-radius: 3px;
border: 1px solid #ac9;
}
div.body div.admonition, div.body div.impl-detail {
border-radius: 3px;
}
div.body div.impl-detail > p {
margin: 0;
}
div.body div.seealso {
border: 1px solid #dddd66;
}
tt, pre {
font-family: monospace, sans-serif;
font-size: 96.5%;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
-o-hyphens: none;
hyphens: none;
}
div.body tt {
border-radius: 3px;
}
div.body tt.descname {
font-size: 120%;
}
div.body tt.xref, div.body a tt {
font-weight: normal;
}
p.deprecated {
border-radius: 3px;
}
table.docutils {
border: 1px solid #ddd;
min-width: 20%;
border-radius: 3px;
margin-top: 10px;
margin-bottom: 10px;
}
table.docutils td, table.docutils th {
border: 1px solid #ddd !important;
border-radius: 3px;
}
table p, table li {
text-align: left !important;
}
table.docutils th {
background-color: #eee;
padding: 0.3em 0.5em;
}
table.docutils td {
background-color: white;
padding: 0.3em 0.5em;
}
table.footnote, table.footnote td {
border: 0 !important;
}
div.footer {
line-height: 150%;
margin-top: -2em;
text-align: right;
width: auto;
margin-right: 10px;
}
/* have arguments of functions or classes also a monospace font */
table.longtable.docutils > tbody > tr > td:first-child,
dl.function > dt,
dl.class > dt,
dl.method > dt
{
font-family: "Bitstream Vera Sans Mono", monospace, serif;
font-size: 96.5%;
}
/* rescale font for <tt> so that it is again 96.5% with respect to body */
table.longtable.docutils > tbody > tr > td:first-child tt,
dl.function > dt tt,
dl.class > dt tt,
dl.method > dt tt
{
font-family: "Bitstream Vera Sans Mono", monospace, serif;
font-size: 100%;
}
td.field-body strong
{
font-family: "Bitstream Vera Sans Mono", monospace, serif;
font-size: 96.5%;
}
# This theme is based on pydoctheme by Georg Brandl
[theme]
inherit = default
stylesheet = kwantdoctheme.css
pygments_style = sphinx
[options]
bodyfont = "Bitstream Vera Serif", Georgia, serif
headfont = "Bitstream Vera Sans", Verdana, sans-serif
footerbgcolor = white
footertextcolor = #555555
relbarbgcolor = white
relbartextcolor = #666666
relbarlinkcolor = #444444
sidebarbgcolor = white
sidebartextcolor = #444444
sidebarlinkcolor = #444444
sidebarwidth = 300
bgcolor = white
textcolor = black
linkcolor = #045e94
visitedlinkcolor = #045e94
headtextcolor = black
headbgcolor = white
headlinkcolor = #aaaaaa
@import "kwantdoctheme.css";
/* spacing around blockquoted fields in parameters/attributes/returns */
/* Essential. Otherwise there is way too much space around*/
td.field-body > blockquote {
margin-top: 0.1em;
margin-bottom: 0.5em;
}
.field-list th {
/* color: rgb(0,50,150); */
/* background-color: #EEE8AA; */
white-space: nowrap; /* Essential. Otherwise the colons can break
into a new line */
}
table.field-list {
border-collapse: separate; /* Essential. Otherwise Parameters and Returns
are sharing one solid colored field. That looks
weird. */
border-spacing: 10px;
border-style: hidden;
}
div.specialnote-title {
font-size: 105%;
font-weight: bold;
font-color: #3B4D3C;
background-color: #DCE4DC;
padding: 1em;
padding-top: 0.4em;
padding-bottom: 0.4em;
margin-top: 1em;
margin-bottom: 0px;
border-width: 1px;
border-color: #546C55;
border-style: solid;
}
div.specialnote-body {
background-color: #DCE4DC;
padding: 1em;
padding-top: 0.1em;
padding-bottom: 0.4em;
margin-top: 0px;
border-width: 1px;
border-top-width: 0px;
border-color: #546C55;
border-style: solid;
}
MathJax.Hub.Config({
TeX: {
Macros: {
bra: ['{\\left\\langle #1\\right|}',1],
ket: ['{\\left| #1\\right\\rangle}',1],
braket: ['\\left\\langle#1|#2\\right\\rangle', 2],
ri: '\\text{i}',
rd: '\\text{d}'
}
}
});
......@@ -97,9 +97,9 @@ $(function() {
// find the height of the viewport to center the '<<' in the page
var viewport_height;
if (window.innerHeight)
viewport_height = window.innerHeight;
viewport_height = window.innerHeight;
else
viewport_height = $(window).height();
viewport_height = $(window).height();
var sidebar_offset = sidebar.offset().top;
var sidebar_height = Math.max(bodywrapper.height(), sidebar.height());
sidebarbutton.find('span').css({
......
......@@ -11,12 +11,23 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
import sys
import os
import string
from distutils.util import get_platform
sys.path.insert(0, "../../build/lib.{0}-{1}.{2}".format(
get_platform(), *sys.version_info[:2]))
package_path = os.path.abspath(
"../../build/lib.{0}-{1}.{2}"
.format(get_platform(), *sys.version_info[:2]))
# Insert into sys.path so that we can import kwant here
sys.path.insert(0, package_path)
# Insert into PYTHONPATH so that jupyter-sphinx will pick it up
os.environ['PYTHONPATH'] = ':'.join((package_path, os.environ.get('PYTHONPATH','')))
import kwant
import kwant.qsymm
import kwant.continuum # sphinx gets confused with lazy loading
# -- General configuration -----------------------------------------------------
......@@ -26,8 +37,9 @@ import kwant
sys.path.insert(0, os.path.abspath('../sphinxext'))
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosummary',
'sphinx.ext.todo', 'sphinx.ext.pngmath', 'numpydoc',
'kwantdoc']
'sphinx.ext.todo', 'sphinx.ext.mathjax', 'sphinx.ext.napoleon',
'sphinx.ext.linkcode', 'jupyter_sphinx', 'sphinx_togglebutton',
'sphinxcontrib.rsvgconverter']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['../templates']
......@@ -42,8 +54,8 @@ source_suffix = '.rst'
master_doc = 'index'
# General information about the project.
project = u'Kwant'
copyright = u'2011-2013, C. W. Groth (CEA), M. Wimmer, A. R. Akhmerov, X. Waintal (CEA), and others'
project = 'Kwant'
copyright = '2011-2017, C. W. Groth (CEA), M. Wimmer, A. R. Akhmerov, X. Waintal (CEA), and others'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
......@@ -52,12 +64,8 @@ copyright = u'2011-2013, C. W. Groth (CEA), M. Wimmer, A. R. Akhmerov, X. Wainta
# The full version, including alpha/beta/rc tags.
release = kwant.__version__
for i, s in enumerate(release):
if s not in '0123456790.':
break
# The short X.Y version.
version = release[:i]
version = release[:len(release) - len(release.lstrip('012345679.'))].rstrip('.')
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
......@@ -99,22 +107,20 @@ pygments_style = 'sphinx'
# Do not show all class members automatically in the class documentation
numpydoc_show_class_members = False
# -- Options for HTML output ---------------------------------------------------
# Jupyter Sphinx config
# http://stackoverflow.com/questions/9728292/creating-latex-math-macros-within-sphinx
pngmath_latex_preamble = r"""\newcommand{\bra}[1]{\left\langle#1\right|}
\newcommand{\ket}[1]{\left|#1\right>}
\newcommand{\braket}[2]{\left\langle#1|#2\right\rangle}
\newcommand{\ri}{\text{i}}
\newcommand{\rd}{\text{d}}
"""
jupyter_sphinx_thebelab_config = {
"binderOptions": {
"repo": "kwant-project/binder",
"ref": "master",
}
}
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
html_theme = 'kwantdoctheme'
html_theme_path = ['..']
html_theme_options = {'collapsiblesidebar': True}
html_style = 'kwant.css'
html_theme = 'sphinx_book_theme'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
......@@ -133,7 +139,7 @@ html_style = 'kwant.css'
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
html_logo = "_static/kwant_logo.png"
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
......@@ -183,13 +189,9 @@ html_domain_indices = False
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = ''
# Output file base name for HTML help builder.
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': '',
......@@ -205,17 +207,29 @@ r"""\makeatletter
\renewcommand{\footrulewidth}{0.4pt}
}
\makeatother
""" + pngmath_latex_preamble}
\newcommand{\bra}[1]{\left\langle#1\right|}
\newcommand{\ket}[1]{\left|#1\right>}
\newcommand{\braket}[2]{\left\langle#1|#2\right\rangle}
\newcommand{\ri}{\text{i}}
\newcommand{\rd}{\text{d}}
\usepackage{unicode-math}
"""}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
# We use "et al." as it is shorter and there's not much space left horizontally.
latex_documents = [
('index', 'kwant.tex', 'Kwant {0} documentation'.format(release),
u'C. W. Groth, M. Wimmer, A. R. Akhmerov, X. Waintal, et al.',
'C. W. Groth, M. Wimmer, A. R. Akhmerov, X. Waintal, et al.',
'manual'),
]
latex_engine = 'xelatex'
latex_use_xindy = False # Xindy not installable in CI environment
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
......@@ -227,9 +241,6 @@ latex_documents = [
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
latex_use_modindex = False
# This is needed too.
latex_domain_indices = False
......@@ -238,7 +249,9 @@ latex_domain_indices = False
autosummary_generate = True
autoclass_content = "both"
autodoc_default_flags = ['show-inheritance']
autodoc_default_options = {
'show-inheritance': True,
}
# -- Teach Sphinx to document bound methods like functions ---------------------
import types
......@@ -251,11 +264,11 @@ 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.im_self is not None and
not issubclass(member.im_class, type) and
member.im_class is not types.ClassType)
member.__self__ is not None and
not issubclass(member.__self__.__class__, type) and
member.__self__.__class__ is not type)
def format_args(self):
args = super(BoundMethodDocumenter, self).format_args()
......@@ -266,3 +279,56 @@ class BoundMethodDocumenter(autodoc.FunctionDocumenter):
def setup(app):
app.add_autodocumenter(BoundMethodDocumenter)
# By default linkcheck only tries once, but experience has shown us that this test is
# very non-specific for detecting dead links. Trying a few times should significantly
# lower the probability of false positives.
linkcheck_retries = 5
# Some websites (particularly IoP) take a long time to respond. The combination of
# this timeout and the retries should make this check sufficiently specific.
linkcheck_timeout = 10
nitpick_ignore = [('py:class', 'Warning'), ('py:class', 'Exception'),
('py:class', 'object'), ('py:class', 'tuple'),
('py:class', 'kwant.operator._LocalOperator'),
('py:class', 'numpy.ndarray'),
('py:class', 'kwant.solvers.common.BlockResult'),
('py:class', 'kwant.builder._FinalizedBuilderMixin')]
# -- Make Sphinx insert source code links --------------------------------------
def linkcode_resolve(domain, info):
def find_source():
# try to find the file and line number, based on code from numpy:
# https://github.com/numpy/numpy/blob/master/doc/source/conf.py#L286
obj = sys.modules[info['module']]
for part in info['fullname'].split('.'):
obj = getattr(obj, part)
import inspect
fn = inspect.getsourcefile(obj)
fn = os.path.relpath(fn, start=os.path.dirname(kwant.__file__))
source, lineno = inspect.getsourcelines(obj)
return fn, lineno, lineno + len(source) - 1
if domain != 'py' or not info['module']:
return None
try:
filename = 'kwant/%s#L%d-%d' % find_source()
except Exception:
filename = info['module'].replace('.', '/') + '.py'
# The following relies on the documented format of kwant.__version__.
rel = release.rstrip('.dirty')
if '.dev' in rel:
try:
refname = rel[rel.index('+g') + 2:]
except ValueError:
return
else:
refname = 'v' + rel
templ = os.environ.get(
"SOURCE_LINK_TEMPLATE",
"https://gitlab.kwant-project.org/kwant/kwant/blob/$r/$f")
return string.Template(templ).safe_substitute(r=refname, f=filename)
......@@ -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"
......
......@@ -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"
......
......@@ -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"
......
################################################################
# Make matplotlib work without X11
################################################################
import matplotlib
matplotlib.use('Agg')
################################################################
# Prepend Kwant's build directory to sys.path
################################################################
import sys
from distutils.util import get_platform
sys.path.insert(0, "../../../build/lib.{0}-{1}.{2}".format(
get_platform(), *sys.version_info[:2]))
################################################################
# Define constants for plotting
################################################################
pt_to_in = 1. / 72.
# Default width of figures in pts
figwidth_pt = 600
figwidth_in = figwidth_pt * pt_to_in
# Width for smaller figures
figwidth_small_pt = 400
figwidth_small_in = figwidth_small_pt * pt_to_in
# Sizes for matplotlib figures
mpl_width_in = figwidth_pt * pt_to_in
mpl_label_size = None # font sizes in points
mpl_tick_size = None
# dpi for conversion from inches
dpi = 90
--- original
+++ modified
@@ -12,6 +12,7 @@
# example, but in the tutorial main text)
# - Modifcations of hoppings/sites after they have been added
+import _defs
from cmath import exp
from math import pi
@@ -40,12 +41,13 @@
sys[lat.shape(ring, (0, r1 + 1))] = 4 * t
sys[lat.neighbors()] = -t
- # In order to introduce a flux through the ring, we introduce a phase on
- # the hoppings on the line cut through one of the arms. Since we want to
- # change the flux without modifying the Builder instance repeatedly, we
- # define the modified hoppings as a function that takes the flux as its
- # parameter phi.
- def fluxphase(site1, site2, phi):
+ # In order to introduce a flux through the ring, we introduce a phase
+ # on the hoppings on the line cut through one of the arms
+
+ # since we want to change the flux without modifying Builder repeatedly,
+ # we define the modified hoppings as a function that takes the flux
+ # through the argument phi.
+ def fluxphase(site1, site2, phi=0):
return exp(1j * phi)
def crosses_branchcut(hop):
@@ -81,6 +83,50 @@
return sys
+def make_system_note1(a=1, t=1.0, W=10, r1=10, r2=20):
+ lat = kwant.lattice.square(a)
+ sys = kwant.Builder()
+ def ring(pos):
+ (x, y) = pos
+ rsq = x**2 + y**2
+ return ( r1**2 < rsq < r2**2)
+ sys[lat.shape(ring, (0, 11))] = 4 * t
+ sys[lat.neighbors()] = -t
+ sym_lead0 = kwant.TranslationalSymmetry((-a, 0))
+ lead0 = kwant.Builder(sym_lead0)
+ def lead_shape(pos):
+ (x, y) = pos
+ return (-1 < x < 1) and ( 0.5 * W < y < 1.5 * W )
+ lead0[lat.shape(lead_shape, (0, W))] = 4 * t
+ lead0[lat.neighbors()] = -t
+ lead1 = lead0.reversed()
+ sys.attach_lead(lead0)
+ sys.attach_lead(lead1)
+ return sys
+
+
+def make_system_note2(a=1, t=1.0, W=10, r1=10, r2=20):
+ lat = kwant.lattice.square(a)
+ sys = kwant.Builder()
+ def ring(pos):
+ (x, y) = pos
+ rsq = x**2 + y**2
+ return ( r1**2 < rsq < r2**2)
+ sys[lat.shape(ring, (0, 11))] = 4 * t
+ sys[lat.neighbors()] = -t
+ sym_lead0 = kwant.TranslationalSymmetry((-a, 0))
+ lead0 = kwant.Builder(sym_lead0)
+ def lead_shape(pos):
+ (x, y) = pos
+ return (-1 < x < 1) and ( -W/2 < y < W/2 )
+ lead0[lat.shape(lead_shape, (0, 0))] = 4 * t
+ lead0[lat.neighbors()] = -t
+ lead1 = lead0.reversed()
+ sys.attach_lead(lead0)
+ sys.attach_lead(lead1, lat(0, 0))
+ return sys
+
+
def plot_conductance(sys, energy, fluxes):
# compute conductance
@@ -90,18 +136,31 @@
smatrix = kwant.smatrix(sys, energy, args=[flux])
data.append(smatrix.transmission(1, 0))
- pyplot.figure()
+ fig = pyplot.figure()
pyplot.plot(normalized_fluxes, data)
- pyplot.xlabel("flux [flux quantum]")
- pyplot.ylabel("conductance [e^2/h]")
- pyplot.show()
+ pyplot.xlabel("flux [flux quantum]",
+ fontsize=_defs.mpl_label_size)
+ pyplot.ylabel("conductance [e^2/h]",
+ fontsize=_defs.mpl_label_size)
+ pyplot.setp(fig.get_axes()[0].get_xticklabels(),
+ fontsize=_defs.mpl_tick_size)
+ pyplot.setp(fig.get_axes()[0].get_yticklabels(),
+ fontsize=_defs.mpl_tick_size)
+ fig.set_size_inches(_defs.mpl_width_in, _defs.mpl_width_in * 3. / 4.)
+ fig.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15)
+ fig.savefig("ab_ring_result.pdf")
+ fig.savefig("ab_ring_result.png", dpi=_defs.dpi)
def main():
sys = make_system()
# Check that the system looks as intended.
- kwant.plot(sys)
+ size = (_defs.figwidth_in, _defs.figwidth_in)
+ for extension in ('pdf', 'png'):
+ kwant.plot(sys, file="ab_ring_sys." + extension,
+ fig_size=size, dpi=_defs.dpi)
+
# Finalize the system.
sys = sys.finalized()
@@ -111,6 +170,17 @@
for i in xrange(100)])
+ # Finally, some plots needed for the notes
+ sys = make_system_note1()
+ for extension in ('pdf', 'png'):
+ kwant.plot(sys, file="ab_ring_note1." + extension,
+ fig_size=size, dpi=_defs.dpi)
+ sys = make_system_note2()
+ for extension in ('pdf', 'png'):
+ kwant.plot(sys, file="ab_ring_note2." + extension,
+ fig_size=size, dpi=_defs.dpi)
+
+
# Call the main function if the script gets executed (as opposed to imported).
# See <http://docs.python.org/library/__main__.html>.
if __name__ == '__main__':
--- original
+++ modified
@@ -9,6 +9,7 @@
# --------------------------
# - Computing the band structure of a finalized lead.
+import _defs
import kwant
# For plotting.
@@ -36,10 +37,19 @@
def main():
lead = make_lead().finalized()
- kwant.plotter.bands(lead, show=False)
- pyplot.xlabel("momentum [(lattice constant)^-1]")
- pyplot.ylabel("energy [t]")
- pyplot.show()
+ fig = kwant.plotter.bands(lead, show=False)
+ pyplot.xlabel("momentum [(lattice constant)^-1]",
+ fontsize=_defs.mpl_label_size)
+ pyplot.ylabel("energy [t]", fontsize=_defs.mpl_label_size)
+ pyplot.setp(fig.get_axes()[0].get_xticklabels(),
+ fontsize=_defs.mpl_tick_size)
+ pyplot.setp(fig.get_axes()[0].get_yticklabels(),
+ fontsize=_defs.mpl_tick_size)
+ fig.set_size_inches(_defs.mpl_width_in, _defs.mpl_width_in * 3. / 4.)
+ fig.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15)
+ for extension in ('pdf', 'png'):
+ fig.savefig("band_structure_result." + extension, dpi=_defs.dpi)
+
# Call the main function if the script gets executed (as opposed to imported).
--- original
+++ modified
@@ -11,6 +11,7 @@
# - Use of `hamiltonian_submatrix` in order to obtain a Hamiltonian
# matrix.
+import _defs
from cmath import exp
import numpy as np
import kwant
@@ -68,29 +69,39 @@
energies.append(ev)
- pyplot.figure()
+ fig = pyplot.figure()
pyplot.plot(Bfields, energies)
- pyplot.xlabel("magnetic field [arbitrary units]")
- pyplot.ylabel("energy [t]")
- pyplot.show()
+ pyplot.xlabel("magnetic field [arbitrary units]",
+ fontsize=_defs.mpl_label_size)
+ pyplot.ylabel("energy [t]", fontsize=_defs.mpl_label_size)
+ pyplot.setp(fig.get_axes()[0].get_xticklabels(),
+ fontsize=_defs.mpl_tick_size)
+ pyplot.setp(fig.get_axes()[0].get_yticklabels(),
+ fontsize=_defs.mpl_tick_size)
+ fig.set_size_inches(_defs.mpl_width_in, _defs.mpl_width_in * 3. / 4.)
+ fig.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15)
+ for extension in ('pdf', 'png'):
+ fig.savefig("closed_system_result." + extension, dpi=_defs.dpi)
def plot_wave_function(sys):
+ size = (_defs.figwidth_in, _defs.figwidth_in)
+
# Calculate the wave functions in the system.
ham_mat = sys.hamiltonian_submatrix(sparse=True)
evecs = sla.eigsh(ham_mat, k=20, which='SM')[1]
# Plot the probability density of the 10th eigenmode.
- kwant.plotter.map(sys, np.abs(evecs[:, 9])**2,
- colorbar=False, oversampling=1)
+ for extension in ('pdf', 'png'):
+ kwant.plotter.map(
+ sys, np.abs(evecs[:, 9])**2, colorbar=False, oversampling=1,
+ file="closed_system_eigenvector." + extension,
+ fig_size=size, dpi=_defs.dpi)
def main():
sys = make_system()
- # Check that the system looks as intended.
- kwant.plot(sys)
-
# Finalize the system.
sys = sys.finalized()
# !/bin/sh
# This script regenerates the .diff files in this directory. It's these files
# that are kept under vesion control instead of the scripts themselves.
for f in [a-zA-Z]*.py; do
# We use custom labels to suppress the time stamps which are unnecessary
# here and would only lead to noise in version control.
grep -v '#HIDDEN' ../tutorial/$f |
diff -u --label original --label modified - $f >$f.diff_
if cmp $f.diff_ $f.diff >/dev/null 2>&1; then
rm $f.diff_
else
mv $f.diff_ $f.diff
fi
done
--- original
+++ modified
@@ -11,6 +11,7 @@
# lattice, namely graphene
from __future__ import division # so that 1/2 == 0.5, and not 0
+import _defs
from math import pi, sqrt, tanh
import kwant
@@ -97,22 +98,40 @@
smatrix = kwant.smatrix(sys, energy)
data.append(smatrix.transmission(0, 1))
- pyplot.figure()
+ fig = pyplot.figure()
pyplot.plot(energies, data)
- pyplot.xlabel("energy [t]")
- pyplot.ylabel("conductance [e^2/h]")
- pyplot.show()
+ pyplot.xlabel("energy [t]",
+ fontsize=_defs.mpl_label_size)
+ pyplot.ylabel("conductance [e^2/h]",
+ fontsize=_defs.mpl_label_size)
+ pyplot.setp(fig.get_axes()[0].get_xticklabels(),
+ fontsize=_defs.mpl_tick_size)
+ pyplot.setp(fig.get_axes()[0].get_yticklabels(),
+ fontsize=_defs.mpl_tick_size)
+ fig.set_size_inches(_defs.mpl_width_in, _defs.mpl_width_in * 3. / 4.)
+ fig.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15)
+ for extension in ('pdf', 'png'):
+ fig.savefig("graphene_result." + extension, dpi=_defs.dpi)
def plot_bandstructure(flead, momenta):
bands = kwant.physics.Bands(flead)
energies = [bands(k) for k in momenta]
- pyplot.figure()
+ fig = pyplot.figure()
pyplot.plot(momenta, energies)
- pyplot.xlabel("momentum [(lattice constant)^-1]")
- pyplot.ylabel("energy [t]")
- pyplot.show()
+ pyplot.xlabel("momentum [(lattice constant)^-1]",
+ fontsize=_defs.mpl_label_size)
+ pyplot.ylabel("energy [t]",
+ fontsize=_defs.mpl_label_size)
+ pyplot.setp(fig.get_axes()[0].get_xticklabels(),
+ fontsize=_defs.mpl_tick_size)
+ pyplot.setp(fig.get_axes()[0].get_yticklabels(),
+ fontsize=_defs.mpl_tick_size)
+ fig.set_size_inches(_defs.mpl_width_in, _defs.mpl_width_in * 3. / 4.)
+ fig.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15)
+ for extension in ('pdf', 'png'):
+ fig.savefig("graphene_bs." + extension, dpi=_defs.dpi)
def main():
@@ -124,8 +143,11 @@
def family_colors(site):
return 0 if site.family == a else 1
- # Plot the closed system without leads.
- kwant.plot(sys, site_color=family_colors, site_lw=0.1, colorbar=False)
+ size = (_defs.figwidth_in, _defs.figwidth_in)
+ for extension in ('pdf', 'png'):
+ kwant.plot(sys, site_color=family_colors, site_lw=0.1, colorbar=False,
+ file="graphene_sys1." + extension,
+ fig_size=size, dpi=_defs.dpi)
# Compute some eigenvalues.
compute_evs(sys.finalized())
@@ -134,9 +156,11 @@
for lead in leads:
sys.attach_lead(lead)
- # Then, plot the system with leads.
- kwant.plot(sys, site_color=family_colors, site_lw=0.1,
- lead_site_lw=0, colorbar=False)
+ size = (_defs.figwidth_in, 0.9 * _defs.figwidth_in)
+ for extension in ('pdf', 'png'):
+ kwant.plot(sys, site_color=family_colors, colorbar=False, site_lw=0.1,
+ file="graphene_sys2." + extension,
+ fig_size=size, dpi=_defs.dpi, lead_site_lw=0)
# Finalize the system.
sys = sys.finalized()
--- original
+++ modified
@@ -9,6 +9,7 @@
# --------------------------
# - demonstrate different ways of plotting
+import _defs
import kwant
from matplotlib import pyplot
@@ -22,7 +23,7 @@
return x**2 + y**2 < r**2
sys = kwant.Builder()
- sys[lat.shape(circle, (0, 0))] = 0
+ sys[lat.shape(circle, (0,0))] = 0
sys[lat.neighbors()] = t
sys.eradicate_dangling()
if tp:
@@ -32,9 +33,11 @@
def plot_system(sys):
- kwant.plot(sys)
- # the standard plot is ok, but not very intelligible. One can do
- # better by playing wioth colors and linewidths
+ # standard plot - not very intelligible for this particular situation
+ size = (_defs.figwidth_in, _defs.figwidth_in)
+ for extension in ('pdf', 'png'):
+ kwant.plot(sys, file="plot_graphene_sys1." + extension,
+ fig_size=size, dpi=_defs.dpi)
# use color and linewidths to get a better plot
def family_color(site):
@@ -43,7 +46,11 @@
def hopping_lw(site1, site2):
return 0.04 if site1.family == site2.family else 0.1
- kwant.plot(sys, site_lw=0.1, site_color=family_color, hop_lw=hopping_lw)
+ size = (_defs.figwidth_in, _defs.figwidth_in)
+ for extension in ('pdf', 'png'):
+ kwant.plot(sys, site_lw=0.1, site_color=family_color,
+ hop_lw=hopping_lw, file="plot_graphene_sys2." + extension,
+ fig_size=size, dpi=_defs.dpi)
def plot_data(sys, n):
@@ -58,7 +65,11 @@
# the usual - works great in general, looks just a bit crufty for
# small systems
- kwant.plotter.map(sys, wf, oversampling=10, cmap='gist_heat_r')
+ size = (_defs.figwidth_in, _defs.figwidth_in)
+ for extension in ('pdf', 'png'):
+ kwant.plotter.map(sys, wf, oversampling=10, cmap='gist_heat_r',
+ file="plot_graphene_data1." + extension,
+ fig_size=size, dpi=_defs.dpi)
# use two different sort of triangles to cleanly fill the space
def family_shape(i):
@@ -68,15 +79,22 @@
def family_color(i):
return 'black' if sys.site(i).family == a else 'white'
- kwant.plot(sys, site_color=wf, site_symbol=family_shape,
- site_size=0.5, hop_lw=0, cmap='gist_heat_r')
+ size = (_defs.figwidth_in, _defs.figwidth_in)
+ for extension in ('pdf', 'png'):
+ kwant.plot(sys, site_color=wf, site_symbol=family_shape,
+ site_size=0.5, hop_lw=0, cmap='gist_heat_r',
+ file="plot_graphene_data2." + extension,
+ fig_size=size, dpi=_defs.dpi)
# plot by changing the symbols itself
def site_size(i):
return 3 * wf[i] / wf.max()
- kwant.plot(sys, site_size=site_size, site_color=(0, 0, 1, 0.3),
- hop_lw=0.1)
+ size = (_defs.figwidth_in, _defs.figwidth_in)
+ for extension in ('pdf', 'png'):
+ kwant.plot(sys, site_size=site_size, site_color=(0,0,1,0.3),
+ hop_lw=0.1, file="plot_graphene_data3." + extension,
+ fig_size=size, dpi=_defs.dpi)
def main():
--- original
+++ modified
@@ -9,6 +9,7 @@
# --------------------------
# - demonstrate different ways of plotting in 3D
+import _defs
import kwant
from matplotlib import pyplot
@@ -33,7 +34,10 @@
# checking shapes:
sys = make_cuboid()
- kwant.plot(sys)
+ size = (_defs.figwidth_in, _defs.figwidth_in)
+ for extension in ('pdf', 'png'):
+ kwant.plot(sys, file="plot_zincblende_sys1." + extension,
+ fig_size=size, dpi=_defs.dpi)
# visualize the crystal structure better for a very small system
sys = make_cuboid(a=1.5, b=1.5, c=1.5)
@@ -41,8 +45,12 @@
def family_colors(site):
return 'r' if site.family == a else 'g'
- kwant.plot(sys, site_size=0.18, site_lw=0.01, hop_lw=0.05,
- site_color=family_colors)
+ size = (_defs.figwidth_in, _defs.figwidth_in)
+ for extension in ('pdf', 'png'):
+ kwant.plot(sys, site_size=0.18, site_lw=0.01, hop_lw=0.05,
+ site_color=family_colors,
+ file="plot_zincblende_sys2." + extension,
+ fig_size=size, dpi=_defs.dpi)
# Call the main function if the script gets executed (as opposed to imported).
--- original
+++ modified
@@ -9,6 +9,7 @@
# --------------------------
# - Functions as values in Builder
+import _defs
import kwant
# For plotting
@@ -55,19 +56,25 @@
smatrix = kwant.smatrix(sys, energy, args=[-welldepth])
data.append(smatrix.transmission(1, 0))
- pyplot.figure()
+ fig = pyplot.figure()
pyplot.plot(welldepths, data)
- pyplot.xlabel("well depth [t]")
- pyplot.ylabel("conductance [e^2/h]")
- pyplot.show()
+ pyplot.xlabel("well depth [t]",
+ fontsize=_defs.mpl_label_size)
+ pyplot.ylabel("conductance [e^2/h]",
+ fontsize=_defs.mpl_label_size)
+ pyplot.setp(fig.get_axes()[0].get_xticklabels(),
+ fontsize=_defs.mpl_tick_size)
+ pyplot.setp(fig.get_axes()[0].get_yticklabels(),
+ fontsize=_defs.mpl_tick_size)
+ fig.set_size_inches(_defs.mpl_width_in, _defs.mpl_width_in * 3. / 4.)
+ fig.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15)
+ for extension in ('pdf', 'png'):
+ fig.savefig("quantum_well_result." + extension, dpi=_defs.dpi)
def main():
sys = make_system()
- # Check that the system looks as intended.
- kwant.plot(sys)
-
# Finalize the system.
sys = sys.finalized()