Skip to content

Commit

Permalink
FIX: [CPP] Correct off-by-one error in the modal interval returned wi…
Browse files Browse the repository at this point in the history
…th the full results
  • Loading branch information
RUrlus committed Dec 28, 2023
1 parent 1d70888 commit f66ff94
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/diptest-core/src/wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,21 @@ py::dict diptest_full(const py::array_t<double>& x, int allow_zero, int debug) {
debug);

using namespace pybind11::literals; // to bring in the `_a` literal NOLINT
// NOTE `diptst` uses indexing starting from 1, so all the indexes returned
// need to be corrected
int lo = lo_hi[0] - 1;
int hi = lo_hi[1] - 1;
return py::dict(
"dip"_a = dip,
"lo"_a = lo_hi[0],
"hi"_a = lo_hi[1],
"xl"_a = x.at(lo_hi[0]),
"xu"_a = x.at(lo_hi[1]),
"lo"_a = lo,
"hi"_a = hi,
"xl"_a = x.at(lo),
"xu"_a = x.at(hi),
"_gcm"_a = gcm,
"_lcm"_a = lcm,
"_lh_2"_a = lo_hi[2],
"_lh_3"_a = lo_hi[3]);
"_lh_2"_a = lo_hi[2] - 1,
"_lh_3"_a = lo_hi[3] - 1
);
} // diptest_full

double diptest_pval(
Expand Down

0 comments on commit f66ff94

Please sign in to comment.