Blob Blame History Raw
diff -up singular-4.1.0/Singular/dyn_modules/python/interpreter_support.cc.orig singular-4.1.0/Singular/dyn_modules/python/interpreter_support.cc
--- singular-4.1.0/Singular/dyn_modules/python/interpreter_support.cc.orig	2017-04-12 09:54:29.000000000 -0600
+++ singular-4.1.0/Singular/dyn_modules/python/interpreter_support.cc	2018-02-14 21:16:46.138812306 -0700
@@ -2,6 +2,7 @@
 #ifdef HAVE_PYTHON_MOD
 #include <sstream>
 #include <boost/python.hpp>
+#include <boost/python/numpy.hpp>
 #include <boost/python/suite/indexing/vector_indexing_suite.hpp>
 #include "Singular/subexpr.h"
 #include "Poly.h"
@@ -20,7 +21,7 @@
 #include "poly_wrap.h"
 extern int inerror;
 using namespace boost::python;
-using boost::python::numeric::array;
+using boost::python::numpy::ndarray;
 using boost::python::extract;
 static void free_leftv(leftv args)
 {
@@ -28,7 +29,7 @@ static void free_leftv(leftv args)
     omFreeBin(args, sleftv_bin);
 }
 
-matrix matrixFromArray(const boost::python::numeric::array& f)
+matrix matrixFromArray(const boost::python::numpy::ndarray& f)
 {
   object o=f.attr("shape");
   object o1=o[0];
@@ -130,7 +131,7 @@ class arg_list
     v->rtyp=VECTOR_CMD;
     internal_append(v);
   }
-  void appendArray(const boost::python::numeric::array& f)
+  void appendArray(const boost::python::numpy::ndarray& f)
   {
     leftv v=initArg();
     matrix m=matrixFromArray(f);
@@ -276,7 +277,7 @@ class idhdl_wrap
       id->data.p=p.as_poly();
     }
   }
-  void writeArray(const boost::python::numeric::array& f)
+  void writeArray(const boost::python::numpy::ndarray& f)
   {
     if(id->typ=MATRIX_CMD)
     {
@@ -323,9 +324,9 @@ class idhdl_wrap
 };
 
 
-static boost::python::numeric::array buildPythonMatrix(matrix m, ring r)
+static boost::python::numpy::ndarray buildPythonMatrix(matrix m, ring r)
 {
-  using boost::python::numeric::array;
+  using boost::python::numpy::ndarray;
   using boost::python::self;
   using boost::python::make_tuple;
   using boost::python::tuple;
@@ -345,11 +346,7 @@ static boost::python::numeric::array bui
     }
     l.append(row);
   }
-  //FIXME: should call this only once
-  boost::python::numeric::array::set_module_and_type("Numeric",
-                             "ArrayType"
-                             );
-  return boost::python::numeric::array(l);
+  return boost::python::numpy::array(l);
 }
 boost::python::object buildPyObjectFromLeftv(leftv v);
 boost::python::list buildPythonList(lists l, ring r)
diff -up singular-4.1.0/Singular/dyn_modules/python/playground.cc.orig singular-4.1.0/Singular/dyn_modules/python/playground.cc
--- singular-4.1.0/Singular/dyn_modules/python/playground.cc.orig	2017-04-12 09:54:29.000000000 -0600
+++ singular-4.1.0/Singular/dyn_modules/python/playground.cc	2018-02-14 20:28:55.954897109 -0700
@@ -2,8 +2,8 @@
 #ifdef HAVE_PYTHON_MOD
 #include <boost/python.hpp>
 #include "Poly.h"
-#include "boost/python/numeric.hpp"
-using boost::python::numeric::array;
+#include "boost/python/numpy.hpp"
+using boost::python::numpy::ndarray;
 using boost::python::self;
 using boost::python::make_tuple;
 using boost::python::tuple;
@@ -24,13 +24,10 @@ object foo()
     }
     l.append(row);
   }
-  boost::python::numeric::array::set_module_and_type("Numeric",
-                             "ArrayType"
-                             );
-  boost::python::numeric::array a(l);
+  boost::python::numpy::ndarray a(l);
   return a;
 }
-object foo2(array f)
+object foo2(ndarray f)
 {
   using boost::python::extract;
   object o=f.attr("shape");
diff -up singular-4.1.0/Singular/dyn_modules/python/python_module.cc.orig singular-4.1.0/Singular/dyn_modules/python/python_module.cc
--- singular-4.1.0/Singular/dyn_modules/python/python_module.cc.orig	2017-04-12 09:54:29.000000000 -0600
+++ singular-4.1.0/Singular/dyn_modules/python/python_module.cc	2018-02-14 20:30:26.498656892 -0700
@@ -72,6 +72,7 @@ extern "C" int SI_MOD_INIT(python_module
   setenv("PYTHONPATH",buf,1);
 
   Py_Initialize();
+  boost::python::numpy::initialize();
   PyRun_SimpleString("from sys import path\n\
 path.insert(0,'.')\n");
   initSingular();
diff -up singular-4.1.0/Singular/dyn_modules/python/wrapper.h.orig singular-4.1.0/Singular/dyn_modules/python/wrapper.h
--- singular-4.1.0/Singular/dyn_modules/python/wrapper.h.orig	2017-04-12 09:54:29.000000000 -0600
+++ singular-4.1.0/Singular/dyn_modules/python/wrapper.h	2018-02-14 20:57:54.557934662 -0700
@@ -2,6 +2,7 @@
 #define PYTHON_SINGULAR_WRAPPER_HEADER
 #include <Python.h>
 #include <boost/python.hpp>
+#include <boost/python/numpy.hpp>
 #include <sstream>
 #include <kernel/mod2.h>
 
@@ -24,7 +25,7 @@
 #include "interpreter_support.h"
 #include "ring_wrap.h"
 #include "intvec_wrap.h"
-using boost::python::numeric::array;
+using boost::python::numpy::ndarray;
 using boost::python::extract;
 
 using namespace boost::python;