Skip to content

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

@xiki-tempula

Description

@xiki-tempula

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions