38 auto seed_details = internal_arithmetic::fetch_seed(handle,
"seed", version, options);
40 auto method = internal_unary::load_method(handle);
42 if (!internal_arithmetic::is_valid_operation(method)) {
43 throw std::runtime_error(
"unrecognized operation in 'method' (got '" + method +
"')");
47 auto side = internal_unary::load_side(handle);
50 if (method !=
"+" && method !=
"-") {
51 throw std::runtime_error(
"'side' cannot be 'none' for operation '" + method +
"'");
53 }
else if (side !=
"left" && side !=
"right") {
54 throw std::runtime_error(
"'side' for operation '" + method +
"' should be 'left' or 'right' (got '" + side +
"')");
62 auto vhandle = ritsuko::hdf5::open_dataset(handle,
"value");
65 if (version.lt(1, 1, 0)) {
66 if (vhandle.getTypeClass() == H5T_STRING) {
67 throw std::runtime_error(
"dataset should be integer, float or boolean");
68 }
else if (vhandle.getTypeClass() == H5T_FLOAT) {
72 auto type = ritsuko::hdf5::open_and_load_scalar_string_attribute(vhandle,
"type");
73 min_type = internal_type::translate_type_1_1(type);
74 if (min_type != INTEGER && min_type != BOOLEAN && min_type != FLOAT) {
75 throw std::runtime_error(
"dataset should be integer, float or boolean");
77 internal_type::check_type_1_1(vhandle, min_type);
81 internal_misc::validate_missing_placeholder(vhandle, version);
83 auto vspace = vhandle.getSpace();
84 size_t ndims = vspace.getSimpleExtentNdims();
87 }
else if (ndims == 1) {
89 vspace.getSimpleExtentDims(&extent);
90 internal_unary::check_along(handle, version, seed_details.dimensions, extent);
92 throw std::runtime_error(
"dataset should be scalar or 1-dimensional");
96 }
catch (std::exception& e) {
97 throw std::runtime_error(
"failed to validate 'value'; " + std::string(e.what()));
102 seed_details.type = internal_arithmetic::determine_output_type(min_type, seed_details.type, method);