Comments (5)
Thanks for spotting that!
I made this change in a misguided attempt to fix this warning:
$ python test_dataset_getitem.py Test1DZeroFloat.test_mask filename: /home/john/h5pyd_test/dataset_test1dzerofloat.h5 /Users/jreadey/anaconda3/lib/python3.6/site-packages/h5pyd-0.3.2-py3.6.egg/h5pyd/_hl/dataset.py:581: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use
array.size > 0 to check that an array is not empty. if args == (Ellipsis,) or args == tuple():
I'm not sure of the proper way to fix this though. Looks like the same code is in h5py as well.
For not I just reverted the change.
from h5pyd.
Thanks for a quick response! I understand now the reason for using is
. It seems one first has to test the type and then the tuple contents:
isinstance(args, tuple) and args == (Ellipsis,)
Closing bug since the change was reverted. Good that you keep the code free from deprecation warnings.
from h5pyd.
You suggestion doesn't quite work since we still get the warning -- the comparison is between args[0] and Ellipsis which triggers the numpy warning.
This revised code seems to do the trick:
# === Check for zero-sized datasets =====
if self._shape is None or numpy.product(self._shape) == 0:
# These are the only access methods NumPy allows for such objects
if len(args) == 0 or len(args) == 1 and isinstance(args[0], tuple) and args[0] == Ellipsis:
return numpy.empty(self._shape, dtype=new_dtype)
from h5pyd.
Sorry, but keeping adding a lot of special conditions won't help in the long run. I suggest playing around a bit in an interactive Python session to find out how isinstance works. isinstance(x, tuple)
is a shorthand for type(x) == tuple
from h5pyd.
I do sort of know how ininstance works and use it in the code above.
This would be a bit cleaner I guess::
if len(args) == 0 or isinstance(args[0], tuple) and args[0] == Ellipsis:
return numpy.empty(self._shape, dtype=new_dtype)
from h5pyd.
Related Issues (20)
- bulk download suggestions HOT 2
- hsget failing when datasets contain fillvalues HOT 2
- Append option for hsload HOT 2
- Passing 'Bearer' token to h5pyd instead of fixed keycloak config HOT 3
- Issue in creating /home directory HOT 14
- How to read HDF5 file in Vaex data frame HOT 7
- Conflict with google-auth-oauthlib-0.6.0 on MacOS HOT 11
- hsload change dataset's datatype class from Compound (H5T_COMPOUND) to Opaque (H5T_OPAQUE) HOT 2
- hsds return "filter "H5Z_FLETCHER_DEFLATE" not recognized" due to hsload datasets with FLETCHER32 filter HOT 3
- h5pyd dataset.chunks not compatible with h5py HOT 2
- hsload fails decoding ASCII encoded attributes HOT 10
- hsload fails with compact datasets HOT 1
- `hsload` fails when an attribute has type `Reference` HOT 4
- hsload fails with datasets using scale offset filter HOT 1
- apply source compression filter in hsload HOT 1
- Show filters applied to any datasets in hsls HOT 1
- h5pyd not evaluating environment variables HOT 1
- An error related to hsrm HOT 12
- Error with 1D chunk sizes HOT 2
- `logging.info` call forces downstream package loggers to emit messages twice
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from h5pyd.