| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,6 @@ | |||
| 1 | 1 | """ | |
| 2 | 2 | Configuration for the order of gallery sections and examples. | |
| 3 | 3 | Paths are relative to the conf.py file. | |
| 4 | - | ||
| 5 | 4 | """ | |
| 6 | 5 | ||
| 7 | 6 | from sphinx_gallery.sorting import ExplicitOrder | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,7 @@ | |||
| 3 | 3 | Tricontour Smooth Delaunay | |
| 4 | 4 | ========================== | |
| 5 | 5 | ||
| 6 | - Demonstrates high-resolution tricontouring of a random set of points ; | ||
| 6 | + Demonstrates high-resolution tricontouring of a random set of points; | ||
| 7 | 7 | a `matplotlib.tri.TriAnalyzer` is used to improve the plot quality. | |
| 8 | 8 | ||
| 9 | 9 | The initial data points and triangular grid for this demo are: | |
@@ -34,14 +34,14 @@ | |||
| 34 | 34 | # Analytical test function | |
| 35 | 35 | #----------------------------------------------------------------------------- | |
| 36 | 36 | def experiment_res(x, y): | |
| 37 | - """ An analytic function representing experiment results """ | ||
| 38 | - x = 2. * x | ||
| 37 | + """An analytic function representing experiment results.""" | ||
| 38 | + x = 2 * x | ||
| 39 | 39 | r1 = np.sqrt((0.5 - x)**2 + (0.5 - y)**2) | |
| 40 | 40 | theta1 = np.arctan2(0.5 - x, 0.5 - y) | |
| 41 | 41 | r2 = np.sqrt((-x - 0.2)**2 + (-y - 0.2)**2) | |
| 42 | 42 | theta2 = np.arctan2(-x - 0.2, -y - 0.2) | |
| 43 | - z = (4 * (np.exp((r1 / 10)**2) - 1) * 30. * np.cos(3 * theta1) + | ||
| 44 | - (np.exp((r2 / 10)**2) - 1) * 30. * np.cos(5 * theta2) + | ||
| 43 | + z = (4 * (np.exp((r1/10)**2) - 1) * 30 * np.cos(3 * theta1) + | ||
| 44 | + (np.exp((r2/10)**2) - 1) * 30 * np.cos(5 * theta2) + | ||
| 45 | 45 | 2 * (x**2 + y**2)) | |
| 46 | 46 | return (np.max(z) - z) / (np.max(z) - np.min(z)) | |
| 47 | 47 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,7 +16,6 @@ | |||
| 16 | 16 | # Analytical test function | |
| 17 | 17 | #----------------------------------------------------------------------------- | |
| 18 | 18 | def function_z(x, y): | |
| 19 | - """ A function of 2 variables """ | ||
| 20 | 19 | r1 = np.sqrt((0.5 - x)**2 + (0.5 - y)**2) | |
| 21 | 20 | theta1 = np.arctan2(0.5 - x, 0.5 - y) | |
| 22 | 21 | r2 = np.sqrt((-x - 0.2)**2 + (-y - 0.2)**2) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,7 +17,7 @@ | |||
| 17 | 17 | # Electrical potential of a dipole | |
| 18 | 18 | #----------------------------------------------------------------------------- | |
| 19 | 19 | def dipole_potential(x, y): | |
| 20 | - """ The electric dipole potential V """ | ||
| 20 | + """The electric dipole potential V, at position *x*, *y*.""" | ||
| 21 | 21 | r_sq = x**2 + y**2 | |
| 22 | 22 | theta = np.arctan2(y, x) | |
| 23 | 23 | z = np.cos(theta)/r_sq | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,9 +1,3 @@ | |||
| 1 | - """ | ||
| 2 | - `ToolManager` | ||
| 3 | - Class that makes the bridge between user interaction (key press, | ||
| 4 | - toolbar clicks, ..) and the actions in response to the user inputs. | ||
| 5 | - """ | ||
| 6 | - | ||
| 7 | 1 | import logging | |
| 8 | 2 | ||
| 9 | 3 | import matplotlib.cbook as cbook | |
@@ -15,7 +9,7 @@ | |||
| 15 | 9 | ||
| 16 | 10 | ||
| 17 | 11 | class ToolEvent(object): | |
| 18 | - """Event for tool manipulation (add/remove)""" | ||
| 12 | + """Event for tool manipulation (add/remove).""" | ||
| 19 | 13 | def __init__(self, name, sender, tool, data=None): | |
| 20 | 14 | self.name = name | |
| 21 | 15 | self.sender = sender | |
@@ -24,17 +18,17 @@ def __init__(self, name, sender, tool, data=None): | |||
| 24 | 18 | ||
| 25 | 19 | ||
| 26 | 20 | class ToolTriggerEvent(ToolEvent): | |
| 27 | - """Event to inform that a tool has been triggered""" | ||
| 21 | + """Event to inform that a tool has been triggered.""" | ||
| 28 | 22 | def __init__(self, name, sender, tool, canvasevent=None, data=None): | |
| 29 | 23 | ToolEvent.__init__(self, name, sender, tool, data) | |
| 30 | 24 | self.canvasevent = canvasevent | |
| 31 | 25 | ||
| 32 | 26 | ||
| 33 | 27 | class ToolManagerMessageEvent(object): | |
| 34 | 28 | """ | |
| 35 | - Event carrying messages from toolmanager | ||
| 29 | + Event carrying messages from toolmanager. | ||
| 36 | 30 | ||
| 37 | - Messages usually get displayed to the user by the toolbar | ||
| 31 | + Messages usually get displayed to the user by the toolbar. | ||
| 38 | 32 | """ | |
| 39 | 33 | def __init__(self, name, sender, message): | |
| 40 | 34 | self.name = name | |
@@ -44,7 +38,8 @@ def __init__(self, name, sender, message): | |||
| 44 | 38 | ||
| 45 | 39 | class ToolManager(object): | |
| 46 | 40 | """ | |
| 47 | - Helper class that groups all the user interactions for a Figure. | ||
| 41 | + Manager for actions triggered by user interactions (key press, toolbar | ||
| 42 | + clicks, ...) on a Figure. | ||
| 48 | 43 | ||
| 49 | 44 | Attributes | |
| 50 | 45 | ---------- | |
@@ -76,14 +71,14 @@ def __init__(self, figure=None): | |||
| 76 | 71 | ||
| 77 | 72 | @property | |
| 78 | 73 | def canvas(self): | |
| 79 | - """Canvas managed by FigureManager""" | ||
| 74 | + """Canvas managed by FigureManager.""" | ||
| 80 | 75 | if not self._figure: | |
| 81 | 76 | return None | |
| 82 | 77 | return self._figure.canvas | |
| 83 | 78 | ||
| 84 | 79 | @property | |
| 85 | 80 | def figure(self): | |
| 86 | - """Figure that holds the canvas""" | ||
| 81 | + """Figure that holds the canvas.""" | ||
| 87 | 82 | return self._figure | |
| 88 | 83 | ||
| 89 | 84 | @figure.setter | |
@@ -138,19 +133,18 @@ def func(event) | |||
| 138 | 133 | ||
| 139 | 134 | def toolmanager_disconnect(self, cid): | |
| 140 | 135 | """ | |
| 141 | - Disconnect callback id *cid* | ||
| 136 | + Disconnect callback id *cid*. | ||
| 142 | 137 | ||
| 143 | 138 | Example usage:: | |
| 144 | 139 | ||
| 145 | - cid = toolmanager.toolmanager_connect('tool_trigger_zoom', | ||
| 146 | - on_press) | ||
| 140 | + cid = toolmanager.toolmanager_connect('tool_trigger_zoom', onpress) | ||
| 147 | 141 | #...later | |
| 148 | 142 | toolmanager.toolmanager_disconnect(cid) | |
| 149 | 143 | """ | |
| 150 | 144 | return self._callbacks.disconnect(cid) | |
| 151 | 145 | ||
| 152 | 146 | def message_event(self, message, sender=None): | |
| 153 | - """ Emit a `ToolManagerMessageEvent`""" | ||
| 147 | + """Emit a `ToolManagerMessageEvent`.""" | ||
| 154 | 148 | if sender is None: | |
| 155 | 149 | sender = self | |
| 156 | 150 | ||
@@ -160,13 +154,12 @@ def message_event(self, message, sender=None): | |||
| 160 | 154 | ||
| 161 | 155 | @property | |
| 162 | 156 | def active_toggle(self): | |
| 163 | - """Currently toggled tools""" | ||
| 164 | - | ||
| 157 | + """Currently toggled tools.""" | ||
| 165 | 158 | return self._toggled | |
| 166 | 159 | ||
| 167 | 160 | def get_tool_keymap(self, name): | |
| 168 | 161 | """ | |
| 169 | - Get the keymap associated with the specified tool | ||
| 162 | + Get the keymap associated with the specified tool. | ||
| 170 | 163 | ||
| 171 | 164 | Parameters | |
| 172 | 165 | ---------- | |
@@ -187,7 +180,7 @@ def _remove_keys(self, name): | |||
| 187 | 180 | ||
| 188 | 181 | def update_keymap(self, name, *keys): | |
| 189 | 182 | """ | |
| 190 | - Set the keymap to associate with the specified tool | ||
| 183 | + Set the keymap to associate with the specified tool. | ||
| 191 | 184 | ||
| 192 | 185 | Parameters | |
| 193 | 186 | ---------- | |
@@ -210,7 +203,7 @@ def update_keymap(self, name, *keys): | |||
| 210 | 203 | ||
| 211 | 204 | def remove_tool(self, name): | |
| 212 | 205 | """ | |
| 213 | - Remove tool from `ToolManager` | ||
| 206 | + Remove tool named *name*. | ||
| 214 | 207 | ||
| 215 | 208 | Parameters | |
| 216 | 209 | ---------- | |
@@ -235,16 +228,16 @@ def remove_tool(self, name): | |||
| 235 | 228 | ||
| 236 | 229 | def add_tool(self, name, tool, *args, **kwargs): | |
| 237 | 230 | """ | |
| 238 | - Add *tool* to `ToolManager` | ||
| 231 | + Add *tool* to `ToolManager`. | ||
| 239 | 232 | ||
| 240 | - If successful adds a new event `tool_trigger_name` where **name** is | ||
| 241 | - the **name** of the tool, this event is fired everytime | ||
| 242 | - the tool is triggered. | ||
| 233 | + If successful, adds a new event ``tool_trigger_{name}`` where ``name`` | ||
| 234 | + is the *name* of the tool; the event is fired everytime the tool is | ||
| 235 | + triggered. | ||
| 243 | 236 | ||
| 244 | 237 | Parameters | |
| 245 | 238 | ---------- | |
| 246 | 239 | name : str | |
| 247 | - Name of the tool, treated as the ID, has to be unique | ||
| 240 | + Name of the tool, treated as the ID, has to be unique. | ||
| 248 | 241 | tool : class_like, i.e. str or type | |
| 249 | 242 | Reference to find the class of the Tool to added. | |
| 250 | 243 | ||
@@ -296,8 +289,8 @@ def _tool_added_event(self, tool): | |||
| 296 | 289 | ||
| 297 | 290 | def _handle_toggle(self, tool, sender, canvasevent, data): | |
| 298 | 291 | """ | |
| 299 | - Toggle tools, need to untoggle prior to using other Toggle tool | ||
| 300 | - Called from trigger_tool | ||
| 292 | + Toggle tools, need to untoggle prior to using other Toggle tool. | ||
| 293 | + Called from trigger_tool. | ||
| 301 | 294 | ||
| 302 | 295 | Parameters | |
| 303 | 296 | ---------- | |
@@ -356,10 +349,9 @@ def _get_cls_to_instantiate(self, callback_class): | |||
| 356 | 349 | else: | |
| 357 | 350 | return None | |
| 358 | 351 | ||
| 359 | - def trigger_tool(self, name, sender=None, canvasevent=None, | ||
| 360 | - data=None): | ||
| 352 | + def trigger_tool(self, name, sender=None, canvasevent=None, data=None): | ||
| 361 | 353 | """ | |
| 362 | - Trigger a tool and emit the tool_trigger_[name] event | ||
| 354 | + Trigger a tool and emit the ``tool_trigger_{name}`` event. | ||
| 363 | 355 | ||
| 364 | 356 | Parameters | |
| 365 | 357 | ---------- | |
@@ -386,11 +378,7 @@ def trigger_tool(self, name, sender=None, canvasevent=None, | |||
| 386 | 378 | self._callbacks.process(s, event) | |
| 387 | 379 | ||
| 388 | 380 | def _trigger_tool(self, name, sender=None, canvasevent=None, data=None): | |
| 389 | - """ | ||
| 390 | - Trigger on a tool | ||
| 391 | - | ||
| 392 | - Method to actually trigger the tool | ||
| 393 | - """ | ||
| 381 | + """Actually trigger a tool.""" | ||
| 394 | 382 | tool = self.get_tool(name) | |
| 395 | 383 | ||
| 396 | 384 | if isinstance(tool, tools.ToolToggleBase): | |
@@ -411,13 +399,12 @@ def _key_press(self, event): | |||
| 411 | 399 | ||
| 412 | 400 | @property | |
| 413 | 401 | def tools(self): | |
| 414 | - """Return the tools controlled by `ToolManager`""" | ||
| 415 | - | ||
| 402 | + """Return the controlled tools.""" | ||
| 416 | 403 | return self._tools | |
| 417 | 404 | ||
| 418 | 405 | def get_tool(self, name, warn=True): | |
| 419 | 406 | """ | |
| 420 | - Return the tool object, also accepts the actual tool for convenience | ||
| 407 | + Return the tool object, also accepts the actual tool for convenience. | ||
| 421 | 408 | ||
| 422 | 409 | Parameters | |
| 423 | 410 | ---------- | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,8 +16,9 @@ class NonIntersectingPathException(ValueError): | |||
| 16 | 16 | ||
| 17 | 17 | def get_intersection(cx1, cy1, cos_t1, sin_t1, | |
| 18 | 18 | cx2, cy2, cos_t2, sin_t2): | |
| 19 | - """ return a intersecting point between a line through (cx1, cy1) | ||
| 20 | - and having angle t1 and a line through (cx2, cy2) and angle t2. | ||
| 19 | + """ | ||
| 20 | + Return the intersection between the line through (*cx1*, *cy1*) at angle | ||
| 21 | + *t1* and the line through (*cx2, cy2) at angle *t2*. | ||
| 21 | 22 | """ | |
| 22 | 23 | ||
| 23 | 24 | # line1 => sin_t1 * (x - cx1) - cos_t1 * (y - cy1) = 0. | |
@@ -397,13 +398,12 @@ def get_parallels(bezier2, width): | |||
| 397 | 398 | ||
| 398 | 399 | ||
| 399 | 400 | def find_control_points(c1x, c1y, mmx, mmy, c2x, c2y): | |
| 400 | - """ Find control points of the bezier line through c1, mm, c2. We | ||
| 401 | - simply assume that c1, mm, c2 which have parametric value 0, 0.5, and 1. | ||
| 402 | 401 | """ | |
| 403 | - | ||
| 402 | + Find control points of the Bezier curve passing through (*c1x*, *c1y*), | ||
| 403 | + (*mmx*, *mmy*), and (*c2x*, *c2y*), at parametric values 0, 0.5, and 1. | ||
| 404 | + """ | ||
| 404 | 405 | cmx = .5 * (4 * mmx - (c1x + c2x)) | |
| 405 | 406 | cmy = .5 * (4 * mmy - (c1y + c2y)) | |
| 406 | - | ||
| 407 | 407 | return [(c1x, c1y), (cmx, cmy), (c2x, c2y)] | |
| 408 | 408 | ||
| 409 | 409 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1531,13 +1531,11 @@ def __init__(self, azdeg=315, altdeg=45, hsv_min_val=0, hsv_max_val=1, | |||
| 1531 | 1531 | ||
| 1532 | 1532 | @property | |
| 1533 | 1533 | def direction(self): | |
| 1534 | - """ The unit vector direction towards the light source """ | ||
| 1535 | - | ||
| 1534 | + """The unit vector direction towards the light source.""" | ||
| 1536 | 1535 | # Azimuth is in degrees clockwise from North. Convert to radians | |
| 1537 | 1536 | # counterclockwise from East (mathematical notation). | |
| 1538 | 1537 | az = np.radians(90 - self.azdeg) | |
| 1539 | 1538 | alt = np.radians(self.altdeg) | |
| 1540 | - | ||
| 1541 | 1539 | return np.array([ | |
| 1542 | 1540 | np.cos(az) * np.cos(alt), | |
| 1543 | 1541 | np.sin(az) * np.cos(alt), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -897,7 +897,7 @@ def __init__(self, *args, **kwargs): | |||
| 897 | 897 | self.fontmap[name] = fullpath | |
| 898 | 898 | ||
| 899 | 899 | def _get_glyph(self, fontname, font_class, sym, fontsize, math=True): | |
| 900 | - """ Override prime symbol to use Bakoma """ | ||
| 900 | + # Override prime symbol to use Bakoma. | ||
| 901 | 901 | if sym == r'\prime': | |
| 902 | 902 | return self.bakoma._get_glyph( | |
| 903 | 903 | fontname, font_class, sym, fontsize, math) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -463,9 +463,8 @@ def get_window_extent(self, renderer): | |||
| 463 | 463 | return Bbox.union(boxes) | |
| 464 | 464 | ||
| 465 | 465 | def _do_cell_alignment(self): | |
| 466 | - """ Calculate row heights and column widths. | ||
| 467 | - | ||
| 468 | - Position cells accordingly. | ||
| 466 | + """ | ||
| 467 | + Calculate row heights and column widths; position cells accordingly. | ||
| 469 | 468 | """ | |
| 470 | 469 | # Calculate row/column widths | |
| 471 | 470 | widths = {} | |
@@ -523,7 +522,7 @@ def _auto_set_column_width(self, col, renderer): | |||
| 523 | 522 | cell.set_width(max_width) | |
| 524 | 523 | ||
| 525 | 524 | def auto_set_font_size(self, value=True): | |
| 526 | - """ Automatically set font size. """ | ||
| 525 | + """Automatically set font size.""" | ||
| 527 | 526 | self._autoFontsize = value | |
| 528 | 527 | self.stale = True | |
| 529 | 528 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -81,7 +81,7 @@ def test_interp_nearest_vs_none(): | |||
| 81 | 81 | ||
| 82 | 82 | ||
| 83 | 83 | def do_figimage(suppressComposite): | |
| 84 | - """ Helper for the next two tests """ | ||
| 84 | + """Helper for the next two tests.""" | ||
| 85 | 85 | fig = plt.figure(figsize=(2, 2), dpi=100) | |
| 86 | 86 | fig.suppressComposite = suppressComposite | |
| 87 | 87 | x, y = np.ix_(np.arange(100) / 100.0, np.arange(100) / 100) | |
@@ -95,19 +95,14 @@ def do_figimage(suppressComposite): | |||
| 95 | 95 | fig.figimage(img[::-1, ::-1], xo=100, yo=100, origin='lower') | |
| 96 | 96 | ||
| 97 | 97 | ||
| 98 | - @image_comparison(baseline_images=['figimage-0'], | ||
| 99 | - extensions=['png', 'pdf']) | ||
| 98 | + @image_comparison(baseline_images=['figimage-0'], extensions=['png', 'pdf']) | ||
| 100 | 99 | def test_figimage0(): | |
| 101 | - 'test the figimage method' | ||
| 102 | - | ||
| 103 | 100 | suppressComposite = False | |
| 104 | 101 | do_figimage(suppressComposite) | |
| 105 | 102 | ||
| 106 | 103 | ||
| 107 | - @image_comparison(baseline_images=['figimage-1'], | ||
| 108 | - extensions=['png', 'pdf']) | ||
| 104 | + @image_comparison(baseline_images=['figimage-1'], extensions=['png', 'pdf']) | ||
| 109 | 105 | def test_figimage1(): | |
| 110 | - 'test the figimage method' | ||
| 111 | 106 | suppressComposite = True | |
| 112 | 107 | do_figimage(suppressComposite) | |
| 113 | 108 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments