Skip to content

Cannot display np.array with dtype = np.float128 #8445

Closed
@jachymb

Description

@jachymb
>>> a = np.zeros((10,10), dtype=np.float128)
>>> a.dtype
dtype('float128')
>>> plt.matshow(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/site-packages/matplotlib/pyplot.py", line 2358, in matshow
    im = ax.matshow(A, **kw)
  File "/usr/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 7389, in matshow
    im = self.imshow(Z, **kw)
  File "/usr/lib/python3.6/site-packages/matplotlib/__init__.py", line 1892, in inner
    return func(ax, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 5118, in imshow
    im.set_data(X)
  File "/usr/lib/python3.6/site-packages/matplotlib/image.py", line 545, in set_data
    raise TypeError("Image data can not convert to float")
TypeError: Image data can not convert to float
>>> plt.matshow(np.array(a, dtype=np.float64))
<matplotlib.image.AxesImage object at 0x7fad7046b400>

I think it should be possible to matshow/imshow matrices of dtype=float128. If there is some technical reason why it can't or shouldn't, at least the error message could be more relevant. Telling the user that float128 can't be converted to float is pretty confusing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions