Skip to content

Commit 8a687e4

Browse files
authored
Merge branch 'master' into master
2 parents 616fb3f + eafa8b2 commit 8a687e4

File tree

9 files changed

+55
-73
lines changed

9 files changed

+55
-73
lines changed

biophysics/Neuron.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,14 +458,14 @@ const Cinfo* Neuron::initCinfo()
458458
"to build up a mapping from Spine entries on the Neuron to "
459459
"chem spines and PSDs, so that volume change operations from "
460460
"the Spine can propagate to the chem systems.",
461-
new OpFunc2< Neuron, Id, Id >( &Neuron::setSpineAndPsdMesh )
461+
new OpFunc2< Neuron, ObjId, ObjId >( &Neuron::setSpineAndPsdMesh )
462462
);
463463
static DestFinfo setSpineAndPsdDsolve( "setSpineAndPsdDsolve",
464464
"Assigns the Dsolves used by spine and PSD to the Neuron. "
465465
"This is used "
466466
"to handle the rescaling of diffusion rates when spines are "
467467
"resized. ",
468-
new OpFunc2< Neuron, Id, Id >( &Neuron::setSpineAndPsdDsolve )
468+
new OpFunc2< Neuron, ObjId, ObjId >( &Neuron::setSpineAndPsdDsolve )
469469
);
470470

471471
/*
@@ -1437,7 +1437,7 @@ void Neuron::buildSegmentTree( const Eref& e )
14371437

14381438

14391439
/// Fills up vector of segments. First entry is soma.
1440-
void Neuron::setSpineAndPsdMesh( Id spineMesh, Id psdMesh )
1440+
void Neuron::setSpineAndPsdMesh( ObjId spineMesh, ObjId psdMesh )
14411441
{
14421442
if ( !spineMesh.element()->cinfo()->isA( "SpineMesh" ) )
14431443
{
@@ -1489,7 +1489,7 @@ void Neuron::setSpineAndPsdMesh( Id spineMesh, Id psdMesh )
14891489
}
14901490
}
14911491

1492-
void Neuron::setSpineAndPsdDsolve( Id spineDsolve, Id psdDsolve )
1492+
void Neuron::setSpineAndPsdDsolve( ObjId spineDsolve, ObjId psdDsolve )
14931493
{
14941494
headDsolve_ = spineDsolve;
14951495
psdDsolve_ = psdDsolve;

biophysics/Neuron.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ class Neuron
6060
vector< string > getSpineDistribution( const Eref& e ) const;
6161

6262
void buildSegmentTree( const Eref& e );
63-
void setSpineAndPsdMesh( Id spineMesh, Id psdMesh );
64-
void setSpineAndPsdDsolve( Id spineDsolve, Id psdDsolve );
63+
void setSpineAndPsdMesh( ObjId spineMesh, ObjId psdMesh );
64+
void setSpineAndPsdDsolve( ObjId spineDsolve, ObjId psdDsolve );
6565

6666
///////////////////////////////////////////////////////////////////
6767
// MechSpec set

diffusion/Dsolve.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ const Cinfo* Dsolve::initCinfo()
138138

139139
static DestFinfo buildNeuroMeshJunctions( "buildNeuroMeshJunctions",
140140
"Builds junctions between NeuroMesh, SpineMesh and PsdMesh",
141-
new EpFunc2< Dsolve, Id, Id >(&Dsolve::buildNeuroMeshJunctions )
142-
);
141+
new EpFunc2< Dsolve, ObjId, ObjId >(&Dsolve::buildNeuroMeshJunctions )
142+
);
143143

144144
///////////////////////////////////////////////////////
145145
// Shared definitions
@@ -880,7 +880,7 @@ void Dsolve::build( double dt )
880880
* Should be called only from the Dsolve handling the NeuroMesh.
881881
*/
882882
// Would like to permit vectors of spines and psd compartments.
883-
void Dsolve::buildNeuroMeshJunctions( const Eref& e, Id spineD, Id psdD )
883+
void Dsolve::buildNeuroMeshJunctions( const Eref& e, ObjId spineD, ObjId psdD )
884884
{
885885
if ( !compartment_.element()->cinfo()->isA( "NeuroMesh" ) )
886886
{

diffusion/Dsolve.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class Dsolve: public ZombiePoolInterface
8282
* there may be many molecules which diffuse across each diffusion
8383
* junction.
8484
*/
85-
void buildNeuroMeshJunctions( const Eref& e, Id spineD, Id psdD );
85+
void buildNeuroMeshJunctions( const Eref& e, ObjId spineD, ObjId psdD );
8686

8787
/**
8888
* Builds junctions between current Dsolve and another. For this

pybind11/Finfo.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,27 @@ py::cpp_function __Finfo__::getDestFinfoSetterFunc2(const ObjId& oid,
182182
return func;
183183
}
184184
}
185+
186+
187+
if(ftype1 == "Id") {
188+
if(ftype2 == "Id") {
189+
std::function<bool(Id, Id)> func = [oid, fname](Id a, Id b) {
190+
return SetGet2<Id, Id>::set(oid, fname, a, b);
191+
};
192+
return func;
193+
}
194+
}
195+
196+
if(ftype1 == "ObjId") {
197+
if(ftype2 == "ObjId") {
198+
std::function<bool(ObjId, ObjId)> func = [oid, fname](ObjId a,
199+
ObjId b) {
200+
return SetGet2<ObjId, ObjId>::set(oid, fname, a, b);
201+
};
202+
return func;
203+
}
204+
}
205+
185206
throw runtime_error("getFieldPropertyDestFinfo2::NotImplemented " + fname +
186207
" for rttType " + finfo->rttiType() + " for oid " +
187208
oid.path());

pybind11/PyRun.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ PyRun::PyRun()
143143
PyRun::~PyRun()
144144
{
145145
Py_XDECREF(globals_);
146-
Py_XDECREF(locals_);
147146
}
148147

149148
void PyRun::setRunString(string statement)

pybind11/pymoose.cpp

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,19 @@ PYBIND11_MODULE(_moose, m)
281281
.def_property_readonly("id", [](ObjId &oid) -> Id { return oid.id; })
282282
.def_property_readonly("dataIndex",
283283
[](ObjId &oid) { return oid.dataIndex; })
284+
.def("getDataIndex", [](const ObjId &oid) { return oid.dataIndex; })
285+
284286
.def_property_readonly("fieldIndex",
285287
[](ObjId &oid) { return oid.fieldIndex; })
288+
289+
.def("getFieldIndex", [](const ObjId &oid) { return oid.fieldIndex; })
290+
286291
.def_property_readonly(
287292
"type", [](ObjId &oid) { return oid.element()->cinfo()->name(); })
288293

294+
.def("getType",
295+
[](ObjId &oid) { return oid.element()->cinfo()->name(); })
296+
289297
.def_property_readonly("path",
290298
[](const ObjId &oid) { return oid.id.path(); })
291299

@@ -335,14 +343,15 @@ PYBIND11_MODULE(_moose, m)
335343
.def("__ne__", [](const MooseVec &a,
336344
const MooseVec &b) { return a.obj() != b.obj(); })
337345
.def("__len__", &MooseVec::len)
338-
.def("__iter__",
339-
[](MooseVec &v) {
340-
// Generate an iterator which is a vector<ObjId>. And then
341-
// pass the reference to the objects.
342-
v.generateIterator();
343-
return py::make_iterator(v.objref().begin(), v.objref().end());
344-
},
345-
py::keep_alive<0, 1>())
346+
.def(
347+
"__iter__",
348+
[](MooseVec &v) {
349+
// Generate an iterator which is a vector<ObjId>. And then
350+
// pass the reference to the objects.
351+
v.generateIterator();
352+
return py::make_iterator(v.objref().begin(), v.objref().end());
353+
},
354+
py::keep_alive<0, 1>())
346355
.def("__getitem__", &MooseVec::getItem)
347356
.def("__getitem__", &MooseVec::getItemRange)
348357

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

379389
m.def("seed", [](py::object &a) { moose::mtseed(a.cast<int>()); });
380-
m.def("rand", [](double a, double b) { return moose::mtrand(a, b); },
381-
"a"_a = 0, "b"_a = 1);
390+
m.def(
391+
"rand", [](double a, double b) { return moose::mtrand(a, b); },
392+
"a"_a = 0, "b"_a = 1);
382393
// This is a wrapper to Shell::wildcardFind. The python interface must
383394
// override it.
384395
m.def("wildcardFind", &wildcardFind2);

python/moose/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def version():
7878
"""Reutrns moose version string."""
7979
return _moose.__version__
8080

81+
__version__ = lambda: version()
8182

8283
def version_info():
8384
"""Return detailed version information.

python/rdesigneur/rdesigneur.py

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -687,56 +687,6 @@ def _parseComptField( self, comptList, plotSpec, knownFields ):
687687
else:
688688
return comptList, kf[1]
689689

690-
# Returns vector of source objects, and the field to use.
691-
# Specifically for _buildMoogli() as there the coordinates of the compartments are needed.
692-
# plotSpec is of the form
693-
# [ region_wildcard, region_expr, path, field, title]
694-
def _MoogparseComptField( self, comptList, plotSpec, knownFields ):
695-
# Put in stuff to go through fields if the target is a chem object
696-
field = plotSpec.field
697-
if not field in knownFields:
698-
print("Warning: Rdesigneur::_parseComptField: Unknown field '{}'".format( field ) )
699-
return (), ""
700-
701-
kf = knownFields[field] # Find the field to decide type.
702-
# if kf[0] in ['CaConcBase', 'ChanBase', 'NMDAChan', 'VClamp']:
703-
# objList = self._collapseElistToPathAndClass( comptList, plotSpec.relpath, kf[0] )
704-
# return objList, kf[1]
705-
if field in [ 'n', 'conc', 'volume']:
706-
path = plotSpec.relpath
707-
pos = path.find( '/' )
708-
if pos == -1: # Assume it is in the dend compartment.
709-
path = 'dend/' + path
710-
pos = path.find( '/' )
711-
chemCompt = path[:pos]
712-
if chemCompt[-5:] == "_endo":
713-
chemCompt = chemCompt[0:-5]
714-
cc = moose.element( self.modelPath + '/chem/' + chemCompt)
715-
voxelVec = []
716-
temp = [ self._makeUniqueNameStr( i ) for i in comptList ]
717-
#print( temp )
718-
#print( "#####################" )
719-
comptSet = set( temp )
720-
#em = [ moose.element(i) for i in cc.elecComptMap ]
721-
em = sorted( [ self._makeUniqueNameStr(i[0]) for i in cc.elecComptMap ] )
722-
#print( em )
723-
#print( "=================================================" )
724-
725-
voxelVec = [i for i in range(len( em ) ) if em[i] in comptSet ]
726-
# Here we collapse the voxelVec into objects to plot.
727-
allObj = moose.vec( self.modelPath + '/chem/' + plotSpec.relpath )
728-
#print "####### allObj=", self.modelPath + '/chem/' + plotSpec[2]
729-
if len( allObj ) >= len( voxelVec ):
730-
objList = [ allObj[int(j)] for j in voxelVec]
731-
else:
732-
objList = []
733-
print( "Warning: Rdesigneur::_parseComptField: unknown Object: '", plotSpec.relpath, "'" )
734-
#print "############", chemCompt, len(objList), kf[1]
735-
return objList, kf[1]
736-
737-
else:
738-
return comptList, kf[1]
739-
740690

741691
def _buildPlots( self ):
742692
knownFields = {

0 commit comments

Comments
 (0)