Skip to content

Capitalize some docstrings. #13108

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from all 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 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@


def compare_versions(a, b):
"return True if a is greater than or equal to b"
"Return whether version *a* is greater than or equal to version *b*."
if isinstance(a, bytes):
cbook.warn_deprecated(
"3.0", message="compare_versions arguments should be strs.")
Expand Down Expand Up @@ -1450,7 +1450,7 @@ def _init_tests():

def test(verbosity=None, coverage=False, switch_backend_warn=True,
recursionlimit=0, **kwargs):
"""run the matplotlib test suite"""
"""Run the matplotlib test suite."""
_init_tests()
if not os.path.isdir(os.path.join(os.path.dirname(__file__), 'tests')):
raise ImportError("Matplotlib test data is not installed")
Expand Down
11 changes: 5 additions & 6 deletions lib/matplotlib/backend_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,16 +271,15 @@ def _tool_trigger_cbk(self, event):
self._set_cursor_cbk(event.canvasevent)

def _add_tool(self, tool):
"""set the cursor when the tool is triggered"""
"""Set the cursor when the tool is triggered."""
if getattr(tool, 'cursor', None) is not None:
self.toolmanager.toolmanager_connect('tool_trigger_%s' % tool.name,
self._tool_trigger_cbk)

def _add_tool_cbk(self, event):
"""Process every newly added tool"""
"""Process every newly added tool."""
if event.tool is self:
return

self._add_tool(event.tool)

def _set_cursor_cbk(self, event):
Expand Down Expand Up @@ -853,7 +852,7 @@ def _cancel_action(self):
return

def _press(self, event):
"""the _press mouse button in zoom to rect mode callback"""
"""Callback for mouse button presses in zoom-to-rectangle mode."""

# If we're already in the middle of a zoom, pressing another
# button works to "cancel"
Expand Down Expand Up @@ -895,7 +894,7 @@ def _switch_off_zoom_mode(self, event):
self._mouse_move(event)

def _mouse_move(self, event):
"""the drag callback in zoom mode"""
"""Callback for mouse moves in zoom-to-rectangle mode."""

if self._xypress:
x, y = event.x, event.y
Expand All @@ -910,7 +909,7 @@ def _mouse_move(self, event):
'rubberband', self, data=(x1, y1, x2, y2))

def _release(self, event):
"""the release mouse button callback in zoom to rect mode"""
"""Callback for mouse button releases in zoom-to-rectangle mode."""

for zoom_id in self._ids_zoom:
self.figure.canvas.mpl_disconnect(zoom_id)
Expand Down
23 changes: 13 additions & 10 deletions lib/matplotlib/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ def set_ticks(self, ticks, update_ticks=True):
self.stale = True

def get_ticks(self, minor=False):
"""Return the x ticks as a list of locations"""
"""Return the x ticks as a list of locations."""
if self._manual_tick_data_values is None:
ax = self.ax
if self.orientation == 'vertical':
Expand All @@ -584,9 +584,10 @@ def get_ticks(self, minor=False):

def set_ticklabels(self, ticklabels, update_ticks=True):
"""
set tick labels. Tick labels are updated immediately unless
update_ticks is *False*. To manually update the ticks, call
*update_ticks* method explicitly.
Set tick labels.

Tick labels are updated immediately unless *update_ticks* is *False*,
in which case one should call `.update_ticks` explicitly.
"""
if isinstance(self.locator, ticker.FixedLocator):
self.formatter = ticker.FixedFormatter(ticklabels)
Expand Down Expand Up @@ -864,7 +865,7 @@ def _find_range(self):
self.vmax = b[-1]

def _central_N(self):
'''number of boundaries **before** extension of ends'''
"""Return the number of boundaries excluding end extensions."""
nb = len(self._boundaries)
if self.extend == 'both':
nb -= 2
Expand Down Expand Up @@ -1128,11 +1129,13 @@ def add_lines(self, CS, erase=True):
erase=erase)

def update_normal(self, mappable):
'''
update solid, lines, etc. Unlike update_bruteforce, it does
not clear the axes. This is meant to be called when the image
or contour plot to which this colorbar belongs is changed.
'''
"""
Update solid patches, lines, etc.

Unlike `.update_bruteforce`, this does not clear the axes. This is
meant to be called when the image or contour plot to which this
colorbar belongs changes.
"""
self.draw_all()
if isinstance(self.mappable, contour.ContourSet):
CS = self.mappable
Expand Down
3 changes: 1 addition & 2 deletions lib/matplotlib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1356,8 +1356,7 @@ def rgb_to_hsv(arr):

def hsv_to_rgb(hsv):
"""
convert hsv values in a numpy array to rgb values
all values assumed to be in range [0, 1]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same point is documented two lines below

Convert hsv values to rgb.

Parameters
----------
Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,6 @@ class MarkerStyle(object):

def __init__(self, marker=None, fillstyle=None):
"""
MarkerStyle

Attributes
----------
markers : list of known marks
Expand Down
50 changes: 17 additions & 33 deletions lib/matplotlib/textpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ def tex_font_map(self):

def _get_font(self, prop):
"""
find a ttf font.
Find the `FT2Font` matching font properties *prop*, with its size set.
"""
fname = font_manager.findfont(prop)
font = get_font(fname)
font.set_size(self.FONT_SCALE, self.DPI)

return font

def _get_hinting_flag(self):
Expand All @@ -71,9 +70,7 @@ def _get_char_id_ps(self, font, ccode):
"3.1",
alternative="font.get_path() and manual translation of the vertices")
def glyph_to_path(self, font, currx=0.):
"""
convert the ft2font glyph to vertices and codes.
"""
"""Convert the *font*'s current glyph to a (vertices, codes) pair."""
verts, codes = font.get_path()
if currx != 0.0:
verts[:, 0] += currx
Expand Down Expand Up @@ -240,8 +237,7 @@ def get_glyphs_with_font(self, font, s, glyph_map=None,
def get_glyphs_mathtext(self, prop, s, glyph_map=None,
return_new_glyphs_only=False):
"""
convert the string *s* to vertices and codes by parsing it with
mathtext.
Parse mathtext string *s* and convert it to a (vertices, codes) pair.
"""

prop = prop.copy()
Expand Down Expand Up @@ -290,9 +286,7 @@ def get_glyphs_mathtext(self, prop, s, glyph_map=None,
glyph_map_new, myrects)

def get_texmanager(self):
"""
return the :class:`matplotlib.texmanager.TexManager` instance
"""
"""Return the cached `~.texmanager.TexManager` instance."""
if self._texmanager is None:
from matplotlib.texmanager import TexManager
self._texmanager = TexManager()
Expand All @@ -301,11 +295,11 @@ def get_texmanager(self):
def get_glyphs_tex(self, prop, s, glyph_map=None,
return_new_glyphs_only=False):
"""
convert the string *s* to vertices and codes using matplotlib's usetex
mode.
Process string *s* with usetex and convert it to a (vertices, codes)
pair.
"""

# codes are modstly borrowed from pdf backend.
# Implementation mostly borrowed from pdf backend.

dvifile = self.get_texmanager().make_dvi(s, self.FONT_SCALE)
with dviread.Dvi(dvifile, self.DPI) as dvi:
Expand Down Expand Up @@ -479,16 +473,12 @@ def __init__(self, xy, s, size=None, prop=None,
self._interpolation_steps = _interpolation_steps

def set_size(self, size):
"""
set the size of the text
"""
"""Set the text size."""
self._size = size
self._invalid = True

def get_size(self):
"""
get the size of the text
"""
"""Get the text size."""
return self._size

@property
Expand All @@ -508,12 +498,10 @@ def codes(self):

def _revalidate_path(self):
"""
update the path if necessary.

The path for the text is initially create with the font size
of FONT_SCALE, and this path is rescaled to other size when
necessary.
Update the path if necessary.

The path for the text is initially create with the font size of
`~.FONT_SCALE`, and this path is rescaled to other size when necessary.
"""
if self._invalid or self._cached_vertices is None:
tr = Affine2D().scale(
Expand Down Expand Up @@ -543,16 +531,12 @@ def is_math_text(self, s):

def text_get_vertices_codes(self, prop, s, usetex):
"""
convert the string *s* to vertices and codes using the
provided font property *prop*. Mostly copied from
backend_svg.py.
Convert string *s* to a (vertices, codes) pair using font property
*prop*.
"""

# Mostly copied from backend_svg.py.
if usetex:
verts, codes = text_to_path.get_text_path(prop, s, usetex=True)
return text_to_path.get_text_path(prop, s, usetex=True)
else:
clean_line, ismath = self.is_math_text(s)
verts, codes = text_to_path.get_text_path(prop, clean_line,
ismath=ismath)

return verts, codes
return text_to_path.get_text_path(prop, clean_line, ismath=ismath)