Skip to content

Commit

Permalink
Merge pull request #2922 from ericpre/tidy_up_range_widget
Browse files Browse the repository at this point in the history
Fixes for matplotlib 3.5 and simplify maintenance of `RangeWidget`
  • Loading branch information
jlaehne committed Apr 14, 2022
2 parents a3e249a + 7244e87 commit 0469916
Show file tree
Hide file tree
Showing 220 changed files with 1,452 additions and 900 deletions.
5 changes: 2 additions & 3 deletions conda_environment_dev.yml
Expand Up @@ -3,12 +3,11 @@ channels:
- conda-forge
dependencies:
# We pin freetype and matplotlib for the image comparison
- freetype=2.9
- matplotlib-base=3.1.3
- freetype=2.10
- matplotlib-base=3.5.1
- cython
- pytest
- pytest-mpl
- pytest-xdist
- pytest-rerunfailures
- pytest-instafail

4 changes: 2 additions & 2 deletions hyperspy/_signals/signal1d.py
Expand Up @@ -844,9 +844,9 @@ def integrate_in_range(self, signal_range='interactive',
"instead.")
deprecation_warning(msg)

if signal_range == 'interactive':
if signal_range == 'interactive': # pragma: no cover
self_copy = self.deepcopy()
ia = IntegrateArea(self_copy, signal_range)
ia = IntegrateArea(self_copy)
ia.gui(display=display, toolkit=toolkit)
integrated_signal1D = self_copy
else:
Expand Down
8 changes: 4 additions & 4 deletions hyperspy/drawing/_widgets/circle.py
Expand Up @@ -106,15 +106,15 @@ def _set_patch(self):
super(CircleWidget, self)._set_patch()
xy = self._get_patch_xy()
ro, ri = self.size
self.patch = [plt.Circle(
self._patch = [plt.Circle(
xy, radius=ro,
fill=False,
lw=self.border_thickness,
ec=self.color,
alpha=self.alpha,
picker=True,)]
if ri > 0:
self.patch.append(
self._patch.append(
plt.Circle(
xy, radius=ri,
fill=False,
Expand Down Expand Up @@ -156,8 +156,8 @@ def _update_patch_size(self):
if len(self.patch) == 1:
# Need to remove the previous patch before using
# `_add_patch_to`
self.ax.artists.remove(self.patch[0])
self.patch = []
self._patch[0].remove()
self._patch = []
self._add_patch_to(self.ax)
self.patch[1].radius = ri
self._update_resizers()
Expand Down
2 changes: 1 addition & 1 deletion hyperspy/drawing/_widgets/horizontal_line.py
Expand Up @@ -34,7 +34,7 @@ def _update_patch_position(self):
def _set_patch(self):
ax = self.ax
kwargs = picker_kwargs(preferences.Plot.pick_tolerance)
self.patch = [ax.axhline(
self._patch = [ax.axhline(
self._pos[0],
color=self.color,
alpha=self.alpha,
Expand Down
2 changes: 1 addition & 1 deletion hyperspy/drawing/_widgets/label.py
Expand Up @@ -93,7 +93,7 @@ def _set_patch(self):
ax = self.ax
trans = transforms.blended_transform_factory(
ax.transData, ax.transAxes)
self.patch = [ax.text(
self._patch = [ax.text(
self._pos[0],
self._pos[1],
self.string,
Expand Down
6 changes: 3 additions & 3 deletions hyperspy/drawing/_widgets/line2d.py
Expand Up @@ -268,7 +268,7 @@ def _set_patch(self):
max_r = max(self.radius_move, self.radius_resize,
self.radius_rotate)
kwargs = picker_kwargs(max_r)
self.patch = [plt.Line2D(
self._patch = [plt.Line2D(
xy[:, 0], xy[:, 1],
linestyle='-',
lw=self.linewidth,
Expand Down Expand Up @@ -298,14 +298,14 @@ def _set_size_patch(self):
lw=self.linewidth,
c=self.color,
**kwargs)
self.patch.append(wi)
self._patch.append(wi)
self._width_indicator_patches.append(wi)

def _remove_size_patch(self):
if not self._width_indicator_patches:
return
for patch in self._width_indicator_patches:
self.patch.remove(patch)
self._patch.remove(patch)
patch.remove()
self._width_indicator_patches = []

Expand Down

0 comments on commit 0469916

Please sign in to comment.