Check least squares params dictionary
Safeguard against invalid user entries.
One possible way to address comment 4 in
@@ -104,6 +104,17 @@ class Inversion:
'tr_solver': 'lsmr'
}
+ # Check that all of the user-specified parameters in the config exist in
+ # `self.least_squares_params`.
+ lsq_keys = list(self.least_squares_params.keys())
+ bad_lsq_keys = []
+ for key in config.least_squares_params.keys():
+ if key not in lsq_keys:
+ bad_lsq_keys.append(key)
+ assert len(bad_lsq_keys) == 0, \
+ "The following least squares parameters are invalid or unknown: " +\
+ ", ".join(bad_lsq_keys)
+
# Update with parameters from config. If they are an empty dict
# (default), this does nothing.
self.least_squares_params.update(config.least_squares_params)
