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/ritsuko.hpp"
6
7#include <stdexcept>
8#include <vector>
9
10#include "utils_public.hpp"
11#include "utils_misc.hpp"
12#include "utils_nary.hpp"
13
19namespace chihaya {
20
29inline ArrayDetails validate_binary_comparison(const H5::Group& group, const ritsuko::Version& version, const Options& options) {
30 auto left_details = fetch_seed(group, "left", version, options);
31 auto right_details = fetch_seed(group, "right", version, options);
32
33 if (!options.details_only) {
34 if (!are_dimensions_equal(left_details.dimensions, right_details.dimensions)) {
35 throw std::runtime_error("'left' and 'right' should have the same dimensions");
36 }
37
38 if ((left_details.type == STRING) != (right_details.type == STRING)) {
39 throw std::runtime_error("both or neither of 'left' and 'right' should contain strings");
40 }
41
42 auto method = load_scalar_string_dataset(group, "method");
43 if (!is_valid_comparison_operation(method)) {
44 throw std::runtime_error("unrecognized 'method' (" + method + ")");
45 }
46 }
47
48 left_details.type = BOOLEAN;
49 return left_details;
50}
51
52}
53
54#endif
Namespace for all chihaya functions.
Definition binary_arithmetic.hpp:20
ArrayDetails validate_binary_comparison(const H5::Group &group, const ritsuko::Version &version, const Options &options)
Definition binary_comparison.hpp:29
Details about an array.
Definition utils_public.hpp:37
Validation options.
Definition utils_public.hpp:67
bool details_only
Definition utils_public.hpp:72
Various public utilities.