Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions biophysics/Neuron.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,14 +458,14 @@ const Cinfo* Neuron::initCinfo()
"to build up a mapping from Spine entries on the Neuron to "
"chem spines and PSDs, so that volume change operations from "
"the Spine can propagate to the chem systems.",
new OpFunc2< Neuron, Id, Id >( &Neuron::setSpineAndPsdMesh )
new OpFunc2< Neuron, ObjId, ObjId >( &Neuron::setSpineAndPsdMesh )
);
static DestFinfo setSpineAndPsdDsolve( "setSpineAndPsdDsolve",
"Assigns the Dsolves used by spine and PSD to the Neuron. "
"This is used "
"to handle the rescaling of diffusion rates when spines are "
"resized. ",
new OpFunc2< Neuron, Id, Id >( &Neuron::setSpineAndPsdDsolve )
new OpFunc2< Neuron, ObjId, ObjId >( &Neuron::setSpineAndPsdDsolve )
);

/*
Expand Down Expand Up @@ -1437,7 +1437,7 @@ void Neuron::buildSegmentTree( const Eref& e )


/// Fills up vector of segments. First entry is soma.
void Neuron::setSpineAndPsdMesh( Id spineMesh, Id psdMesh )
void Neuron::setSpineAndPsdMesh( ObjId spineMesh, ObjId psdMesh )
{
if ( !spineMesh.element()->cinfo()->isA( "SpineMesh" ) )
{
Expand Down Expand Up @@ -1489,7 +1489,7 @@ void Neuron::setSpineAndPsdMesh( Id spineMesh, Id psdMesh )
}
}

void Neuron::setSpineAndPsdDsolve( Id spineDsolve, Id psdDsolve )
void Neuron::setSpineAndPsdDsolve( ObjId spineDsolve, ObjId psdDsolve )
{
headDsolve_ = spineDsolve;
psdDsolve_ = psdDsolve;
Expand Down
4 changes: 2 additions & 2 deletions biophysics/Neuron.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class Neuron
vector< string > getSpineDistribution( const Eref& e ) const;

void buildSegmentTree( const Eref& e );
void setSpineAndPsdMesh( Id spineMesh, Id psdMesh );
void setSpineAndPsdDsolve( Id spineDsolve, Id psdDsolve );
void setSpineAndPsdMesh( ObjId spineMesh, ObjId psdMesh );
void setSpineAndPsdDsolve( ObjId spineDsolve, ObjId psdDsolve );

///////////////////////////////////////////////////////////////////
// MechSpec set
Expand Down
6 changes: 3 additions & 3 deletions diffusion/Dsolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ const Cinfo* Dsolve::initCinfo()

static DestFinfo buildNeuroMeshJunctions( "buildNeuroMeshJunctions",
"Builds junctions between NeuroMesh, SpineMesh and PsdMesh",
new EpFunc2< Dsolve, Id, Id >(&Dsolve::buildNeuroMeshJunctions )
);
new EpFunc2< Dsolve, ObjId, ObjId >(&Dsolve::buildNeuroMeshJunctions )
);

///////////////////////////////////////////////////////
// Shared definitions
Expand Down Expand Up @@ -880,7 +880,7 @@ void Dsolve::build( double dt )
* Should be called only from the Dsolve handling the NeuroMesh.
*/
// Would like to permit vectors of spines and psd compartments.
void Dsolve::buildNeuroMeshJunctions( const Eref& e, Id spineD, Id psdD )
void Dsolve::buildNeuroMeshJunctions( const Eref& e, ObjId spineD, ObjId psdD )
{
if ( !compartment_.element()->cinfo()->isA( "NeuroMesh" ) )
{
Expand Down
2 changes: 1 addition & 1 deletion diffusion/Dsolve.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Dsolve: public ZombiePoolInterface
* there may be many molecules which diffuse across each diffusion
* junction.
*/
void buildNeuroMeshJunctions( const Eref& e, Id spineD, Id psdD );
void buildNeuroMeshJunctions( const Eref& e, ObjId spineD, ObjId psdD );

/**
* Builds junctions between current Dsolve and another. For this
Expand Down
20 changes: 20 additions & 0 deletions pybind11/Finfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,26 @@ 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());
Expand Down
1 change: 0 additions & 1 deletion pybind11/PyRun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ PyRun::PyRun()
PyRun::~PyRun()
{
Py_XDECREF(globals_);
Py_XDECREF(locals_);
}

void PyRun::setRunString(string statement)
Expand Down
35 changes: 23 additions & 12 deletions pybind11/pymoose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(); })

Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions python/moose/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def version():
"""Reutrns moose version string."""
return _moose.__version__

__version__ = lambda: version()

def version_info():
"""Return detailed version information.
Expand Down
4 changes: 2 additions & 2 deletions python/rdesigneur/rdesigneur.py
Original file line number Diff line number Diff line change
Expand Up @@ -1179,10 +1179,10 @@ def _decorateWithSpines( self ):

def _loadElec( self, efile, elecname ):
if ( efile[ len( efile ) - 2:] == ".p" ):
self.elecid = moose.loadModel( efile, '/library/' + elecname)[0]
self.elecid = moose.loadModel( efile, '/library/' + elecname)
print(self.elecid)
elif ( efile[ len( efile ) - 4:] == ".swc" ):
self.elecid = moose.loadModel( efile, '/library/' + elecname)[0]
self.elecid = moose.loadModel( efile, '/library/' + elecname)
else:
nm = NeuroML()
print("in _loadElec, combineSegments = ", self.combineSegments)
Expand Down