Skip to content

Commit 038e805

Browse files
authored
Merge pull request #24929 from anntzer/cs
Small unrelated cleanups/style fixes.
2 parents e0dc18d + 6264d81 commit 038e805

File tree

3 files changed

+14
-32
lines changed

3 files changed

+14
-32
lines changed

lib/matplotlib/cbook.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
"""
22
A collection of utility functions and classes. Originally, many
33
(but not all) were from the Python Cookbook -- hence the name cbook.
4-
5-
This module is safe to import from anywhere within Matplotlib;
6-
it imports Matplotlib only at runtime.
74
"""
85

96
import collections
@@ -853,21 +850,11 @@ def get_siblings(self, a):
853850
class GrouperView:
854851
"""Immutable view over a `.Grouper`."""
855852

856-
def __init__(self, grouper):
857-
self._grouper = grouper
858-
859-
class _GrouperMethodForwarder:
860-
def __set_name__(self, owner, name):
861-
wrapped = getattr(Grouper, name)
862-
forwarder = functools.wraps(wrapped)(
863-
lambda self, *args, **kwargs: wrapped(
864-
self._grouper, *args, **kwargs))
865-
setattr(owner, name, forwarder)
866-
867-
__contains__ = _GrouperMethodForwarder()
868-
__iter__ = _GrouperMethodForwarder()
869-
joined = _GrouperMethodForwarder()
870-
get_siblings = _GrouperMethodForwarder()
853+
def __init__(self, grouper): self._grouper = grouper
854+
def __contains__(self, item): return item in self._grouper
855+
def __iter__(self): return iter(self._grouper)
856+
def joined(self, a, b): return self._grouper.joined(a, b)
857+
def get_siblings(self, a): return self._grouper.get_siblings(a)
871858

872859

873860
def simple_linear_interpolation(a, steps):

lib/mpl_toolkits/axes_grid1/inset_locator.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,9 @@ def __init__(self, bbox1, bbox2, loc1, loc2=None, **kwargs):
218218
raise ValueError("transform should not be set")
219219

220220
kwargs["transform"] = IdentityTransform()
221-
if 'fill' in kwargs:
222-
super().__init__(**kwargs)
223-
else:
224-
fill = bool({'fc', 'facecolor', 'color'}.intersection(kwargs))
225-
super().__init__(fill=fill, **kwargs)
221+
kwargs.setdefault(
222+
"fill", bool({'fc', 'facecolor', 'color'}.intersection(kwargs)))
223+
super().__init__(**kwargs)
226224
self.bbox1 = bbox1
227225
self.bbox2 = bbox2
228226
self.loc1 = loc1

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -884,16 +884,13 @@ def get_proj(self):
884884
# Look into the middle of the world coordinates:
885885
R = 0.5 * box_aspect
886886

887-
# elev stores the elevation angle in the z plane
888-
# azim stores the azimuth angle in the x,y plane
889-
elev_rad = np.deg2rad(art3d._norm_angle(self.elev))
890-
azim_rad = np.deg2rad(art3d._norm_angle(self.azim))
891-
887+
# elev: elevation angle in the z plane.
888+
# azim: azimuth angle in the xy plane.
892889
# Coordinates for a point that rotates around the box of data.
893-
# p0, p1 corresponds to rotating the box only around the
894-
# vertical axis.
895-
# p2 corresponds to rotating the box only around the horizontal
896-
# axis.
890+
# p0, p1 corresponds to rotating the box only around the vertical axis.
891+
# p2 corresponds to rotating the box only around the horizontal axis.
892+
elev_rad = np.deg2rad(self.elev)
893+
azim_rad = np.deg2rad(self.azim)
897894
p0 = np.cos(elev_rad) * np.cos(azim_rad)
898895
p1 = np.cos(elev_rad) * np.sin(azim_rad)
899896
p2 = np.sin(elev_rad)

0 commit comments

Comments
 (0)