Skip to content

Commit c4d7bc6

Browse files
author
Dilawar Singh
committed
We go both API integrated.
1 parent f0ac785 commit c4d7bc6

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

pybind11/pymoose.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ py::object getLookupValueFinfoItem(const ObjId& oid, const string& fname, const
133133
return r;
134134
}
135135

136-
py::object getLookupValueFinfo(const ObjId& oid, const string& fname)
136+
py::function getLookupValueFinfo(const ObjId& oid, const string& fname)
137137
{
138138
std::function<py::object(const string&)> f = [oid, fname](const string& key) {
139139
return getLookupValueFinfoItem(oid, fname, key);

python/moose/moose.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ def __parent(path):
2121

2222
t0 = time.time()
2323

24+
# Hack:
25+
class __Finfo__(object):
26+
def __init__(self, finfo):
27+
super().__init__()
28+
self.finfo = finfo
29+
30+
def __getitem__(self, k):
31+
return self.finfo(k)
32+
33+
def __call__(self, k):
34+
self.finfo(k)
35+
2436
class __Neutral__(_cmoose._ObjId):
2537

2638
__metaclass__ = None
@@ -38,7 +50,11 @@ def __setattr__(self, attr, val):
3850
self.setField(attr, val)
3951

4052
def __getattr__(self, attr):
41-
return super(__Neutral__, self).getField(attr)
53+
x = super(__Neutral__, self).getField(attr)
54+
if not callable(x):
55+
return x
56+
# else return a dict.
57+
return __Finfo__(x)
4258

4359

4460
for p in _cmoose.wildcardFind('/##[TYPE=Cinfo]'):

tests/pybind11/test_shell.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,11 @@ def test_ksolve2():
332332
run_and_assert(kin, "ksolve1_test2.png")
333333

334334
def test_ksolve3():
335-
a = moose.Neutral('x')
335+
moose.Neutral('x')
336336
a = moose.Neutral('x/x')
337337
print(a.isA)
338338
print(a.isA('Compartment'))
339-
#print(a.isA['Compartment'])
339+
print(a.isA['Compartment'])
340340

341341
def main():
342342
test_ksolve0()

0 commit comments

Comments
 (0)