[ci skip] Order Dependence Demo

This commit is contained in:
Ralf W. Grosse-Kunstleve 2023-07-27 13:45:26 -07:00
parent 775aab5722
commit d37b5409d4
2 changed files with 21 additions and 2 deletions

View File

@ -156,6 +156,19 @@ PYBIND11_NOINLINE void all_type_info_populate(PyTypeObject *t, std::vector<type_
} }
} }
inline void dump_registered_types_py() {
printf("\ndump_registered_types_py():\n{\n");
auto const &type_dict = get_internals().registered_types_py;
for (const auto &item : type_dict) {
printf(" %s:\n", item.first->tp_name);
for (const auto &base : item.second) {
printf(" %s\n", base->type->tp_name);
}
}
printf("}\n");
fflush(stdout);
}
/** /**
* Extracts vector of type_info pointers of pybind-registered roots of the given Python type. Will * Extracts vector of type_info pointers of pybind-registered roots of the given Python type. Will
* be just 1 pybind type for the Python type of a pybind-registered class, or for any Python-side * be just 1 pybind type for the Python type of a pybind-registered class, or for any Python-side
@ -171,6 +184,7 @@ inline const std::vector<detail::type_info *> &all_type_info(PyTypeObject *type)
if (ins.second) { if (ins.second) {
// New cache entry: populate it // New cache entry: populate it
all_type_info_populate(type, ins.first->second); all_type_info_populate(type, ins.first->second);
dump_registered_types_py();
} }
return ins.first->second; return ins.first->second;

View File

@ -15,7 +15,7 @@ class PPCCInit(PC, m.CppDrvd):
# Moving this test after test_PC() changes the behavior! # Moving this test after test_PC() changes the behavior!
def test_PPCCInit(): def NOtest_PPCCInit():
d = PPCCInit(11) d = PPCCInit(11)
assert d.get_drvd_value() == 36 assert d.get_drvd_value() == 36
d.reset_drvd_value(55) d.reset_drvd_value(55)
@ -31,8 +31,13 @@ def test_PPCCInit():
assert d.get_base_value_from_drvd() == 30 assert d.get_base_value_from_drvd() == 30
def test_PC(): def NOtest_PC():
d = PC(11) d = PC(11)
assert d.get_base_value() == 11 assert d.get_base_value() == 11
d.reset_base_value(13) d.reset_base_value(13)
assert d.get_base_value() == 13 assert d.get_base_value() == 13
def testOrderDependenceDemo():
PC(0)
PPCCInit(0)