diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 2eb1c7053650..a4e14e04b249 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -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.") @@ -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") diff --git a/lib/matplotlib/backend_tools.py b/lib/matplotlib/backend_tools.py index 27119a5b80dc..77286ff5c6e0 100644 --- a/lib/matplotlib/backend_tools.py +++ b/lib/matplotlib/backend_tools.py @@ -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): @@ -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" @@ -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 @@ -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) diff --git a/lib/matplotlib/colorbar.py b/lib/matplotlib/colorbar.py index aac6179292ed..e4a861e73b37 100644 --- a/lib/matplotlib/colorbar.py +++ b/lib/matplotlib/colorbar.py @@ -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': @@ -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) @@ -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 @@ -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 diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index 3597bf59415d..81075357fe10 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -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] + Convert hsv values to rgb. Parameters ---------- diff --git a/lib/matplotlib/markers.py b/lib/matplotlib/markers.py index 9e0df137c100..470069176c76 100644 --- a/lib/matplotlib/markers.py +++ b/lib/matplotlib/markers.py @@ -222,8 +222,6 @@ class MarkerStyle(object): def __init__(self, marker=None, fillstyle=None): """ - MarkerStyle - Attributes ---------- markers : list of known marks diff --git a/lib/matplotlib/textpath.py b/lib/matplotlib/textpath.py index df4b520e7846..7bf44164f389 100644 --- a/lib/matplotlib/textpath.py +++ b/lib/matplotlib/textpath.py @@ -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): @@ -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 @@ -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() @@ -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() @@ -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: @@ -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 @@ -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( @@ -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)