dfm / dfm/corner.py

ValueError: Axis limits cannot be NaN or Inf

Open
#225 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
576
Forks
234
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the traceback and the call to Generating in generatingModels.py, then inspect corner_plot and its corner.corner invocation. Try the reported run while checking x, r, and the computed weights, since the failure occurs when corner.py sets axis limits. Done means identifying a reproducible cause for the NaN or Inf limit and verifying the behavior after the cause is addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
matplotlib, numpy, python
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.