Skip to content

Commit 1beb573

Browse files
Merge pull request #532 from pydata/add_floordiv
Fix fmod bug
2 parents e789d78 + 2359726 commit 1beb573

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

numexpr/bespoke_functions.hpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ inline long rintl(long x) {return x;}
3030
inline int fabsi(int x) {return x<0 ? -x: x;}
3131
inline long fabsl(long x) {return x<0 ? -x: x;}
3232
// fmod function for ints
33-
inline int fmodi(int x, int y) {return (int)fmodf((float)x, (float)y);}
34-
inline long fmodl(long x, long y) {return (long)fmodf((long)x, (long)y);}
33+
// TODO: Have to add FUNC_III, FUNC_LLL signatures to functions.hpp to enable these
34+
// inline int fmodi(int x, int y) {return (int)fmodf((float)x, (float)y);}
35+
// inline long fmodl(long x, long y) {return (long)fmodf((long)x, (long)y);}
3536

3637
#ifdef USE_VML
3738
static void viRint(MKL_INT n, const int* x, int* dest)
@@ -84,20 +85,21 @@ static void vdfmod(MKL_INT n, const double* x1, const double* x2, double* dest)
8485
dest[j] = fmod(x1[j], x2[j]);
8586
};
8687
};
87-
static void vifmod(MKL_INT n, const int* x1, const int* x2, int* dest)
88-
{
89-
MKL_INT j;
90-
for(j=0; j < n; j++) {
91-
dest[j] = fmodi(x1[j], x2[j]);
92-
};
93-
};
94-
static void vlfmod(MKL_INT n, const long* x1, const long* x2, long* dest)
95-
{
96-
MKL_INT j;
97-
for(j=0; j < n; j++) {
98-
dest[j] = fmodl(x1[j], x2[j]);
99-
};
100-
};
88+
// TODO: Have to add FUNC_III, FUNC_LLL signatures to functions.hpp
89+
// static void vifmod(MKL_INT n, const int* x1, const int* x2, int* dest)
90+
// {
91+
// MKL_INT j;
92+
// for(j=0; j < n; j++) {
93+
// dest[j] = fmodi(x1[j], x2[j]);
94+
// };
95+
// };
96+
// static void vlfmod(MKL_INT n, const long* x1, const long* x2, long* dest)
97+
// {
98+
// MKL_INT j;
99+
// for(j=0; j < n; j++) {
100+
// dest[j] = fmodl(x1[j], x2[j]);
101+
// };
102+
// };
101103

102104
/* no isnan, isfinite, isinf or signbit in VML */
103105
static void vsIsfinite(MKL_INT n, const float* x1, bool* dest)

numexpr/expressions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,11 @@ def function(*args):
186186
return ConstantNode(func(*[x.value for x in args]))
187187
kind = commonKind(args)
188188
if kind in ('int', 'long'):
189-
if func.__name__ not in ('copy', 'abs', 'fmod', 'ones_like', 'round', 'sign'):
189+
if func.__name__ not in ('copy', 'abs', 'ones_like', 'round', 'sign'):
190190
# except for these special functions (which return ints for int inputs in NumPy)
191191
# just do a cast to double
192+
# FIXME: 'fmod' outputs ints for NumPy when inputs are ints, but need to
193+
# add new function signatures FUNC_LLL FUNC_III to support this
192194
kind = 'double'
193195
else:
194196
# Apply regular casting rules

numexpr/tests/test_numexpr.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -903,8 +903,10 @@ class Skip(Exception): pass
903903
or "%" in expr
904904
or "arctan2" in expr
905905
or "fmod" in expr
906-
# or "hypot" in expr
907-
# or "nextafter" in expr
906+
or "hypot" in expr
907+
or "nextafter" in expr
908+
or "copysign" in expr
909+
or "trunc" in expr
908910
or "floor" in expr
909911
or "ceil" in expr
910912
)

0 commit comments

Comments
 (0)