Skip to content

Commit

Permalink
XSPEC: fix up error message
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DougBurke committed Sep 26, 2024
1 parent b71a91a commit 507cbd6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sherpa/astro/xspec/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 507cbd6

Please sign in to comment.