From b416e4864cc492caf9062a2ad0f55c9b6a885808 Mon Sep 17 00:00:00 2001 From: Christoph Groth <christoph.groth@cea.fr> Date: Wed, 26 Sep 2018 11:56:13 +0200 Subject: [PATCH] expand whatsnew item about defaults values being no longer allowed --- doc/source/pre/whatsnew/1.4.rst | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/doc/source/pre/whatsnew/1.4.rst b/doc/source/pre/whatsnew/1.4.rst index e7674772..42b6b5c5 100644 --- a/doc/source/pre/whatsnew/1.4.rst +++ b/doc/source/pre/whatsnew/1.4.rst @@ -6,8 +6,8 @@ See also the `full list of changes up to the most recent bugfix release of the 1.4 series <https://gitlab.kwant-project.org/kwant/kwant/compare/v1.4.0...latest-1.4>`_. -Value functions no longer accept default values for parameters --------------------------------------------------------------- +Value functions may no longer have default values for parameters +---------------------------------------------------------------- Using value functions with default values for parameters can be problematic, especially when re-using value functions between simulations. When parameters have default values it is easy to forget that such a @@ -35,6 +35,16 @@ Concretely, the above means that the following no longer works:: # Raises ValueError syst = syst.finalized() +As a solution, simply remove the default values and always provide ``t``. +To deal with many parameters, the following idiom may be useful:: + + defaults = dict(a=0, b=1, c=2, d=3) + ... + smatrix = kwant.smatrix(syst, E, params=dict(defaults, d=4, e=5)) + +Note that it allows to override defaults as well as to add additional +parameters. + System parameter substitution ----------------------------- After the introduction of ``Builder.fill`` it has become possible to construct -- GitLab