Repository: jjhelmus/pyfive

Issue:
Access values with path
One thing that is not yet possible and that would help a lot. For example, with version 0.2.0:
Using Python 2.7.12 (default, Jul  1 2016, 15:12:24) 
[GCC 5.4.0 20160609] on linux2

> > > import h5py
> > > import pyfive
> > > 
> > > f5 = h5py.File('tests/latest.hdf5')
> > > f5["group1/subgroup1/dataset3"].value
> > > array([ 0.,  1.,  2.,  3.], dtype=float32)
> > > ffive = pyfive.File('tests/latest.hdf5')
> > > ffive["group1/subgroup1/dataset3"].value
> > > Traceback (most recent call last):
> > >   File "<stdin>", line 1, in <module>
> > >   File "pyfive/high_level.py", line 48, in **getitem**
> > >     raise KeyError('%s not found in group' % (y))
> > > KeyError: 'group1/subgroup1/dataset3 not found in group'


Discussion:

Patch:
diff --git a/pyfive/high_level.py b/pyfive/high_level.py
index 121b980..7bcaded 100644
--- a/pyfive/high_level.py
+++ b/pyfive/high_level.py
@@ -321,6 +321,13 @@ class Dataset(object):
         """ dtype attribute. """
         return self._dataobjects.dtype
 
+    @property
+    def value(self):
+        """ alias for dataset[()]. """
+        DeprecationWarning(
+            "dataset.value has been deprecated. Use dataset[()] instead.")
+        return self[()]
+
     @property
     def size(self):
         """ size attribute. """


Test patch:
diff --git a/tests/test_high_level.py b/tests/test_high_level.py
index c92eca1..7741cbd 100644
--- a/tests/test_high_level.py
+++ b/tests/test_high_level.py
@@ -92,6 +92,9 @@ def test_dataset_class():
         assert_array_equal(dset1[:], np.arange(4))
         assert_array_equal(dset2[:], np.arange(4))
 
+        assert_array_equal(dset1.value, np.arange(4))
+        assert_array_equal(dset2.value, np.arange(4))
+
         assert dset1.len() == 4
         assert dset2.len() == 4