Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swc issues and moogList #416

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' into master
Dilawar Singh authored Sep 7, 2020
commit 8a687e4934be4e7ec2a16323c9aa554ac2f8e30c
21 changes: 21 additions & 0 deletions pybind11/Finfo.cpp
Original file line number Diff line number Diff line change
@@ -182,6 +182,27 @@ py::cpp_function __Finfo__::getDestFinfoSetterFunc2(const ObjId& oid,
return func;
}
}


if(ftype1 == "Id") {
if(ftype2 == "Id") {
std::function<bool(Id, Id)> func = [oid, fname](Id a, Id b) {
return SetGet2<Id, Id>::set(oid, fname, a, b);
};
return func;
}
}

if(ftype1 == "ObjId") {
if(ftype2 == "ObjId") {
std::function<bool(ObjId, ObjId)> func = [oid, fname](ObjId a,
ObjId b) {
return SetGet2<ObjId, ObjId>::set(oid, fname, a, b);
};
return func;
}
}

throw runtime_error("getFieldPropertyDestFinfo2::NotImplemented " + fname +
" for rttType " + finfo->rttiType() + " for oid " +
oid.path());
1 change: 0 additions & 1 deletion pybind11/PyRun.cpp
Original file line number Diff line number Diff line change
@@ -143,7 +143,6 @@ PyRun::PyRun()
PyRun::~PyRun()
{
Py_XDECREF(globals_);
Py_XDECREF(locals_);
}

void PyRun::setRunString(string statement)
35 changes: 23 additions & 12 deletions pybind11/pymoose.cpp
Original file line number Diff line number Diff line change
@@ -281,11 +281,19 @@ PYBIND11_MODULE(_moose, m)
.def_property_readonly("id", [](ObjId &oid) -> Id { return oid.id; })
.def_property_readonly("dataIndex",
[](ObjId &oid) { return oid.dataIndex; })
.def("getDataIndex", [](const ObjId &oid) { return oid.dataIndex; })

.def_property_readonly("fieldIndex",
[](ObjId &oid) { return oid.fieldIndex; })

.def("getFieldIndex", [](const ObjId &oid) { return oid.fieldIndex; })

.def_property_readonly(
"type", [](ObjId &oid) { return oid.element()->cinfo()->name(); })

.def("getType",
[](ObjId &oid) { return oid.element()->cinfo()->name(); })

.def_property_readonly("path",
[](const ObjId &oid) { return oid.id.path(); })

@@ -335,14 +343,15 @@ PYBIND11_MODULE(_moose, m)
.def("__ne__", [](const MooseVec &a,
const MooseVec &b) { return a.obj() != b.obj(); })
.def("__len__", &MooseVec::len)
.def("__iter__",
[](MooseVec &v) {
// Generate an iterator which is a vector<ObjId>. And then
// pass the reference to the objects.
v.generateIterator();
return py::make_iterator(v.objref().begin(), v.objref().end());
},
py::keep_alive<0, 1>())
.def(
"__iter__",
[](MooseVec &v) {
// Generate an iterator which is a vector<ObjId>. And then
// pass the reference to the objects.
v.generateIterator();
return py::make_iterator(v.objref().begin(), v.objref().end());
},
py::keep_alive<0, 1>())
.def("__getitem__", &MooseVec::getItem)
.def("__getitem__", &MooseVec::getItemRange)

@@ -357,8 +366,9 @@ PYBIND11_MODULE(_moose, m)
})
// This is to provide old API support. Some scripts use .vec even on a
// vec to get a vec. So silly or so Zen?!
.def_property_readonly("vec", [](const MooseVec &vec) { return &vec; },
py::return_value_policy::reference_internal)
.def_property_readonly(
"vec", [](const MooseVec &vec) { return &vec; },
py::return_value_policy::reference_internal)
.def_property_readonly("type",
[](const MooseVec &v) { return "moose.vec"; })
.def("connect", &MooseVec::connectToSingle)
@@ -377,8 +387,9 @@ PYBIND11_MODULE(_moose, m)
*/

m.def("seed", [](py::object &a) { moose::mtseed(a.cast<int>()); });
m.def("rand", [](double a, double b) { return moose::mtrand(a, b); },
"a"_a = 0, "b"_a = 1);
m.def(
"rand", [](double a, double b) { return moose::mtrand(a, b); },
"a"_a = 0, "b"_a = 1);
// This is a wrapper to Shell::wildcardFind. The python interface must
// override it.
m.def("wildcardFind", &wildcardFind2);
1 change: 1 addition & 0 deletions python/moose/__init__.py
Original file line number Diff line number Diff line change
@@ -78,6 +78,7 @@ def version():
"""Reutrns moose version string."""
return _moose.__version__

__version__ = lambda: version()

def version_info():
"""Return detailed version information.
50 changes: 0 additions & 50 deletions python/rdesigneur/rdesigneur.py
Original file line number Diff line number Diff line change
@@ -687,56 +687,6 @@ def _parseComptField( self, comptList, plotSpec, knownFields ):
else:
return comptList, kf[1]

# Returns vector of source objects, and the field to use.
# Specifically for _buildMoogli() as there the coordinates of the compartments are needed.
# plotSpec is of the form
# [ region_wildcard, region_expr, path, field, title]
def _MoogparseComptField( self, comptList, plotSpec, knownFields ):
# Put in stuff to go through fields if the target is a chem object
field = plotSpec.field
if not field in knownFields:
print("Warning: Rdesigneur::_parseComptField: Unknown field '{}'".format( field ) )
return (), ""

kf = knownFields[field] # Find the field to decide type.
# if kf[0] in ['CaConcBase', 'ChanBase', 'NMDAChan', 'VClamp']:
# objList = self._collapseElistToPathAndClass( comptList, plotSpec.relpath, kf[0] )
# return objList, kf[1]
if field in [ 'n', 'conc', 'volume']:
path = plotSpec.relpath
pos = path.find( '/' )
if pos == -1: # Assume it is in the dend compartment.
path = 'dend/' + path
pos = path.find( '/' )
chemCompt = path[:pos]
if chemCompt[-5:] == "_endo":
chemCompt = chemCompt[0:-5]
cc = moose.element( self.modelPath + '/chem/' + chemCompt)
voxelVec = []
temp = [ self._makeUniqueNameStr( i ) for i in comptList ]
#print( temp )
#print( "#####################" )
comptSet = set( temp )
#em = [ moose.element(i) for i in cc.elecComptMap ]
em = sorted( [ self._makeUniqueNameStr(i[0]) for i in cc.elecComptMap ] )
#print( em )
#print( "=================================================" )

voxelVec = [i for i in range(len( em ) ) if em[i] in comptSet ]
# Here we collapse the voxelVec into objects to plot.
allObj = moose.vec( self.modelPath + '/chem/' + plotSpec.relpath )
#print "####### allObj=", self.modelPath + '/chem/' + plotSpec[2]
if len( allObj ) >= len( voxelVec ):
objList = [ allObj[int(j)] for j in voxelVec]
else:
objList = []
print( "Warning: Rdesigneur::_parseComptField: unknown Object: '", plotSpec.relpath, "'" )
#print "############", chemCompt, len(objList), kf[1]
return objList, kf[1]

else:
return comptList, kf[1]


def _buildPlots( self ):
knownFields = {
You are viewing a condensed version of this merge commit. You can view the full changes here.