| 144 | } |
| 145 | |
| 146 | bp::object histogram_init(bp::tuple args, bp::dict kwargs) { |
| 147 | |
| 148 | bp::object self = args[0]; |
| 149 | |
| 150 | if (kwargs) { throw std::invalid_argument("no keyword arguments allowed"); } |
| 151 | |
| 152 | const unsigned dim = bp::len(args) - 1; |
| 153 | |
| 154 | // normal constructor |
| 155 | pyhistogram::axes_type axes; |
| 156 | for (unsigned i = 0; i < dim; ++i) { |
| 157 | bp::object pa = args[i + 1]; |
| 158 | bool success = false; |
| 159 | boost::mp11::mp_for_each<bh::axis::any_std>(axes_appender(pa, axes, success)); |
| 160 | if (!success) { |
| 161 | std::string msg = "require an axis object, got "; |
| 162 | msg += bp::extract<std::string>(bp::str(pa)); |
| 163 | PyErr_SetString(PyExc_TypeError, msg.c_str()); |
| 164 | bp::throw_error_already_set(); |
| 165 | } |
| 166 | } |
| 167 | pyhistogram h(axes, typename pyhistogram::storage_type()); |
| 168 | return self.attr("__init__")(std::move(h)); |
| 169 | } |
| 170 | |
| 171 | template <typename T> |
| 172 | struct fetcher { |
nothing calls this directly
no test coverage detected