Skip to content

Commit 4268bbe

Browse files
MAINT: Replace some occurrences of NAN with NPY_NAN.
1 parent 8e1a6ea commit 4268bbe

File tree

9 files changed

+27
-27
lines changed

9 files changed

+27
-27
lines changed

src/corr/corr_gufunc.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,20 @@ static void pearson_corr_int_core(
9292
)
9393
{
9494
if (n == 1) {
95-
*p_out = NAN;
95+
*p_out = NPY_NAN;
9696
return;
9797
}
9898
if (n == 2) {
9999
T x0 = *p_x;
100100
T x1 = get(p_x, x_stride, 1);
101101
if (x0 == x1) {
102-
*p_out = NAN;
102+
*p_out = NPY_NAN;
103103
return;
104104
}
105105
T y0 = *p_y;
106106
T y1 = get(p_y, y_stride, 1);
107107
if (y0 == y1) {
108-
*p_out = NAN;
108+
*p_out = NPY_NAN;
109109
return;
110110
}
111111
if (((x0 < x1) && (y0 < y1)) || ((x0 > x1) && (y0 > y1))) {
@@ -120,15 +120,15 @@ static void pearson_corr_int_core(
120120
U xmean = strided_mean<T, U>(n, p_x, x_stride);
121121
U x_delta_maxabs = strided_delta_maxabs<T, U>(n, p_x, x_stride, xmean);
122122
if (x_delta_maxabs == 0) {
123-
*p_out = NAN;
123+
*p_out = NPY_NAN;
124124
return;
125125
}
126126
U xnorm = strided_delta_norm<T, U>(n, p_x, x_stride, xmean, x_delta_maxabs);
127127

128128
U ymean = strided_mean<T, U>(n, p_y, y_stride);
129129
U y_delta_maxabs = strided_delta_maxabs<T, U>(n, p_y, y_stride, ymean);
130130
if (y_delta_maxabs == 0) {
131-
*p_out = NAN;
131+
*p_out = NPY_NAN;
132132
return;
133133
}
134134
U ynorm = strided_delta_norm<T, U>(n, p_y, y_stride, ymean, y_delta_maxabs);
@@ -154,20 +154,20 @@ static void pearson_corr_core(
154154
)
155155
{
156156
if (n == 1) {
157-
*p_out = NAN;
157+
*p_out = NPY_NAN;
158158
return;
159159
}
160160
if (n == 2) {
161161
T x0 = *p_x;
162162
T x1 = get(p_x, x_stride, 1);
163163
if (!std::isfinite(x0) || !std::isfinite(x1) || (x0 == x1)) {
164-
*p_out = NAN;
164+
*p_out = NPY_NAN;
165165
return;
166166
}
167167
T y0 = *p_y;
168168
T y1 = get(p_y, y_stride, 1);
169169
if (!std::isfinite(y0) || !std::isfinite(y1) || (y0 == y1)) {
170-
*p_out = NAN;
170+
*p_out = NPY_NAN;
171171
return;
172172
}
173173
if (((x0 < x1) && (y0 < y1)) || ((x0 > x1) && (y0 > y1))) {
@@ -182,15 +182,15 @@ static void pearson_corr_core(
182182
U xmean = strided_mean<T, U>(n, p_x, x_stride);
183183
U x_delta_maxabs = strided_delta_maxabs<T, U>(n, p_x, x_stride, xmean);
184184
if (x_delta_maxabs == 0) {
185-
*p_out = NAN;
185+
*p_out = NPY_NAN;
186186
return;
187187
}
188188
U xnorm = strided_delta_norm<T, U>(n, p_x, x_stride, xmean, x_delta_maxabs);
189189

190190
U ymean = strided_mean<T, U>(n, p_y, y_stride);
191191
U y_delta_maxabs = strided_delta_maxabs<T, U>(n, p_y, y_stride, ymean);
192192
if (y_delta_maxabs == 0) {
193-
*p_out = NAN;
193+
*p_out = NPY_NAN;
194194
return;
195195
}
196196
U ynorm = strided_delta_norm<T, U>(n, p_y, y_stride, ymean, y_delta_maxabs);

src/fillnan1d/fillnan1d_gufunc.c.src

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static void fillnan1d_@typename@_loop(char **args, const npy_intp *dimensions,
5757
if (k == dimensions[1]) {
5858
// All values are nan. Fill output with nan.
5959
for (int i = 0; i < dimensions[1]; ++i) {
60-
*((@ctype@ *) (pout + i*steps[3])) = NAN;
60+
*((@ctype@ *) (pout + i*steps[3])) = NPY_NAN;
6161
}
6262
}
6363
else {

src/linear_interp1d/linear_interp1d_gufunc.c.src

+3-3
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static void linear_interp1d_@typename@_loop(char **args, const npy_intp *dimensi
9898
// No extrapolation. Output is NAN if x is outside the values
9999
// given in xp.
100100
for (int j = 0; j < nloops; ++j, pout += out_stride) {
101-
*((@ctype@ *) pout) = NAN;
101+
*((@ctype@ *) pout) = NPY_NAN;
102102
}
103103
return;
104104
}
@@ -127,7 +127,7 @@ static void linear_interp1d_@typename@_loop(char **args, const npy_intp *dimensi
127127
for (int j = 0; j < nloops; ++j, px += steps[0], pxp += steps[1], pfp += steps[2],
128128
pout += out_stride) {
129129
if (n < 1) {
130-
*((@ctype@ *) pout) = NAN;
130+
*((@ctype@ *) pout) = NPY_NAN;
131131
continue;
132132
}
133133
@ctype@ x = *((@ctype@ *) px);
@@ -136,7 +136,7 @@ static void linear_interp1d_@typename@_loop(char **args, const npy_intp *dimensi
136136
if ((x < left) || (x > right)) {
137137
// No extrapolation. Output is NAN if x is outside the values
138138
// given in xp.
139-
*((@ctype@ *) pout) = NAN;
139+
*((@ctype@ *) pout) = NPY_NAN;
140140
continue;
141141
}
142142

src/log1p/log1p_ufunc.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ log1p_theorem4_F_F_loop(char **args, const npy_intp *dimensions,
353353
complex_float z = *(complex_float *) in;
354354

355355
if (isnan(crealf(z)) || isnan(cimagf(z))) {
356-
w = CMPLXF(NAN, NAN);
356+
w = CMPLXF(NPY_NAN, NPY_NAN);
357357
}
358358
else {
359359
w = log1pf_theorem4(z);
@@ -376,7 +376,7 @@ log1p_theorem4_D_D_loop(char **args, const npy_intp *dimensions,
376376
complex_double z = *(complex_double *) in;
377377

378378
if (isnan(creal(z)) || isnan(cimag(z))) {
379-
w = CMPLX(NAN, NAN);
379+
w = CMPLX(NPY_NAN, NPY_NAN);
380380
}
381381
else {
382382
w = log1p_theorem4(z);
@@ -399,7 +399,7 @@ log1p_doubledouble_F_F_loop(char **args, const npy_intp *dimensions,
399399
complex_float z = *(complex_float *) in;
400400

401401
if (isnan(crealf(z)) || isnan(cimagf(z))) {
402-
w = CMPLXF(NAN, NAN);
402+
w = CMPLXF(NPY_NAN, NPY_NAN);
403403
}
404404
else {
405405
w = log1pf_doubledouble(z);
@@ -422,7 +422,7 @@ log1p_doubledouble_D_D_loop(char **args, const npy_intp *dimensions,
422422
complex_double z = *(complex_double *) in;
423423

424424
if (isnan(creal(z)) || isnan(cimag(z))) {
425-
w = CMPLX(NAN, NAN);
425+
w = CMPLX(NPY_NAN, NPY_NAN);
426426
}
427427
else {
428428
w = log1p_doubledouble(z);

src/logfactorial/logfactorial_ufunc.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static void logfactorial_int32_loop(char **args, const npy_intp *dimensions,
3939
// the C function logfactorial(x).
4040
int64_t x = (int64_t) *(int32_t *)in;
4141
if (x < 0) {
42-
*((double *)out) = NAN;
42+
*((double *)out) = NPY_NAN;
4343
}
4444
else {
4545
*((double *)out) = logfactorial(x);
@@ -58,7 +58,7 @@ static void logfactorial_int64_loop(char **args, const npy_intp *dimensions,
5858
for (npy_intp i = 0; i < dimensions[0]; ++i, in += in_step, out += out_step) {
5959
int64_t x = *(int64_t *)in;
6060
if (x < 0) {
61-
*((double *)out) = NAN;
61+
*((double *)out) = NPY_NAN;
6262
}
6363
else {
6464
*((double *)out) = logfactorial(x);

src/mad/mad_gufunc.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static void gini_core(
120120
T denom = (*p_unbiased) ? (n - 1)*total : n*total;
121121

122122
if (sum == 0 && denom == 0) {
123-
*p_out = NAN;
123+
*p_out = NPY_NAN;
124124
#ifdef __clang__
125125
feclearexcept(FE_INVALID);
126126
#endif

src/means/means_gufunc.c.src

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static void gmean_@typename@_loop(char **args, const npy_intp *dimensions,
8585
}
8686
}
8787
if (has_neg) {
88-
*(@ctype_out@ *) out = NAN;
88+
*(@ctype_out@ *) out = NPY_NAN;
8989
}
9090
else if (has_zero) {
9191
*(@ctype_out@ *) out = 0.0;

src/multivariate_logbeta/multivariate_logbeta_gufunc.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static void multivariate_logbeta_core(
4040
)
4141
{
4242
if (n == 0) {
43-
*p_out = NAN;
43+
*p_out = NPY_NAN;
4444
return;
4545
}
4646
if (x_stride == sizeof(T)) {

src/wjaccard/wjaccard_gufunc.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static void wjaccard_realtype_core(
3737
// The gufunc is configured to require n > 0, so it is safe to
3838
// dereference p_x and p_y without first checking that n > 0.
3939
if (std::isnan(*p_x) || std::isnan(*p_y)) {
40-
*p_out = NAN;
40+
*p_out = NPY_NAN;
4141
return;
4242
}
4343
U numer = std::min(*p_x, *p_y);
@@ -46,15 +46,15 @@ static void wjaccard_realtype_core(
4646
T xk = get(p_x, x_stride, k);
4747
T yk = get(p_y, y_stride, k);
4848
if (std::isnan(xk) || std::isnan(yk)) {
49-
*p_out = NAN;
49+
*p_out = NPY_NAN;
5050
return;
5151
}
5252
numer += std::min(xk, yk);
5353
denom += std::max(xk, yk);
5454
}
5555
if (denom == 0) {
5656
if (numer == 0) {
57-
*p_out = NAN;
57+
*p_out = NPY_NAN;
5858
}
5959
else {
6060
*p_out = -INFINITY;
@@ -93,7 +93,7 @@ static void wjaccard_integer_core(
9393
}
9494
if (denom == 0) {
9595
if (numer == 0) {
96-
*p_out = NAN;
96+
*p_out = NPY_NAN;
9797
}
9898
else {
9999
*p_out = -INFINITY;

0 commit comments

Comments
 (0)