h5py: Correct way to slice array datasets

后端 未结 3 1182
北恋
北恋 2020-12-24 08:14

I\'m a bit confused here:

As far as I have understood, h5py\'s .value method reads an entire dataset and dumps it into an array, which is slow and disco

3条回答
  •  醉话见心
    2020-12-24 09:03

    Based on the title of your post, the 'correct' way to slice array datasets is to use the builtin slice notation

    All of your answers would be equivalent to file["test"][:]

    [:] selects all elements in the array

    More information about slicing notation can be found here, http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html

    I use hdf5 + python often, I've never had to use the .value methods. When you access a dataset in an array like such as myarr = file["test"]

    python copies the dataset in the hdf5 into an array for you already.

提交回复
热议问题