Skip to content

Commit

Permalink
Merge pull request #24929 from anntzer/cs
Browse files Browse the repository at this point in the history
Small unrelated cleanups/style fixes.
  • Loading branch information
timhoffm committed Jan 10, 2023
2 parents e0dc18d + 6264d81 commit 038e805
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 32 deletions.
23 changes: 5 additions & 18 deletions lib/matplotlib/cbook.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
"""
A collection of utility functions and classes. Originally, many
(but not all) were from the Python Cookbook -- hence the name cbook.
This module is safe to import from anywhere within Matplotlib;
it imports Matplotlib only at runtime.
"""

import collections
Expand Down Expand Up @@ -853,21 +850,11 @@ def get_siblings(self, a):
class GrouperView:
"""Immutable view over a `.Grouper`."""

def __init__(self, grouper):
self._grouper = grouper

class _GrouperMethodForwarder:
def __set_name__(self, owner, name):
wrapped = getattr(Grouper, name)
forwarder = functools.wraps(wrapped)(
lambda self, *args, **kwargs: wrapped(
self._grouper, *args, **kwargs))
setattr(owner, name, forwarder)

__contains__ = _GrouperMethodForwarder()
__iter__ = _GrouperMethodForwarder()
joined = _GrouperMethodForwarder()
get_siblings = _GrouperMethodForwarder()
def __init__(self, grouper): self._grouper = grouper
def __contains__(self, item): return item in self._grouper
def __iter__(self): return iter(self._grouper)
def joined(self, a, b): return self._grouper.joined(a, b)
def get_siblings(self, a): return self._grouper.get_siblings(a)


def simple_linear_interpolation(a, steps):
Expand Down
8 changes: 3 additions & 5 deletions lib/mpl_toolkits/axes_grid1/inset_locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,9 @@ def __init__(self, bbox1, bbox2, loc1, loc2=None, **kwargs):
raise ValueError("transform should not be set")

kwargs["transform"] = IdentityTransform()
if 'fill' in kwargs:
super().__init__(**kwargs)
else:
fill = bool({'fc', 'facecolor', 'color'}.intersection(kwargs))
super().__init__(fill=fill, **kwargs)
kwargs.setdefault(
"fill", bool({'fc', 'facecolor', 'color'}.intersection(kwargs)))
super().__init__(**kwargs)
self.bbox1 = bbox1
self.bbox2 = bbox2
self.loc1 = loc1
Expand Down
15 changes: 6 additions & 9 deletions lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,16 +884,13 @@ def get_proj(self):
# Look into the middle of the world coordinates:
R = 0.5 * box_aspect

# elev stores the elevation angle in the z plane
# azim stores the azimuth angle in the x,y plane
elev_rad = np.deg2rad(art3d._norm_angle(self.elev))
azim_rad = np.deg2rad(art3d._norm_angle(self.azim))

# elev: elevation angle in the z plane.
# azim: azimuth angle in the xy plane.
# Coordinates for a point that rotates around the box of data.
# p0, p1 corresponds to rotating the box only around the
# vertical axis.
# p2 corresponds to rotating the box only around the horizontal
# axis.
# p0, p1 corresponds to rotating the box only around the vertical axis.
# p2 corresponds to rotating the box only around the horizontal axis.
elev_rad = np.deg2rad(self.elev)
azim_rad = np.deg2rad(self.azim)
p0 = np.cos(elev_rad) * np.cos(azim_rad)
p1 = np.cos(elev_rad) * np.sin(azim_rad)
p2 = np.sin(elev_rad)
Expand Down

0 comments on commit 038e805

Please sign in to comment.