chihaya
Validating delayed array operations in HDF5
Loading...
Searching...
No Matches
subset_assignment.hpp
Go to the documentation of this file.
1#ifndef CHIHAYA_SUBSET_ASSIGNMENT_HPP
2#define CHIHAYA_SUBSET_ASSIGNMENT_HPP
3
4#include "H5Cpp.h"
5#include "ritsuko/ritsuko.hpp"
6
7#include <stdexcept>
8#include <vector>
9#include <algorithm>
10
11#include "utils_public.hpp"
12#include "utils_list.hpp"
13#include "utils_misc.hpp"
14#include "utils_subset.hpp"
15#include "utils_dimensions.hpp"
16
22namespace chihaya {
23
32inline ArrayDetails validate_subset_assignment(const H5::Group& group, const ritsuko::Version& version, const Options& options) {
33 auto seed_details = fetch_seed(group, "seed", version, options);
34 const auto& seed_dims = seed_details.dimensions;
35
36 auto value_details = fetch_seed(group, "value", version, options);
37 if (!options.details_only) {
38 if ((value_details.type == STRING) != (seed_details.type == STRING)) {
39 throw std::runtime_error("both or neither of the 'seed' and 'value' arrays should contain strings");
40 }
41 if (seed_dims.size() != value_details.dimensions.size()) {
42 throw std::runtime_error("'seed' and 'value' arrays should have the same dimensionality");
43 }
44
45 auto ihandle = group.openGroup("index");
46 auto collected = validate_subset_index_list(ihandle, seed_dims, version);
47 auto expected_dims = seed_dims;
48 for (auto p : collected) {
49 expected_dims[p.first] = p.second;
50 }
51
52 if (!are_dimensions_equal(expected_dims, value_details.dimensions)) {
53 throw std::runtime_error("'value' dimension extents are not consistent with lengths of indices in 'index'");
54 }
55 }
56
57 // Promotion.
58 seed_details.type = std::max(seed_details.type, value_details.type);
59 return seed_details;
60}
61
62}
63
64#endif
Namespace for all chihaya functions.
Definition binary_arithmetic.hpp:20
ArrayDetails validate_subset_assignment(const H5::Group &group, const ritsuko::Version &version, const Options &options)
Definition subset_assignment.hpp:32
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.