[h5py] 412/455: Fix auto-conversion for reference types
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:56 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to annotated tag 1.3.0
in repository h5py.
commit 7eaf52681b2b0d95615262bc05fc577f2b47fd97
Author: andrewcollette <andrew.collette at gmail.com>
Date: Sat Feb 20 05:06:42 2010 +0000
Fix auto-conversion for reference types
---
h5py/highlevel.py | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/h5py/highlevel.py b/h5py/highlevel.py
index 06cb6e7..afe5466 100644
--- a/h5py/highlevel.py
+++ b/h5py/highlevel.py
@@ -54,6 +54,17 @@ def is_hdf5(fname):
return h5f.is_hdf5(fname)
return False
+def _guess_dtype(data):
+ """ Attempt to guess an appropriate dtype for the object, returning None
+ if nothing is appropriate (or if it should be left up the the array
+ constructor to figure out)
+ """
+ if isinstance(data, h5r.RegionReference):
+ return h5t.special_dtype(ref=h5r.RegionReference)
+ if isinstance(data, h5r.Reference):
+ return h5t.special_dtype(ref=h5r.Reference)
+ return None
+
# === Base classes ============================================================
class HLObject(object):
@@ -268,7 +279,7 @@ class Group(HLObject, _DictCompat):
htype.commit(self.id, name, lcpl=self._lcpl)
else:
- ds = self.create_dataset(None, data=obj)
+ ds = self.create_dataset(None, data=obj, dtype=_guess_dtype(obj))
h5o.link(ds.id, self.id, name, **plists)
def _set16(self, name, obj):
@@ -1346,7 +1357,7 @@ class AttributeManager(_DictCompat):
Broadcasting isn't supported for attributes.
"""
with phil:
- self.create(name, data=value)
+ self.create(name, data=value, dtype=_guess_dtype(value))
def __delitem__(self, name):
""" Delete an attribute (which must already exist). """
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/h5py.git
More information about the debian-science-commits
mailing list