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

alchemlyb.visualisation.plot_convergence cannot handel the case where the final error is NaN #318

Closed
xiki-tempula opened this issue Jun 1, 2023 · 0 comments · Fixed by #319

Comments

@xiki-tempula
Copy link
Collaborator

If the input to alchemlyb.visualisation.plot_convergence is in such format

        Forward  Forward_Error  Backward  Backward_Error  data_fraction
0 -9.095031e-09    2225.996551  0.000002     3457.639809            0.5
1 -1.334738e-06            NaN -0.000001             NaN            1.0

The function would quit with

---------------------------------------------------------------------------
IndexError                Traceback (most recent call last)
Cell In[29], line 1
----> 1 ax.fill_between([0, 1], np.nan, np.nan)
File ~/miniconda/envs/exs-orionbssfloes/lib/python3.8/site-packages/matplotlib/__init__.py:1442, in _preprocess_data.<locals>.inner(ax, data, *args, **kwargs)
  1439 @functools.wraps(func)
  1440 def inner(ax, *args, data=None, **kwargs):
  1441   if data is None:
-> 1442     return func(ax, *map(sanitize_sequence, args), **kwargs)
  1444   bound = new_sig.bind(ax, *args, **kwargs)
  1445   auto_label = (bound.arguments.get(label_namer)
  1446          or bound.kwargs.get(label_namer))
File ~/miniconda/envs/exs-orionbssfloes/lib/python3.8/site-packages/matplotlib/axes/_axes.py:5431, in Axes.fill_between(self, x, y1, y2, where, interpolate, step, **kwargs)
  5429 def fill_between(self, x, y1, y2=0, where=None, interpolate=False,
  5430         step=None, **kwargs):
-> 5431   return self._fill_between_x_or_y(
  5432     "x", x, y1, y2,
  5433     where=where, interpolate=interpolate, step=step, **kwargs)
File ~/miniconda/envs/exs-orionbssfloes/lib/python3.8/site-packages/matplotlib/axes/_axes.py:5420, in Axes._fill_between_x_or_y(self, ind_dir, ind, dep1, dep2, where, interpolate, step, **kwargs)
  5417 collection = mcoll.PolyCollection(polys, **kwargs)
  5419 # now update the datalim and autoscale
-> 5420 pts = np.row_stack([np.column_stack([ind[where], dep1[where]]),
  5421           np.column_stack([ind[where], dep2[where]])])
  5422 if ind_dir == "y":
  5423   pts = pts[:, ::-1]
File ~/miniconda/envs/exs-orionbssfloes/lib/python3.8/site-packages/numpy/ma/core.py:3254, in MaskedArray.__getitem__(self, indx)
  3249   return None
  3251 if _mask is not nomask:
  3252   # _mask cannot be a subclass, so it tells us whether we should
  3253   # expect a scalar. It also cannot be of dtype object.
-> 3254   mout = _mask[indx]
  3255   scalar_expected = _is_scalar(mout)
  3257 else:
  3258   # attempt to apply the heuristic to avoid constructing a full mask
IndexError: invalid index to scalar variable.
@xiki-tempula xiki-tempula mentioned this issue Jun 1, 2023
@xiki-tempula xiki-tempula linked a pull request Jun 1, 2023 that will close this issue
orbeckst pushed a commit that referenced this issue Jun 1, 2023
- fix #318
- only plot final error estimate in  alchemlyb.visualisation.plot_convergence if it is not NaN

Co-authored-by: Zhiyi Wu <[email protected]>
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

Successfully merging a pull request may close this issue.

1 participant