| 618 | |
| 619 | template<typename Numeric> |
| 620 | bool stem(const std::vector<Numeric> &x, const std::vector<Numeric> &y, const std::map<std::string, std::string>& keywords) |
| 621 | { |
| 622 | assert(x.size() == y.size()); |
| 623 | |
| 624 | detail::_interpreter::get(); |
| 625 | |
| 626 | // using numpy arrays |
| 627 | PyObject* xarray = detail::get_array(x); |
| 628 | PyObject* yarray = detail::get_array(y); |
| 629 | |
| 630 | // construct positional args |
| 631 | PyObject* args = PyTuple_New(2); |
| 632 | PyTuple_SetItem(args, 0, xarray); |
| 633 | PyTuple_SetItem(args, 1, yarray); |
| 634 | |
| 635 | // construct keyword args |
| 636 | PyObject* kwargs = PyDict_New(); |
| 637 | for (std::map<std::string, std::string>::const_iterator it = |
| 638 | keywords.begin(); it != keywords.end(); ++it) { |
| 639 | PyDict_SetItemString(kwargs, it->first.c_str(), |
| 640 | PyString_FromString(it->second.c_str())); |
| 641 | } |
| 642 | |
| 643 | PyObject* res = PyObject_Call( |
| 644 | detail::_interpreter::get().s_python_function_stem, args, kwargs); |
| 645 | |
| 646 | Py_DECREF(args); |
| 647 | Py_DECREF(kwargs); |
| 648 | if (res) |
| 649 | Py_DECREF(res); |
| 650 | |
| 651 | return res; |
| 652 | } |
| 653 | |
| 654 | template< typename Numeric > |
| 655 | bool fill(const std::vector<Numeric>& x, const std::vector<Numeric>& y, const std::map<std::string, std::string>& keywords) |