From 2d3c51ade6a5ef6e9a20f7ef3cfbde3b25f7473d Mon Sep 17 00:00:00 2001 From: Christoph Groth <christoph.groth@cea.fr> Date: Wed, 27 Mar 2019 10:06:20 +0100 Subject: [PATCH] fix avoidable backwards incompatibility: System.parameters When System.parameters was introduced, we thought it would be a good idea to also use this new attribute. The plan was to check in hamiltonian_submatrix() whether any unneeded parameters are provided by the user. This turned out to be impossible, so the only check that remained was whether all the necessary parameters are indeed provided. However, this check is not necessary, because the 'hamiltonian' method is in any way obliged to signal an error when it does not obtain the necessary parameters. --- doc/source/pre/whatsnew/1.4.rst | 2 ++ kwant/_system.pyx | 14 -------------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/doc/source/pre/whatsnew/1.4.rst b/doc/source/pre/whatsnew/1.4.rst index 945a4bfb..167b8430 100644 --- a/doc/source/pre/whatsnew/1.4.rst +++ b/doc/source/pre/whatsnew/1.4.rst @@ -341,3 +341,5 @@ Changes in Kwant 1.4.1 - The list of user-visible changes was rearranged to emphasize backwards-incompatible changes by moving them to the top of the list and adding the entry `Value functions may no longer take unnamed arguments`_. +- Kwant no longer requires the existence of a `parameters` attribute for + low-level systems. diff --git a/kwant/_system.pyx b/kwant/_system.pyx index 45e0da43..71860ed6 100644 --- a/kwant/_system.pyx +++ b/kwant/_system.pyx @@ -243,17 +243,6 @@ def make_dense_full(ham, args, params, CGraph gr, diag, return h_sub -def _check_parameters_match(expected_parameters, params): - if params is None: - params = {} - missing = set(expected_parameters) - set(params) - - if missing: - msg = ('System is missing required parameters: ', - ', '.join(map('"{}"'.format, missing))) - raise TypeError(''.join(msg)) - - @deprecate_args @cython.binding(True) @cython.embedsignature(True) @@ -301,9 +290,6 @@ def hamiltonian_submatrix(self, args=(), to_sites=None, from_sites=None, n = self.graph.num_nodes matrix = ta.matrix - if not args: # Then perhaps parameters - _check_parameters_match(self.parameters, params) - if from_sites is None: diag = n * [None] from_norb = np.empty(n, gint_dtype) -- GitLab