Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Keep the intermediate values in float64 #414

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions bottleneck/src/move_template.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ mover(char *name,
/* dtype = [['float64'], ['float32']] */
MOVE(move_sum, DTYPE0) {
Py_ssize_t count;
npy_DTYPE0 asum, ai, aold;
// Keep the intermediate values in float64 to reduce precision error.
// See issue pydata/bottleneck#164.
npy_float64 asum, ai, aold;
INIT(NPY_DTYPE0)
BN_BEGIN_ALLOW_THREADS
WHILE {
Expand Down Expand Up @@ -156,7 +158,9 @@ MOVE_MAIN(move_sum, 0)
/* dtype = [['float64'], ['float32']] */
MOVE(move_mean, DTYPE0) {
Py_ssize_t count;
npy_DTYPE0 asum, ai, aold, count_inv;
// Keep the intermediate values in float64 to reduce precision error.
// See issue pydata/bottleneck#164.
npy_float64 asum, ai, aold, count_inv;
INIT(NPY_DTYPE0)
BN_BEGIN_ALLOW_THREADS
WHILE {
Expand Down Expand Up @@ -244,7 +248,9 @@ MOVE_MAIN(move_mean, 0)
/* dtype = [['float64'], ['float32']] */
MOVE(NAME, DTYPE0) {
Py_ssize_t count;
npy_DTYPE0 delta, amean, assqdm, ai, aold, yi, count_inv, ddof_inv;
// Keep the intermediate values in float64 to reduce precision error.
// See issue pydata/bottleneck#164.
npy_float64 delta, amean, assqdm, ai, aold, yi, count_inv, ddof_inv;
INIT(NPY_DTYPE0)
BN_BEGIN_ALLOW_THREADS
WHILE {
Expand Down