summaryrefslogtreecommitdiff
path: root/numpy/f2py/lib/python_wrapper.py
diff options
context:
space:
mode:
authorPearu Peterson <pearu.peterson@gmail.com>2006-10-01 20:48:37 +0000
committerPearu Peterson <pearu.peterson@gmail.com>2006-10-01 20:48:37 +0000
commitbd4a480813a01fcd0e963d8b5d7cc1a579fa073f (patch)
tree8b2153ab5f19e04f45b45077d6e2c1cc1200566a /numpy/f2py/lib/python_wrapper.py
parentc3c53e6805beb164581f041a69c9f51c2740d344 (diff)
downloadnumpy-bd4a480813a01fcd0e963d8b5d7cc1a579fa073f.tar.gz
F2PY G3: fixed bugs, added float and complex scalars support.
Diffstat (limited to 'numpy/f2py/lib/python_wrapper.py')
-rw-r--r--numpy/f2py/lib/python_wrapper.py44
1 files changed, 8 insertions, 36 deletions
diff --git a/numpy/f2py/lib/python_wrapper.py b/numpy/f2py/lib/python_wrapper.py
index 35f3147fc..432f96c8f 100644
--- a/numpy/f2py/lib/python_wrapper.py
+++ b/numpy/f2py/lib/python_wrapper.py
@@ -23,6 +23,7 @@ extern \"C\" {
#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API
#include "numpy/arrayobject.h"
+#include "numpy/arrayscalars.h"
%(header_list)s
@@ -140,13 +141,7 @@ class PythonCAPIIntrinsicType(WrapperBase):
self.ctype = ctype = typedecl.get_c_type()
if ctype.startswith('npy_'):
- from generate_pyobj_tofrom_funcs import pyobj_to_npy_scalar
- d = pyobj_to_npy_scalar(ctype)
- for v in d.values():
- self.resolve_dependencies(parent, v)
- for k,v in d.items():
- l = getattr(parent, k+'_list')
- l.append(v)
+ WrapperCCode(parent, 'pyobj_from_%s' % (ctype))
return
if not ctype.startswith('f2py_type_'):
@@ -598,38 +593,14 @@ initialize_%(typename)s_interface(initialize_%(typename)s_interface_c);\
if __name__ == '__main__':
- #from utils import str2stmt, get_char_bit
-
- stmt = parse("""
- module rat
- integer :: i
- type info
- integer flag
- end type info
- type rational
- integer n
- integer d
- type(info) i
- end type rational
- end module rat
- subroutine foo(a)
- use rat
- type(rational) a
- end
- """)
- #stmt = stmt.content[-1].content[1]
- #print stmt
- #wrapgen = TypeWrapper(stmt)
- #print wrapgen.fortran_code()
- #print wrapgen.c_code()
foo_code = """! -*- f90 -*-
module rat
type info
- integer flag
+ complex flag
end type info
type rational
- integer n,d
+ !integer n,d
type(info) i
end type rational
end module rat
@@ -685,14 +656,15 @@ if __name__ == '__main__':
#print foo.info.__doc__
#print foo.rational.__doc__
#print dir(foo.rational)
- i = foo.info(7)
+ i = foo.info(70+3j)
+ print 'i=',i
#print i #,i.as_tuple()
#print 'i.flag=',i.flag
- r = foo.rational(2,3,i)
+ r = foo.rational(i)
print r
j = r.i
print 'r.i.flag=',(r.i).flag
- print 'j.flag=',j.flag
+ print 'j.flag=',type(j.flag)
#print 'r=',r
sys.exit()
n,d,ii = r.as_tuple()