Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e24322c

Browse filesBrowse files
authored
Merge pull request #7288 from mherkazandjian/style_typos_fixes
Style typos fixes
2 parents b9ba7ea + 1261fff commit e24322c
Copy full SHA for e24322c

File tree

Expand file treeCollapse file tree

1 file changed

+46
-51
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+46
-51
lines changed

‎lib/matplotlib/cbook.py

Copy file name to clipboardExpand all lines: lib/matplotlib/cbook.py
+46-51Lines changed: 46 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,13 @@ def is_missing(self, s):
269269

270270

271271
class tostr(converter):
272-
'convert to string or None'
272+
"""convert to string or None"""
273273
def __init__(self, missing='Null', missingval=''):
274274
converter.__init__(self, missing=missing, missingval=missingval)
275275

276276

277277
class todatetime(converter):
278-
'convert to a datetime or None'
278+
"""convert to a datetime or None"""
279279
def __init__(self, fmt='%Y-%m-%d', missing='Null', missingval=None):
280280
'use a :func:`time.strptime` format string for conversion'
281281
converter.__init__(self, missing, missingval)
@@ -289,9 +289,9 @@ def __call__(self, s):
289289

290290

291291
class todate(converter):
292-
'convert to a date or None'
292+
"""convert to a date or None"""
293293
def __init__(self, fmt='%Y-%m-%d', missing='Null', missingval=None):
294-
'use a :func:`time.strptime` format string for conversion'
294+
"""use a :func:`time.strptime` format string for conversion"""
295295
converter.__init__(self, missing, missingval)
296296
self.fmt = fmt
297297

@@ -303,7 +303,7 @@ def __call__(self, s):
303303

304304

305305
class tofloat(converter):
306-
'convert to a float or None'
306+
"""convert to a float or None"""
307307
def __init__(self, missing='Null', missingval=None):
308308
converter.__init__(self, missing)
309309
self.missingval = missingval
@@ -315,7 +315,7 @@ def __call__(self, s):
315315

316316

317317
class toint(converter):
318-
'convert to an int or None'
318+
"""convert to an int or None"""
319319
def __init__(self, missing='Null', missingval=None):
320320
converter.__init__(self, missing)
321321

@@ -326,7 +326,7 @@ def __call__(self, s):
326326

327327

328328
class _BoundMethodProxy(object):
329-
'''
329+
"""
330330
Our own proxy object which enables weak references to bound and unbound
331331
methods and arbitrary callables. Pulls information about the function,
332332
class, and instance out of a bound method. Stores a weak reference to the
@@ -337,7 +337,7 @@ class _BoundMethodProxy(object):
337337
@license: The BSD License
338338
339339
Minor bugfixes by Michael Droettboom
340-
'''
340+
"""
341341
def __init__(self, cb):
342342
self._hash = hash(cb)
343343
self._destroy_callbacks = []
@@ -386,13 +386,13 @@ def __setstate__(self, statedict):
386386
self.inst = ref(inst)
387387

388388
def __call__(self, *args, **kwargs):
389-
'''
389+
"""
390390
Proxy for a call to the weak referenced object. Take
391391
arbitrary params to pass to the callable.
392392
393393
Raises `ReferenceError`: When the weak reference refers to
394394
a dead object
395-
'''
395+
"""
396396
if self.inst is not None and self.inst() is None:
397397
raise ReferenceError
398398
elif self.inst is not None:
@@ -408,10 +408,10 @@ def __call__(self, *args, **kwargs):
408408
return mtd(*args, **kwargs)
409409

410410
def __eq__(self, other):
411-
'''
411+
"""
412412
Compare the held function and instance with that held by
413413
another proxy.
414-
'''
414+
"""
415415
try:
416416
if self.inst is None:
417417
return self.func == other.func and other.inst is None
@@ -421,9 +421,9 @@ def __eq__(self, other):
421421
return False
422422

423423
def __ne__(self, other):
424-
'''
424+
"""
425425
Inverse of __eq__.
426-
'''
426+
"""
427427
return not self.__eq__(other)
428428

429429
def __hash__(self):
@@ -626,7 +626,7 @@ def local_over_kwdict(local_var, kwargs, *keys):
626626

627627

628628
def strip_math(s):
629-
'remove latex formatting from mathtext'
629+
"""remove latex formatting from mathtext"""
630630
remove = (r'\mathdefault', r'\rm', r'\cal', r'\tt', r'\it', '\\', '{', '}')
631631
s = s[1:-1]
632632
for r in remove:
@@ -658,12 +658,12 @@ def __repr__(self):
658658

659659

660660
def unique(x):
661-
'Return a list of unique elements of *x*'
661+
"""Return a list of unique elements of *x*"""
662662
return list(six.iterkeys(dict([(val, 1) for val in x])))
663663

664664

665665
def iterable(obj):
666-
'return true if *obj* is iterable'
666+
"""return true if *obj* is iterable"""
667667
try:
668668
iter(obj)
669669
except TypeError:
@@ -672,7 +672,7 @@ def iterable(obj):
672672

673673

674674
def is_string_like(obj):
675-
'Return True if *obj* looks like a string'
675+
"""Return True if *obj* looks like a string"""
676676
if isinstance(obj, six.string_types):
677677
return True
678678
# numpy strings are subclass of str, ma strings are not
@@ -689,9 +689,7 @@ def is_string_like(obj):
689689

690690

691691
def is_sequence_of_strings(obj):
692-
"""
693-
Returns true if *obj* is iterable and contains strings
694-
"""
692+
"""Returns true if *obj* is iterable and contains strings"""
695693
if not iterable(obj):
696694
return False
697695
if is_string_like(obj) and not isinstance(obj, np.ndarray):
@@ -707,9 +705,7 @@ def is_sequence_of_strings(obj):
707705

708706

709707
def is_hashable(obj):
710-
"""
711-
Returns true if *obj* can be hashed
712-
"""
708+
"""Returns true if *obj* can be hashed"""
713709
try:
714710
hash(obj)
715711
except TypeError:
@@ -718,7 +714,7 @@ def is_hashable(obj):
718714

719715

720716
def is_writable_file_like(obj):
721-
'return true if *obj* looks like a file object with a *write* method'
717+
"""return true if *obj* looks like a file object with a *write* method"""
722718
return hasattr(obj, 'write') and six.callable(obj.write)
723719

724720

@@ -736,12 +732,12 @@ def file_requires_unicode(x):
736732

737733

738734
def is_scalar(obj):
739-
'return true if *obj* is not string like and is not iterable'
735+
"""return true if *obj* is not string like and is not iterable"""
740736
return not is_string_like(obj) and not iterable(obj)
741737

742738

743739
def is_numlike(obj):
744-
'return true if *obj* looks like a number'
740+
"""return true if *obj* looks like a number"""
745741
try:
746742
obj + 1
747743
except:
@@ -1034,7 +1030,7 @@ def __call__(self, path):
10341030

10351031

10361032
def dict_delall(d, keys):
1037-
'delete all of the *keys* from the :class:`dict` *d*'
1033+
"""delete all of the *keys* from the :class:`dict` *d*"""
10381034
for key in keys:
10391035
try:
10401036
del d[key]
@@ -1084,17 +1080,17 @@ def get_split_ind(seq, N):
10841080
.
10851081
"""
10861082

1087-
sLen = 0
1083+
s_len = 0
10881084
# todo: use Alex's xrange pattern from the cbook for efficiency
10891085
for (word, ind) in zip(seq, xrange(len(seq))):
1090-
sLen += len(word) + 1 # +1 to account for the len(' ')
1091-
if sLen >= N:
1086+
s_len += len(word) + 1 # +1 to account for the len(' ')
1087+
if s_len >= N:
10921088
return ind
10931089
return len(seq)
10941090

10951091

10961092
def wrap(prefix, text, cols):
1097-
'wrap *text* with *prefix* at length *cols*'
1093+
"""wrap *text* with *prefix* at length *cols*"""
10981094
pad = ' ' * len(prefix.expandtabs())
10991095
available = cols - len(pad)
11001096

@@ -1208,7 +1204,7 @@ def get_recursive_filelist(args):
12081204

12091205

12101206
def pieces(seq, num=2):
1211-
"Break up the *seq* into *num* tuples"
1207+
"""Break up the *seq* into *num* tuples"""
12121208
start = 0
12131209
while 1:
12141210
item = seq[start:start + num]
@@ -1284,7 +1280,7 @@ def allpairs(x):
12841280
class maxdict(dict):
12851281
"""
12861282
A dictionary with a maximum size; this doesn't override all the
1287-
relevant methods to contrain size, just setitem, so use with
1283+
relevant methods to constrain the size, just setitem, so use with
12881284
caution
12891285
"""
12901286
def __init__(self, maxsize):
@@ -1313,7 +1309,7 @@ def __init__(self, default=None):
13131309
self._default = default
13141310

13151311
def __call__(self):
1316-
'return the current element, or None'
1312+
"""return the current element, or None"""
13171313
if not len(self._elements):
13181314
return self._default
13191315
else:
@@ -1326,14 +1322,14 @@ def __getitem__(self, ind):
13261322
return self._elements.__getitem__(ind)
13271323

13281324
def forward(self):
1329-
'move the position forward and return the current element'
1330-
N = len(self._elements)
1331-
if self._pos < N - 1:
1325+
"""move the position forward and return the current element"""
1326+
n = len(self._elements)
1327+
if self._pos < n - 1:
13321328
self._pos += 1
13331329
return self()
13341330

13351331
def back(self):
1336-
'move the position back and return the current element'
1332+
"""move the position back and return the current element"""
13371333
if self._pos > 0:
13381334
self._pos -= 1
13391335
return self()
@@ -1349,7 +1345,7 @@ def push(self, o):
13491345
return self()
13501346

13511347
def home(self):
1352-
'push the first element onto the top of the stack'
1348+
"""push the first element onto the top of the stack"""
13531349
if not len(self._elements):
13541350
return
13551351
self.push(self._elements[0])
@@ -1359,7 +1355,7 @@ def empty(self):
13591355
return len(self._elements) == 0
13601356

13611357
def clear(self):
1362-
'empty the stack'
1358+
"""empty the stack"""
13631359
self._pos = -1
13641360
self._elements = []
13651361

@@ -1411,7 +1407,7 @@ def finddir(o, match, case=False):
14111407

14121408

14131409
def reverse_dict(d):
1414-
'reverse the dictionary -- may lose data if values are not unique!'
1410+
"""reverse the dictionary -- may lose data if values are not unique!"""
14151411
return dict([(v, k) for k, v in six.iteritems(d)])
14161412

14171413

@@ -1424,7 +1420,7 @@ def restrict_dict(d, keys):
14241420

14251421

14261422
def report_memory(i=0): # argument may go away
1427-
'return the memory consumed by process'
1423+
"""return the memory consumed by process"""
14281424
from matplotlib.compat.subprocess import Popen, PIPE
14291425
pid = os.getpid()
14301426
if sys.platform == 'sunos5':
@@ -1473,7 +1469,7 @@ def report_memory(i=0): # argument may go away
14731469

14741470

14751471
def safezip(*args):
1476-
'make sure *args* are equal len before zipping'
1472+
"""make sure *args* are equal len before zipping"""
14771473
Nx = len(args[0])
14781474
for i, arg in enumerate(args[1:]):
14791475
if len(arg) != Nx:
@@ -1482,7 +1478,7 @@ def safezip(*args):
14821478

14831479

14841480
def issubclass_safe(x, klass):
1485-
'return issubclass(x, klass) and return False on a TypeError'
1481+
"""return issubclass(x, klass) and return False on a TypeError"""
14861482

14871483
try:
14881484
return issubclass(x, klass)
@@ -2120,7 +2116,7 @@ def __call__(self, key):
21202116
# iteration
21212117
iters = [myiter(it) for it in iterables]
21222118
minvals = minkey = True
2123-
while 1:
2119+
while True:
21242120
minvals = ([_f for _f in [it.key for it in iters] if _f])
21252121
if minvals:
21262122
minkey = min(minvals)
@@ -2198,7 +2194,7 @@ def _reshape_2D(X):
21982194

21992195

22002196
def violin_stats(X, method, points=100):
2201-
'''
2197+
"""
22022198
Returns a list of dictionaries of data which can be used to draw a series
22032199
of violin plots. See the `Returns` section below to view the required keys
22042200
of the dictionary. Users can skip this function and pass a user-defined set
@@ -2235,7 +2231,7 @@ def violin_stats(X, method, points=100):
22352231
- median: The median value for this column of data.
22362232
- min: The minimum value for this column of data.
22372233
- max: The maximum value for this column of data.
2238-
'''
2234+
"""
22392235

22402236
# List of dictionaries describing each of the violins.
22412237
vpstats = []
@@ -2318,7 +2314,7 @@ def _step_validation(x, *args):
23182314
args = tuple(np.asanyarray(y) for y in args)
23192315
x = np.asanyarray(x)
23202316
if x.ndim != 1:
2321-
raise ValueError("x must be 1 dimenional")
2317+
raise ValueError("x must be 1 dimensional")
23222318
if len(args) == 0:
23232319
raise ValueError("At least one Y value must be passed")
23242320

@@ -2501,8 +2497,7 @@ def safe_first_element(obj):
25012497

25022498

25032499
def sanitize_sequence(data):
2504-
"""Converts dictview object to list
2505-
"""
2500+
"""Converts dictview object to list"""
25062501
if six.PY3 and isinstance(data, collections.abc.MappingView):
25072502
return list(data)
25082503
return data

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.