Skip to content
Snippets Groups Projects
Commit 2d3c51ad authored by Christoph Groth's avatar Christoph Groth
Browse files

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.
parent 66104ecf
No related branches found
No related tags found
No related merge requests found
...@@ -341,3 +341,5 @@ Changes in Kwant 1.4.1 ...@@ -341,3 +341,5 @@ Changes in Kwant 1.4.1
- The list of user-visible changes was rearranged to emphasize - The list of user-visible changes was rearranged to emphasize
backwards-incompatible changes by moving them to the top of the list and backwards-incompatible changes by moving them to the top of the list and
adding the entry `Value functions may no longer take unnamed arguments`_. 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.
...@@ -243,17 +243,6 @@ def make_dense_full(ham, args, params, CGraph gr, diag, ...@@ -243,17 +243,6 @@ def make_dense_full(ham, args, params, CGraph gr, diag,
return h_sub 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 @deprecate_args
@cython.binding(True) @cython.binding(True)
@cython.embedsignature(True) @cython.embedsignature(True)
...@@ -301,9 +290,6 @@ def hamiltonian_submatrix(self, args=(), to_sites=None, from_sites=None, ...@@ -301,9 +290,6 @@ def hamiltonian_submatrix(self, args=(), to_sites=None, from_sites=None,
n = self.graph.num_nodes n = self.graph.num_nodes
matrix = ta.matrix matrix = ta.matrix
if not args: # Then perhaps parameters
_check_parameters_match(self.parameters, params)
if from_sites is None: if from_sites is None:
diag = n * [None] diag = n * [None]
from_norb = np.empty(n, gint_dtype) from_norb = np.empty(n, gint_dtype)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment