Skip to content

Commit

Permalink
* Removes static numpy initialization strategy for the Pulse simulator (
Browse files Browse the repository at this point in the history
#609) (#611)

It was causing the error: Cannot import numpy.core.multiarray only on
older versions of CentOS.
  • Loading branch information
atilag authored Feb 12, 2020
1 parent ad3fac1 commit 9b19985
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/open_pulse/numeric_integrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ PyArrayObject * td_ode_rhs(
CALLGRIND_START_INSTRUMENTATION;
#endif

const static auto numpy_initialized = init_numpy();
import_array();

// I left this commented on porpose so we can use logging eventually
// This is just a RAII for the logger
Expand Down
10 changes: 1 addition & 9 deletions src/open_pulse/python_to_cpp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@
#include "iterators.hpp"
#include "eval_hamiltonian.hpp"

static bool init_numpy(){
static bool initialized = false;
if(!initialized){
import_array();
initialized = true;
}
};

bool check_is_integer(PyObject * value){
if(value == nullptr)
throw std::invalid_argument("PyObject is null!");
Expand Down Expand Up @@ -117,7 +109,7 @@ bool check_is_dict(PyObject * value){
bool check_is_np_array(PyArrayObject * value){
if(value == nullptr)
throw std::invalid_argument("Numpy ndarray is null!");
init_numpy();
import_array();
// Check that it's a numpy ndarray
if(!PyArray_Check(value))
return false;
Expand Down

0 comments on commit 9b19985

Please sign in to comment.