Skip to content
Snippets Groups Projects
Commit 94b9cd98 authored by Olivier BICHLER's avatar Olivier BICHLER
Browse files

Added minor tests

parent 0f22b49a
No related branches found
No related tags found
2 merge requests!212Version 0.3.0,!161Add support for namespaced attributes in DynamicAttributes
Pipeline #50737 passed
......@@ -100,6 +100,23 @@ class test_operator_binding(unittest.TestCase):
attrs.d = 23.89
self.assertEqual(aidge_core.test_DynamicAttributes_binding_check(attrs), 23.89)
op = aidge_core.GenericOperatorOp("any_type", 1,0,1)
with self.assertRaises(RuntimeError):
op.attr.something
op.attr.something = aidge_core.DynamicAttributes()
try:
self.assertEqual(str(op.attr), "AttrDict({'something': AttrDict({})})")
except Exception:
self.fail("op.attr.something raised Exception unexpectedly!")
op.attr.something.arg1 = 4
self.assertEqual(op.attr.something.arg1, 4)
# auto create the namespace another_thing (not enabled)
#op.attr.another_thing.arg = 44
#self.assertEqual(op.attr.another_thing.arg, 44)
def test_forward_dims(self):
in_dims=[25, 25]
input = aidge_core.Producer(in_dims, name="In")
......
......@@ -47,6 +47,7 @@ void init_Attributes(py::module& m){
py::class_<DynamicAttributes, std::shared_ptr<DynamicAttributes>, Attributes>(m, "DynamicAttributes")
.def(py::init<>())
.def("add_attr", &DynamicAttributes::addAttrPy, py::arg("name"), py::arg("value"))
.def("del_attr", &DynamicAttributes::delAttr, py::arg("name"));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment