Mercurial > pytave
changeset 21:905659caf44b pytave-task
Support for Python lists and dictionaries (cell arrays and structs)
author | David Grundberg <individ@acc.umu.se> |
---|---|
date | Mon, 17 Nov 2008 10:02:52 +0100 |
parents | ae09a25b1206 (diff) 9a773d71a973 (current diff) |
children | 1a26d85a01be |
files | octave_to_python.cc |
diffstat | 4 files changed, 46 insertions(+), 48 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Mon Nov 17 09:57:29 2008 +0100 +++ b/ChangeLog Mon Nov 17 10:02:52 2008 +0100 @@ -1,3 +1,16 @@ +2008-11-10 David Grundberg <individ@acc.umu.se> + + * octave_to_python.cc: Remove static storage class on explicitely + specialized templates. + +2008-10-23 David Grundberg <individ@acc.umu.se> + + * pytave.cc: Use octave_main() to initialize Octave. Introduces + readline history clashes with interactive Python interpreter. + * configure.ac: Better testing for Python dependencies. + * configure.ac: Renamed my_ to pytave_ + * configure.ac: Fixed whitespace. + 2008-10-20 David Grundberg <individ@acc.umu.se> * Makefile.am: added test/exceptions.py to extra dist.
--- a/configure.ac Mon Nov 17 09:57:29 2008 +0100 +++ b/configure.ac Mon Nov 17 10:02:52 2008 +0100 @@ -22,10 +22,9 @@ AC_ARG_WITH([octave], [AS_HELP_STRING([--with-octave], [Optionally set Octave package to use. - @<:@default=check@:>@])], + @<:@default=check@:>@])], [with_octave=$withval], [with_octave=check]) - AS_IF([test "x$with_octave" == xno], [ AC_MSG_FAILURE([--without-octave was given but Octave required]) @@ -48,8 +47,7 @@ [ AC_MSG_WARN([Could not find octave-config.]) ], -[ - +[ PYTAVE_OCTAVE_RPATH=`$octaveconfig -p OCTLIBDIR` PYTAVE_OCTAVE_INCLUDE_PATH=`$octaveconfig -p OCTINCLUDEDIR` AC_MSG_RESULT([ results of the Octave check:]) @@ -67,15 +65,17 @@ old_libs="$LIBS" LIBS="-loctave -lcruft -loctinterp $LIBS" - AC_CACHE_CHECK([whether linking to Octave library works], [my_cv_lib_octave], + AC_CACHE_CHECK([whether linking to Octave library works], [pytave_cv_lib_octave], [ - my_cv_lib_octave=no - AC_LANG_ASSERT(C++) - AC_LINK_IFELSE(AC_LANG_PROGRAM([[#include <octave/oct.h> - #include <octave/Matrix.h> ]], - [[MatrixType()]]), - [my_cv_lib_octave=yes], - [my_cv_lib_octave=no]) + pytave_cv_lib_octave=no + AC_LANG_ASSERT(C++) + AC_LINK_IFELSE( + AC_LANG_PROGRAM( + [[#include <octave/oct.h> + #include <octave/Matrix.h> ]], + [[MatrixType()]]), + [pytave_cv_lib_octave=yes], + [pytave_cv_lib_octave=no]) ]) @@ -88,21 +88,25 @@ # Look for boost::python AX_PYTHON() +old_libs="$LIBS" +AS_IF([test "x$PYTHON_LIB" != "x"],[ +LIBS="-l$PYTHON_LIB $LIBS" +],[]) AX_BOOST_PYTHON() +LIBS="$old_libs" # Now check the two vital libs, if they have problems, halt. pytave_fatal_errors=no -AS_IF(test "x$my_cv_lib_octave" != "xyes", +AS_IF(test "x$pytave_cv_lib_octave" != "xyes", [ AC_MSG_WARN([Linking to Octave failed.]) pytave_fatal_errors=yes ], []) -# XXX: hohoho, this is ugly. -AS_IF(test "x$ac_cv_boost_python" != "xyes", +AS_IF(test "x$BOOST_PYTHON_LIB" == "x", [ - AC_MSG_WARN([Boost::Python test failed.]) + AC_MSG_WARN([Cannot find Boost::Python lib.]) pytave_fatal_errors=yes ], []) @@ -125,7 +129,6 @@ AC_PROG_MAKE_SET # Checks for libraries. - # Checks for header files. @@ -141,7 +144,7 @@ PYTAVE_MODULE_INSTALL_PATH=/../invalidpath, ], [ - PYTAVE_MODULE_INSTALL_PATH=${prefix} + PYTAVE_MODULE_INSTALL_PATH=${prefix} ]) # Substitutes for the Makefile/Jamfile
--- a/octave_to_python.cc Mon Nov 17 09:57:29 2008 +0100 +++ b/octave_to_python.cc Mon Nov 17 10:02:52 2008 +0100 @@ -75,7 +75,7 @@ } template <> - static void copy_octarray_to_pyarrobj<double, NDArray>( + void copy_octarray_to_pyarrobj<double, NDArray>( PyArrayObject *pyarr, const NDArray &matrix, const unsigned int matindex, @@ -104,7 +104,7 @@ #ifdef PYTAVE_USE_OCTAVE_FLOATS template <> - static void copy_octarray_to_pyarrobj<float, FloatNDArray>( + void copy_octarray_to_pyarrobj<float, FloatNDArray>( PyArrayObject *pyarr, const FloatNDArray &matrix, const unsigned int matindex,
--- a/pytave.cc Mon Nov 17 09:57:29 2008 +0100 +++ b/pytave.cc Mon Nov 17 10:02:52 2008 +0100 @@ -24,21 +24,14 @@ #undef HAVE_STAT /* Both boost.python and octave define HAVE_STAT... */ #include <octave/oct.h> +#include <octave/octave.h> +#include <octave/ov.h> #include <octave/parse.h> -#include <octave/load-path.h> -#include <octave/file-io.h> -#include <octave/ops.h> #include <iostream> #include <sstream> - #include <sys/types.h> -#include <octave/Matrix.h> -#include <octave/ov.h> -#include <octave/builtins.h> -#include <octave/defaults.h> - #include "pytavedefs.h" #include "exceptions.h" @@ -59,27 +52,16 @@ return; } - set_liboctave_error_handler(error); - set_liboctave_warning_handler(warning); - set_liboctave_warning_with_id_handler(warning_with_id); - - // New in Octave 3 - initialize_default_warning_state(); + // Initialize Octave. + // Also print Octave startup message. + char* argv[] = {"octave", "--no-line-editing", "--no-history", NULL}; + octave_main(3, argv, 1); - install_defaults(); - initialize_file_io(); - initialize_symbol_tables(); - install_types(); - - install_ops(); + // Initialize Python Numeric Array - install_builtins(); - - // true argument new in Octave 3 - load_path::initialize(true); // or use false to set empty path - - // initialize python numeric array - import_array(); + // This is actually a macro that becomes a block expression. If an error + // occurs, e.g. Numeric Array not installed, an exception is set. + import_array() } boost::python::tuple get_exceptions() {