30 auto seed_details = fetch_numeric_seed(group,
"seed", version, options);
31 if (seed_details.type == STRING) {
32 throw std::runtime_error(
"type of 'seed' should be integer, float or boolean");
36 auto method = load_scalar_string_dataset(group,
"method");
37 if (method ==
"sign") {
38 seed_details.type = INTEGER;
40 }
else if (method ==
"abs") {
41 seed_details.type = std::max(seed_details.type, INTEGER);
43 }
else if (method ==
"log") {
45 if (group.exists(
"base")) {
46 auto vhandle = group.openDataSet(
"base");
47 if (vhandle.getSpace().getSimpleExtentNdims() != 0) {
48 throw std::runtime_error(
"'base' should be a scalar");
50 if (version.lt(1, 1, 0)) {
51 if (vhandle.getTypeClass() != H5T_FLOAT) {
52 throw std::runtime_error(
"'base' should be a floating-point number");
55 if (ritsuko::hdf5::exceeds_float_limit(vhandle, 64)) {
56 throw std::runtime_error(
"'base' should have a datatype that fits into a 64-bit float");
61 seed_details.type = FLOAT;
63 }
else if (method ==
"round" || method ==
"signif") {
65 auto vhandle = group.openDataSet(
"digits");
66 if (vhandle.getSpace().getSimpleExtentNdims() != 0) {
67 throw std::runtime_error(
"'digits' should be a scalar");
70 if (version.lt(1, 1, 0)) {
71 if (vhandle.getTypeClass() != H5T_INTEGER) {
72 throw std::runtime_error(
"'digits' should be an integer");
75 if (ritsuko::hdf5::exceeds_integer_limit(vhandle, 32,
true)) {
76 throw std::runtime_error(
"'digits' should have a datatype that fits into a 32-bit signed integer");
80 seed_details.type = FLOAT;
82 }
else if (is_other_math(method)) {
83 seed_details.type = FLOAT;
86 throw std::runtime_error(
"unrecognized operation in 'method' (got '" + method +
"')");
ArrayDetails validate_unary_math(const H5::Group &group, const ritsuko::Version &version, const Options &options)
Definition unary_math.hpp:29