Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
Work from home.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dilawar Singh committed Mar 27, 2020
1 parent 4ea29e9 commit 72f7b62
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
18 changes: 9 additions & 9 deletions basecode/Cinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ const Cinfo* Cinfo::baseCinfo() const
*/
const Finfo* Cinfo::findFinfo(const string& name) const
{
map<string, Finfo*>::const_iterator i = finfoMap_.find(name);
auto i = finfoMap_.find(name);
if (i != finfoMap_.end())
return i->second;
return 0;
Expand All @@ -229,21 +229,21 @@ const FinfoWrapper Cinfo::findFinfoWrapper(const string& name) const
return FinfoWrapper(findFinfo(name));
}

vector<string> Cinfo::getFinfoNames() const
std::vector<pair<string, string>> Cinfo::getFinfoNameAndType() const
{
vector<string> res;
for (auto& f : srcFinfos_) res.push_back("srcFinfos:" + f->name());
vector<pair<string, string>> res;
for (auto& f : srcFinfos_) res.push_back({"srcFinfos", f->name()});

for (auto& f : destFinfos_) res.push_back("destFinfo:" + f->name());
for (auto& f : destFinfos_) res.push_back({"destFinfo", f->name()});

for (auto& f : valueFinfos_) res.push_back("valueFinfo:" + f->name());
for (auto& f : valueFinfos_) res.push_back({"valueFinfo", f->name()});

for (auto& f : lookupFinfos_) res.push_back("lookupFinfo:" + f->name());
for (auto& f : lookupFinfos_) res.push_back({"lookupFinfo", f->name()});

for (auto& f : sharedFinfos_) res.push_back("sharedFinfo:" + f->name());
for (auto& f : sharedFinfos_) res.push_back({"sharedFinfo", f->name()});

for (auto& f : fieldElementFinfos_)
res.push_back("fieldElement:" + f->name());
res.push_back({"fieldElement", f->name()});

return res;
}
Expand Down
2 changes: 1 addition & 1 deletion basecode/Cinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class Cinfo {
const map<string, Finfo*>& finfoMap() const;

// Used in python bindings. Also return type of finfo.
vector<string> getFinfoNames() const;
std::vector<std::pair<string,string>> getFinfoNameAndType() const;

/**
* Returns the Dinfo, which manages creation and destruction
Expand Down
7 changes: 4 additions & 3 deletions pybind11/pymoose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ py::object getFieldElement(const ObjId& oid, const string& fname)
{
auto cinfo = oid.element()->cinfo();
auto finfo = cinfo->findFinfo(fname);
if (!finfo) {
py::print("Field " + fname + " is not found on " + oid.path());
if (! finfo) {
py::object avl = py::cast(cinfo->getFinfoNameAndType());
py::print("Field " + fname + " is not found on '" + oid.path()
+ "'. Available: ", avl);
return pybind11::none();
}
}
Expand Down Expand Up @@ -212,7 +214,6 @@ PYBIND11_MODULE(_cmoose, m)
.def_property_readonly("name", &Cinfo::name)
.def_property_readonly("finfoMap", &Cinfo::finfoMap,
py::return_value_policy::reference)
.def_property_readonly("finfoNames", &Cinfo::getFinfoNames)
.def("findFinfo", &Cinfo::findFinfoWrapper)
.def("baseCinfo", &Cinfo::baseCinfo,
py::return_value_policy::reference);
Expand Down
2 changes: 1 addition & 1 deletion tests/pybind11/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def makereac2():

sum.cobj.setField("numVars", 2)

print('xxx', sum.cobj.getField('x'))
print('xxx', sum.cobj.getFieldElement('x'))
quit()

A.connect("nOut", sum.cobj.getField("x"), "input")
Expand Down

0 comments on commit 72f7b62

Please sign in to comment.