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

Commit 6126a64

Browse files
author
Dilawar Singh
committed
snippets/savemodel.py is causing problem now.
1 parent 15eae1d commit 6126a64

File tree

8 files changed

+35
-19
lines changed

8 files changed

+35
-19
lines changed

pybind11/MooseVec.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ vector<py::object> MooseVec::getAttribute(const string& name)
105105
return res;
106106
}
107107

108-
// FIXME: Only double is supported here. Not sure if this is enough.
108+
// FIXME: Only double is supported here. Not sure if this is enough. This
109+
// should be the API function.
109110
py::array_t<double> MooseVec::getAttributeNumpy(const string &name)
110111
{
111112
auto cinfo = oid_.element()->cinfo();
@@ -128,7 +129,7 @@ py::array_t<double> MooseVec::getAttributeNumpy(const string &name)
128129
return py::array_t<double>(res.size(), res.data());
129130
}
130131

131-
throw runtime_error("getAttributeNumpy::NotImplemented : " + name +
132+
throw runtime_error("MooseVec::getAttributeNumpy::NotImplemented : " + name +
132133
" with rttType " + finfo->rttiType() + " and type: '" +
133134
finfoType + "'");
134135
return py::array_t<double>();

pybind11/MooseVec.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ class MooseVec
3939
ObjId getDataItem(const size_t i) const;
4040
ObjId getFieldItem(const size_t i) const;
4141

42+
// Set attribute to vector.
4243
void setAttrOneToAll(const string& name, const py::object& val);
4344

4445
void setAttrOneToOne(const string& name, const py::sequence& val);
4546

47+
// Get attributes.
4648
vector<py::object> getAttribute(const string& name);
4749
py::array_t<double> getAttributeNumpy(const string& name);
4850

pybind11/helper.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ ObjId shellConnect(const ObjId& src, const string& srcField, const ObjId& tgt,
203203
return getShellPtr()->doAddMsg(msgType, src, srcField, tgt, tgtField);
204204
}
205205

206+
#if 0
206207
void mooseMoveId(const Id& a, const ObjId& b)
207208
{
208209
getShellPtr()->doMove(a, b);
@@ -213,6 +214,12 @@ void mooseMoveObjId(const ObjId& a, const ObjId& b)
213214
getShellPtr()->doMove(a.id, b);
214215
}
215216

217+
void mooseMoveObPath(const string& a, const ObjId& b)
218+
{
219+
getShellPtr()->doMove(a.id, b);
220+
}
221+
#endif
222+
216223
void mooseSetClock(const unsigned int clockId, double dt)
217224
{
218225
getShellPtr()->doSetClock(clockId, dt);

pybind11/helper.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,17 @@ Id initShell();
3939

4040
bool mooseExists(const string& path);
4141

42+
#if 0
4243
void mooseMoveId(const Id& a, const ObjId& b);
4344
void mooseMoveObjId(const ObjId& a, const ObjId& b);
45+
#endif
46+
47+
template<typename P=ObjId, typename Q=ObjId>
48+
inline void mooseMove(const P& src, const Q& tgt)
49+
{
50+
getShellPtr()->doMove(Id(src), ObjId(tgt));
51+
}
52+
4453

4554
inline MooseVec mooseObjIdPath(const string& p)
4655
{

pybind11/pymoose.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,9 @@ PYBIND11_MODULE(_moose, m)
315315
},
316316
py::keep_alive<0, 1>())
317317
.def("__getitem__", &MooseVec::getItem)
318-
.def("__setattr__", &MooseVec::setAttrOneToOne)
319318
.def("__setattr__", &MooseVec::setAttrOneToAll)
320-
.def("__getattr__", &MooseVec::getAttributeNumpy)
319+
.def("__setattr__", &MooseVec::setAttrOneToOne)
320+
.def("__getattr__", &MooseVec::getAttribute)
321321
.def("__repr__", [](const MooseVec & v)->string {
322322
return "<moose.vec class=" + v.dtype() + " path=" + v.path() +
323323
" id=" + std::to_string(v.id()) + " size=" +
@@ -346,8 +346,10 @@ PYBIND11_MODULE(_moose, m)
346346
m.def("create", &mooseCreateFromPath);
347347
m.def("create", &mooseCreateFromObjId);
348348
m.def("create", &mooseCreateFromId);
349-
m.def("move", &mooseMoveId);
350-
m.def("move", &mooseMoveObjId);
349+
m.def("move", &mooseMove<ObjId, ObjId>);
350+
m.def("move", &mooseMove<ObjId, string>);
351+
m.def("move", &mooseMove<string, ObjId>);
352+
m.def("move", &mooseMove<string, string>);
351353
m.def("reinit", &mooseReinit);
352354
m.def("start", &mooseStart, "runtime"_a, "notify"_a = false);
353355
m.def("stop", &mooseStop);

python/moose/chemUtil/add_Delete_ChemicalSolver.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,7 @@ def mooseAddChemSolver(modelRoot, solver):
6161
Add the solvers only if all are Chemical compartment
6262
"""
6363
compts = moose.wildcardFind(modelRoot + '/##[ISA=ChemCompt]')
64-
print([(x.__metaclass__, x.className) for x in compts] )
65-
print(compts, solver, '1111')
66-
print([isinstance(x, (moose.CubeMesh, moose.CylMesh)) for x in compts])
67-
6864
if all(isinstance(x, (moose.CubeMesh,moose.CylMesh)) for x in compts):
69-
print('111')
7065
if not compts:
7166
return ("Atleast one compartment is required ")
7267
elif ( len(compts) > 3 ):

python/moose/chemUtil/chemConnectUtil.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ def validColorcheck(color):
112112
def xyPosition(objInfo,xory):
113113
try:
114114
return float(moose.element(objInfo).getField(xory))
115-
except ValueError as e:
116-
return float(0)
115+
except ValueError:
116+
return 0.0
117117

118118
def setupMeshObj(modelRoot):
119119
''' Setup compartment and its members pool,reaction,enz cplx under self.meshEntry dictionaries \
@@ -152,10 +152,10 @@ def setupMeshObj(modelRoot):
152152
tablist = moose.wildcardFind(meshEnt.path+'/##[ISA=StimulusTable]')
153153
if mol_cpl or funclist or enzlist or realist or tablist:
154154
for m in mol_cpl:
155-
if isinstance(moose.element(m.parent),moose.CplxEnzBase):
155+
if isinstance(moose.element(m.parent), moose.CplxEnzBase):
156156
cplxlist.append(m)
157157
objInfo = m.parent.path+'/info'
158-
elif isinstance(moose.element(m),moose.PoolBase):
158+
elif isinstance(moose.element(m), moose.PoolBase):
159159
mollist.append(m)
160160
objInfo =m.path+'/info'
161161
if moose.exists(objInfo):
@@ -277,11 +277,10 @@ def setupItem(modelPath,cntDict):
277277
tablist.append((moose.element(tabconnect),'tab',countuniqItem[tabconnect]))
278278
cntDict[tab] = tablist
279279

280-
def countitems(mitems,objtype):
280+
def countitems(mitems, objtype):
281281
items = []
282-
items = moose.element(mitems).neighbors[objtype]
282+
items = mitems.neighbors[objtype]
283283
uniqItems = set(items)
284-
#countuniqItems = Counter(items)
285284
countuniqItems = dict((i, items.count(i)) for i in items)
286285
return(uniqItems,countuniqItems)
287286

python/moose/genesis/writeKkit.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
# --StimulusTable
6161

6262
def mooseWriteKkit( modelpath, filename, sceneitems={}):
63+
print('111')
6364
global foundmatplotlib_
6465
if not foundmatplotlib_:
6566
print('No maplotlib found.'
@@ -154,7 +155,7 @@ def mooseWriteKkit( modelpath, filename, sceneitems={}):
154155
writeFooter1(f)
155156
writeNotes(modelpath,f)
156157
writeFooter2(f)
157-
print('Written to file '+filename)
158+
print('kkit model is written to file '+filename)
158159
return errors, True
159160
else:
160161
print("Warning: writeKkit:: No model found on " , modelpath)

0 commit comments

Comments
 (0)