1#ifndef CHIHAYA_COMBINE_HPP
2#define CHIHAYA_COMBINE_HPP
5#include "ritsuko/ritsuko.hpp"
6#include "ritsuko/hdf5/hdf5.hpp"
13#include "utils_list.hpp"
14#include "utils_misc.hpp"
26inline ArrayDetails
validate(
const H5::Group&,
const ritsuko::Version&, Options&);
46 uint64_t along = internal_misc::load_along(handle, version);
48 auto shandle = ritsuko::hdf5::open_group(handle,
"seeds");
49 internal_list::ListDetails list_params;
51 list_params = internal_list::validate(shandle, version);
52 }
catch (std::exception& e) {
53 throw std::runtime_error(std::string(
"failed to load 'seeds' list; ") + e.what());
55 if (list_params.present.size() != list_params.length) {
56 throw std::runtime_error(
"missing elements in the 'seeds' list");
59 std::vector<size_t> dimensions;
63 size_t num_strings = 0;
65 for (
const auto& p : list_params.present) {
66 auto current = ritsuko::hdf5::open_group(shandle, p.second.c_str());
71 }
catch (std::exception& e) {
72 throw std::runtime_error(
"failed to validate 'seeds/" + p.second +
"'; " + std::string(e.what()));
78 if (
static_cast<size_t>(along) >= dimensions.size()) {
79 throw std::runtime_error(
"'along' should be less than the seed dimensionality");
83 if (type < cur_seed.
type) {
86 if (dimensions.size() != cur_seed.
dimensions.size()) {
87 throw std::runtime_error(
"dimensionality mismatch between seeds");
89 for (
size_t d = 0; d < dimensions.size(); ++d) {
90 if (d ==
static_cast<size_t>(along)) {
92 }
else if (dimensions[d] != cur_seed.
dimensions[d]) {
93 throw std::runtime_error(
"inconsistent dimension extents between seeds");
98 num_strings += (cur_seed.
type == STRING);
101 if (num_strings != 0 && num_strings != list_params.length) {
102 throw std::runtime_error(
"either none or all of the arrays to be combined should contain strings");
ArrayDetails validate(const H5::Group &handle, const ritsuko::Version &version, Options &options)
Definition: combine.hpp:45
Namespace for all chihaya functions.
Definition: binary_arithmetic.hpp:22
ArrayDetails validate(const H5::Group &handle, const ritsuko::Version &version, Options &options)
Definition: validate.hpp:92
ArrayType
Definition: utils_public.hpp:27
Details about an array.
Definition: utils_public.hpp:36
std::vector< size_t > dimensions
Definition: utils_public.hpp:56
ArrayType type
Definition: utils_public.hpp:50
Validation options.
Definition: utils_public.hpp:66