@@ -372,7 +372,33 @@ class LHDFStore(object):
372
372
373
373
Examples
374
374
--------
375
- # TODO : write examples
375
+ >>> from larray import ndtest
376
+ >>> with LHDFStore('hdf_file.h5') as s:
377
+ ... # dump and read an axis
378
+ ... s['a'] = Axis("a=a0..a2")
379
+ ... a = s['a']
380
+ ... # dump and read a group
381
+ ... s['a01'] = a['a0,a1'] >> 'a01'
382
+ ... a01 = s['a01']
383
+ ... # dump and read an array
384
+ ... s['arr'] = ndtest((3, 3))
385
+ ... arr = s['arr']
386
+ ... # add and read top level metadata
387
+ ... s.meta.author = 'John Smith'
388
+ ... metadata = s.meta
389
+ ... # get filepath
390
+ ... s.filename
391
+ ... # display list of items stored in the hdf file
392
+ ... s.keys()
393
+ ... # display list of items and their type
394
+ ... print(s.summary())
395
+ 'hdf_file.h5'
396
+ ['/a', '/a01', '/arr', '/arr/axis_a', '/arr/axis_b']
397
+ /a: Axis
398
+ /a01: Group
399
+ /arr: Array
400
+ /arr/axis_a: Axis
401
+ /arr/axis_b: Axis
376
402
"""
377
403
def __init__ (self , filepath , mode = None , complevel = None , complib = None ,
378
404
fletcher32 = False , engine = 'auto' , ** kwargs ):
@@ -475,6 +501,10 @@ def keys(self):
475
501
Return a (potentially unordered) list of the keys corresponding to the
476
502
objects stored in the HDFStore. These are ABSOLUTE path-names (e.g.
477
503
have the leading '/'
504
+
505
+ See Also
506
+ --------
507
+ LHDFStore
478
508
"""
479
509
return [n ._v_pathname for n in self ._storer .groups ()]
480
510
@@ -494,16 +524,13 @@ def summary(self):
494
524
"""
495
525
Return a list of LArray stored in the HDF5 file.
496
526
497
- Examples
527
+ See Also
498
528
--------
499
- TODO: write examples
529
+ LHDFStore
500
530
"""
501
531
if self .is_open :
502
- res = ""
503
- for name , group in self .items ():
504
- _type = getattr (group ._v_attrs , 'type' , 'Unknown' )
505
- res += "{}: {}\n " .format (name , _type )
506
- return res
532
+ return '\n ' .join (["{}: {}" .format (name , getattr (group ._v_attrs , 'type' , 'Unknown' ))
533
+ for name , group in self .items ()])
507
534
else :
508
535
return "File {} is CLOSED" .format (self .filename )
509
536
0 commit comments