From 324ce7ebe8dd8a84eb68478099684c0fba08e972 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 19 Apr 2011 18:39:14 -0400 Subject: [PATCH] dataset.value has been deprecated since h5py version 1.3. From http://mail.scipy.org/pipermail/scipy-user/2010-February/024364.html [SciPy-User] [ANN] HDF5 for Python (h5py) 1.3.0 beta Andrew Collette andrew.collette@gmail.... Tue Feb 23 15:52:12 CST 2010 ... - Dataset .value attribute is deprecated. Use dataset[...] or dataset[()]. ... --- posts/HDF5.mdwn | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/posts/HDF5.mdwn b/posts/HDF5.mdwn index f3760e6..ff50d91 100644 --- a/posts/HDF5.mdwn +++ b/posts/HDF5.mdwn @@ -80,7 +80,7 @@ Reading from and writing to a dataset >>> dset = f['dset'] >>> dset - >>> dset.value + >>> dset[...] array([[ 0, 1, 2, 3, 4, 5], [ 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17], @@ -239,10 +239,10 @@ Just use the [Numpy slice indexing][slice] you're used to. >>> import h5py >>> import numpy - >>> f = h5py.File('hype.h5', 'w') + >>> f = h5py.File('slice.h5', 'w') >>> f['IntArray'] = numpy.ones((8, 10)) >>> dset = f['IntArray'] - >>> dset.value + >>> dset[...] array([[ 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.], [ 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.], [ 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.], @@ -252,7 +252,7 @@ Just use the [Numpy slice indexing][slice] you're used to. [ 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.], [ 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.]]) >>> f['IntArray'][:,5:] = 2 - >>> dset.value + >>> dset[...] array([[ 1., 1., 1., 1., 1., 2., 2., 2., 2., 2.], [ 1., 1., 1., 1., 1., 2., 2., 2., 2., 2.], [ 1., 1., 1., 1., 1., 2., 2., 2., 2., 2.], @@ -262,7 +262,7 @@ Just use the [Numpy slice indexing][slice] you're used to. [ 1., 1., 1., 1., 1., 2., 2., 2., 2., 2.], [ 1., 1., 1., 1., 1., 2., 2., 2., 2., 2.]]) >>> dset[1:4,2:6] = 5 - >>> f['IntArray'].value + >>> f['IntArray'][...] array([[ 1., 1., 1., 1., 1., 2., 2., 2., 2., 2.], [ 1., 1., 5., 5., 5., 5., 2., 2., 2., 2.], [ 1., 1., 5., 5., 5., 5., 2., 2., 2., 2.], @@ -273,7 +273,27 @@ Just use the [Numpy slice indexing][slice] you're used to. [ 1., 1., 1., 1., 1., 2., 2., 2., 2., 2.]]) >>> f.close() +Here's an example of altering a scalar value: + + >>> import h5py + >>> import numpy + >>> f = h5py.File('scalar.h5', 'w') + >>> f['int'] = 1 + >>> dset = f['int'] + >>> f['int'][...] + 1 + >>> f['int'][...] = 2 + >>> f['int'][...] + 2 + >>> f.pop('int') + >>> f.close() + +I haven't been able to track down official documentation for the +`dataset[...]` syntax, but it is mentioned in [the 1.3 release +announcement][message] that Andrew sent to the `scipy-user` list. + [slice]: http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html +[message]: http://mail.scipy.org/pipermail/scipy-user/2010-February/024364.html Datatypes --------- @@ -285,12 +305,12 @@ Your array's `numpy.dtype` will be preserved. >>> f['complex'] = 2 + 3j >>> f['complex'].dtype dtype('complex128') - >>> type(f['complex'].value) + >>> type(f['complex'][...]) >>> f['complex array'] = [1 + 2j, 3 + 4j] >>> f['complex array'].dtype dtype('complex128') - >>> type(f['complex array'].value) + >>> type(f['complex array'][...]) >>> f.close() @@ -358,7 +378,7 @@ Extendible datasets must be chunked. (2,) >>> c[:] = [9, 8, 7] >>> c.resize((6,)) - >>> c.value + >>> c[...] array([1, 2, 3, 0, 0, 0]) >>> c.resize((6,2)) Traceback (most recent call last): -- 2.26.2