Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

BUG: special: fix compilation of _ufuncs_cxx extension

  • Loading branch information...
commit e3cfc53273e7852abff974452620813546500a2e 1 parent 71fd1cf
@pv authored
View
2  .gitattributes
@@ -18,6 +18,6 @@ scipy/sparse/csgraph/_traversal.c binary
scipy/spatial/ckdtree.c binary
scipy/spatial/qhull.c binary
scipy/special/_ufuncs.c binary
-scipy/special/_ufuncs_cxx.c binary
+scipy/special/_ufuncs_cxx.cxx binary
scipy/stats/_rank.c binary
scipy/stats/vonmises_cython.c binary
View
4 scipy/special/SConscript
@@ -91,11 +91,15 @@ src = ['_ufuncs.c', 'amos_wrappers.c', 'specfun_wrappers.c', \
'toms_wrappers.c','cdf_wrappers.c','ufunc_extras.c',
'_logit.c.src']
+src_cxx = ['_ufuncs_cxx.cxx']
+
env.NumpyPythonExtension('_ufuncs',
source = src,
LIBS = ['sc_amos', 'sc_toms', 'sc_c_misc', 'sc_cephes', 'sc_mach',\
'sc_cdf', 'sc_specfunlib'])
+env.NumpyPythonExtension('_ufuncs_cxx', source = src_cxx)
+
# Specfun extension
env.Prepend(LIBS = ['sc_specfunlib'])
env.NumpyPythonExtension('specfun', source = 'specfun.pyf',
View
1  scipy/special/__init__.py
@@ -523,6 +523,7 @@ class also has an attribute ``weights`` which returns the roots, weights,
#from special_version import special_version as __version__
from _ufuncs import *
+from _ufuncs_cxx import *
from basic import *
import specfun
View
9 scipy/special/basic.py
@@ -6,7 +6,9 @@
where, mgrid, cos, sin, exp, place, seterr, issubdtype, extract, \
complexfloating, less, vectorize, inexact, nan, zeros, sometrue
from _ufuncs import ellipkm1, mathieu_a, mathieu_b, iv, jv, gamma, psi, zeta, \
- hankel1, hankel2, yv, kv, gammaln, errprint, ndtri
+ hankel1, hankel2, yv, kv, gammaln, ndtri
+import _ufuncs
+import _ufuncs_cxx
import types
import specfun
import orthogonal
@@ -31,6 +33,11 @@
class SpecialFunctionWarning(Warning):
pass
+def errprint(inflag=None):
+ _ufuncs_cxx._errprint(inflag)
+ return _ufuncs._errprint(inflag)
+errprint.__doc__ = _ufuncs._errprint.__doc__
+
def sinc(x):
"""Returns sin(pi*x)/(pi*x) at all points of array x.
"""
View
3  scipy/special/bento.info
@@ -36,6 +36,9 @@ Library:
cdf_wrappers.c,
ufunc_extras.c,
_logit.c.src
+ Extension: _ufuncs_cxx
+ Sources:
+ _ufuncs_cxx.cxx
Extension: specfun
Sources:
specfun.pyf
View
22 scipy/special/generate_ufuncs.py
@@ -256,8 +256,6 @@
# Error handling system
#
-cdef extern int scipy_special_print_error_messages
-
cdef extern from "stdarg.h":
ctypedef struct va_list:
pass
@@ -269,10 +267,11 @@
fake_type int_type "int"
cdef extern from "Python.h":
- object PyErr_Warn(object, char *)
int PyOS_vsnprintf(char *, size_t, char *, va_list va) nogil
-cdef public void scipy_special_raise_warning(char *fmt, ...) nogil:
+from cpython.exc cimport PyErr_WarnEx
+
+cdef public void scipy_special_raise_warning(char *fmt, ...) nogil except *:
cdef char msg[1024]
cdef va_list ap
@@ -282,9 +281,9 @@
with gil:
from scipy.special import SpecialFunctionWarning
- PyErr_Warn(SpecialFunctionWarning, msg)
+ PyErr_WarnEx(SpecialFunctionWarning, msg, 1)
-def errprint(inflag=None):
+def _errprint(inflag=None):
\"\"\"
errprint(flag)
@@ -307,6 +306,8 @@ def errprint(inflag=None):
"""
EXTRA_CODE = EXTRA_CODE_COMMON + """
+cdef extern int scipy_special_print_error_messages
+
#
# Aliases
#
@@ -315,6 +316,7 @@ def errprint(inflag=None):
"""
EXTRA_CODE_CXX = EXTRA_CODE_COMMON + """
+cdef public int scipy_special_print_error_messages
"""
@@ -696,9 +698,6 @@ def generate(filename, ufunc_str, extra_code):
# This file is automatically generated by generate_ufuncs.py.
# Do not edit manually!
-cdef extern from "complex.h":
- pass
-
cimport numpy as np
cimport libc
@@ -724,10 +723,11 @@ def main():
generate("_ufuncs_cxx.pyx", UFUNCS_CXX, EXTRA_CODE_CXX)
subprocess.call(['cython', '_ufuncs.pyx'])
- subprocess.call(['cython', '_ufuncs_cxx.pyx'])
+ subprocess.call(['cython', '--cplus', '-o', '_ufuncs_cxx.cxx',
+ '_ufuncs_cxx.pyx'])
# Strip comments
- for fn in ['_ufuncs.c', '_ufuncs_cxx.c']:
+ for fn in ['_ufuncs.c', '_ufuncs_cxx.cxx']:
f = open(fn, 'r')
text = f.read()
f.close()
View
8 scipy/special/setup.py
@@ -62,6 +62,14 @@ def configuration(parent_package='',top_path=None):
define_macros = define_macros,
extra_info=get_info("npymath"))
+ # Extension _ufuncs_cxx
+ curdir = os.path.abspath(os.path.dirname(__file__))
+ config.add_extension('_ufuncs_cxx',
+ sources=['_ufuncs_cxx.cxx'],
+ include_dirs=[curdir],
+ define_macros=define_macros,
+ extra_info=get_info("npymath"))
+
config.add_data_files('tests/*.py')
config.add_data_files('tests/data/README')
config.add_data_files('tests/data/*.npz')
Please sign in to comment.
Something went wrong with that request. Please try again.