diff --git a/changelog.rst b/changelog.rst index e1ec25d5d0ecb00756993a5b6804e7a27e90b38e..2716fa599127e48f29b5ee884e0a2afab7c9e327 100644 --- a/changelog.rst +++ b/changelog.rst @@ -8,7 +8,13 @@ Yet to be versioned and released. Only available from *dev* branch until then. .. rubric:: Bug fixes * fix irrelevant rank check failure when passing arrays (and not tensors) - (`#6 <https://gitlab.irstea.fr/HYCAR-Hydro/evalhyd/evalhyd-cpp/-/issues/6>`_) + (`CPP#6 <https://gitlab.irstea.fr/HYCAR-Hydro/evalhyd/evalhyd-cpp/-/issues/6>`_, + `R#4 <https://gitlab.irstea.fr/HYCAR-Hydro/evalhyd/evalhyd-r/-/issues/4>`_) +* fix crashing conditional masking functionality at runtime with certain + compilers on Windows (in particular when building with Rtools for R>4.1.3) due + to the presence of square brackets in the regular expressions that do not seem + supported + (`R#6 <https://gitlab.irstea.fr/HYCAR-Hydro/evalhyd/evalhyd-r/-/issues/6>`_) v0.1.0 ------ diff --git a/include/evalhyd/detail/masks.hpp b/include/evalhyd/detail/masks.hpp index d1d503e257a826f6448f199c42265daa874fcd65..fe40d078f6cd4836b63fd72499a96c56ffbb9382 100644 --- a/include/evalhyd/detail/masks.hpp +++ b/include/evalhyd/detail/masks.hpp @@ -35,7 +35,10 @@ namespace evalhyd // observed or predicted (median or mean for probabilist) streamflow // e.g. q{>9.} q{<9} q{>=99.0} q{<=99} q{>9,<99} q{==9} q{!=9} std::regex exp_q ( - R"((q_obs|q_prd_median|q_prd_mean)\{(((<|>|<=|>=|==|!=)(mean,?|median,?|qtl[0-1]\.[0-9]+,?|[0-9]+\.?[0-9]*,?))+)\})" + R"((q_obs|q_prd_median|q_prd_mean)\{(((<|>|<=|>=|==|!=)(mean,?|median,?|qtl(0|1)\.(0|1|2|3|4|5|6|7|8|9)+,?|(0|1|2|3|4|5|6|7|8|9)+\.?(0|1|2|3|4|5|6|7|8|9)*,?))+)\})" + // NOTE: this should be `R"((q_obs|q_prd_median|q_prd_mean)\{(((<|>|<=|>=|==|!=)(mean,?|median,?|qtl[0-1]\.[0-9]+,?|[0-9]+\.?[0-9]*,?))+)\})"` + // but there is a bug in the building chain for R packages + // https://gitlab.irstea.fr/HYCAR-Hydro/evalhyd/evalhyd-r/-/issues/6 ); for (std::sregex_iterator i = @@ -51,7 +54,12 @@ namespace evalhyd std::vector<std::vector<std::string>> conditions; // pattern supported to specify masking conditions based on streamflow - std::regex ex (R"((<|>|<=|>=|==|!=)(mean|median|qtl[0-1]\.[0-9]+|[0-9]+\.?[0-9]*))"); + std::regex ex ( + R"((<|>|<=|>=|==|!=)(mean|median|qtl(0|1)\.(0|1|2|3|4|5|6|7|8|9)+|(0|1|2|3|4|5|6|7|8|9)+\.?(0|1|2|3|4|5|6|7|8|9)*))" + // NOTE: this should be `R"((<|>|<=|>=|==|!=)(mean|median|qtl[0-1]\.[0-9]+|[0-9]+\.?[0-9]*))"` + // but there is a bug in the building chain for R packages + // https://gitlab.irstea.fr/HYCAR-Hydro/evalhyd/evalhyd-r/-/issues/6 + ); for (std::sregex_iterator j = std::sregex_iterator(str.begin(), str.end(), ex); @@ -92,7 +100,12 @@ namespace evalhyd // pattern supported to specify conditions to generate masks on time index // e.g. t{0:10} t{0:10,20:30} t{0,1,2,3} t{0:10,30,40,50} t{:} - std::regex exp_t (R"((t)\{(:|([0-9]+:[0-9]+,?|[0-9]+,?)+)\})"); + std::regex exp_t ( + R"((t)\{(:|((0|1|2|3|4|5|6|7|8|9)+:(0|1|2|3|4|5|6|7|8|9)+,?|(0|1|2|3|4|5|6|7|8|9)+,?)+)\})" + // NOTE: this should be `R"((t)\{(:|([0-9]+:[0-9]+,?|[0-9]+,?)+)\})"` + // but there is a bug in the building chain for R packages + // https://gitlab.irstea.fr/HYCAR-Hydro/evalhyd/evalhyd-r/-/issues/6 + ); for (std::sregex_iterator i = std::sregex_iterator(msk_str.begin(), msk_str.end(), exp_t); @@ -114,7 +127,12 @@ namespace evalhyd else { // pattern supported to specify masking conditions based on time index - std::regex e (R"([0-9]+:[0-9]+|[0-9]+)"); + std::regex e ( + R"((0|1|2|3|4|5|6|7|8|9)+:(0|1|2|3|4|5|6|7|8|9)+|(0|1|2|3|4|5|6|7|8|9)+)" + // NOTE: this should be `R"([0-9]+:[0-9]+|[0-9]+)"` + // but there is a bug in the building chain for R packages + // https://gitlab.irstea.fr/HYCAR-Hydro/evalhyd/evalhyd-r/-/issues/6 + ); for (std::sregex_iterator j = std::sregex_iterator(s.begin(), s.end(), e);