Skip to content

Difference with numpy indexing #652

Description

@huard

Slicing a Numpy multidimensional array and the same h5py dataset yields different results.

>>> import numpy as np
>>> import h5py as h5

>>> dims = [1,2,3,4]
>>> a = np.arange(np.prod(dims)).reshape(dims)
>>> F = h5.File('test.h5')
>>> F.create_dataset('test', data=a)
>>> a[0,slice(None), [0,1]]
array([[[ 0,  1,  2,  3],
        [12, 13, 14, 15]],

       [[ 4,  5,  6,  7],
        [16, 17, 18, 19]]])
>>> F['test'][0,slice(None),[0,1]]
array([[[ 0,  1,  2,  3],
        [ 4,  5,  6,  7]],

       [[12, 13, 14, 15],
        [16, 17, 18, 19]]])

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions