[Numpy-discussion] Knownfails due to platform and numpy.c99
Friedrich Romstedt
friedrichromstedt@gmail....
Tue Nov 2 09:01:33 CDT 2010
Hello,
This is a NEPP (proposal for a numpy enhancement proposal).
It's quite near to Depp, which means idiot in german, but I hope
that's not the case.
Some tests fail currently because of platform issues. I.e., the
platform clib or similar supplies some partly broken implementation
which we use.
The current approach is to mark those tests on those platforms as K fail.
On the other hand, there are platforms which *don't* supply the
functions, and there a numpy own implementation chimes in. (Afaik.)
1. We want to test the numpy own implementations, and not the OS
supplied ones. This can be seen by the fact that we regard a test not
as failing (or, as K fail) if it is due to OS issues. Meaning we only
really want to take care about those systems where *our*
implementation is used.
2. I propose to export the numpy own implementations *always* under a
distinct name, e.g. numpy.c99.exp().
3. And to test those functions on all platforms, they never have to fail.
4. And to not test the OS supplied versions, since we don't care
about them failing anyway.
Implementation
a) always define the C level functions, but under another name not
conflicting with the OS defined ones. E.g.: numpy_cexp().
b) If the OS supplies a function, okay, use it.
c) If the OS doesn't supply the function, then define it as a
wrapper, which just calls numpy_*().
If a Python user needs corner case safety, he would be advised to use
the numpy.c99.*, e.g. numpy.c99.exp(). For C level users, it would be
to use numpy_*(), e.g. numpy_cexp() instead of cexp(). Both functions
would always be supplied, but do not need to be identical. Using the
C99 compliant version might cause speed tradeoff.
::
// Include the system header:
#include <...>
// Define the C99 compliant version:
void numpy_cexp(float r, float i, float *or, float *oi){ ...; }
// Wrap the C99 compliant version in the usual-named function if necessary ...
#ifndef HAVE_CEXP
void cexp(...){ wrap(); }
#endif
... export numpy_cexp() as ``numpy.c99.exp`` ...
... export cexp() as ``numpy.exp``
--
The following might not be feasible if we *have to* include the system
headers in any way.
Ralf suggested the very good addition, to support a compilation flag
-DC99COMPLIANT or similar, in that case, numpy headers would not
incude the system ones (assumed they do), and would always define the
functions using the numpy_*() ones.
::
// Do not include the system headers if requested so:
#ifndef C99COMPLIANT
#include <...>
#endif
// Define the C99 compliant version:
void numpy_cexp(float r, float i, float *or, float *oi){ ...; }
// Wrap the C99 compliant version in the usual-named function if necessary ...
#ifdef C99COMPLIANT
void cexp(...){ wrap(); }
#else
#ifndef HAVE_CEXP
void cexp(...){ wrap(); }
#endif
#endif
... export numpy_cexp() as ``numpy.c99.exp`` ...
... export cexp() as ``numpy.exp``
--
Friedrich
More information about the NumPy-Discussion
mailing list