HDFGroup / h5pyd

h5py distributed - Python client library for HDF Rest API
Other
111 stars 39 forks source link

The `-` operator is not supported in numpy (kind of) #33

Closed kotfic closed 6 years ago

kotfic commented 6 years ago

For me, code like the following:

# specify a chunk layout
f.create_dataset("chunked_data", (1024,1024,1024), dtype='f4',chunks=(1,1024,1024))
dset = f["chunked_data"]
dset.chunks

Is producing the following numpy type error:

TypeError                                 Traceback (most recent call last)
<ipython-input-13-1e2d51a33867> in <module>()
      1 # specify a chunk layout
----> 2 f.create_dataset("chunked_data", (1024,1024,1024), dtype='f4',chunks=(1,1024,1024))
      3 dset = f["chunked_data"]
      4 dset.chunks

~/src/h5pyd/h5pyd/_hl/group.py in create_dataset(self, name, shape, dtype, data, **kwds)
    148 
    149         with phil:
--> 150             dsid = dataset.make_new_dset(self, shape, dtype, data, **kwds)
    151             dset = dataset.Dataset(dsid)
    152 

~/src/h5pyd/h5pyd/_hl/dataset.py in make_new_dset(parent, shape, dtype, data, chunks, compression, shuffle, fletcher32, maxshape, compression_opts, fillvalue, scaleoffset, track_times)
    116     tmp_shape = maxshape if maxshape is not None else shape
    117     # Validate chunk shape
--> 118     if isinstance(chunks, tuple) and (-numpy.array([ i>=j for i,j in zip(tmp_shape,chunks) if i is not None])).any():
    119         errmsg = "Chunk shape must not be greater than data shape in any dimension. "\
    120                  "{} is not compatible with {}".format(chunks, shape)

TypeError: The numpy boolean negative, the `-` operator, is not supported, use the `~` operator or the logical_not function instead.

I am running python 3.6.1 and numpy 1.13.1 on archlinux inside of a virtual environment.

Use of the '-' operator is apparently being debated. Either way it looks like numpy is trying to move away from its usage.