Elffuss BraidHub

kikocis/auto-code-rover public

main · 1.8 KiBRawPermalink
1[Bug]: scalar mappable format_cursor_data crashes on BoundarNorm
2### Bug summary
3
4In 3.5.0 if you do:
5
6```python
7import matplotlib.pyplot as plt
8import numpy as np
9import matplotlib as mpl
10
11fig, ax = plt.subplots()
12norm = mpl.colors.BoundaryNorm(np.linspace(-4, 4, 5), 256)
13X = np.random.randn(10, 10)
14pc = ax.imshow(X, cmap='RdBu_r', norm=norm)
15```
16
17and mouse over the image, it crashes with
18
19```
20File "/Users/jklymak/matplotlib/lib/matplotlib/artist.py", line 1282, in format_cursor_data
21 neighbors = self.norm.inverse(
22 File "/Users/jklymak/matplotlib/lib/matplotlib/colors.py", line 1829, in inverse
23 raise ValueError("BoundaryNorm is not invertible")
24ValueError: BoundaryNorm is not invertible
25```
26
27and interaction stops.
28
29Not sure if we should have a special check here, a try-except, or actually just make BoundaryNorm approximately invertible.
30
31
32### Matplotlib Version
33
34main 3.5.0
35
36
37[Bug]: scalar mappable format_cursor_data crashes on BoundarNorm
38### Bug summary
39
40In 3.5.0 if you do:
41
42```python
43import matplotlib.pyplot as plt
44import numpy as np
45import matplotlib as mpl
46
47fig, ax = plt.subplots()
48norm = mpl.colors.BoundaryNorm(np.linspace(-4, 4, 5), 256)
49X = np.random.randn(10, 10)
50pc = ax.imshow(X, cmap='RdBu_r', norm=norm)
51```
52
53and mouse over the image, it crashes with
54
55```
56File "/Users/jklymak/matplotlib/lib/matplotlib/artist.py", line 1282, in format_cursor_data
57 neighbors = self.norm.inverse(
58 File "/Users/jklymak/matplotlib/lib/matplotlib/colors.py", line 1829, in inverse
59 raise ValueError("BoundaryNorm is not invertible")
60ValueError: BoundaryNorm is not invertible
61```
62
63and interaction stops.
64
65Not sure if we should have a special check here, a try-except, or actually just make BoundaryNorm approximately invertible.
66
67
68### Matplotlib Version
69
70main 3.5.0
71
72