diff --git a/doc/source/reference/kwant.rst b/doc/source/reference/kwant.rst index fe1a48d7c3da7ce5a7231ad3b2c89462020d47d5..5dc52a970844da7c7b6ef26f36cf5ea18f86b600 100644 --- a/doc/source/reference/kwant.rst +++ b/doc/source/reference/kwant.rst @@ -3,9 +3,18 @@ .. module:: kwant -The top-level Kwant package serves as a container for sub-packages and does not -have any functions of its own. For convenience, short names are provided for a -few widely used objects from the sub-packages: +For convenience, short names are provided for a few widely used objects from +the sub-packages. +Otherwise, this package has only very limited functionality of its own. + +Generic functionality +--------------------- +The version of Kwant is available under the name ``__version__``. + +.. autosummary:: + :toctree: generated/ + + KwantDeprecationWarning .. currentmodule:: kwant.builder @@ -43,7 +52,3 @@ From `kwant.solvers.default` ldos smatrix wave_function - -Version information -------------------- -The version of Kwant is available under the name ``__version__``. diff --git a/kwant/__init__.py b/kwant/__init__.py index 9a8f92209987db0d855b45a0ff94dec312dbe637..3f9ea7dba1c7540f4123cd2204dc752ebf7b7d7f 100644 --- a/kwant/__init__.py +++ b/kwant/__init__.py @@ -6,6 +6,8 @@ # the AUTHORS file at the top-level directory of this distribution and at # http://kwant-project.org/authors. +__all__ = [] + import numpy # Needed by C. Gohlke's Windows package. try: @@ -16,12 +18,14 @@ except ImportError: and relaunch your Python intepreter from there.""" raise ImportError(msg) -__all__ = ['system', 'version', 'builder', 'lattice', 'solvers', - 'digest', 'rmt'] -for module in __all__: - exec 'from . import {0}'.format(module) +from ._common import KwantDeprecationWarning +__all__.append('KwantDeprecationWarning') -from .version import version as __version__ +from ._common import version as __version__ + +for module in ['system', 'builder', 'lattice', 'solvers', 'digest', 'rmt']: + exec 'from . import {0}'.format(module) + __all__.append(module) # Make selected functionality available directly in the root namespace. available = [('builder', ['Builder', 'HoppingKind']), diff --git a/kwant/version.py b/kwant/_common.py similarity index 80% rename from kwant/version.py rename to kwant/_common.py index 82bf68e9aff3d89972059f38cb5be8d817a6adbe..291b1e4c66c21e6738f1cb4c9f910b05275f23c1 100644 --- a/kwant/version.py +++ b/kwant/_common.py @@ -1,4 +1,4 @@ -# Copyright 2011-2013 Kwant authors. +# Copyright 2011-2014 Kwant authors. # # 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 @@ -9,7 +9,7 @@ import subprocess import os -__all__ = ['version'] +__all__ = ['version', 'KwantDeprecationWarning'] distr_root = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) @@ -63,3 +63,14 @@ if version is None: from _static_version import version except: version = "unknown" + + +class KwantDeprecationWarning(Warning): + """Class of warnings about a deprecated feature of Kwant. + + DeprecatedWarning has been made invisible by default in Python 2.7 in order + to not confuse non-developer users with warnings that are not relevant to + them. In the case of Kwant, by far most users are developers, so we feel + that a KwantDeprecationWarning that is visible by default is useful. + """ + pass diff --git a/setup.py b/setup.py index bbafc61961362f752261048f569e4799cece985f..d060349e274cfd613ed3087f8455b4dce7a735e4 100755 --- a/setup.py +++ b/setup.py @@ -202,7 +202,7 @@ The existing MANIFEST file seems to have been generated by distutils (it begins with a comment). It may well be incomplete.""" -# This is an exact copy of the function from kwant/version.py. We can't import +# This is an exact copy of the function from kwant/_common.py. We can't import # it here (because Kwant is not yet built when this scipt is run), so we just # include a copy. def get_version_from_git():