Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 99f11d5

Browse files
ericpretimhoffm
andauthored
Improve docstring and simplify code
Co-authored-by: Tim Hoffmann <[email protected]>
1 parent 9f07529 commit 99f11d5

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

lib/matplotlib/widgets.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2238,9 +2238,8 @@ def on_select(min: float, max: float) -> Any
22382238
If `True`, the event triggered outside the span selector will be
22392239
ignored.
22402240
2241-
snap_values : 1D array-like, default: None
2242-
Snap the extents of the selector to the values defined in
2243-
``snap_values``.
2241+
snap_values : 1D array-like, optional
2242+
Snap the selector edges to the given values.
22442243
22452244
Examples
22462245
--------
@@ -2585,12 +2584,11 @@ def _contains(self, event):
25852584
@staticmethod
25862585
def _snap(values, snap_values):
25872586
"""Snap values to a given array values (snap_values)."""
2588-
indices = np.empty_like(values, dtype="uint")
25892587
# take into account machine precision
25902588
eps = np.min(np.abs(np.diff(snap_values))) * 1e-12
2591-
for i, v in enumerate(values):
2592-
indices[i] = np.abs(snap_values - v + np.sign(v) * eps).argmin()
2593-
return snap_values[indices]
2589+
return tuple(
2590+
snap_values[np.abs(snap_values - v + np.sign(v) * eps).argmin()]
2591+
for v in values)
25942592

25952593
@property
25962594
def extents(self):
@@ -2874,7 +2872,6 @@ def onselect(eclick: MouseEvent, erelease: MouseEvent)
28742872
use_data_coordinates : bool, default: False
28752873
If `True`, the "square" shape of the selector is defined in
28762874
data coordinates instead of display coordinates.
2877-
28782875
"""
28792876

28802877

0 commit comments

Comments
 (0)