{"action":"created","issue":{"url":"https://api.github.com/repos/h5py/h5py/issues/441","repository_url":"https://api.github.com/repos/h5py/h5py","labels_url":"https://api.github.com/repos/h5py/h5py/issues/441/labels{/name}","comments_url":"https://api.github.com/repos/h5py/h5py/issues/441/comments","events_url":"https://api.github.com/repos/h5py/h5py/issues/441/events","html_url":"https://github.com/h5py/h5py/issues/441","id":32865216,"number":441,"title":"Python3 error storing a tuple of strings as attribute","user":{"login":"monkeybutter","id":2526498,"avatar_url":"https://avatars1.githubusercontent.com/u/2526498?v=4","gravatar_id":"","url":"https://api.github.com/users/monkeybutter","html_url":"https://github.com/monkeybutter","followers_url":"https://api.github.com/users/monkeybutter/followers","following_url":"https://api.github.com/users/monkeybutter/following{/other_user}","gists_url":"https://api.github.com/users/monkeybutter/gists{/gist_id}","starred_url":"https://api.github.com/users/monkeybutter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monkeybutter/subscriptions","organizations_url":"https://api.github.com/users/monkeybutter/orgs","repos_url":"https://api.github.com/users/monkeybutter/repos","events_url":"https://api.github.com/users/monkeybutter/events{/privacy}","received_events_url":"https://api.github.com/users/monkeybutter/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2014-05-06T04:16:24Z","updated_at":"2018-05-14T01:22:29Z","closed_at":"2014-05-11T22:54:58Z","author_association":"NONE","body":"I'm in the process of making my code python3 compatible and I'm getting an error in the following line:\n\n```\ndset.attrs['Column Names'] = ('X', 'Y', 'Z', 'Intensity', 'Distance', 'Angle')\n```\n\nThe error shows:\n\n```\nTraceback (most recent call last):\n  File \"test.py\", line 10, in write_to_hdf5\n    dset.attrs['Column Names'] = ('X', 'Y', 'Z', 'Intensity', 'Distance', 'Angle')\n  File \"/home/roz016/anaconda/envs/py3k/lib/python3.3/site-packages/h5py/_hl/attrs.py\", line 71, in __setitem__\n    self.create(name, data=value, dtype=base.guess_dtype(value))\n  File \"/home/roz016/anaconda/envs/py3k/lib/python3.3/site-packages/h5py/_hl/attrs.py\", line 108, in create\n    htype = h5t.py_create(dtype, logical=True)\n  File \"h5t.pyx\", line 1379, in h5py.h5t.py_create (h5py/h5t.c:12683)\n  File \"h5t.pyx\", line 1457, in h5py.h5t.py_create (h5py/h5t.c:12578)\nTypeError: No conversion path for dtype: dtype('<U9')\n```\n\nThis code works perfectly fine using python2.7. Isn't it possible to store string tuples as attributes using python3?\n"},"comment":{"url":"https://api.github.com/repos/h5py/h5py/issues/comments/388672002","html_url":"https://github.com/h5py/h5py/issues/441#issuecomment-388672002","issue_url":"https://api.github.com/repos/h5py/h5py/issues/441","id":388672002,"user":{"login":"chrisjbillington","id":1044087,"avatar_url":"https://avatars0.githubusercontent.com/u/1044087?v=4","gravatar_id":"","url":"https://api.github.com/users/chrisjbillington","html_url":"https://github.com/chrisjbillington","followers_url":"https://api.github.com/users/chrisjbillington/followers","following_url":"https://api.github.com/users/chrisjbillington/following{/other_user}","gists_url":"https://api.github.com/users/chrisjbillington/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisjbillington/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisjbillington/subscriptions","organizations_url":"https://api.github.com/users/chrisjbillington/orgs","repos_url":"https://api.github.com/users/chrisjbillington/repos","events_url":"https://api.github.com/users/chrisjbillington/events{/privacy}","received_events_url":"https://api.github.com/users/chrisjbillington/received_events","type":"User","site_admin":false},"created_at":"2018-05-14T01:22:29Z","updated_at":"2018-05-14T01:22:29Z","author_association":"NONE","body":"The 'tag' is part of HDF5. HDF5 lets you set the character set for string types, so it's possible to store an array of fixed length bytestrings with the character set set to 'UTF8' indicating that the bytes comprise UTF8 encoded strings. This is the general mechanism for unicode support in HDF5: just store bytes and tell the application whether the encoding is ASCII or UTF8.\r\n\r\nIn pull request #1031 I demonstrate this, storing a fixed-length bytestring numpy array (the bytes being UTF8 encoded strings) and setting the character set in HDF5 to UTF8, and decoding it to a numpy 'U' array upon read. I no longer like this approach (it is easier to store an array of vlen unicode strings - note that these are also the same as vlen ASCII strings except for this character encoding tag). Both of these approaches are compatible with other applications: if I open the resulting file in hdfview it displays the string arrays with unicode characters correctly."}}
{"actor":{"display_login":"chrisjbillington"}}