proplot-dev / proplot

🎨 A succinct matplotlib wrapper for making beautiful, publication-quality graphics
https://proplot.readthedocs.io
MIT License
1.07k stars 96 forks source link

bug: error with the latest dev version AttributeError: 'list' object has no attribute 'dtype' #411

Closed syrte closed 1 year ago

syrte commented 1 year ago

Got error with the latest dev version:

fig, ax = pplt.subplot()
ax.plot(np.arange(10))

Traceback

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_109695/309448141.py in <module>
      1 fig, ax = pplt.subplot()
----> 2 ax.plot(np.arange(10))

~/local/conda/envs/nemo/lib/python3.8/site-packages/proplot/internals/inputs.py in _preprocess_or_redirect(self, *args, **kwargs)
    292 
    293                 # Call main function
--> 294                 return func(self, *args, **kwargs)  # call unbound method
    295 
    296         return _preprocess_or_redirect

~/local/conda/envs/nemo/lib/python3.8/site-packages/proplot/axes/plot.py in plot(self, *args, **kwargs)
   2899         """
   2900         kwargs = _parse_vert(default_vert=True, **kwargs)
-> 2901         return self._apply_plot(*args, **kwargs)
   2902 
   2903     @inputs._preprocess_or_redirect('y', 'x', allow_extra=True)

~/local/conda/envs/nemo/lib/python3.8/site-packages/proplot/axes/plot.py in _apply_plot(self, vert, *pairs, **kwargs)
   2858             ys, kw = inputs._dist_reduce(ys, **kw)
   2859             guide_kw = _pop_params(kw, self._update_guide)  # after standardize
-> 2860             for _, n, x, y, kw in self._iter_arg_cols(xs, ys, **kw):
   2861                 kw = self._parse_cycle(n, **kw)
   2862                 *eb, kw = self._add_error_bars(x, y, vert=vert, default_barstds=True, **kw)  # noqa: E501

~/local/conda/envs/nemo/lib/python3.8/site-packages/proplot/axes/plot.py in _iter_arg_cols(self, label, labels, values, *args, **kwargs)
   4216             labels = [
   4217                 str(_not_none(label, ''))
-> 4218                 for label in inputs._to_numpy_array(labels)
   4219             ]
   4220         else:

~/local/conda/envs/nemo/lib/python3.8/site-packages/proplot/internals/inputs.py in _to_numpy_array(data, strip_units)
    131     elif isinstance(data, (DataFrame, Series, Index)):
    132         data = data.values
--> 133     if data.dtype == bool:
    134         data = data.view(np.uint8)
    135     if Quantity is not ndarray and isinstance(data, Quantity):

AttributeError: 'list' object has no attribute 'dtype'

debug

> ~/local/conda/envs/nemo/lib/python3.8/site-packages/proplot/internals/inputs.py(133)_to_numpy_array()
    131     elif isinstance(data, (DataFrame, Series, Index)):
    132         data = data.values
--> 133     if data.dtype == bool:
    134         data = data.view(np.uint8)
    135     if Quantity is not ndarray and isinstance(data, Quantity):

ipdb> p data
[None]

The error seems related to this PR https://github.com/proplot-dev/proplot/pull/410.

syrte commented 1 year ago

It works if I remove the two lines introduced in PR https://github.com/proplot-dev/proplot/pull/410 Not sure if it is related to my specific configuration. Let's see if there are others who met this problem as well.

scottstanie commented 1 year ago

Yes you're right, sorry about that. It is from that PR since I didn't test a wide variety of inputs in my quick fix. I'll try and add something to avoid the bad dtype check, but I'm open to people's ideas about robustly checking for it

lukelbd commented 1 year ago

Thanks for the report -- not your fault @scottstanie. That was a very sloppy approval on my part. Should have been more careful in the review, and travis CI should have caught it when you created the PR anyway. Seems proplot is out of credits again, and the CI webhook is not functioning (red triangle in screenshot); have just contacted Travis to replenish credits.

Screenshot 2023-03-25 at 18 11 42

Eventually I need to switch to github actions, as travis has unfortunately become very unreliable / hostile to open source projects. I am also planning to improve the CI testing -- currently I simply have travis CI compile the documentation examples, but I have a full testing suite based on pytest-mpl uncommitted on my machine that I am planning to add to the CI workflow this spring (#413). PRs / community contributions should then be much simpler / safer.