Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate dimensions in fancy selection fails #31

Closed
andrewcollette opened this issue Dec 27, 2012 · 3 comments
Closed

Validate dimensions in fancy selection fails #31

andrewcollette opened this issue Dec 27, 2012 · 3 comments
Labels

Comments

@andrewcollette
Copy link
Contributor

Original author: fal...@gmail.com (February 20, 2009 12:06:41)

Here it is a script showing the problem:

{{{
import numpy as np
import h5py

SHAPE = (4,5)
DTYPE = np.dtype('i')
SIZE = np.product(SHAPE)

f = h5py.File('/tmp/test.hdf5','w')
mydata = np.arange(SIZE,dtype=DTYPE).reshape(SHAPE)
dset = f.create_dataset("mydata", data=mydata)
f.flush()

keys = (slice(None), [0,1,2,3,4])
a = mydata[keys]
print "numpy-->", a
b = dset[keys]
print "h5py-->", b
assert np.alltrue(a == b)
f.close()
}}}

which raise the next error:

{{{
numpy--> [[ 0 1 2 3 4]
[ 5 6 7 8 9]
[10 11 12 13 14]
[15 16 17 18 19]]
Traceback (most recent call last):
File "multidim.py", line 16, in <module>
b = dset[keys]
File "/home/faltet/python/h5py/trunk/h5py/highlevel.py", line 889, in
getitem
selection = sel.select(self.shape, args)
File "/home/faltet/python/h5py/trunk/h5py/selections.py", line 42, in select
sel[args]
File "/home/faltet/python/h5py/trunk/h5py/selections.py", line 338, in
getitem
validate_number(select_idx, length)
File "/home/faltet/python/h5py/trunk/h5py/selections.py", line 295, in
validate_number
raise IndexError('Index out of bounds: %d' % num)
IndexError: Index out of bounds: 5
}}}

Attached is a fix for this.

Original issue: http://code.google.com/p/h5py/issues/detail?id=31

@andrewcollette
Copy link
Contributor Author

From fal...@gmail.com on February 20, 2009 12:08:54
Ops. I missed to comment that the patch here should be applied after issue #29.

@andrewcollette
Copy link
Contributor Author

From andrew.c...@gmail.com on February 23, 2009 21:52:58
Patch applied; needs unit tests

@andrewcollette
Copy link
Contributor Author

From andrew.c...@gmail.com on June 16, 2009 23:45:06
Add test for 1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant