{"action":"created","issue":{"url":"https://api.github.com/repos/h5py/h5py/issues/1051","repository_url":"https://api.github.com/repos/h5py/h5py","labels_url":"https://api.github.com/repos/h5py/h5py/issues/1051/labels{/name}","comments_url":"https://api.github.com/repos/h5py/h5py/issues/1051/comments","events_url":"https://api.github.com/repos/h5py/h5py/issues/1051/events","html_url":"https://github.com/h5py/h5py/issues/1051","id":329820909,"node_id":"MDU6SXNzdWUzMjk4MjA5MDk=","number":1051,"title":"h5py==2.8.0 floats cast to python.float or numpy.float64 non-deterministically (windows)","user":{"login":"davidnewman02","id":22216572,"node_id":"MDQ6VXNlcjIyMjE2NTcy","avatar_url":"https://avatars0.githubusercontent.com/u/22216572?v=4","gravatar_id":"","url":"https://api.github.com/users/davidnewman02","html_url":"https://github.com/davidnewman02","followers_url":"https://api.github.com/users/davidnewman02/followers","following_url":"https://api.github.com/users/davidnewman02/following{/other_user}","gists_url":"https://api.github.com/users/davidnewman02/gists{/gist_id}","starred_url":"https://api.github.com/users/davidnewman02/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidnewman02/subscriptions","organizations_url":"https://api.github.com/users/davidnewman02/orgs","repos_url":"https://api.github.com/users/davidnewman02/repos","events_url":"https://api.github.com/users/davidnewman02/events{/privacy}","received_events_url":"https://api.github.com/users/davidnewman02/received_events","type":"User","site_admin":false},"labels":[{"id":14488209,"node_id":"MDU6TGFiZWwxNDQ4ODIwOQ==","url":"https://api.github.com/repos/h5py/h5py/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/h5py/h5py/milestones/15","html_url":"https://github.com/h5py/h5py/milestone/15","labels_url":"https://api.github.com/repos/h5py/h5py/milestones/15/labels","id":3411882,"node_id":"MDk6TWlsZXN0b25lMzQxMTg4Mg==","number":15,"title":"2.8.1","description":"","creator":{"login":"tacaswell","id":199813,"node_id":"MDQ6VXNlcjE5OTgxMw==","avatar_url":"https://avatars3.githubusercontent.com/u/199813?v=4","gravatar_id":"","url":"https://api.github.com/users/tacaswell","html_url":"https://github.com/tacaswell","followers_url":"https://api.github.com/users/tacaswell/followers","following_url":"https://api.github.com/users/tacaswell/following{/other_user}","gists_url":"https://api.github.com/users/tacaswell/gists{/gist_id}","starred_url":"https://api.github.com/users/tacaswell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tacaswell/subscriptions","organizations_url":"https://api.github.com/users/tacaswell/orgs","repos_url":"https://api.github.com/users/tacaswell/repos","events_url":"https://api.github.com/users/tacaswell/events{/privacy}","received_events_url":"https://api.github.com/users/tacaswell/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":15,"state":"open","created_at":"2018-06-08T20:58:47Z","updated_at":"2018-11-05T09:03:32Z","due_on":null,"closed_at":null},"comments":19,"created_at":"2018-06-06T11:07:34Z","updated_at":"2018-11-05T13:32:44Z","closed_at":null,"author_association":"NONE","body":"When reading a file using h5py==2.80, float values read from the file as a numpy.float64 do not cast correctly back to a python.float\r\ni.e.\r\n```\r\nread_float = h5py.File(filename,'r')['test_group'].attrs['test_float']\r\ncast_float = numpy.asscalar(read_float)\r\ntype(cast_float) # This returns either a python.float or a numpy.float64 at random\r\n```\r\nThis works fine in h5py==2.7.1; although it throws a FutureWarning which seems tangentially related \r\n`FutureWarning: Conversion of the second argument of issubdtype from 'float' to 'np.floating' is deprecated. In future, it will be treated as 'np.float64 == np.dtype(float).type'`\r\n\r\n\r\nTo assist reproducing bugs, please include the following:\r\n * Operating System Windows10\r\n*  h5py    2.8.0\r\n*  HDF5    1.10.2\r\n*  Python  3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)]\r\n*  sys.platform    win32\r\n*  sys.maxsize     9223372036854775807\r\n*  numpy   1.14.3\r\n\r\n\r\n**To reproduce:**\r\n1 - Create a minimal fast5 file\r\n```\r\n# create_simple_fast5.py\r\nimport h5py\r\nfilename = r\"C:\\test.fast5\"\r\n\r\nwith h5py.File(filename,'w') as fh:\r\n    fh.create_group('test_group')\r\n    fh['test_group'].attrs['test_float'] = 3.7\r\n```\r\n2 - Read it and inspect value\r\n``` \r\n# test_load_h5py.py\r\n# Read and cast resulting numpy.float64 to python.float using np.asscalar\r\nimport h5py\r\nimport numpy\r\nfilename = r\"C:\\test.fast5\"\r\n\r\nwith h5py.File(filename,'r') as fh:\r\n    test_out = fh['test_group'].attrs['test_float']\r\n    np_out = numpy.asscalar(test_out)\r\n    print(type(test_out), type(np_out)) # The type of np_out is not deterministic\r\n```\r\n3- Run in a loop\r\n```\r\n# run_loop.py\r\nimport subprocess\r\n\r\nfor i in range(100):\r\n    subprocess.call([\"python\", \"test_load_h5py.py\"])\r\n```\r\nThe resulting datatype after the `numpy.asscalar` conversion is non-deterministic \r\n```\r\n<class 'numpy.float64'> <class 'float'>\r\n<class 'numpy.float64'> <class 'float'>\r\n<class 'numpy.float64'> <class 'float'>\r\n<class 'numpy.float64'> <class 'numpy.float64'>\r\n<class 'numpy.float64'> <class 'float'>\r\n<class 'numpy.float64'> <class 'float'>\r\n<class 'numpy.float64'> <class 'numpy.float64'>\r\netc...\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/h5py/h5py/issues/comments/435874424","html_url":"https://github.com/h5py/h5py/issues/1051#issuecomment-435874424","issue_url":"https://api.github.com/repos/h5py/h5py/issues/1051","id":435874424,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNTg3NDQyNA==","user":{"login":"takluyver","id":327925,"node_id":"MDQ6VXNlcjMyNzkyNQ==","avatar_url":"https://avatars3.githubusercontent.com/u/327925?v=4","gravatar_id":"","url":"https://api.github.com/users/takluyver","html_url":"https://github.com/takluyver","followers_url":"https://api.github.com/users/takluyver/followers","following_url":"https://api.github.com/users/takluyver/following{/other_user}","gists_url":"https://api.github.com/users/takluyver/gists{/gist_id}","starred_url":"https://api.github.com/users/takluyver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/takluyver/subscriptions","organizations_url":"https://api.github.com/users/takluyver/orgs","repos_url":"https://api.github.com/users/takluyver/repos","events_url":"https://api.github.com/users/takluyver/events{/privacy}","received_events_url":"https://api.github.com/users/takluyver/received_events","type":"User","site_admin":false},"created_at":"2018-11-05T13:32:44Z","updated_at":"2018-11-05T13:32:44Z","author_association":"MEMBER","body":"Where you're checking `type(test_out)` and consistently seeing `<class 'numpy.float64'>`, it seems there are actually two different objects with the same repr: `numpy.float64` and `numpy.longdouble` will both show up as `numpy.float64` on Windows when you examine them. You can check `test_out.dtype.char` to see the difference.\r\n\r\nWhich of `longdouble` and `float64` is more correct for reading HDF5 data when they're the same size? Clearly it should be consistent, but which one should it consistently use?"}}
{"actor":{"display_login":"takluyver"}}