From 507cbd6bc25e8ae744674caadba62fce113d61f1 Mon Sep 17 00:00:00 2001 From: Douglas Burke Date: Thu, 26 Sep 2024 11:58:57 -0400 Subject: [PATCH] XSPEC: fix up error message The error message that happens in the rare case of the XSPEC model failing now a) correctly lists the parameters and their values previously the parameters were being mapped to the low-energy axis, which is obviously garbage b) any keyword arguments are now also included in the error message The energy grid could be included, but this is something the caller can more-easily identify than a particular set of parameters (and keyword argyments) so it's not worth adding to the already-long line. --- sherpa/astro/xspec/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sherpa/astro/xspec/__init__.py b/sherpa/astro/xspec/__init__.py index 5fed743a78..155d8a6213 100644 --- a/sherpa/astro/xspec/__init__.py +++ b/sherpa/astro/xspec/__init__.py @@ -1433,11 +1433,17 @@ def calc(self, p, *args, **kwargs): # - model class # - model name # - parameter list + # - any kwargs # msg = f"{ve}: {self.type}.{self.name}" - for par, val in zip(self.pars, args[0]): + for par, val in zip(self.pars, p): msg += f" {par.name}={val}" + if kwargs: + msg += " KEYWORDS " + for k, v in kwargs.items(): + msg += f"{k}={v}" + raise ValueError(msg) from None # This check is being skipped in the 4.8.0 release as it