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

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
Show changes
Showing
with 2664 additions and 330 deletions
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -9,7 +9,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
# Additional tools for running CI
file rsync openssh-client \
# Documentation building
inkscape texlive-full zip \
inkscape texlive-full zip librsvg2-bin \
&& apt-get clean && \
rm -rf /var/lib/apt/lists/*
......@@ -18,3 +18,5 @@ COPY kwant-latest.yml kwant-stable.yml kwant-stable-no-extras.yml /
RUN conda env create -qf kwant-stable.yml
RUN conda env create -qf kwant-stable-no-extras.yml
RUN conda env create -qf kwant-latest.yml
RUN /usr/local/envs/kwant-latest/bin/python -m ipykernel install --user --name kwant-latest
......@@ -23,6 +23,9 @@ dependencies:
- pytest-flakes
- pytest-pep8
# Documentation building
- sphinx=1.7.4 # later versions seem to have problems
- sphinx
- numpydoc
- requests
- jupyter_sphinx
- pip:
- sphinxcontrib-svg2pdfconverter
......@@ -19,7 +19,3 @@ dependencies:
- pytest-cov
- pytest-flakes
- pytest-pep8
# Documentation building
- sphinx=1.7.4 # later versions seem to have problems
- numpydoc
- requests
......@@ -22,7 +22,3 @@ dependencies:
- pytest-cov
- pytest-flakes
- pytest-pep8
# Documentation building
- sphinx=1.7.4 # later versions seem to have problems
- numpydoc
- requests
......@@ -29,22 +29,29 @@ except ImportError:
raise
from ._common import KwantDeprecationWarning, UserCodeError
__all__.extend(['KwantDeprecationWarning', 'UserCodeError'])
for module in ['system', 'builder', 'lattice', 'solvers', 'digest', 'rmt',
'operator', 'kpm', 'wraparound']:
exec('from . import {0}'.format(module))
__all__.append(module)
# Pre-import most submodules. (We make exceptions for submodules that have
# special dependencies or where that would take too long.)
from . import system
from . import builder
from . import lattice
from . import solvers
from . import digest
from . import rmt
from . import operator
from . import kpm
from . import wraparound
__all__.extend(['system', 'builder', 'lattice', 'solvers', 'digest', 'rmt',
'operator', 'kpm', 'wraparound'])
# Make selected functionality available directly in the root namespace.
available = [('builder', ['Builder', 'HoppingKind']),
('lattice', ['TranslationalSymmetry']),
('solvers.default',
['smatrix', 'greens_function', 'ldos', 'wave_function'])]
for module, names in available:
exec('from .{0} import {1}'.format(module, ', '.join(names)))
__all__.extend(names)
from .builder import Builder, HoppingKind
__all__.extend(['Builder', 'HoppingKind'])
from .lattice import TranslationalSymmetry
__all__.extend(['TranslationalSymmetry'])
from .solvers.default import smatrix, greens_function, ldos, wave_function
__all__.extend(['smatrix', 'greens_function', 'ldos', 'wave_function'])
# Importing plotter might not work, but this does not have to be a problem --
# only no plotting will be available.
......
......@@ -13,6 +13,7 @@ import inspect
import warnings
import importlib
import functools
import collections
from contextlib import contextmanager
__all__ = ['KwantDeprecationWarning', 'UserCodeError']
......@@ -191,3 +192,27 @@ class lazy_import:
package = sys.modules[self.__package]
setattr(package, self.__module, mod)
return getattr(mod, name)
def _hashable(obj):
return isinstance(obj, collections.abc.Hashable)
def memoize(f):
"""Decorator to memoize a function that works even with unhashable args.
This decorator will even work with functions whose args are not hashable.
The cache key is made up by the hashable arguments and the ids of the
non-hashable args. It is up to the user to make sure that non-hashable
args do not change during the lifetime of the decorator.
This decorator will keep reevaluating functions that return None.
"""
def lookup(*args):
key = tuple(arg if _hashable(arg) else id(arg) for arg in args)
result = cache.get(key)
if result is None:
cache[key] = result = f(*args)
return result
cache = {}
return lookup
This diff is collapsed.
......@@ -10,11 +10,12 @@ try:
from .discretizer import discretize, discretize_symbolic, build_discretized
from ._common import sympify, lambdify
from ._common import momentum_operators, position_operators
from .landau_levels import to_landau_basis, discretize_landau, LandauLattice
except ImportError as error:
msg = ("'kwant.continuum' is not available because one or more of its "
"dependencies is not installed.")
raise ImportError(msg) from error
__all__ = ['discretize', 'discretize_symbolic', 'build_discretized',
'to_landau_basis', 'discretize_landau', 'LandauLattice',
'sympify', 'lambdify', 'momentum_operators', 'position_operators']
This diff is collapsed.
This diff is collapsed.
......@@ -9,8 +9,7 @@
"""Functionality for graphs"""
# Merge the public interface of all submodules.
__all__ = []
for module in ['core', 'defs']:
exec('from . import {0}'.format(module))
exec('from .{0} import *'.format(module))
exec('__all__.extend({0}.__all__)'.format(module))
from .core import *
from .defs import *
__all__ = [core.__all__ + defs.__all__]
This diff is collapsed.