Re: Interfacing a dynamic shared library gives me different results in 2.7 versus 3.5

2016-05-24 Thread Siyi Deng
Here is a summary of what I did with numpy and the dll I have verified that the values entering the last dll call (dl.cfunction) are identical across platforms. The c function has a signature as follows: int cfunction(int len_data, float* data, int* ac, int num_ac, int flag1, int

Re: Interfacing a dynamic shared library gives me different results in 2.7 versus 3.5

2016-05-24 Thread Siyi Deng
The c function has a signature as follows: int cfun(int len_data, float* data, int* a, int num_a, int flag1, int flag2, int flag3, float* param, float* out1, float* out2, float* out3) and in python: import numpy as np import ctypes as ct data = np.atleast_2d(np.float32(data

Re: Interfacing a dynamic shared library gives me different results in 2.7 versus 3.5

2016-05-24 Thread Chris Angelico
On Wed, May 25, 2016 at 2:32 AM, Steven D'Aprano wrote: > On Wed, 25 May 2016 02:18 am, Siyi Deng wrote: > >> Hello ChrisA, >> I don't quite understand, the binary shared library contains no python >> interfaces, it should be independent of python. > > In your first post, you said you were using n

Re: Interfacing a dynamic shared library gives me different results in 2.7 versus 3.5

2016-05-24 Thread Steven D'Aprano
On Wed, 25 May 2016 02:18 am, Siyi Deng wrote: > Hello ChrisA, > I don't quite understand, the binary shared library contains no python > interfaces, it should be independent of python. In your first post, you said you were using numpy. How is that independent of Python? > As a matter of fact,

Re: Interfacing a dynamic shared library gives me different results in 2.7 versus 3.5

2016-05-24 Thread Chris Angelico
On Wed, May 25, 2016 at 2:18 AM, Siyi Deng wrote: > I don't quite understand, the binary shared library contains no python > interfaces, it should be independent of python. As a matter of fact, I have > successfully used it in Conda python 2.7, 3.5, Julialang as well as c++ > executables. I th

Re: Interfacing a dynamic shared library gives me different results in 2.7 versus 3.5

2016-05-24 Thread Siyi Deng
Hello ChrisA, I don't quite understand, the binary shared library contains no python interfaces, it should be independent of python. As a matter of fact, I have successfully used it in Conda python 2.7, 3.5, Julialang as well as c++ executables. I think the fact that only stock python 2.7 faile

Re: Interfacing a dynamic shared library gives me different results in 2.7 versus 3.5

2016-05-24 Thread Chris Angelico
On Tue, May 24, 2016 at 5:15 PM, Siyi Deng wrote: > Thanks for all the replies. > > It turned out that the Apple OS X stock python 2.7 gives the wrong results, > but other distributions like 2.7 from miniconda gives the correct results. > Facepalm. When you use a binary shared library, it has t

Re: Interfacing a dynamic shared library gives me different results in 2.7 versus 3.5

2016-05-24 Thread Siyi Deng
Thanks for all the replies. It turned out that the Apple OS X stock python 2.7 gives the wrong results, but other distributions like 2.7 from miniconda gives the correct results. Facepalm. -- https://mail.python.org/mailman/listinfo/python-list

Re: Interfacing a dynamic shared library gives me different results in 2.7 versus 3.5

2016-05-23 Thread Steven D'Aprano
On Monday 23 May 2016 13:15, Siyi Deng wrote: > I have a dynamic library doing some numerical computations. > > I used ctypes to interact it by passing numpy arrays back and forth. > > Python 3.5 gives me the correct results. > > Python 2.7 gives me different, erroneous results, but it never cr

Re: Interfacing a dynamic shared library gives me different results in 2.7 versus 3.5

2016-05-23 Thread Fabien
On 05/23/2016 05:15 AM, Siyi Deng wrote: I have a dynamic library doing some numerical computations. I used ctypes to interact it by passing numpy arrays back and forth. Python 3.5 gives me the correct results. Python 2.7 gives me different, erroneous results, but it never crashes. How is this po

Interfacing a dynamic shared library gives me different results in 2.7 versus 3.5

2016-05-22 Thread Siyi Deng
I have a dynamic library doing some numerical computations. I used ctypes to interact it by passing numpy arrays back and forth. Python 3.5 gives me the correct results. Python 2.7 gives me different, erroneous results, but it never crashes. How is this possible? There is no string operatio