Why won't H5PYDataset.get_data() work within function?

69 Views Asked by At

I have a function which is supposed to unpack an H5PY dataset, temp.hdf5, which only contains one example so it can be evaluated:

def getprob():
    test_set = H5PYDataset('temp.hdf5', which_sets=('test',))
    handle = test_set.open()
    test_data = test_set.get_data(handle, slice(0,1))
    xx = test_data[0]
    YY = test_data[1]
    l, prob, rho_orig, rho_larger, rho_largest = f(xx)
    return prob[9][0]

Where test_data[0] is 28x28 array of integers and test_data[1] is an integer between 0 and 9.

The problem is that, from within the function, test_data[0] is always a 28x28 array of zeros, even though it is not within 'temp.hdf5'. test_data[1] always loads properly, though.

When these lines of code are run outside of the function, everything works just fine.

What is going on here?

0

There are 0 best solutions below