Skip to content

Commit fc34547

Browse files
author
Dilawar Singh
committed
Need to polish the API.
1 parent 6af0f2c commit fc34547

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

basecode/Cinfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ void Cinfo::registerFinfo(Finfo* f)
150150
string Cinfo::getFinfoType(const Finfo* f) const
151151
{
152152
if (dynamic_cast<const DestFinfo*>(f)) {
153-
return "DestInfo";
153+
return "DestFinfo";
154154
} else if (dynamic_cast<const SrcFinfo*>(f)) {
155155
return "SrcFinfo";
156156
} else if (dynamic_cast<const ValueFinfoBase*>(f)) {

pybind11/pymoose.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ py::object getValueFinfo(const ObjId& oid, const string& fname, const Finfo* f)
7777
r = pybind11::float_(getProp<double>(oid, fname));
7878
else if (rttType == "float")
7979
r = pybind11::float_(getProp<double>(oid, fname));
80-
else if (rttType == "vector<double>")
81-
r = py::cast(getProp<vector<double>>(oid, fname));
80+
else if (rttType == "vector<double>") {
81+
// r = py::cast(getProp<vector<double>>(oid, fname));
82+
r = getFieldNumpy<double>(oid, fname);
83+
}
8284
else if (rttType == "string")
8385
r = pybind11::str(getProp<string>(oid, fname));
8486
else if (rttType == "char")
@@ -114,7 +116,8 @@ inline ObjId getElementFinfoItem(const ObjId& oid, const size_t& i)
114116
return ObjId(oid.path(), oid.dataIndex, i);
115117
}
116118

117-
py::list getElementFinfo(const ObjId& objid, const string& fname, const Finfo* f)
119+
py::list getElementFinfo(const ObjId& objid, const string& fname,
120+
const Finfo* f)
118121
{
119122
auto rttType = f->rttiType();
120123
auto oid = ObjId(objid.path() + '/' + fname);
@@ -176,13 +179,19 @@ py::object getLookupValueFinfo(const ObjId& oid, const string& fname,
176179
return py::cast(__Finfo__(oid, fname, f));
177180
}
178181

179-
py::object getDestFinfo(const ObjId& obj, const string& fname, const Finfo* f)
182+
py::function getDestFinfo(const ObjId& obj, const string& fname, const Finfo* f)
180183
{
181184
auto rttType = f->rttiType();
182-
cout << " Setting " << fname << " with rttType " << rttType << " on object "
183-
<< obj.path() << endl;
184-
185-
return py::none();
185+
if (rttType == "Id") {
186+
std::function<bool(const ObjId& tgt)> f = [obj, fname](const ObjId& tgt) {
187+
return SetGet1<ObjId>::set(obj, fname, tgt);
188+
};
189+
return py::cast(f);
190+
}
191+
else
192+
cout << "NotImplented: Setting " << fname << " with rttType '"
193+
<< rttType << "' on object " << obj.path() << endl;
194+
return py::function();
186195
}
187196

188197
py::object getProperty(const ObjId& oid, const string& fname)
@@ -212,7 +221,7 @@ py::object getProperty(const ObjId& oid, const string& fname)
212221
}
213222

214223
cerr << "NotImplemented: getProperty for " << fname << " with rttType "
215-
<< finfo->rttiType() << " and type: " << finfoType << endl;
224+
<< finfo->rttiType() << " and type: '" << finfoType << "'" << endl;
216225
return pybind11::none();
217226
}
218227

tests/py_moose/test_kkit.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ def test_kkit():
2727

2828
vals = x.vector
2929
stats = [vals.min(), vals.max(), vals.mean(), vals.std()]
30-
expected = [0.0, 0.00040464, 0.0001444, 0.00013177]
31-
assert numpy.allclose(stats, expected,
32-
rtol=1e-4), 'Got %s expected %s' % (stats, expected)
30+
expected = [0.0, 0.00040324746614066575, 0.0001433307666099328, 0.0001313134713700798]
31+
assert numpy.allclose(stats, expected), 'Got %s expected %s' % (stats, expected)
3332

3433
def main():
3534
test_kkit()

0 commit comments

Comments
 (0)