31 auto seed_details = fetch_numeric_seed(group,
"seed", version, options);
33 auto method = load_scalar_string_dataset(group,
"method");
35 if (!is_valid_arithmetic_operation(method)) {
36 throw std::runtime_error(
"unrecognized operation in 'method' (got '" + method +
"')");
40 auto side = load_scalar_string_dataset(group,
"side");
43 if (method !=
"+" && method !=
"-") {
44 throw std::runtime_error(
"'side' cannot be 'none' for operation '" + method +
"'");
46 }
else if (side !=
"left" && side !=
"right") {
47 throw std::runtime_error(
"'side' for operation '" + method +
"' should be 'left' or 'right' (got '" + side +
"')");
55 auto vhandle = group.openDataSet(
"value");
58 if (version.lt(1, 1, 0)) {
59 val_type = translate_type_0_99(vhandle.getTypeClass());
61 auto type = load_scalar_string_attribute(vhandle,
"type");
62 val_type = translate_type_1_1(type);
63 check_type_1_1(vhandle, val_type);
66 if (val_type != INTEGER && val_type != BOOLEAN && val_type != FLOAT) {
67 throw std::runtime_error(
"dataset should be integer, float or boolean");
71 validate_missing_placeholder(vhandle, version);
73 auto vspace = vhandle.getSpace();
74 const auto ndims = vspace.getSimpleExtentNdims();
77 }
else if (ndims == 1) {
79 vspace.getSimpleExtentDims(&extent);
80 check_unary_along(group, version, seed_details.dimensions, extent);
82 throw std::runtime_error(
"dataset should be scalar or 1-dimensional");
86 }
catch (std::exception& e) {
87 throw std::runtime_error(
"failed to validate 'value'; " + std::string(e.what()));
92 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:30