Skip to content

Commit

Permalink
test: ensure all models are covered by param tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Nov 29, 2021
1 parent 67d8eb5 commit bfe2be7
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,20 @@ def test_model_params():
model_parameters = {"Gaussian1D": ["amplitude", "stddev", "mean"],
"Const1D": ["amplitude"],
"Linear1D": ["slope", "intercept"],
"Polynomial1D": ["c0", "c1"],
"PowerLaw1D": ["amplitude", "x_0", "alpha"],
"Lorentz1D": ["amplitude", "x_0", "fwhm"],
"Voigt1D": ["x_0", "amplitude_L", "fwhm_L", "fwhm_G"],
"BlackBody": ["temperature", "scale"],
}

for model_name, expected_params in model_parameters.items():
for model_name in initializers.MODELS.keys():
if model_name not in model_parameters.keys():
# this would be caught later by the assertion anyways,
# but raising an error will be more clear that the
# test needs to be updated rather than the code breaking
raise ValueError(f"{model_name} not in test dictionary of expected parameters")
expected_params = model_parameters.get(model_name, [])
params = initializers.get_model_parameters(model_name)
assert len(params) == len(expected_params)
assert np.all([p in expected_params for p in params])
Expand Down

0 comments on commit bfe2be7

Please # to comment.