public void H5Sget_simple_extent_typeTest3() { hid_t space = H5S.create(H5S.class_t.SCALAR); Assert.IsTrue(space >= 0); Assert.IsTrue( H5S.get_simple_extent_type(space) == H5S.class_t.SCALAR); Assert.IsTrue(H5S.close(space) >= 0); }
public void H5Sget_simple_extent_typeTest1() { hsize_t[] dims = { 1, 2, 3 }; hid_t space = H5S.create_simple(dims.Length, dims, dims); Assert.IsTrue(space >= 0); Assert.IsTrue( H5S.get_simple_extent_type(space) == H5S.class_t.SIMPLE); Assert.IsTrue(H5S.close(space) >= 0); }
public void H5Sset_extent_noneTest1() { hsize_t[] dims = { 10, 20, 30 }; hid_t space = H5S.create_simple(dims.Length, dims, dims); Assert.IsTrue(space > 0); Assert.IsTrue(H5S.set_extent_none(space) >= 0); Assert.IsTrue( H5S.get_simple_extent_type(space) == H5S.class_t.NO_CLASS); Assert.IsTrue(H5S.close(space) >= 0); }
public static T ReadScalarNumericAttribute <T>(hid_t attribute) where T : struct { var space = H5A.get_space(attribute); if (space < 0) { throw new Exception("Failed to get space"); } if (H5S.get_simple_extent_type(space) != H5S.class_t.SCALAR) { H5S.close(space); throw new Exception("Not a scalar data space"); } H5S.close(space); var type = H5A.get_type(attribute); if (type < 0) { throw new Exception("Failed to get type"); } var typeClass = H5T.get_class(type); H5T.close(type); if (typeClass != H5T.class_t.INTEGER && typeClass != H5T.class_t.FLOAT) { throw new Exception("Not an integral or floating point data type"); } // TODO: // Check if value can be cast to type of this attribute. // // TODO: // T[] value = new T[1]; // H5A.read(attribute, NumericTypeToHDF5Type<T>(), new PinnedObject(value)); object boxedValue = new T(); if (H5A.read(attribute, NumericTypeToHDF5Type <T>(), new PinnedObject(boxedValue)) < 0) { throw new Exception("Failed to read attribute"); } return((T)boxedValue); }
public static bool WriteScalarNumericAttribute <T>(hid_t attribute, T value, hid_t type) where T : struct { var space = H5A.get_space(attribute); if (space < 0) { throw new Exception("Failed to get space"); } if (H5S.get_simple_extent_type(space) != H5S.class_t.SCALAR) { H5S.close(space); throw new Exception("Not a scalar data space"); } H5S.close(space); var attributeType = H5A.get_type(attribute); if (attributeType < 0) { throw new Exception("Failed to get type"); } var attributeTypeClass = H5T.get_class(attributeType); H5T.close(attributeType); if (attributeTypeClass != H5T.class_t.INTEGER && attributeTypeClass != H5T.class_t.FLOAT) { throw new Exception("Not an integral or floating point data type"); } // TODO: // Check if value can be cast to type of this attribute. object boxedValue = value; H5A.write(attribute, type, new PinnedObject(boxedValue)); return(true); }
public static bool WriteFixedStringAttribute(hid_t attribute, string value, bool utf8) { if (value == null) { throw new ArgumentNullException("value"); } var space = H5A.get_space(attribute); if (space < 0) { throw new Exception("Failed to get data space"); } if (H5S.get_simple_extent_type(space) != H5S.class_t.SCALAR) { H5S.close(space); throw new Exception("Not a scalar data space"); } H5S.close(space); var type = H5A.get_type(attribute); if (type < 0) { throw new Exception("Failed to get type"); } var typeClass = H5T.get_class(type); if (typeClass != H5T.class_t.STRING) { H5T.close(type); throw new Exception("Not a string attribute"); } var isVariableString = H5T.is_variable_str(type); H5T.close(type); if (isVariableString < 0) { throw new Exception("H5T.is_variable_str failed"); } if (isVariableString > 0) { throw new Exception("Not a fixed string attribute"); } // TODO: Do we really need to create a new memory type here? var bytes = value.ToBytes(utf8); var memType = CreateFixedStringType(bytes, utf8); // TODO: type or memType here? H5A.write(attribute, memType, new PinnedObject(bytes)); H5T.close(memType); return(true); }
public void H5Sget_simple_extent_typeTest4() { Assert.IsTrue( H5S.get_simple_extent_type(Utilities.RandomInvalidHandle()) == H5S.class_t.NO_CLASS); }