@@ -116,7 +116,7 @@ def format_timestamp(t):
116
116
if time_str == '00:00:00' :
117
117
return date_str
118
118
else :
119
- return '{0 }T{1 }' .format (date_str , time_str )
119
+ return '{}T{}' .format (date_str , time_str )
120
120
121
121
122
122
def format_timedelta (t , timedelta_format = None ):
@@ -212,12 +212,12 @@ def summarize_variable(name, var, col_width, show_values=True,
212
212
marker = ' ' , max_width = None ):
213
213
if max_width is None :
214
214
max_width = OPTIONS ['display_width' ]
215
- first_col = pretty_print (' {0 } {1 } ' .format (marker , name ), col_width )
215
+ first_col = pretty_print (' {} {} ' .format (marker , name ), col_width )
216
216
if var .dims :
217
- dims_str = '({0 }) ' .format (', ' .join (map (str , var .dims )))
217
+ dims_str = '({}) ' .format (', ' .join (map (str , var .dims )))
218
218
else :
219
219
dims_str = ''
220
- front_str = '{0}{1}{2 } ' .format (first_col , dims_str , var .dtype )
220
+ front_str = '{}{}{ } ' .format (first_col , dims_str , var .dtype )
221
221
if show_values :
222
222
values_str = format_array_flat (var , max_width - len (front_str ))
223
223
elif isinstance (var ._data , dask_array_type ):
@@ -229,9 +229,9 @@ def summarize_variable(name, var, col_width, show_values=True,
229
229
230
230
231
231
def _summarize_coord_multiindex (coord , col_width , marker ):
232
- first_col = pretty_print (' {0 } {1 } ' .format (
232
+ first_col = pretty_print (' {} {} ' .format (
233
233
marker , coord .name ), col_width )
234
- return '{0 }({1 }) MultiIndex' .format (first_col , str (coord .dims [0 ]))
234
+ return '{}({}) MultiIndex' .format (first_col , str (coord .dims [0 ]))
235
235
236
236
237
237
def _summarize_coord_levels (coord , col_width , marker = '-' ):
@@ -265,13 +265,13 @@ def summarize_coord(name, var, col_width):
265
265
def summarize_attr (key , value , col_width = None ):
266
266
"""Summary for __repr__ - use ``X.attrs[key]`` for full value."""
267
267
# Indent key and add ':', then right-pad if col_width is not None
268
- k_str = ' {0 }:' .format (key )
268
+ k_str = ' {}:' .format (key )
269
269
if col_width is not None :
270
270
k_str = pretty_print (k_str , col_width )
271
271
# Replace tabs and newlines, so we print on one line in known width
272
272
v_str = str (value ).replace ('\t ' , '\\ t' ).replace ('\n ' , '\\ n' )
273
273
# Finally, truncate to the desired display width
274
- return maybe_truncate ('{0 } {1 }' .format (k_str , v_str ),
274
+ return maybe_truncate ('{} {}' .format (k_str , v_str ),
275
275
OPTIONS ['display_width' ])
276
276
277
277
@@ -305,7 +305,7 @@ def _calculate_col_width(col_items):
305
305
def _mapping_repr (mapping , title , summarizer , col_width = None ):
306
306
if col_width is None :
307
307
col_width = _calculate_col_width (mapping )
308
- summary = ['{0 }:' .format (title )]
308
+ summary = ['{}:' .format (title )]
309
309
if mapping :
310
310
summary += [summarizer (k , v , col_width ) for k , v in mapping .items ()]
311
311
else :
@@ -331,19 +331,19 @@ def coords_repr(coords, col_width=None):
331
331
def indexes_repr (indexes ):
332
332
summary = []
333
333
for k , v in indexes .items ():
334
- summary .append (wrap_indent (repr (v ), '{0 }: ' .format (k )))
334
+ summary .append (wrap_indent (repr (v ), '{}: ' .format (k )))
335
335
return '\n ' .join (summary )
336
336
337
337
338
338
def dim_summary (obj ):
339
- elements = ['{0 }: {1 }' .format (k , v ) for k , v in obj .sizes .items ()]
339
+ elements = ['{}: {}' .format (k , v ) for k , v in obj .sizes .items ()]
340
340
return ', ' .join (elements )
341
341
342
342
343
343
def unindexed_dims_repr (dims , coords ):
344
344
unindexed_dims = [d for d in dims if d not in coords ]
345
345
if unindexed_dims :
346
- dims_str = ', ' .join ('{0 }' .format (d ) for d in unindexed_dims )
346
+ dims_str = ', ' .join ('{}' .format (d ) for d in unindexed_dims )
347
347
return 'Dimensions without coordinates: ' + dims_str
348
348
else :
349
349
return None
@@ -384,10 +384,10 @@ def short_dask_repr(array, show_dtype=True):
384
384
"""
385
385
chunksize = tuple (c [0 ] for c in array .chunks )
386
386
if show_dtype :
387
- return 'dask.array<shape={0 }, dtype={1 }, chunksize={2 }>' .format (
387
+ return 'dask.array<shape={}, dtype={}, chunksize={}>' .format (
388
388
array .shape , array .dtype , chunksize )
389
389
else :
390
- return 'dask.array<shape={0 }, chunksize={1 }>' .format (
390
+ return 'dask.array<shape={}, chunksize={}>' .format (
391
391
array .shape , chunksize )
392
392
393
393
@@ -397,17 +397,17 @@ def short_data_repr(array):
397
397
elif array ._in_memory or array .size < 1e5 :
398
398
return short_array_repr (array .values )
399
399
else :
400
- return u'[{0 } values with dtype={1 }]' .format (array .size , array .dtype )
400
+ return u'[{} values with dtype={}]' .format (array .size , array .dtype )
401
401
402
402
403
403
def array_repr (arr ):
404
404
# used for DataArray, Variable and IndexVariable
405
405
if hasattr (arr , 'name' ) and arr .name is not None :
406
- name_str = '{0 } ' .format (arr .name )
406
+ name_str = '{!r } ' .format (arr .name )
407
407
else :
408
408
name_str = ''
409
409
410
- summary = ['<xarray.{0 } {1 }({2 })>' .format (
410
+ summary = ['<xarray.{} {}({})>' .format (
411
411
type (arr ).__name__ , name_str , dim_summary (arr ))]
412
412
413
413
summary .append (short_data_repr (arr ))
@@ -427,12 +427,12 @@ def array_repr(arr):
427
427
428
428
429
429
def dataset_repr (ds ):
430
- summary = ['<xarray.{0 }>' .format (type (ds ).__name__ )]
430
+ summary = ['<xarray.{}>' .format (type (ds ).__name__ )]
431
431
432
432
col_width = _calculate_col_width (_get_col_items (ds .variables ))
433
433
434
434
dims_start = pretty_print ('Dimensions:' , col_width )
435
- summary .append ('{0 }({1 })' .format (dims_start , dim_summary (ds )))
435
+ summary .append ('{}({})' .format (dims_start , dim_summary (ds )))
436
436
437
437
if ds .coords :
438
438
summary .append (coords_repr (ds .coords , col_width = col_width ))
0 commit comments