MCPcopy Create free account
hub / github.com/boostorg/histogram / category_init

Function category_init

src/python/axis.cpp:105–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105bp::object category_init(bp::tuple args, bp::dict kwargs) {
106 bp::object self = args[0];
107
108 if (bp::len(args) == 1) {
109 PyErr_SetString(PyExc_TypeError, "require at least one argument");
110 bp::throw_error_already_set();
111 }
112
113 boost::string_view label;
114 while (bp::len(kwargs) > 0) {
115 bp::tuple kv = kwargs.popitem();
116 const char* key_cstr = bp::extract<const char*>(kv[0]);
117 boost::string_view k(key_cstr, bp::len(kv[0]));
118 bp::object v = kv[1];
119 if (k == "label")
120 label = boost::string_view(bp::extract<const char*>(v), bp::len(v));
121 else {
122 std::stringstream s;
123 s << "keyword " << k << " not recognized";
124 PyErr_SetString(PyExc_KeyError, s.str().c_str());
125 bp::throw_error_already_set();
126 }
127 }
128
129 std::vector<int> c;
130 for (int i = 1, n = bp::len(args); i < n; ++i) c.push_back(bp::extract<int>(args[i]));
131
132 return self.attr("__init__")(bha::category<>(c.begin(), c.end(), label));
133}
134
135template <typename T>
136void axis_set_label(T& t, bp::str s) {

Callers

nothing calls this directly

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected