For the purposes of my simulation, I worked around this by adding some code in mech_getattro which checks to see if the current mechanism is extracellular, and if so to ignore the naming convention. This seems like a suboptimal way of dealing with this problem, though (also, it is still not possible to subscript vext to find the value of, say, vext[1], etc).
Code: Select all
static PyObject* mech_getattro(NPyMechObj* self, PyObject* name) {
Py_INCREF(name);
char* n = PyString_AsString(name);
printf("mech_getattro %s\n", n);
PyObject* result = 0;
NrnProperty np(self->prop_);
char buf[200];
int isptr = (strncmp(n, "_ref_", 5) == 0);
if (strcmp(memb_func[self->prop_->type].sym->name, "extracellular") == 0) {
sprintf(buf, "%s", isptr?n+5:n);
}
else {
sprintf(buf, "%s_%s", isptr?n+5:n, memb_func[self->prop_->type].sym->name);
}
Symbol* sym = np.find(buf);
if (sym) {
printf("mech_getattro sym %s\n", sym->name);
double* px = np.prop_pval(sym, 0);
if (isptr) {
result = nrn_hocobj_ptr(px);
}else{
result = Py_BuildValue("d", *px);
}
}else{
result = PyObject_GenericGetAttr((PyObject*)self, name);
}
Py_DECREF(name);
return result;
}