DESC icon indicating copy to clipboard operation
DESC copied to clipboard

Add a warning if any computed quantity from `XXX.compute` is NaN

Open dpanici opened this issue 8 months ago • 1 comments

something like

any_is_nan = any([ np.any(np.isnan(data[key])) for key in data.keys() ]

warnif(any_is_nan, UserWarning, "Detected one or more quantities computed as NaN, please check that the requested quantities are defined on the grid used")

at the end of each XXX.compute method of objects would be nice to warn the use of any NaN which exist when computing quantities. This also I predict would cause a lot of errors in our CI from areas where this is happening silently/benignly (like when plotting this I am certain happens all the time)

dpanici avatar Mar 28 '25 18:03 dpanici

Related to #1138, as I think right now NaN exist in plotted quantities (for example on axis) but the blanket suppression would prevent the warning from coming through

dpanici avatar Mar 28 '25 18:03 dpanici

Note that we deliberately return NaN in some cases, eg kinetic profiles for equilibria that don't have them assigned. The way the code is structured, if the user computes pressure we also always compute the kinetic profiles but set them to NaN, so this may cause some false positives unless we add some special logic

f0uriest avatar Jun 10 '25 16:06 f0uriest