38 auto shandle = group.openGroup(
"seed");
39 seed_details = validate_numeric_seed(shandle, version, options);
41 std::throw_with_nested(std::runtime_error(
"failed to validate 'seed'"));
46 auto mhandle = group.openDataSet(
"method");
47 method = read_scalar_string_dataset(mhandle);
50 if (!is_valid_arithmetic_operation(method)) {
51 throw std::runtime_error(
"unrecognized operation '" + method +
"'");
55 std::throw_with_nested(std::runtime_error(
"failed to validate 'method'"));
60 auto shandle = group.openDataSet(
"side");
61 side = read_scalar_string_dataset(shandle);
65 if (method !=
"+" && method !=
"-") {
66 throw std::runtime_error(
"cannot be 'none' for operation '" + method +
"'");
68 }
else if (side !=
"left" && side !=
"right") {
69 throw std::runtime_error(
"expected 'left' or 'right' for operation '" + method +
"'");
73 std::throw_with_nested(std::runtime_error(
"failed to validate 'side'"));
80 enum Failure { VALUE, ALONG };
81 Failure who_failed = VALUE;
83 auto vhandle = group.openDataSet(
"value");
85 if (version.lt(1, 1, 0)) {
86 val_type = translate_type_0_99(vhandle.getTypeClass());
89 auto thandle = vhandle.openAttribute(
"type");
90 auto type = read_scalar_string_attribute(thandle);
91 val_type = translate_type_1_1(type);
92 check_type_1_1(vhandle, val_type);
94 std::throw_with_nested(std::runtime_error(
"failed to validate the 'type' attribute"));
98 if (val_type != INTEGER && val_type != BOOLEAN && val_type != FLOAT) {
99 throw std::runtime_error(
"dataset should be integer, float or boolean");
103 validate_missing_placeholder(vhandle, version);
105 auto vspace = vhandle.getSpace();
106 auto ndims = vspace.getSimpleExtentNdims();
109 }
else if (ndims == 1) {
111 vspace.getSimpleExtentDims(&extent);
113 auto ahandle = group.openDataSet(
"along");
114 check_unary_along(ahandle, version, seed_details.
dimensions, extent);
117 throw std::runtime_error(
"dataset should be scalar or 1-dimensional");
123 switch (who_failed) {
124 case VALUE: desc =
"value";
break;
125 case ALONG: desc =
"along";
break;
127 std::throw_with_nested(std::runtime_error(
"failed to validate '" + desc +
"'"));
132 seed_details.
type = determine_arithmetic_output_type(val_type, seed_details.
type, method);
ArrayDetails validate_unary_arithmetic(const H5::Group &group, const ritsuko::Version &version, const Options &options)
Definition unary_arithmetic.hpp:35