Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: Axis limits cannot be NaN or Inf #225

Open
astronom-v-cube opened this issue Mar 31, 2023 · 3 comments
Open

ValueError: Axis limits cannot be NaN or Inf #225

astronom-v-cube opened this issue Mar 31, 2023 · 3 comments

Comments

@astronom-v-cube
Copy link

My issues are rather informational in nature, since I was unable to establish the exact cause of the problem and reproduce it. Maybe someone else can do it if they see it.
When using the library at random moments I start getting this error:

Traceback (most recent call last):
  File "c:\Users\Дмитрий\Documents\solar_radio_diagnostics\using.py", line 79, in <module>
    gen.Generating(ngenerations=1, nchildren=1, sigmacoeff=8, points=2**5, method='new_random_first_gen', do_plot = True, refx = recoverable_params)
  File "c:\Users\Дмитрий\Documents\solar_radio_diagnostics\generatingModels.py", line 223, in Generating
    self.corner_plot(self.x, self.r, self.gen, ngenerations, nchildren, sigmacoeff, points, method)
  File "c:\Users\Дмитрий\Documents\solar_radio_diagnostics\generatingModels.py", line 48, in corner_plot
    corner.corner(data = x, weights = (1/r).ravel(), titles = titles, fig = corner_figure, truths = truths, title_fmt = None, show_titles = True, range = ranges, truth_color = 'red', axes_scale = ('linear', 'linear', 'log', 'linear'))
  File "C:\Users\Дмитрий\AppData\Roaming\Python\Python310\site-packages\corner\corner.py", line 248, in corner
    return corner_impl(
  File "C:\Users\Дмитрий\AppData\Roaming\Python\Python310\site-packages\corner\core.py", line 296, in corner_impl
    _set_ylim(force_range, new_fig, ax, [0, 1.1 * np.max(n)])
  File "C:\Users\Дмитрий\AppData\Roaming\Python\Python310\site-packages\corner\core.py", line 922, in _set_ylim
    return ax.set_ylim(new_ylim)
  File "C:\Users\Дмитрий\AppData\Roaming\Python\Python310\site-packages\matplotlib\axes\_base.py", line 4011, in set_ylim
    top = self._validate_converted_limits(top, self.convert_yunits)
  File "C:\Users\Дмитрий\AppData\Roaming\Python\Python310\site-packages\matplotlib\axes\_base.py", line 3601, in _validate_converted_limits
    raise ValueError("Axis limits cannot be NaN or Inf")
ValueError: Axis limits cannot be NaN or Inf

When restarting the same code, without any changes, the error goes away. The range parameter obviously does not have such values.
Maybe it's about working on windows and the fact that I don't use plt.show(), but savefig()?...
The error appears in waves, that is, it is observed for three or four code runs, and then disappears without any action on my part.

@dfm
Copy link
Owner

dfm commented Mar 31, 2023

This doesn't seem like a corner problem to me really. It has something to do with the inputs you're passing in which must change on each rerun. Please try to isolate what exactly is different about the inputs that fail. My guess is that some of the r values in weights=1/r are close to zero so you're passing in an infinite weight for some of the samples which won't work so well :D

@astronom-v-cube
Copy link
Author

The values displayed when an error is received are in the order 1e4 - 1e6. With values close to 0, it just worked well for me)

@dfm
Copy link
Owner

dfm commented Apr 7, 2023

In that case, please put together a minimal, reproducible example that demonstrates the problem. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants