@@ -52,8 +52,8 @@ def _arith_method(op, name, str_rep=None, default_axis=None, fill_zeros=None,
5252 def wrapper (self , other ):
5353 if isinstance (other , np .ndarray ):
5454 if len (self ) != len (other ):
55- raise AssertionError ("length mismatch: %d vs. %d" %
56- ( len (self ), len (other )))
55+ raise AssertionError ("length mismatch: {self} vs. {other}"
56+ . format ( self = len (self ), other = len (other )))
5757 if not isinstance (other , ABCSparseArray ):
5858 dtype = getattr (other , 'dtype' , None )
5959 other = SparseArray (other , fill_value = self .fill_value ,
@@ -66,7 +66,8 @@ def wrapper(self, other):
6666
6767 return _wrap_result (name , result , self .sp_index , fill )
6868 else : # pragma: no cover
69- raise TypeError ('operation with %s not supported' % type (other ))
69+ raise TypeError ('operation with {other} not supported'
70+ .format (other = type (other )))
7071
7172 if name .startswith ("__" ):
7273 name = name [2 :- 2 ]
@@ -218,9 +219,9 @@ def __new__(cls, data, sparse_index=None, index=None, kind='integer',
218219 else :
219220 values = _sanitize_values (data )
220221 if len (values ) != sparse_index .npoints :
221- raise AssertionError ("Non array-like type {0 } must have "
222- " the same length as the"
223- " index" .format (type (values )))
222+ raise AssertionError ("Non array-like type {type } must "
223+ "have the same length as the index "
224+ .format (type = type (values )))
224225 # Create array, do *not* copy data by default
225226 if copy :
226227 subarr = np .array (values , dtype = dtype , copy = True )
@@ -330,9 +331,10 @@ def __len__(self):
330331 return 0
331332
332333 def __unicode__ (self ):
333- return '%s\n Fill: %s\n %s' % (printing .pprint_thing (self ),
334- printing .pprint_thing (self .fill_value ),
335- printing .pprint_thing (self .sp_index ))
334+ return '{self}\n Fill: {fill}\n {index}' .format (
335+ self = printing .pprint_thing (self ),
336+ fill = printing .pprint_thing (self .fill_value ),
337+ index = printing .pprint_thing (self .sp_index ))
336338
337339 def disable (self , other ):
338340 raise NotImplementedError ('inplace binary ops not supported' )
@@ -377,8 +379,8 @@ def fill_value(self, value):
377379 if is_dtype_equal (self .dtype , new_dtype ):
378380 self ._fill_value = fill_value
379381 else :
380- msg = 'unable to set fill_value {0 } to {1 } dtype'
381- raise ValueError (msg .format (value , self .dtype ))
382+ msg = 'unable to set fill_value {fill } to {dtype } dtype'
383+ raise ValueError (msg .format (fill = value , dtype = self .dtype ))
382384
383385 def get_values (self , fill = None ):
384386 """ return a dense representation """
@@ -466,7 +468,8 @@ def take(self, indices, axis=0, allow_fill=True,
466468 nv .validate_take (tuple (), kwargs )
467469
468470 if axis :
469- raise ValueError ("axis must be 0, input was {0}" .format (axis ))
471+ raise ValueError ("axis must be 0, input was {axis}"
472+ .format (axis = axis ))
470473
471474 if is_integer (indices ):
472475 # return scalar
@@ -482,12 +485,12 @@ def take(self, indices, axis=0, allow_fill=True,
482485 'all indices must be >= -1' )
483486 raise ValueError (msg )
484487 elif (n <= indices ).any ():
485- msg = 'index is out of bounds for size {0}'
486- raise IndexError (msg . format ( n ) )
488+ msg = 'index is out of bounds for size {size}' . format ( size = n )
489+ raise IndexError (msg )
487490 else :
488491 if ((indices < - n ) | (n <= indices )).any ():
489- msg = 'index is out of bounds for size {0}'
490- raise IndexError (msg . format ( n ) )
492+ msg = 'index is out of bounds for size {size}' . format ( size = n )
493+ raise IndexError (msg )
491494
492495 indices = indices .astype (np .int32 )
493496 if not (allow_fill and fill_value is not None ):
@@ -543,8 +546,8 @@ def astype(self, dtype=None, copy=True):
543546 else :
544547 fill_value = dtype .type (self .fill_value )
545548 except ValueError :
546- msg = 'unable to coerce current fill_value {0 } to {1 } dtype'
547- raise ValueError (msg .format (self .fill_value , dtype ))
549+ msg = 'unable to coerce current fill_value {fill } to {dtype } dtype'
550+ raise ValueError (msg .format (fill = self .fill_value , dtype = dtype ))
548551 return self ._simple_new (sp_values , self .sp_index ,
549552 fill_value = fill_value )
550553
0 commit comments