chihaya
Validating delayed array operations in HDF5
Loading...
Searching...
No Matches
binary_logic.hpp
Go to the documentation of this file.
1#ifndef CHIHAYA_BINARY_LOGIC_HPP
2#define CHIHAYA_BINARY_LOGIC_HPP
3
4#include "H5Cpp.h"
5#include "ritsuko/ritsuko.hpp"
6
7#include <stdexcept>
8#include <vector>
9#include <string>
10
11#include "utils_public.hpp"
12#include "utils_misc.hpp"
13#include "utils_nary.hpp"
14
20namespace chihaya {
21
30inline ArrayDetails validate_binary_logic(const H5::Group& group, const ritsuko::Version& version, const Options& options) {
31 ArrayDetails left_details;
32 try {
33 auto lhandle = group.openGroup("left");
34 left_details = validate_numeric_seed(lhandle, version, options);
35 } catch (...) {
36 std::throw_with_nested(std::runtime_error("failed to validate 'left'"));
37 }
38
39 ArrayDetails right_details;
40 try {
41 auto rhandle = group.openGroup("right");
42 right_details = validate_numeric_seed(rhandle, version, options);
43 } catch (...) {
44 std::throw_with_nested(std::runtime_error("failed to validate 'right'"));
45 }
46
47 if (!options.details_only) {
48 if (!are_dimensions_equal(left_details.dimensions, right_details.dimensions)) {
49 throw std::runtime_error("'left' and 'right' should have the same dimensions");
50 }
51
52 try {
53 auto mhandle = group.openDataSet("method");
54 auto method = read_scalar_string_dataset(mhandle);
55 if (!is_valid_logic_operation(method)) {
56 throw std::runtime_error("unrecognized operation '" + method + "'");
57 }
58 } catch (...) {
59 std::throw_with_nested(std::runtime_error("failed to validate 'method'"));
60 }
61 }
62
63 left_details.type = BOOLEAN;
64 return left_details;
65}
66
67}
68
69#endif
Namespace for all chihaya functions.
Definition binary_arithmetic.hpp:20
ArrayDetails validate_binary_logic(const H5::Group &group, const ritsuko::Version &version, const Options &options)
Definition binary_logic.hpp:30
Details about an array.
Definition utils_public.hpp:38
std::vector< std::size_t > dimensions
Definition utils_public.hpp:58
ArrayType type
Definition utils_public.hpp:52
Options for validate().
Definition utils_public.hpp:79
bool details_only
Definition utils_public.hpp:84
Various public utilities.