@@ -278,13 +278,13 @@ def is_missing(self, s):
278
278
279
279
280
280
class tostr (converter ):
281
- ' convert to string or None'
281
+ """ convert to string or None"""
282
282
def __init__ (self , missing = 'Null' , missingval = '' ):
283
283
converter .__init__ (self , missing = missing , missingval = missingval )
284
284
285
285
286
286
class todatetime (converter ):
287
- ' convert to a datetime or None'
287
+ """ convert to a datetime or None"""
288
288
def __init__ (self , fmt = '%Y-%m-%d' , missing = 'Null' , missingval = None ):
289
289
'use a :func:`time.strptime` format string for conversion'
290
290
converter .__init__ (self , missing , missingval )
@@ -298,9 +298,9 @@ def __call__(self, s):
298
298
299
299
300
300
class todate (converter ):
301
- ' convert to a date or None'
301
+ """ convert to a date or None"""
302
302
def __init__ (self , fmt = '%Y-%m-%d' , missing = 'Null' , missingval = None ):
303
- ' use a :func:`time.strptime` format string for conversion'
303
+ """ use a :func:`time.strptime` format string for conversion"""
304
304
converter .__init__ (self , missing , missingval )
305
305
self .fmt = fmt
306
306
@@ -312,7 +312,7 @@ def __call__(self, s):
312
312
313
313
314
314
class tofloat (converter ):
315
- ' convert to a float or None'
315
+ """ convert to a float or None"""
316
316
def __init__ (self , missing = 'Null' , missingval = None ):
317
317
converter .__init__ (self , missing )
318
318
self .missingval = missingval
@@ -324,7 +324,7 @@ def __call__(self, s):
324
324
325
325
326
326
class toint (converter ):
327
- ' convert to an int or None'
327
+ """ convert to an int or None"""
328
328
def __init__ (self , missing = 'Null' , missingval = None ):
329
329
converter .__init__ (self , missing )
330
330
@@ -335,7 +335,7 @@ def __call__(self, s):
335
335
336
336
337
337
class _BoundMethodProxy (object ):
338
- '''
338
+ """
339
339
Our own proxy object which enables weak references to bound and unbound
340
340
methods and arbitrary callables. Pulls information about the function,
341
341
class, and instance out of a bound method. Stores a weak reference to the
@@ -346,7 +346,7 @@ class _BoundMethodProxy(object):
346
346
@license: The BSD License
347
347
348
348
Minor bugfixes by Michael Droettboom
349
- '''
349
+ """
350
350
def __init__ (self , cb ):
351
351
self ._hash = hash (cb )
352
352
self ._destroy_callbacks = []
@@ -395,13 +395,13 @@ def __setstate__(self, statedict):
395
395
self .inst = ref (inst )
396
396
397
397
def __call__ (self , * args , ** kwargs ):
398
- '''
398
+ """
399
399
Proxy for a call to the weak referenced object. Take
400
400
arbitrary params to pass to the callable.
401
401
402
402
Raises `ReferenceError`: When the weak reference refers to
403
403
a dead object
404
- '''
404
+ """
405
405
if self .inst is not None and self .inst () is None :
406
406
raise ReferenceError
407
407
elif self .inst is not None :
@@ -417,10 +417,10 @@ def __call__(self, *args, **kwargs):
417
417
return mtd (* args , ** kwargs )
418
418
419
419
def __eq__ (self , other ):
420
- '''
420
+ """
421
421
Compare the held function and instance with that held by
422
422
another proxy.
423
- '''
423
+ """
424
424
try :
425
425
if self .inst is None :
426
426
return self .func == other .func and other .inst is None
@@ -430,9 +430,9 @@ def __eq__(self, other):
430
430
return False
431
431
432
432
def __ne__ (self , other ):
433
- '''
433
+ """
434
434
Inverse of __eq__.
435
- '''
435
+ """
436
436
return not self .__eq__ (other )
437
437
438
438
def __hash__ (self ):
@@ -635,7 +635,7 @@ def local_over_kwdict(local_var, kwargs, *keys):
635
635
636
636
637
637
def strip_math (s ):
638
- ' remove latex formatting from mathtext'
638
+ """ remove latex formatting from mathtext"""
639
639
remove = (r'\mathdefault' , r'\rm' , r'\cal' , r'\tt' , r'\it' , '\\ ' , '{' , '}' )
640
640
s = s [1 :- 1 ]
641
641
for r in remove :
@@ -667,12 +667,12 @@ def __repr__(self):
667
667
668
668
669
669
def unique (x ):
670
- ' Return a list of unique elements of *x*'
670
+ """ Return a list of unique elements of *x*"""
671
671
return list (six .iterkeys (dict ([(val , 1 ) for val in x ])))
672
672
673
673
674
674
def iterable (obj ):
675
- ' return true if *obj* is iterable'
675
+ """ return true if *obj* is iterable"""
676
676
try :
677
677
iter (obj )
678
678
except TypeError :
@@ -681,7 +681,7 @@ def iterable(obj):
681
681
682
682
683
683
def is_string_like (obj ):
684
- ' Return True if *obj* looks like a string'
684
+ """ Return True if *obj* looks like a string"""
685
685
if isinstance (obj , six .string_types ):
686
686
return True
687
687
# numpy strings are subclass of str, ma strings are not
@@ -698,9 +698,7 @@ def is_string_like(obj):
698
698
699
699
700
700
def is_sequence_of_strings (obj ):
701
- """
702
- Returns true if *obj* is iterable and contains strings
703
- """
701
+ """Returns true if *obj* is iterable and contains strings"""
704
702
if not iterable (obj ):
705
703
return False
706
704
if is_string_like (obj ) and not isinstance (obj , np .ndarray ):
@@ -716,9 +714,7 @@ def is_sequence_of_strings(obj):
716
714
717
715
718
716
def is_hashable (obj ):
719
- """
720
- Returns true if *obj* can be hashed
721
- """
717
+ """Returns true if *obj* can be hashed"""
722
718
try :
723
719
hash (obj )
724
720
except TypeError :
@@ -727,7 +723,7 @@ def is_hashable(obj):
727
723
728
724
729
725
def is_writable_file_like (obj ):
730
- ' return true if *obj* looks like a file object with a *write* method'
726
+ """ return true if *obj* looks like a file object with a *write* method"""
731
727
return hasattr (obj , 'write' ) and six .callable (obj .write )
732
728
733
729
@@ -745,12 +741,12 @@ def file_requires_unicode(x):
745
741
746
742
747
743
def is_scalar (obj ):
748
- ' return true if *obj* is not string like and is not iterable'
744
+ """ return true if *obj* is not string like and is not iterable"""
749
745
return not is_string_like (obj ) and not iterable (obj )
750
746
751
747
752
748
def is_numlike (obj ):
753
- ' return true if *obj* looks like a number'
749
+ """ return true if *obj* looks like a number"""
754
750
try :
755
751
obj + 1
756
752
except :
@@ -1041,7 +1037,7 @@ def __call__(self, path):
1041
1037
1042
1038
1043
1039
def dict_delall (d , keys ):
1044
- ' delete all of the *keys* from the :class:`dict` *d*'
1040
+ """ delete all of the *keys* from the :class:`dict` *d*"""
1045
1041
for key in keys :
1046
1042
try :
1047
1043
del d [key ]
@@ -1091,17 +1087,17 @@ def get_split_ind(seq, N):
1091
1087
.
1092
1088
"""
1093
1089
1094
- sLen = 0
1090
+ s_len = 0
1095
1091
# todo: use Alex's xrange pattern from the cbook for efficiency
1096
1092
for (word , ind ) in zip (seq , xrange (len (seq ))):
1097
- sLen += len (word ) + 1 # +1 to account for the len(' ')
1098
- if sLen >= N :
1093
+ s_len += len (word ) + 1 # +1 to account for the len(' ')
1094
+ if s_len >= N :
1099
1095
return ind
1100
1096
return len (seq )
1101
1097
1102
1098
1103
1099
def wrap (prefix , text , cols ):
1104
- ' wrap *text* with *prefix* at length *cols*'
1100
+ """ wrap *text* with *prefix* at length *cols*"""
1105
1101
pad = ' ' * len (prefix .expandtabs ())
1106
1102
available = cols - len (pad )
1107
1103
@@ -1215,7 +1211,7 @@ def get_recursive_filelist(args):
1215
1211
1216
1212
1217
1213
def pieces (seq , num = 2 ):
1218
- "Break up the *seq* into *num* tuples"
1214
+ """ Break up the *seq* into *num* tuples"" "
1219
1215
start = 0
1220
1216
while 1 :
1221
1217
item = seq [start :start + num ]
@@ -1291,7 +1287,7 @@ def allpairs(x):
1291
1287
class maxdict (dict ):
1292
1288
"""
1293
1289
A dictionary with a maximum size; this doesn't override all the
1294
- relevant methods to contrain size, just setitem, so use with
1290
+ relevant methods to constrain the size, just setitem, so use with
1295
1291
caution
1296
1292
"""
1297
1293
def __init__ (self , maxsize ):
@@ -1320,7 +1316,7 @@ def __init__(self, default=None):
1320
1316
self ._default = default
1321
1317
1322
1318
def __call__ (self ):
1323
- ' return the current element, or None'
1319
+ """ return the current element, or None"""
1324
1320
if not len (self ._elements ):
1325
1321
return self ._default
1326
1322
else :
@@ -1333,14 +1329,14 @@ def __getitem__(self, ind):
1333
1329
return self ._elements .__getitem__ (ind )
1334
1330
1335
1331
def forward (self ):
1336
- ' move the position forward and return the current element'
1337
- N = len (self ._elements )
1338
- if self ._pos < N - 1 :
1332
+ """ move the position forward and return the current element"""
1333
+ n = len (self ._elements )
1334
+ if self ._pos < n - 1 :
1339
1335
self ._pos += 1
1340
1336
return self ()
1341
1337
1342
1338
def back (self ):
1343
- ' move the position back and return the current element'
1339
+ """ move the position back and return the current element"""
1344
1340
if self ._pos > 0 :
1345
1341
self ._pos -= 1
1346
1342
return self ()
@@ -1356,7 +1352,7 @@ def push(self, o):
1356
1352
return self ()
1357
1353
1358
1354
def home (self ):
1359
- ' push the first element onto the top of the stack'
1355
+ """ push the first element onto the top of the stack"""
1360
1356
if not len (self ._elements ):
1361
1357
return
1362
1358
self .push (self ._elements [0 ])
@@ -1366,7 +1362,7 @@ def empty(self):
1366
1362
return len (self ._elements ) == 0
1367
1363
1368
1364
def clear (self ):
1369
- ' empty the stack'
1365
+ """ empty the stack"""
1370
1366
self ._pos = - 1
1371
1367
self ._elements = []
1372
1368
@@ -1424,7 +1420,7 @@ def finddir(o, match, case=False):
1424
1420
1425
1421
1426
1422
def reverse_dict (d ):
1427
- ' reverse the dictionary -- may lose data if values are not unique!'
1423
+ """ reverse the dictionary -- may lose data if values are not unique!"""
1428
1424
return dict ([(v , k ) for k , v in six .iteritems (d )])
1429
1425
1430
1426
@@ -1437,7 +1433,7 @@ def restrict_dict(d, keys):
1437
1433
1438
1434
1439
1435
def report_memory (i = 0 ): # argument may go away
1440
- ' return the memory consumed by process'
1436
+ """ return the memory consumed by process"""
1441
1437
from matplotlib .compat .subprocess import Popen , PIPE
1442
1438
pid = os .getpid ()
1443
1439
if sys .platform == 'sunos5' :
@@ -1485,7 +1481,7 @@ def report_memory(i=0): # argument may go away
1485
1481
1486
1482
1487
1483
def safezip (* args ):
1488
- ' make sure *args* are equal len before zipping'
1484
+ """ make sure *args* are equal len before zipping"""
1489
1485
Nx = len (args [0 ])
1490
1486
for i , arg in enumerate (args [1 :]):
1491
1487
if len (arg ) != Nx :
@@ -1494,7 +1490,7 @@ def safezip(*args):
1494
1490
1495
1491
1496
1492
def issubclass_safe (x , klass ):
1497
- ' return issubclass(x, klass) and return False on a TypeError'
1493
+ """ return issubclass(x, klass) and return False on a TypeError"""
1498
1494
1499
1495
try :
1500
1496
return issubclass (x , klass )
@@ -2184,7 +2180,7 @@ def __call__(self, key):
2184
2180
# iteration
2185
2181
iters = [myiter (it ) for it in iterables ]
2186
2182
minvals = minkey = True
2187
- while 1 :
2183
+ while True :
2188
2184
minvals = ([_f for _f in [it .key for it in iters ] if _f ])
2189
2185
if minvals :
2190
2186
minkey = min (minvals )
@@ -2262,7 +2258,7 @@ def _reshape_2D(X):
2262
2258
2263
2259
2264
2260
def violin_stats (X , method , points = 100 ):
2265
- '''
2261
+ """
2266
2262
Returns a list of dictionaries of data which can be used to draw a series
2267
2263
of violin plots. See the `Returns` section below to view the required keys
2268
2264
of the dictionary. Users can skip this function and pass a user-defined set
@@ -2299,7 +2295,7 @@ def violin_stats(X, method, points=100):
2299
2295
- median: The median value for this column of data.
2300
2296
- min: The minimum value for this column of data.
2301
2297
- max: The maximum value for this column of data.
2302
- '''
2298
+ """
2303
2299
2304
2300
# List of dictionaries describing each of the violins.
2305
2301
vpstats = []
@@ -2382,7 +2378,7 @@ def _step_validation(x, *args):
2382
2378
args = tuple (np .asanyarray (y ) for y in args )
2383
2379
x = np .asanyarray (x )
2384
2380
if x .ndim != 1 :
2385
- raise ValueError ("x must be 1 dimenional " )
2381
+ raise ValueError ("x must be 1 dimensional " )
2386
2382
if len (args ) == 0 :
2387
2383
raise ValueError ("At least one Y value must be passed" )
2388
2384
0 commit comments