10000 Make EventCollection behavior consistent with docstring · matplotlib/matplotlib@b1a7ad9 · GitHub
[go: up one dir, main page]

Skip to content

Commit b1a7ad9

Browse files
committed
Make EventCollection behavior consistent with docstring
1 parent f22d22d commit b1a7ad9

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
11321132
linestyles : str or tuple or a sequence of such values, optional.
11331133
Default is 'solid'. Valid strings are [ 'solid' | 'dashed' |
11341134
'dashdot' | 'dotted' | '-' | '--' | '-.' | ':' ]. Dash tuples
1135-
have to follow::
1135+
have to be of the form::
11361136
11371137
(offset, onoffseq),
11381138

lib/matplotlib/collections.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,7 @@ class EventCollection(LineCollection):
12511251
_edge_default = True
12521252

12531253
def __init__(self,
1254-
positions, # Can be None.
1254+
positions, # Cannot be None.
12551255
orientation=None,
12561256
lineoffset=0,
12571257
linelength=1,
@@ -1264,7 +1264,7 @@ def __init__(self,
12641264
"""
12651265
Parameters
12661266
----------
1267-
positions : 1D array-like object or None.
1267+
positions : 1D array-like object.
12681268
Each value is an event.
12691269
12701270
orientation : [ None (default) | 'horizontal' | 'vertical'], optional.
@@ -1286,9 +1286,8 @@ def __init__(self,
12861286
If it is None, defaults to its rcParams setting, in sequence form.
12871287
12881288
linestyle : str or tuple, optional. Default is 'solid'.
1289-
If it is a string, it has to be among [ 'solid' | 'dashed' |
1290-
'dashdot' | 'dotted' | '-' | '--' | '-.' | ':' ]. If it is a dash
1291-
tuple, it has to be of the form::
1289+
Valid strings are [ 'solid' | 'dashed' | 'dashdot' | 'dotted' |
1290+
'-' | '--' | '-.' | ':' ]. Dash tuples have to be of the form::
12921291
12931292
(offset, onoffseq),
12941293
@@ -1311,11 +1310,12 @@ def __init__(self,
13111310

13121311
segment = (lineoffset + linelength / 2.,
13131312
lineoffset - linelength / 2.)
1313+
positions = np.asarray(positions)
13141314
if len(positions) == 0:
13151315
segments = []
1316-
elif hasattr(positions, 'ndim') and positions.ndim > 1:
1317-
raise ValueError('if positions is an ndarray it cannot have '
1318-
'dimensionality strictly greater than 1 ')
1316+
elif positions.ndim > 1:
1317+
raise ValueError('positions cannot have a dimensionality greater '
1318+
'than 1 (in the ndarray sense)')
13191319
elif (orientation is None or orientation.lower() == 'none' or
13201320
orientation.lower() == 'horizontal'):
13211321
positions.sort()

0 commit comments

Comments
 (0)
0