Skip to content

Commit b4ba17a

Browse files
authored
MINOR: [C++] Make argument name consistent (#44973)
Followup to apache/arrow#44955 Authored-by: Antoine Pitrou <antoine@python.org> Signed-off-by: Antoine Pitrou <antoine@python.org>
1 parent c88c297 commit b4ba17a

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

cpp/src/arrow/testing/math.cc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ namespace arrow {
2828
namespace {
2929

3030
template <typename Float>
31-
bool WithinUlpOneWay(Float left, Float right, int n_ulp) {
31+
bool WithinUlpOneWay(Float left, Float right, int n_ulps) {
3232
// The delta between 1.0 and the FP value immediately before it.
3333
// We're using this value because `frexp` returns a mantissa between 0.5 and 1.0.
3434
static const Float kOneUlp = Float(1.0) - std::nextafter(Float(1.0), Float(0.0));
3535

36-
DCHECK_GE(n_ulp, 1);
36+
DCHECK_GE(n_ulps, 1);
3737

3838
if (left == 0) {
3939
return left == right;
@@ -45,36 +45,36 @@ bool WithinUlpOneWay(Float left, Float right, int n_ulp) {
4545

4646
int left_exp;
4747
Float left_mant = std::frexp(left, &left_exp);
48-
Float delta = static_cast<Float>(n_ulp) * kOneUlp;
48+
Float delta = static_cast<Float>(n_ulps) * kOneUlp;
4949
Float lower_bound = std::ldexp(left_mant - delta, left_exp);
5050
Float upper_bound = std::ldexp(left_mant + delta, left_exp);
5151
return right >= lower_bound && right <= upper_bound;
5252
}
5353

5454
template <typename Float>
55-
bool WithinUlpGeneric(Float left, Float right, int n_ulp) {
55+
bool WithinUlpGeneric(Float left, Float right, int n_ulps) {
5656
if (!std::isfinite(left) || !std::isfinite(right)) {
5757
return left == right;
5858
}
59-
return (std::abs(left) <= std::abs(right)) ? WithinUlpOneWay(left, right, n_ulp)
60-
: WithinUlpOneWay(right, left, n_ulp);
59+
return (std::abs(left) <= std::abs(right)) ? WithinUlpOneWay(left, right, n_ulps)
60+
: WithinUlpOneWay(right, left, n_ulps);
6161
}
6262

6363
template <typename Float>
64-
void AssertWithinUlpGeneric(Float left, Float right, int n_ulp) {
65-
if (!WithinUlpGeneric(left, right, n_ulp)) {
66-
FAIL() << left << " and " << right << " are not within " << n_ulp << " ulps";
64+
void AssertWithinUlpGeneric(Float left, Float right, int n_ulps) {
65+
if (!WithinUlpGeneric(left, right, n_ulps)) {
66+
FAIL() << left << " and " << right << " are not within " << n_ulps << " ulps";
6767
}
6868
}
6969

7070
} // namespace
7171

72-
bool WithinUlp(float left, float right, int n_ulp) {
73-
return WithinUlpGeneric(left, right, n_ulp);
72+
bool WithinUlp(float left, float right, int n_ulps) {
73+
return WithinUlpGeneric(left, right, n_ulps);
7474
}
7575

76-
bool WithinUlp(double left, double right, int n_ulp) {
77-
return WithinUlpGeneric(left, right, n_ulp);
76+
bool WithinUlp(double left, double right, int n_ulps) {
77+
return WithinUlpGeneric(left, right, n_ulps);
7878
}
7979

8080
void AssertWithinUlp(float left, float right, int n_ulps) {

cpp/src/arrow/testing/math.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
namespace arrow {
2323

2424
ARROW_TESTING_EXPORT
25-
bool WithinUlp(float left, float right, int n_ulp);
25+
bool WithinUlp(float left, float right, int n_ulps);
2626
ARROW_TESTING_EXPORT
27-
bool WithinUlp(double left, double right, int n_ulp);
27+
bool WithinUlp(double left, double right, int n_ulps);
2828

2929
ARROW_TESTING_EXPORT
3030
void AssertWithinUlp(float left, float right, int n_ulps);

0 commit comments

Comments
 (0)