-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
MAINT: Simplify npymath #22090
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
MAINT: Simplify npymath #22090
Changes from all commits
f33e579
e9e8cee
9e481ad
aceba28
c35cb18
16a6405
c304f6f
37b2cf1
b0878cf
ee2103b
759e0cd
2c4cc10
704ca94
b6d52fc
d1cbf3f
25629dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,7 +145,8 @@ def check_func( | |
headers=headers, | ||
) | ||
|
||
def check_funcs_once(funcs_name, headers=["feature_detection_math.h"]): | ||
def check_funcs_once(funcs_name, headers=["feature_detection_math.h"], | ||
add_to_moredefs=True): | ||
call = dict([(f, True) for f in funcs_name]) | ||
call_args = dict([(f, FUNC_CALL_ARGS[f]) for f in funcs_name]) | ||
st = config.check_funcs_once( | ||
|
@@ -156,7 +157,7 @@ def check_funcs_once(funcs_name, headers=["feature_detection_math.h"]): | |
call_args=call_args, | ||
headers=headers, | ||
) | ||
if st: | ||
if st and add_to_moredefs: | ||
moredefs.extend([(fname2def(f), 1) for f in funcs_name]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If |
||
return st | ||
|
||
|
@@ -173,7 +174,7 @@ def check_funcs(funcs_name, headers=["feature_detection_math.h"]): | |
return 1 | ||
|
||
#use_msvc = config.check_decl("_MSC_VER") | ||
if not check_funcs_once(MANDATORY_FUNCS): | ||
if not check_funcs_once(MANDATORY_FUNCS, add_to_moredefs=False): | ||
raise SystemError("One of the required function to build numpy is not" | ||
" available (the list is %s)." % str(MANDATORY_FUNCS)) | ||
|
||
|
@@ -184,20 +185,12 @@ def check_funcs(funcs_name, headers=["feature_detection_math.h"]): | |
# config.h in the public namespace, so we have a clash for the common | ||
# functions we test. We remove every function tested by python's | ||
# autoconf, hoping their own test are correct | ||
for f in OPTIONAL_STDFUNCS_MAYBE: | ||
if config.check_decl(fname2def(f), | ||
headers=["Python.h", "math.h"]): | ||
if f in OPTIONAL_STDFUNCS: | ||
OPTIONAL_STDFUNCS.remove(f) | ||
else: | ||
OPTIONAL_FILE_FUNCS.remove(f) | ||
for f in OPTIONAL_FUNCS_MAYBE: | ||
if config.check_decl(fname2def(f), headers=["Python.h"]): | ||
OPTIONAL_FILE_FUNCS.remove(f) | ||
rgommers marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
check_funcs(OPTIONAL_STDFUNCS) | ||
check_funcs(OPTIONAL_FILE_FUNCS, headers=["feature_detection_stdio.h"]) | ||
check_funcs(OPTIONAL_MISC_FUNCS, headers=["feature_detection_misc.h"]) | ||
|
||
|
||
|
||
for h in OPTIONAL_HEADERS: | ||
if config.check_func("", decl=False, call=False, headers=[h]): | ||
|
@@ -249,10 +242,6 @@ def check_funcs(funcs_name, headers=["feature_detection_math.h"]): | |
m = fn.replace("(", "_").replace(")", "_") | ||
moredefs.append((fname2def(m), 1)) | ||
|
||
# C99 functions: float and long double versions | ||
check_funcs(C99_FUNCS_SINGLE) | ||
check_funcs(C99_FUNCS_EXTENDED) | ||
|
||
def check_complex(config, mathlibs): | ||
priv = [] | ||
pub = [] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,42 +2,31 @@ | |
#define NUMPY_CORE_SRC_COMMON_NPY_CONFIG_H_ | ||
|
||
#include "config.h" | ||
#include "npy_cpu_features.h" | ||
#include "npy_cpu_dispatch.h" | ||
#include "numpy/numpyconfig.h" | ||
#include "numpy/npy_cpu.h" | ||
#include "numpy/utils.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The removed headers are needed for simd dispatch, and are not part of the configuring done here. |
||
#include "numpy/npy_os.h" | ||
|
||
/* blocklist */ | ||
|
||
/* Disable broken Sun Workshop Pro math functions */ | ||
#ifdef __SUNPRO_C | ||
|
||
#undef HAVE_ATAN2 | ||
#undef HAVE_ATAN2F | ||
#undef HAVE_ATAN2L | ||
|
||
#endif | ||
|
||
/* Disable broken functions on z/OS */ | ||
#if defined (__MVS__) | ||
|
||
#undef HAVE_POWF | ||
#undef HAVE_EXPF | ||
#define NPY_BLOCK_POWF | ||
#define NPY_BLOCK_EXPF | ||
#undef HAVE___THREAD | ||
|
||
#endif | ||
|
||
/* Disable broken MS math functions */ | ||
#if defined(__MINGW32_VERSION) | ||
|
||
#undef HAVE_ATAN2 | ||
#undef HAVE_ATAN2F | ||
#undef HAVE_ATAN2L | ||
#define NPY_BLOCK_ATAN2 | ||
#define NPY_BLOCK_ATAN2F | ||
#define NPY_BLOCK_ATAN2L | ||
|
||
#undef HAVE_HYPOT | ||
#undef HAVE_HYPOTF | ||
#undef HAVE_HYPOTL | ||
#define NPY_BLOCK_HYPOT | ||
#define NPY_BLOCK_HYPOTF | ||
#define NPY_BLOCK_HYPOTL | ||
|
||
#endif | ||
|
||
|
@@ -77,23 +66,23 @@ | |
#undef HAVE_CABSF | ||
#undef HAVE_CABSL | ||
|
||
#undef HAVE_HYPOT | ||
#undef HAVE_HYPOTF | ||
#undef HAVE_HYPOTL | ||
#define NPY_BLOCK_HYPOT | ||
#define NPY_BLOCK_HYPOTF | ||
#define NPY_BLOCK_HYPOTL | ||
|
||
#endif | ||
|
||
|
||
/* Intel C for Windows uses POW for 64 bits longdouble*/ | ||
#if defined(_MSC_VER) && defined(__INTEL_COMPILER) | ||
#if defined(HAVE_POWL) && (NPY_SIZEOF_LONGDOUBLE == 8) | ||
#undef HAVE_POWL | ||
#if NPY_SIZEOF_LONGDOUBLE == 8 | ||
#define NPY_BLOCK_POWL | ||
#endif | ||
#endif /* defined(_MSC_VER) && defined(__INTEL_COMPILER) */ | ||
|
||
/* powl gives zero division warning on OS X, see gh-8307 */ | ||
#if defined(HAVE_POWL) && defined(NPY_OS_DARWIN) | ||
#undef HAVE_POWL | ||
#if defined(NPY_OS_DARWIN) | ||
#define NPY_BLOCK_POWL | ||
#endif | ||
|
||
#ifdef __CYGWIN__ | ||
|
@@ -130,7 +119,7 @@ | |
#undef HAVE_CACOS | ||
|
||
/* log2(exp2(i)) off by a few eps */ | ||
#undef HAVE_LOG2 | ||
#define NPY_BLOCK_LOG2 | ||
|
||
/* np.power(..., dtype=np.complex256) doesn't report overflow */ | ||
#undef HAVE_CPOWL | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -770,27 +770,12 @@ NumPyOS_ascii_ftoLf(FILE *fp, long double *value) | |
NPY_NO_EXPORT npy_longlong | ||
NumPyOS_strtoll(const char *str, char **endptr, int base) | ||
{ | ||
#if defined HAVE_STRTOLL | ||
return strtoll(str, endptr, base); | ||
#elif defined _MSC_VER | ||
return _strtoi64(str, endptr, base); | ||
#else | ||
/* ok on 64 bit posix */ | ||
return PyOS_strtol(str, endptr, base); | ||
#endif | ||
} | ||
|
||
NPY_NO_EXPORT npy_ulonglong | ||
NumPyOS_strtoull(const char *str, char **endptr, int base) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should these now more or less pointless wrapper functions be deprecated somehow...? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed there is more cleanup that can be done to turn one-line functions into defines (if they are exported) or to deprecate them (if they are internal). I was primarily targeting cleaning up the dead code from npymath in this PR. Maybe we should have a github project for code cleanup and add this as a task. |
||
{ | ||
#if defined HAVE_STRTOULL | ||
return strtoull(str, endptr, base); | ||
#elif defined _MSC_VER | ||
return _strtoui64(str, endptr, base); | ||
#else | ||
/* ok on 64 bit posix */ | ||
return PyOS_strtoul(str, endptr, base); | ||
#endif | ||
} | ||
|
||
rgommers marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
Uh oh!
There was an error while loading. Please reload this page.