| 1712 | |
| 1713 | template<typename Numeric> |
| 1714 | inline void yticks(const std::vector<Numeric> &ticks, const std::vector<std::string> &labels = {}, const std::map<std::string, std::string>& keywords = {}) |
| 1715 | { |
| 1716 | assert(labels.size() == 0 || ticks.size() == labels.size()); |
| 1717 | |
| 1718 | detail::_interpreter::get(); |
| 1719 | |
| 1720 | // using numpy array |
| 1721 | PyObject* ticksarray = detail::get_array(ticks); |
| 1722 | |
| 1723 | PyObject* args; |
| 1724 | if(labels.size() == 0) { |
| 1725 | // construct positional args |
| 1726 | args = PyTuple_New(1); |
| 1727 | PyTuple_SetItem(args, 0, ticksarray); |
| 1728 | } else { |
| 1729 | // make tuple of tick labels |
| 1730 | PyObject* labelstuple = PyTuple_New(labels.size()); |
| 1731 | for (size_t i = 0; i < labels.size(); i++) |
| 1732 | PyTuple_SetItem(labelstuple, i, PyUnicode_FromString(labels[i].c_str())); |
| 1733 | |
| 1734 | // construct positional args |
| 1735 | args = PyTuple_New(2); |
| 1736 | PyTuple_SetItem(args, 0, ticksarray); |
| 1737 | PyTuple_SetItem(args, 1, labelstuple); |
| 1738 | } |
| 1739 | |
| 1740 | // construct keyword args |
| 1741 | PyObject* kwargs = PyDict_New(); |
| 1742 | for(std::map<std::string, std::string>::const_iterator it = keywords.begin(); it != keywords.end(); ++it) |
| 1743 | { |
| 1744 | PyDict_SetItemString(kwargs, it->first.c_str(), PyString_FromString(it->second.c_str())); |
| 1745 | } |
| 1746 | |
| 1747 | PyObject* res = PyObject_Call(detail::_interpreter::get().s_python_function_yticks, args, kwargs); |
| 1748 | |
| 1749 | Py_DECREF(args); |
| 1750 | Py_DECREF(kwargs); |
| 1751 | if(!res) throw std::runtime_error("Call to yticks() failed"); |
| 1752 | |
| 1753 | Py_DECREF(res); |
| 1754 | } |
| 1755 | |
| 1756 | template<typename Numeric> |
| 1757 | inline void yticks(const std::vector<Numeric> &ticks, const std::map<std::string, std::string>& keywords) |
nothing calls this directly
no test coverage detected