robclewley / pydstool

PyDSTool main development repo
http://pydstool.sf.net
Other
171 stars 65 forks source link

swig issues on win32 #80

Closed breisfeld closed 9 years ago

breisfeld commented 9 years ago

Hi,

I installed the latest revision of PyDSTool from git (153421f962496f0a14454f8b67ad5883c2bf2504), and while running the examples, I get a number of errors apparently related to swig. Is there something I need to do based on my naïve installation of swig on win32 (unzipping the swig binaries and changing my path to include the unzipped directory)?

Thanks.

$ python .\run_all_tests.py
...
Summary:
Basic PyDSTool functions: appears to work on your system
Map related modules: appears to work on your system
VODE related modules: appears to work on your system
Symbolic differentiation module: appears to work on your syste
Parameter estimation module: appears to work on your system
PyCont: appears to be broken on your system
Dopri ODE systems: appears to be broken on your system
Radau ODE systems: appears to be broken on your system
Parameter estimation module with external compilers: appears t
PyCont interface to AUTO: appears to be broken on your system
$ swig
Must specify an input file. Use -help for available options.
$ python PyCont_vanDerPol.py
At end of testing you can delete the temp file vanderPol.dat
Must specify an input file. Use -help for available options.
error: command 'C:\\Program Files\\swig\\swig.exe' failed with exit status 1
$ python
Python 2.7.8 |Anaconda 2.1.0 (32-bit)| (default, Jul  2 2014, 15:13:35) [MSC v.1500 32 bit (Intel)] on win32
robclewley commented 9 years ago

I've seen several problems with Anaconda-based installs like this. First, please check through this discussion thread to see that you're not having any of the same problems (SWIG is discussed lower down there):

https://sourceforge.net/p/pydstool/discussion/472291/thread/3a3b2ced/

There might be a problem with Anaconda using a different set of paths whereby it can't see swig even though at the OS prompt you can. If you run an offending program from the OS prompt as 'python problem_script.py' you should see output of what compiler command is issued to the OS. You can try running that command by hand by copy-pasting into a terminal window, and let us know what you see. That's all I can think of for now! I can look again later.

breisfeld commented 9 years ago

Thanks for the reply.

In my bug report, I reported the command-line output of python PyCont_vanDerPol.py. Was this not what you were looking for?

Also, I did see that sourceforge bug report before posting here. At first, the bug seemed similar, but toward the end of the thread, it seemed as if the OP had a different issue.

Could there be an problem on w32 such that swig is not being given a legitimate input file path (thus the Must specify an input file. message from swig)?

z2v commented 9 years ago

There should be file build.log in radau5_temp directory. Show us its contents, please.

breisfeld commented 9 years ago

Here you go:

running build_ext
running build_src
build_src
building py_modules sources
building library "radau5" sources
building library "lapack_lite" sources
building extension "_radau5_vanderPol_vf" sources
swig.exe: H:\python\packages\pydstool\examples\radau5_temp\radau5_vanderPol_vf.i
C:\Program Files\swig\swig.exe -python -ID:\Python27\Anaconda\lib\site-packages\numpy\core\include -IH:\python\packages\pydstool\examples -ID:\Python27\Anaconda\lib\site-packages\pydstool-0.90.0-py2.7-win32.egg\PyDSTool\integrator -o H:\python\packages\pydstool\examples\radau5_temp\radau5_vanderPol_vf_wrap.c -outdir  H:\python\packages\pydstool\examples\radau5_temp\radau5_vanderPol_vf.i
z2v commented 9 years ago

Fixed? What was the problem?

breisfeld commented 9 years ago

Sorry, I didn't mean to close this issue. I hit the wrong button.

z2v commented 9 years ago

So is there radau5_vanderPol_vf.i in radau5_temp directory?

breisfeld commented 9 years ago

Here are the contents of radau_temp:

SaddleNode_vf.c
stance_vf.c
vanderPol_vf.c
build.log
cplx_eg_vf.c
DAE_test_vf.c
freefinger_noforce_massmatrix_vf.c
HindmarshRoseFast_vf.c
LPneuron_vf.c
radau5_cplx_eg_vf.i
radau5_DAE_test_vf.i
radau5_freefinger_noforce_massmatrix_vf.i
radau5_HindmarshRoseFast_vf.i
radau5_LPneuron_vf.i
radau5_SaddleNode_vf.i
radau5_stance_vf.i
radau5_vanderPol_vf.i

Here is a listing of radau5_vanderPol_vf.i:

%module radau5_vanderPol_vf
%module radau5

%include typemaps.i
%include carrays.i

%array_functions(double,doubleArray)
%array_functions(int, intArray)

%{
#include "interface.h"
#include "radau5mod.h"
%}

%typemap(in) double * {
    int i, n;
    if(!PyList_Check($input)) {
        PyErr_SetString(PyExc_ValueError,"Expected a list as input");
        return NULL;
    }
    n = PyList_Size($input);
    $1 = (double *) malloc(n*sizeof(double));
    for( i = 0; i < n; i++ ) {
        PyObject *o = PyList_GetItem($input,i);
        if(PyNumber_Check(o)) {
            $1[i] = PyFloat_AsDouble(o);
        }
        else {
            PyErr_SetString(PyExc_ValueError,"List elements must be numbers.");
            return NULL;
        }
    }
}

%typemap(in) int * {
    int i, n;
    if(!PyList_Check($input)) {
        PyErr_SetString(PyExc_ValueError,"Expected a list as input");
        return NULL;
    }
    n = PyList_Size($input);
    $1 = (int *) malloc(n*sizeof(int));
    for( i = 0; i < n; i++ ) {
        PyObject *o = PyList_GetItem($input,i);
        if(PyNumber_Check(o)) {
            $1[i] = PyInt_AsLong(o);
        }
        else {
            PyErr_SetString(PyExc_ValueError,"List elements must be numbers.");
            return NULL;
        }
    }
}

%typemap(freearg) double* {
    if($1) free($1);
}

extern PyObject* Integrate(double *ic, double t, double hinit, double hmax,
            double safety,
            double jacRecompute, double newtonStop,
            double stepChangeLB, double stepChangeUB,
            double stepSizeLB, double stepSizeUB,
            int hessenberg,  int maxNewton,
            int newtonStart, int index1dim, int index2dim,
            int index3dim, int stepSizeStrategy,
            int DAEstructureM1, int DAEstructureM2,
            int useJac, int useMass, int verbose,
            int calcAux, int calcSpecTimes);

extern PyObject* InitBasic(int PhaseDim, int ParamDim, int nAux, int nEvents, int nExtInputs,
            int HasJac, int HasJacP, int HasMass, int extraSize);

extern PyObject* CleanUp( void );

extern PyObject* InitInteg(int Maxpts, double *atol, double *rtol );

extern PyObject* ClearInteg( void );

extern PyObject* InitEvents( int Maxevtpts, int *EventActive, int *EventDir, int *EventTerm,
              double *EventInterval, double *EventDelay, double *EventTol,
              int *Maxbisect, double EventNearCoef);

extern PyObject* ClearEvents( void );

extern PyObject* InitExtInputs( int nExtInputs, int *extInputLens, double *extInputVals,
             double *extInputTimes);

extern PyObject* ClearExtInputs( void );

extern PyObject* SetRunParameters(double *ic, double *pars, double gt0, double t0,
                double tend, int refine, int specTimeLen, double *specTimes,
                double *upperBounds, double *lowerBounds );

extern PyObject* ClearParams( void );

extern PyObject* Reset( void );

extern PyObject* SetContParameters(double tend, double *pars, double *upperBounds, double *lowerBounds);

extern PyObject* Vfield(double t, double *x, double *p);

extern PyObject* Jacobian(double t, double *x, double *p);

extern PyObject* JacobianP(double t, double *x, double *p);

extern PyObject* AuxFunc(double t, double *x, double *p);

extern PyObject* MassMatrix(double t, double *x, double *p);
z2v commented 9 years ago

@breisfeld, Ok, it seems that there is a bug in numpy.distutils build_ext --inplace implementation. I've made workaround. Please, pull changes from my bug/80-swig branch and check, if it fixes your problem.

breisfeld commented 9 years ago

With the fix...

Summary:
Basic PyDSTool functions: appears to work on your system
Map related modules: appears to work on your system
VODE related modules: appears to work on your system
Symbolic differentiation module: appears to work on your system
Parameter estimation module: appears to work on your system
PyCont: appears to be broken on your system
Dopri ODE systems: appears to work on your system
Radau ODE systems: appears to work on your system
Parameter estimation module with external compilers: appears to work on your system
PyCont interface to AUTO: appears to work on your system

Thanks!

As you can see, there is one failure (PyCont), but that is seems like it is test specific:

Test scripts that failed:
        PyCont_Hopfield.py
$ python .\PyCont_Hopfield.py
D:\Python27\Anaconda\lib\site-packages\numpy\core\fromnumeric.py:2499: VisibleDeprecationWarning: `rank` is deprecated;
use the `ndim` attribute or function instead. To find the rank of a matrix see `numpy.linalg.matrix_rank`.
  VisibleDeprecationWarning)
done in 9.281 seconds!
Computing curve...
Traceback (most recent call last):
  File ".\PyCont_Hopfield.py", line 89, in <module>
    PyCont['FO1'].backward()
  File "D:\Python27\Anaconda\lib\site-packages\pydstool-0.90.0-py2.7-win32.egg\PyDSTool\PyCont\Continuation.py", line 14
35, in backward
    for k, v in pt.labels[ctype]['data'].V.items():
KeyError: 'LP'
z2v commented 9 years ago

'PyCont_Hopfield' failure is known (see issue #21), but not fixed yet.

Thanks for the feedback.

FabricioS commented 7 years ago

On debian sid (unstable), I needed to revert the commit aedbffc proposed by z2v to be able to use the Dopri integrator. With the commit applied, I got the same bug as in this thread: https://sourceforge.net/p/pydstool/discussion/472291/thread/9bcf84f5/?limit=25#ab03

Further debugging indicates that the compiled object files are not where they should be:

%run Dopri_backwards_test.py
running build_ext
running build_src
build_src
building py_modules sources
building extension "/some_path/pydstool/examples/dop853_temp._dop853_my_ode_vf" sources
swig: /some_path/pydstool/examples/dop853_temp/dop853_my_ode_vf.i
swig -python -I/usr/lib/python3/dist-packages/numpy/core/include -I/some_path/pydstool/examples -I/some_path/pydstool/PyDSTool/integrator -o /some_path/pydstool/examples/dop853_temp/dop853_my_ode_vf_wrap.c -outdir /some_path/pydstool/examples/dop853_temp /some_path/pydstool/examples/dop853_temp/dop853_my_ode_vf.i
build_src: building npy-pkg config files
customize UnixCCompiler
customize UnixCCompiler using build_ext
building '/some_path/pydstool/examples/dop853_temp._dop853_my_ode_vf' extension
compiling C sources
C compiler: x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-LIjGUm/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC

compile options: '-I/usr/lib/python3/dist-packages/numpy/core/include -I/some_path/pydstool/examples -I/some_path/pydstool/PyDSTool/integrator -I/usr/lib/python3/dist-packages/numpy/core/include -I/usr/include/python3.5m -c'
extra options: '-w -Wno-return-type -Wall -D__DOPRI__'
x86_64-linux-gnu-gcc: /some_path/pydstool/examples/dop853_temp/my_ode_vf.c
Messages de l'assembleur:
Erreur fatale: ne peut créer /some_path/pydstool/examples/dop853_temp/some_path/pydstool/examples/dop853_temp/my_ode_vf.o: Aucun fichier ou dossier de ce type
Messages de l'assembleur:
Erreur fatale: ne peut créer /some_path/pydstool/examples/dop853_temp/some_path/pydstool/examples/dop853_temp/my_ode_vf.o: Aucun fichier ou dossier de ce type
An exception has occurred, use %tb to see the full traceback.

SystemExit: error: Command "x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-LIjGUm/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/lib/python3/dist-packages/numpy/core/include -I/some_path/pydstool/examples -I/some_path/pydstool/PyDSTool/integrator -I/usr/lib/python3/dist-packages/numpy/core/include -I/usr/include/python3.5m -c /some_path/pydstool/examples/dop853_temp/my_ode_vf.c -o /some_path/pydstool/examples/dop853_temp/some_path/pydstool/examples/dop853_temp/my_ode_vf.o -w -Wno-return-type -Wall -D__DOPRI__" failed with exit status 1

Note the duplication of the tempdir part of the output directory (tempdir=/some_path/pydstool/examples/dop853_temp/ here)