File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 7
7
#include < nanobind/eigen/dense.h>
8
8
#include < nanobind/eigen/sparse.h>
9
9
10
+ #include < string_view>
11
+
10
12
namespace proxsuite {
11
13
namespace common {
12
14
namespace python {
13
15
namespace detail {
14
- inline auto
16
+ inline nanobind::str
15
17
type_name_short (nanobind::handle h)
16
18
{
17
19
namespace nb = nanobind;
18
20
assert (h.is_type ());
19
- return nb::type_name (h);
21
+ // nb::type_name return the type_name with modules.
22
+ // In the next step, we will trim the modules to only keep the type name.
23
+ auto str = nb::type_name (h);
24
+ std::string_view work_str (str.c_str ());
25
+ auto dot_index = work_str.find_last_of (' .' );
26
+ if (dot_index == std::string_view::npos) {
27
+ return str;
28
+ } else {
29
+ return nb::str (work_str.data () + dot_index + 1 );
30
+ }
31
+ // return nb::str(dot_it++, str.end());
20
32
}
21
33
} // namespace detail
22
34
You can’t perform that action at this time.
0 commit comments