8000 Regression in 3.4.0rc1 in creating ListedColormap from a set · Issue #19544 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Regression in 3.4.0rc1 in creating ListedColormap from a set #19544
Closed
@mwaskom

Description

@mwaskom

Bug report

Bug summary

Apparently I have some code that creates a ListedColormap object from a set of RGB tuples (I'm not sure why) and this fails on the 3.4.0 release candidate, but didn't previously.

Code for reproduction

import matplotlib as mpl
print(mpl.__version__)
colors = [(0, .5, 1), (1, .2, .5), (.4, 1, .2)]
cmap = mpl.colors.ListedColormap(set(colors))
print(cmap([0, .5, 1]))

Actual outcome

3.4.0rc1
Traceback (most recent call last):
  File "mpl_debug.py", line 5, in <module>
    print(cmap([0, .5, 1]))
  File "/Users/mwaskom/miniconda3/envs/mpl34_test/lib/python3.8/site-packages/matplotlib/colors.py", line 598, in __call__
    self._init()
  File "/Users/mwaskom/miniconda3/envs/mpl34_test/lib/python3.8/site-packages/matplotlib/colors.py", line 1036, in _init
    self._lut[:-3] = to_rgba_array(self.colors)
  File "/Users/mwaskom/miniconda3/envs/mpl34_test/lib/python3.8/site-packages/matplotlib/colors.py", line 369, in to_rgba_array
    rgba = np.column_stack([c, np.ones(len(c))])
  File "<__array_function__ internals>", line 5, in column_stack
  File "/Users/mwaskom/miniconda3/envs/mpl34_test/lib/python3.8/site-packages/numpy/lib/shape_base.py", line 656, in column_stack
    return _nx.concatenate(arrays, 1)
  File "<__array_function__ internals>", line 5, in concatenate
ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 0, the array at index 0 has size 1 and the array at index 1 has size 3

Expected outcome

3.3.2
[[1.  0.2 0.5 1. ]
 [0.4 1.  0.2 1. ]
 [0.  0.5 1.  1. ]]

Matplotlib version

  • Operating system: macos
  • Matplotlib version (import matplotlib; print(matplotlib.__version__)): 3.4.0.rc1
  • Matplotlib backend (print(matplotlib.get_backend())): macosx
  • Python version: 3.8.x
  • Jupyter version (if applicable): na
  • Other libraries:

Installed the release candidate by pointing pip at the tarball on the github releases page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0