chihaya
Validating delayed array operations in HDF5
Loading...
Searching...
No Matches
binary_comparison.hpp
Go to the documentation of this file.
1#ifndef CHIHAYA_BINARY_COMPARISON_HPP
2#define CHIHAYA_BINARY_COMPARISON_HPP
3
4#include "H5Cpp.h"
5#include "ritsuko/hdf5/hdf5.hpp"
6#include "ritsuko/ritsuko.hpp"
7
8#include <stdexcept>
9#include <vector>
10
11#include "utils_public.hpp"
12#include "utils_misc.hpp"
13#include "utils_comparison.hpp"
14#include "utils_unary.hpp"
15
21namespace chihaya {
22
27namespace binary_comparison {
28
37inline ArrayDetails validate(const H5::Group& handle, const ritsuko::Version& version, Options& options) {
38 auto left_details = internal_misc::load_seed_details(handle, "left", version, options);
39 auto right_details = internal_misc::load_seed_details(handle, "right", version, options);
40
41 if (!options.details_only) {
42 if (!internal_misc::are_dimensions_equal(left_details.dimensions, right_details.dimensions)) {
43 throw std::runtime_error("'left' and 'right' should have the same dimensions");
44 }
45
46 if ((left_details.type == STRING) != (right_details.type == STRING)) {
47 throw std::runtime_error("both or neither of 'left' and 'right' should contain strings");
48 }
49 }
50
51 auto method = internal_unary::load_method(handle);
52 if (!options.details_only) {
53 if (!internal_comparison::is_valid_operation(method)) {
54 throw std::runtime_error("unrecognized 'method' (" + method + ")");
55 }
56 }
57
58 left_details.type = BOOLEAN;
59 return left_details;
60}
61
62}
63
64}
65
66#endif
ArrayDetails validate(const H5::Group &handle, const ritsuko::Version &version, Options &options)
Definition: binary_comparison.hpp:37
Namespace for all chihaya functions.
Definition: binary_arithmetic.hpp:22
Details about an array.
Definition: utils_public.hpp:36
Validation options.
Definition: utils_public.hpp:66
bool details_only
Definition: utils_public.hpp:71
Various public utilities.