37 auto shandle = group.openGroup(
"seed");
38 seed_details =
validate(shandle, version, options);
40 std::throw_with_nested(std::runtime_error(
"failed to validate 'seed'"));
42 if (seed_details.
type == STRING) {
43 throw std::runtime_error(
"type of 'seed' should be integer, float or boolean");
48 auto mhandle = group.openDataSet(
"method");
49 method = read_scalar_string_dataset(mhandle);
51 std::throw_with_nested(std::runtime_error(
"failed to validate 'method'"));
54 if (method ==
"sign") {
55 seed_details.
type = INTEGER;
57 }
else if (method ==
"abs") {
58 seed_details.
type = std::max(seed_details.
type, INTEGER);
60 }
else if (method ==
"log") {
62 if (group.exists(
"base")) {
64 auto vhandle = group.openDataSet(
"base");
65 if (vhandle.getSpace().getSimpleExtentNdims() != 0) {
66 throw std::runtime_error(
"expected a scalar dataset");
68 if (version.lt(1, 1, 0)) {
69 if (vhandle.getTypeClass() != H5T_FLOAT) {
70 throw std::runtime_error(
"expected a floating-point number");
73 if (ritsuko::hdf5::exceeds_float_limit(vhandle, 64)) {
74 throw std::runtime_error(
"expected a datatype that fits into a 64-bit float");
78 std::throw_with_nested(std::runtime_error(
"failed to validate 'base'"));
82 seed_details.
type = FLOAT;
84 }
else if (method ==
"round" || method ==
"signif") {
87 auto vhandle = group.openDataSet(
"digits");
88 if (vhandle.getSpace().getSimpleExtentNdims() != 0) {
89 throw std::runtime_error(
"'expected a scalar dataset");
92 if (version.lt(1, 1, 0)) {
93 if (vhandle.getTypeClass() != H5T_INTEGER) {
94 throw std::runtime_error(
"expected an integer");
97 if (ritsuko::hdf5::exceeds_integer_limit(vhandle, 32,
true)) {
98 throw std::runtime_error(
"expected a datatype that fits into a 32-bit signed integer");
102 std::throw_with_nested(std::runtime_error(
"failed to validate 'digits'"));
105 seed_details.
type = FLOAT;
107 }
else if (is_other_math(method)) {
108 seed_details.
type = FLOAT;
111 throw std::runtime_error(
"unrecognized operation '" + method +
"' in 'method'");
ArrayDetails validate(const H5::Group &group, const ritsuko::Version &version, const Options &options)
Definition validate.hpp:96
ArrayDetails validate_unary_math(const H5::Group &group, const ritsuko::Version &version, const Options &options)
Definition unary_math.hpp:34