Код: Выделить всё
const auto att = dataSet.openAttribute(attributeName);
if (att.getDataType() == H5::PredType::NATIVE_DOUBLE) {
att.read(att.getDataType(), &attributeValue);
}
else if (att.getDataType() == H5::PredType::NATIVE_FLOAT) {
float temp = 0.F;
att.read(att.getDataType(), &temp);
attributeValue = static_cast(temp);
}
else {
// we throw an exception indicating we don't support the type
}
Код: Выделить всё
func (s *Attribute) Read(data interface{}, dtype *Datatype) error
Код: Выделить всё
func (s *Attribute) GetType() Identifier
Код: Выделить всё
if attr.GetType().ID() == hdf5.T_NATIVE_DOUBLE.ID() {
// handle as a double
}
Я просмотрел онлайн-документацию по адресу https://godoc.org/gonum.org/v1/hdf5, но не смог найти решение своей проблемы. (Или любой пример чтения атрибутов HDF5 с использованием GO.)
Кому-нибудь удалось сделать что-то подобное? Или большинство примеров просто предполагают тип, а не запрашивают его?
Подробнее здесь: https://stackoverflow.com/questions/548 ... data-types
Мобильная версия