Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Super-ify parts of the code base, part 2#18043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
dopplershift merged 5 commits intomatplotlib:masterfromQuLogic:super2
Jul 25, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletionsdoc/devel/contributing.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -409,7 +409,7 @@ function is a simple pass-through to

# in pylab.py
def text(*args, **kwargs):
ret =gca().text(*args, **kwargs)
ret = gca().text(*args, **kwargs)
draw_if_interactive()
return ret

Expand All@@ -427,7 +427,7 @@ illustration) just passes them on to the

# in text.py
def __init__(self, x=0, y=0, text='', **kwargs):
Artist.__init__(self)
super().__init__()
self.update(kwargs)

``update`` does the work looking for methods named like
Expand Down
12 changes: 6 additions & 6 deletionsexamples/text_labels_and_annotations/line_with_text.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,35 +17,35 @@ class MyLine(lines.Line2D):
def __init__(self, *args, **kwargs):
# we'll update the position when the line data is set
self.text = mtext.Text(0, 0, '')
lines.Line2D.__init__(self,*args, **kwargs)
super().__init__(*args, **kwargs)

# we can't access the label attr until *after* the line is
# initiated
self.text.set_text(self.get_label())

def set_figure(self, figure):
self.text.set_figure(figure)
lines.Line2D.set_figure(self,figure)
super().set_figure(figure)

def set_axes(self, axes):
self.text.set_axes(axes)
lines.Line2D.set_axes(self,axes)
super().set_axes(axes)

def set_transform(self, transform):
# 2 pixel offset
texttrans = transform + mtransforms.Affine2D().translate(2, 2)
self.text.set_transform(texttrans)
lines.Line2D.set_transform(self,transform)
super().set_transform(transform)

def set_data(self, x, y):
if len(x):
self.text.set_position((x[-1], y[-1]))

lines.Line2D.set_data(self,x, y)
super().set_data(x, y)

def draw(self, renderer):
# draw my label at the end of the line with 2 pixel offset
lines.Line2D.draw(self,renderer)
super().draw(renderer)
self.text.draw(renderer)

# Fixing random state for reproducibility
Expand Down
2 changes: 1 addition & 1 deletionexamples/userdemo/colormap_normalizations.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -94,7 +94,7 @@
class MidpointNormalize(colors.Normalize):
def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False):
self.midpoint = midpoint
colors.Normalize.__init__(self,vmin, vmax, clip)
super().__init__(vmin, vmax, clip)

def __call__(self, value, clip=None):
# I'm ignoring masked values and all kinds of edge cases to make a
Expand Down
11 changes: 5 additions & 6 deletionslib/matplotlib/colorbar.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1218,15 +1218,15 @@ def __init__(self, ax, mappable, **kwargs):
)
kwargs.setdefault(
'ticks', ticker.FixedLocator(cs.levels, nbins=10))
ColorbarBase.__init__(self,ax, **kwargs)
super().__init__(ax, **kwargs)
if not cs.filled:
self.add_lines(cs)
else:
if getattr(mappable.cmap, 'colorbar_extend', False) is not False:
kwargs.setdefault('extend', mappable.cmap.colorbar_extend)
if isinstance(mappable, martist.Artist):
_add_disjoint_kwargs(kwargs, alpha=mappable.get_alpha())
ColorbarBase.__init__(self,ax, **kwargs)
super().__init__(ax, **kwargs)

@cbook.deprecated("3.3", alternative="update_normal")
def on_mappable_changed(self, mappable):
Expand DownExpand Up@@ -1256,8 +1256,7 @@ def add_lines(self, CS, erase=True):
tcolors = [c[0] for c in CS.tcolors]
tlinewidths = [t[0] for t in CS.tlinewidths]
# Wishlist: Make colorbar lines auto-follow changes in contour lines.
ColorbarBase.add_lines(self, CS.levels, tcolors, tlinewidths,
erase=erase)
super().add_lines(CS.levels, tcolors, tlinewidths, erase=erase)

def update_normal(self, mappable):
"""
Expand DownExpand Up@@ -1338,7 +1337,7 @@ def remove(self):
If the colorbar was created with ``use_gridspec=True`` the previous
gridspec is restored.
"""
ColorbarBase.remove(self)
super().remove()
self.mappable.callbacksSM.disconnect(self.mappable.colorbar_cid)
self.mappable.colorbar = None
self.mappable.colorbar_cid = None
Expand DownExpand Up@@ -1606,7 +1605,7 @@ def __init__(self, ax, mappable, **kw):
# so add a new attribute which will be a list of the
# colored patches in the colorbar
self.solids_patches = []
Colorbar.__init__(self,ax, mappable, **kw)
super().__init__(ax, mappable, **kw)

def _add_solids(self, X, Y, C):
"""
Expand Down
6 changes: 3 additions & 3 deletionslib/matplotlib/colors.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -782,7 +782,7 @@ def __init__(self, name, segmentdata, N=256, gamma=1.0):
"""
# True only if all colors in map are identical; needed for contouring.
self.monochrome = False
Colormap.__init__(self,name, N)
super().__init__(name, N)
self._segmentdata = segmentdata
self._gamma = gamma

Expand DownExpand Up@@ -940,7 +940,7 @@ def __init__(self, colors, name='from_list', N=None):
else:
self.colors = [gray] * N
self.monochrome = True
Colormap.__init__(self,name, N)
super().__init__(name, N)

def _init(self):
self._lut = np.zeros((self.N + 3, 4), float)
Expand DownExpand Up@@ -1335,7 +1335,7 @@ class PowerNorm(Normalize):
a power-law normalization over that range.
"""
def __init__(self, gamma, vmin=None, vmax=None, clip=False):
Normalize.__init__(self,vmin, vmax, clip)
super().__init__(vmin, vmax, clip)
self.gamma = gamma

def __call__(self, value, clip=None):
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/contour.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -42,7 +42,7 @@ class ClabelText(text.Text):

def get_rotation(self):
new_angle, = self.get_transform().transform_angles(
[text.Text.get_rotation(self)], [self.get_position()])
[super().get_rotation()], [self.get_position()])
return new_angle


Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/dviread.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -629,7 +629,7 @@ class Vf(Dvi):
"""

def __init__(self, filename):
Dvi.__init__(self,filename, 0)
super().__init__(filename, 0)
try:
self._first_font = None
self._chars = {}
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/legend.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -365,7 +365,7 @@ def __init__(self, parent, handles, labels,
from matplotlib.axes import Axes
from matplotlib.figure import Figure

Artist.__init__(self)
super().__init__()

if prop is None:
if fontsize is not None:
Expand Down
22 changes: 9 additions & 13 deletionslib/matplotlib/legend_handler.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -147,7 +147,7 @@ def __init__(self, marker_pad=0.3, numpoints=None, **kw):
-----
Any other keyword arguments are given to `HandlerBase`.
"""
HandlerBase.__init__(self,**kw)
super().__init__(**kw)

self._numpoints = numpoints
self._marker_pad = marker_pad
Expand DownExpand Up@@ -193,7 +193,7 @@ def __init__(self, numpoints=None, yoffsets=None, **kw):
-----
Any other keyword arguments are given to `HandlerNpoints`.
"""
HandlerNpoints.__init__(self,numpoints=numpoints, **kw)
super().__init__(numpoints=numpoints, **kw)
self._yoffsets = yoffsets

def get_ydata(self, legend, xdescent, ydescent, width, height, fontsize):
Expand DownExpand Up@@ -223,8 +223,7 @@ def __init__(self, marker_pad=0.3, numpoints=None, **kw):
-----
Any other keyword arguments are given to `HandlerNpoints`.
"""
HandlerNpoints.__init__(self, marker_pad=marker_pad,
numpoints=numpoints, **kw)
super().__init__(marker_pad=marker_pad, numpoints=numpoints, **kw)

def create_artists(self, legend, orig_handle,
xdescent, ydescent, width, height, fontsize,
Expand DownExpand Up@@ -280,7 +279,7 @@ def patch_func(legend=legend, orig_handle=orig_handle,
-----
Any other keyword arguments are given to `HandlerBase`.
"""
HandlerBase.__init__(self,**kw)
super().__init__(**kw)
self._patch_func = patch_func

def _create_patch(self, legend, orig_handle,
Expand DownExpand Up@@ -339,7 +338,7 @@ class HandlerRegularPolyCollection(HandlerNpointsYoffsets):
r"""Handler for `.RegularPolyCollection`\s."""

def __init__(self, yoffsets=None, sizes=None, **kw):
HandlerNpointsYoffsets.__init__(self,yoffsets=yoffsets, **kw)
super().__init__(yoffsets=yoffsets, **kw)

self._sizes = sizes

Expand DownExpand Up@@ -439,8 +438,7 @@ def __init__(self, xerr_size=0.5, yerr_size=None,
self._xerr_size = xerr_size
self._yerr_size = yerr_size

HandlerLine2D.__init__(self, marker_pad=marker_pad,
numpoints=numpoints, **kw)
super().__init__(marker_pad=marker_pad, numpoints=numpoints, **kw)

def get_err_size(self, legend, xdescent, ydescent,
width, height, fontsize):
Expand DownExpand Up@@ -564,10 +562,8 @@ def __init__(self, marker_pad=0.3, numpoints=None,
Any other keyword arguments are given to `HandlerNpointsYoffsets`.
"""

HandlerNpointsYoffsets.__init__(self, marker_pad=marker_pad,
numpoints=numpoints,
yoffsets=yoffsets,
**kw)
super().__init__(marker_pad=marker_pad, numpoints=numpoints,
yoffsets=yoffsets, **kw)
self._bottom = bottom

def get_ydata(self, legend, xdescent, ydescent, width, height, fontsize):
Expand DownExpand Up@@ -652,7 +648,7 @@ class HandlerTuple(HandlerBase):
def __init__(self, ndivide=1, pad=None, **kwargs):
self._ndivide = ndivide
self._pad = pad
HandlerBase.__init__(self,**kwargs)
super().__init__(**kwargs)

def create_artists(self, legend, orig_handle,
xdescent, ydescent, width, height, fontsize,
Expand Down
6 changes: 3 additions & 3 deletionslib/matplotlib/lines.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -300,7 +300,7 @@ def __init__(self, xdata, ydata,
:meth:`set_drawstyle` for a description of the draw styles.

"""
Artist.__init__(self)
super().__init__()

#convert sequences to numpy arrays
if not np.iterable(xdata):
Expand DownExpand Up@@ -721,7 +721,7 @@ def set_transform(self, t):
----------
t : `matplotlib.transforms.Transform`
"""
Artist.set_transform(self,t)
super().set_transform(t)
self._invalidx = True
self._invalidy = True
self.stale = True
Expand DownExpand Up@@ -1276,7 +1276,7 @@ def set_dashes(self, seq):

def update_from(self, other):
"""Copy properties from *other* to self."""
Artist.update_from(self,other)
super().update_from(other)
self._linestyle = other._linestyle
self._linewidth = other._linewidth
self._color = other._color
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp