7 #include <structmember.h>
17 #define M_PI (3.14159265358979323846)
31 #include <nanobind/nanobind.h>
33 namespace nb = nanobind;
141 extern char* (*nrnpy_pysec_name_p_)(
Section*);
151 PyErr_SetString(PyExc_ReferenceError,
"can't access a deleted section");
155 PyErr_SetString(PyExc_ReferenceError,
"mechanism instance is invalid");
159 static char buf[512];
180 #if PY_VERSION_HEX >= 0x030D0000
182 int err = PyWeakref_GetRef(cell_weakref, &
cell);
186 }
else if (err == 0) {
197 }
else if (
cell != Py_None) {
208 auto pyobj = nb::borrow(obj);
209 if (!nb::hasattr(pyobj,
string)) {
212 auto obj_seg = pyobj.attr(
string);
232 #if PY_VERSION_HEX >= 0x030D0000
234 int err = PyWeakref_GetRef(cell_weakref, &
cell);
261 delete[]
self->name_;
263 Py_XDECREF(self->cell_weakref_);
264 if (self->sec_->prop) {
267 if (self->sec_->prop && !self->sec_->prop->dparam[0].get<
Symbol*>()) {
284 Py_XDECREF(self->pysec_);
295 Py_XDECREF(self->pysec_);
306 Py_XDECREF(self->pysec_);
317 Py_XDECREF(self->pymech_);
327 Py_XDECREF(self->pyseg_);
329 self->prop_id_.~non_owning_identifier_without_container();
367 Py_XDECREF(self->pymech_);
377 Py_XDECREF(self->pymech_);
387 Py_XDECREF(self->pymech_);
407 static const char* kwlist[] = {
"name",
"cell",
NULL};
408 if (
self !=
NULL && !self->sec_) {
409 delete[]
self->name_;
411 self->cell_weakref_ = 0;
416 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"|sO", (
char**) kwlist, &
name, &
cell)) {
420 self->cell_weakref_ = PyWeakref_NewRef(
cell,
NULL);
421 if (!self->cell_weakref_) {
428 size_t n = strlen(
name) + 1;
433 auto cell_str = nb::steal(PyObject_Str(
cell));
435 Py_XDECREF(self->cell_weakref_);
439 if (!str.is_valid()) {
441 "cell name contains non ascii character");
442 Py_XDECREF(self->cell_weakref_);
445 char* cp = str.c_str();
447 self->name_ =
new char[
n];
448 std::snprintf(self->name_,
n,
"%s.%s", cp,
name);
450 self->name_ =
new char[
n];
451 std::strncpy(self->name_,
name,
n);
454 self->sec_ = nrnpy_newsection(
self);
467 if (
self !=
NULL && !self->pysec_) {
471 self->allseg_iter_ = 0;
473 self->pysec_ = pysec;
483 auto self = nb::steal(
type->tp_alloc(
type, 0));
490 return self.release().ptr();
498 auto self = nb::steal(
type->tp_alloc(
type, 0));
505 return self.release().ptr();
523 if (!PyArg_ParseTuple(args,
"O!d",
psection_type, &pysec, &x)) {
526 if (x > 1.0 && x < 1.0001) {
529 if (x < 0. || x > 1.0) {
530 PyErr_SetString(PyExc_ValueError,
"segment position range is 0 <= x <= 1");
538 self->pysec_ = pysec;
560 self->pyseg_ = pyseg;
582 self->pymech_ =
NULL;
585 self->attr_from_sec_ = 0;
633 *psec = pyseg->pysec_->sec_;
634 if (!(*psec)->prop) {
635 hoc_execerr_ext(
"nrn.Segment associated with deleted internal Section");
642 if (PyList_Check(py_obj.ptr())) {
644 if (obj_list.size() != 1) {
645 hoc_execerror(
"If a list is supplied, it must be of length 1", 0);
647 py_obj = obj_list[0];
650 auto seg_obj = py_obj.attr(
"segment");
651 if (!seg_obj.is_valid()) {
652 hoc_execerror(
"not a Python nrn.Segment, rxd.node, or other with a segment property",
660 hoc_execerror(
"not a Python nrn.Segment, rxd.node, or other with a segment property",
671 auto* pyseg = (
NPySegObj*) py_obj_seg.ptr();
672 *psec = pyseg->pysec_->sec_;
674 if (!(*psec)->prop) {
675 hoc_execerr_ext(
"nrn.Segment associated with deleted internal Section");
687 Py_XDECREF(self->pyseg_);
688 self->pyseg_ = pyseg;
726 if (!PyArg_ParseTuple(args,
"i", &i0)) {
729 if (i0 < 0 || i0 >=
sec->npt3d) {
730 PyErr_SetString(PyExc_Exception,
"Arg out of range\n");
742 Py_ssize_t
narg = PyTuple_GET_SIZE(args);
744 if (!PyArg_ParseTuple(args,
"i", &req)) {
749 PyErr_SetString(PyExc_Exception,
"Arg out of range\n");
764 double x, y, z, diam;
765 Py_ssize_t
narg = PyTuple_GET_SIZE(args);
767 if (!PyArg_ParseTuple(args,
"id", &
i, &diam)) {
770 if (i < 0 || i >=
sec->npt3d) {
771 PyErr_SetString(PyExc_Exception,
"Arg out of range\n");
775 }
else if (
narg == 5) {
776 if (!PyArg_ParseTuple(args,
"idddd", &
i, &x, &y, &z, &diam)) {
779 if (i < 0 || i >=
sec->npt3d) {
780 PyErr_SetString(PyExc_Exception,
"Arg out of range\n");
785 PyErr_SetString(PyExc_Exception,
"Wrong number of arguments\n");
800 if (!PyArg_ParseTuple(args,
"idddd", &
i, &x, &y, &z, &d)) {
803 if (i < 0 || i >
sec->npt3d) {
804 PyErr_SetString(PyExc_Exception,
"Arg out of range\n");
820 if (!PyArg_ParseTuple(args,
"dddd", &x, &y, &z, &d)) {
836 Py_ssize_t
narg = PyTuple_GET_SIZE(args);
840 if (!PyArg_ParseTuple(args,
"i", &style)) {
844 PyErr_SetString(PyExc_AttributeError,
"If exactly one argument, it must be 0.");
848 }
else if (
narg == 4) {
851 if (!PyArg_ParseTuple(args,
"iddd", &style, &x, &y, &z)) {
857 PyErr_SetString(PyExc_Exception,
"Wrong number of arguments.");
861 return PyBool_FromLong(
sec->logical_connection !=
nullptr);
872 if (!PyArg_ParseTuple(args,
"i", &
i)) {
876 if (i < 0 || i >
n) {
877 PyErr_SetString(PyExc_Exception,
"Arg out of range\n");
880 return &
sec->pt3d[
i];
889 return PyFloat_FromDouble((
double) pt3d->
x);
902 return PyFloat_FromDouble((
double) pt3d->
y);
915 return PyFloat_FromDouble((
double) pt3d->
z);
928 return PyFloat_FromDouble((
double) pt3d->
arc);
941 return PyFloat_FromDouble((
double)
fabs(pt3d->
d));
951 if (pt3d ==
nullptr) {
954 return PyBool_FromLong(pt3d->
d < 0);
978 std::string
name = fmt::format(
"{}({:g})", sname, pyseg->
x_);
990 auto buf = fmt::format(
"__nrnsec_{:p}", (
void*) self->sec_);
1001 if (!PyArg_ParseTuple(args,
"O", &po)) {
1004 if (PyCallable_Check(po) == 0) {
1005 PyErr_SetString(PyExc_TypeError,
"argument must be a callable");
1022 auto arglist = nb::steal(Py_BuildValue(
"(O)",
self));
1034 return PyBool_FromLong(self->sec_->prop &&
1044 if (!
sec || !
sec->prop) {
1100 for (psec =
sec->parentsec; psec; psec = psec->
parentsec) {
1125 return Py_BuildValue(
"d", x);
1133 if (!item.is_valid()) {
1136 if (PyList_Append(sl, item.ptr()) != 0) {
1148 nb::object
result = nb::steal(PyList_New(0));
1158 return result.release().ptr();
1180 auto result = nb::steal(PyList_New(0));
1189 return result.release().ptr();
1205 for (;
sec->parentsec;
sec =
sec->parentsec) {
1225 if (self->cell_weakref_) {
1226 #if PY_VERSION_HEX >= 0x030D0000
1228 int ret = PyWeakref_GetRef(self->cell_weakref_, &
cell);
1235 result = nb::borrow(PyWeakref_GetObject(self->cell_weakref_));
1237 }
else if (
auto* o = self->sec_->prop->dparam[6].get<
Object*>(); self->sec_->prop && o) {
1242 return result.release().ptr();
1269 void* other_ptr = (
void*) other;
1283 void* self_ptr = (
void*) (self->sec_);
1284 void* other_ptr = (
void*) other;
1286 void* self_ptr = (
void*) (self->sec_);
1287 other_ptr = (
void*) (((
NPySecObj*) other)->sec_);
1294 Py_INCREF(Py_NotImplemented);
1295 return Py_NotImplemented;
1304 return PyBool_FromLong(PyArg_ParseTuple(args,
"O", &pysec) &&
1306 ((
NPySecObj*) pysec)->sec_ == self->sec_);
1314 std::string
s =
memb_func[
self->type_].sym->name;
1315 if (!self->prop_id_) {
1317 if (!
sec || !
sec->prop) {
1318 s =
"<mechanism of deleted section>";
1320 s =
"<segment invalid or or mechanism uninserted>";
1333 std::string
s =
memb_func[
self->pymech_->type_].sym->name;
1335 s +=
self->f_->name;
1348 auto& f =
self->f_->func;
1352 sym.
name = (
char*) self->f_->name;
1353 std::vector<neuron::unique_cstr> strings_to_free;
1357 double x = (f) (self->pymech_->prop_);
1358 result = nb::steal(Py_BuildValue(
"d", x));
1359 }
catch (std::exception
const& e) {
1360 std::ostringstream oss;
1361 oss <<
"mechanism.function call error: " << e.what();
1362 PyErr_SetString(PyExc_RuntimeError, oss.str().c_str());
1366 return result.release().ptr();
1375 return PyBool_FromLong(
nrn_is_ion(self->type_));
1384 Py_XINCREF(self->pyseg_);
1393 auto* pymech =
self->pymech_;
1435 PyErr_SetString(PyExc_ReferenceError,
"no Symbol");
1445 auto* pymech =
self->pymech_;
1461 double parentx, childend;
1464 if (!PyArg_ParseTuple(args,
"O|dd", &
p, &parentx, &childend)) {
1469 if (parentx == -1000.) {
1474 if (parentx != -1000.) {
1479 PyErr_SetString(PyExc_TypeError,
"first arg not a nrn.Section or nrn.Segment");
1485 if (parentx > 1. || parentx < 0.) {
1486 PyErr_SetString(PyExc_ValueError,
"out of range 0 <= parentx <= 1.");
1489 if (childend != 0. && childend != 1.) {
1490 PyErr_SetString(PyExc_ValueError,
"child connection end must be 0 or 1");
1509 if (!PyArg_ParseTuple(args,
"s", &tname)) {
1513 if (PyArg_ParseTuple(args,
"O", &tpyobj)) {
1514 auto _tpyobj_tracker = nb::borrow(tpyobj);
1516 auto out_o = nb::steal(PyObject_CallMethod(tpyobj,
"insert",
"O", (
PyObject*)
self));
1517 if (!out_o.is_valid()) {
1521 "insert argument must be either a string or an object with an insert method");
1528 PyErr_SetString(PyExc_TypeError,
"insert takes a single positional argument");
1538 PyErr_SetString(PyExc_ValueError,
"argument not a density mechanism name.");
1556 if (!PyArg_ParseTuple(args,
"s", &tname)) {
1566 PyErr_SetString(PyExc_ValueError,
"argument not a density mechanism name.");
1583 char* mechanism_name;
1585 if (!PyArg_ParseTuple(args,
"s", &mechanism_name)) {
1613 if (segiter ==
NULL) {
1642 self->allseg_iter_ = -1;
1654 if (self->allseg_iter_ > n1) {
1663 Py_INCREF(self->pysec_);
1664 seg->
pysec_ =
self->pysec_;
1665 if (self->allseg_iter_ == -1) {
1667 }
else if (self->allseg_iter_ == n1) {
1670 seg->
x_ = (double(self->allseg_iter_) + 0.5) / ((
double) n1);
1672 ++
self->allseg_iter_;
1683 if (self->seg_iter_ >= n1) {
1692 Py_INCREF(self->pysec_);
1693 seg->
pysec_ =
self->pysec_;
1694 seg->
x_ = (double(self->seg_iter_) + 0.5) / ((
double) n1);
1714 return result.release().ptr();
1737 if (
sec->recalc_area_) {
1740 double x =
self->x_;
1742 if (x > 0. && x < 1.) {
1746 return Py_BuildValue(
"d", a);
1755 return length * (d0 * d0 + d0 * d1 + d1 * d1);
1758 static inline double interpolate(
double x0,
double x1,
double y0,
double y1,
double xnew) {
1765 return y0 + (y1 - y0) * (xnew - x0) / (x1 - x0);
1774 while (right - left > 1) {
1775 int mid = (left + right) / 2;
1776 if (
sec->pt3d[mid].arc < x) {
1790 if (
sec->recalc_area_) {
1793 double x =
self->x_;
1796 if (x > 0. && x < 1.) {
1798 int nseg =
sec->nnode - 1;
1800 int iseg = x * nseg;
1801 double seg_left_arc = iseg * length;
1802 double seg_right_arc = (iseg + 1) * length;
1803 if (
sec->npt3d > 1) {
1805 double left_diam =
fabs(
sec->pt3d[i_left].d);
1806 double right_diam =
fabs(
sec->pt3d[i_left + 1].d);
1807 double left_arc = seg_left_arc;
1809 sec->pt3d[i_left].arc,
sec->pt3d[i_left + 1].arc, left_diam, right_diam, left_arc);
1811 for (
i = i_left + 1;
i <
sec->npt3d &&
sec->pt3d[
i].arc < seg_right_arc;
i++) {
1814 left_arc =
sec->pt3d[
i].arc;
1815 left_diam = right_diam;
1817 if (i < sec->npt3d) {
1819 left_arc,
sec->pt3d[
i].arc, left_diam,
fabs(
sec->pt3d[
i].d), seg_right_arc);
1830 double diam =
p->param(0);
1831 a =
M_PI * diam * diam / 4 * length;
1837 return Py_BuildValue(
"d", a);
1848 if (
sec->recalc_area_) {
1856 return Py_BuildValue(
"d",
ri);
1895 return mi.release().ptr();
1931 }
else if (err == 1) {
1936 PyErr_SetString(PyExc_AttributeError,
buf);
1963 if (dh.
holds<
double*>()) {
1964 return Py_BuildValue(
"d", *dh.
get<
double*>());
1972 if (dh.
holds<
double*>()) {
1983 auto _pyname_tracker = nb::borrow(pyname);
1985 char*
n =
name.c_str();
1986 if (!
name.is_valid()) {
1992 if (strcmp(
n,
"L") == 0) {
1994 }
else if (strcmp(
n,
"Ra") == 0) {
1996 }
else if (strcmp(
n,
"nseg") == 0) {
1997 result = nb::steal(Py_BuildValue(
"i",
sec->nnode - 1));
2005 if (d.is_invalid_handle()) {
2015 }
else if (strcmp(
n,
"rallbranch") == 0) {
2016 result = nb::steal(Py_BuildValue(
"d",
sec->prop->dparam[4].get<
double>()));
2017 }
else if (strcmp(
n,
"__dict__") == 0) {
2018 nb::dict out_dict{};
2019 out_dict[
"L"] = nb::none();
2020 out_dict[
"Ra"] = nb::none();
2021 out_dict[
"nseg"] = nb::none();
2022 out_dict[
"rallbranch"] = nb::none();
2025 result = nb::steal(PyObject_GenericGetAttr((
PyObject*)
self, pyname));
2027 return result.release().ptr();
2037 PyErr_SetString(PyExc_ReferenceError,
"can't access a deleted section");
2042 auto _pyname_tracker = nb::borrow(pyname);
2044 char*
n =
name.c_str();
2045 if (!
name.is_valid()) {
2050 if (strcmp(
n,
"L") == 0) {
2052 if (PyArg_Parse(
value,
"d", &x) == 1 && x > 0.) {
2054 sec->prop->dparam[2] = x;
2057 sec->recalc_area_ = 1;
2060 PyErr_SetString(PyExc_ValueError,
"L must be > 0.");
2063 }
else if (strcmp(
n,
"Ra") == 0) {
2065 if (PyArg_Parse(
value,
"d", &x) == 1 && x > 0.) {
2066 sec->prop->dparam[7] = x;
2068 sec->recalc_area_ = 1;
2070 PyErr_SetString(PyExc_ValueError,
"Ra must be > 0.");
2073 }
else if (strcmp(
n,
"nseg") == 0) {
2075 if (PyArg_Parse(
value,
"i", &nseg) == 1 && nseg > 0 && nseg <= 32767) {
2078 PyErr_SetString(PyExc_ValueError,
"nseg must be an integer in range 1 to 32767");
2086 PyErr_SetString(PyExc_IndexError,
"missing index");
2091 if (d.is_invalid_handle()) {
2094 }
else if (!d.holds<
double*>()) {
2095 PyErr_SetString(PyExc_ValueError,
"can't assign value to opaque pointer");
2097 }
else if (!PyArg_Parse(
value,
"d", d.get<
double*>())) {
2098 PyErr_SetString(PyExc_ValueError,
"bad value");
2105 }
else if (strcmp(
n,
"rallbranch") == 0) {
2107 if (PyArg_Parse(
value,
"d", &x) == 1 && x > 0.) {
2108 sec->prop->dparam[4] = x;
2110 sec->recalc_area_ = 1;
2112 PyErr_SetString(PyExc_ValueError,
"rallbranch must be > 0");
2116 err = PyObject_GenericSetAttr((
PyObject*)
self, pyname,
value);
2133 PyErr_SetString(PyExc_ReferenceError,
2134 "mechanism instance became invalid in middle of the mechanism iterator");
2142 self->pymech_ = mnext;
2171 if (self->i_ >= self->msym_->s_varn) {
2178 Py_INCREF(self->pymech_);
2196 auto _pyname_tracker = nb::borrow(pyname);
2198 char*
n =
name.c_str();
2199 if (!
name.is_valid()) {
2207 if (strcmp(
n,
"v") == 0) {
2209 result = nb::steal(Py_BuildValue(
"d",
NODEV(nd)));
2224 int mtype = sym->
u.
rng.type;
2234 r->pymech_->pyseg_ =
self;
2237 r->attr_from_sec_ = 0;
2241 if (d.is_invalid_handle()) {
2251 }
else if (strncmp(
n,
"_ref_", 5) == 0) {
2252 if (strcmp(
n + 5,
"v") == 0) {
2256 sym->
type == RANGEVAR) {
2269 if (d.is_invalid_handle()) {
2273 if (d.holds<
double*>()) {
2285 }
else if (strcmp(
n,
"__dict__") == 0) {
2287 nb::dict out_dict{};
2288 out_dict[
"v"] = nb::none();
2289 out_dict[
"diam"] = nb::none();
2290 out_dict[
"cm"] = nb::none();
2294 out_dict[pn] = nb::none();
2299 result = nb::steal(PyObject_GenericGetAttr((
PyObject*)
self, pyname));
2301 return result.release().ptr();
2319 PyErr_SetString(PyExc_ValueError,
"must be a hoc pointer");
2323 PyErr_SetString(PyExc_AttributeError,
2324 " For assignment, only POINTER var can have a _ref_ prefix");
2333 PyErr_SetString(PyExc_ReferenceError,
"nrn.Segment can't access a deleted section");
2339 auto _pyname_tracker = nb::borrow(pyname);
2341 char*
n =
name.c_str();
2342 if (!
name.is_valid()) {
2347 if (strcmp(
n,
"x") == 0) {
2349 if (PyArg_Parse(
value,
"d", &x) == 1 && x > 0. && x <= 1.) {
2352 }
else if (x > 1. - 1e-9) {
2358 PyErr_SetString(PyExc_ValueError,
"x must be in range 0. to 1.");
2364 PyErr_Format(PyExc_IndexError,
"%s needs an index for assignment", sym->
name);
2369 if (d.is_invalid_handle()) {
2373 if (d.holds<
double*>()) {
2374 if (!PyArg_Parse(
value,
"d", d.get<
double*>())) {
2375 PyErr_SetString(PyExc_ValueError,
"bad value");
2379 sec->recalc_area_ = 1;
2386 PyErr_SetString(PyExc_ValueError,
"can't assign value to opaque pointer");
2390 }
else if (strncmp(
n,
"_ref_", 5) == 0) {
2392 if (rvsym && rvsym->
type == RANGEVAR) {
2399 err = PyObject_GenericSetAttr((
PyObject*)
self, pyname,
value);
2402 err = PyObject_GenericSetAttr((
PyObject*)
self, pyname,
value);
2412 int nlen = strlen(
n);
2413 int mlen = strlen(m);
2414 int u = nlen - mlen - 1;
2415 if (u > 0 &&
n[u] ==
'_') {
2416 if (strcmp(
n + (u + 1), m) != 0) {
2419 strncpy(
buf,
n, sz);
2428 for (
int i = 0;
i <
cnt; ++
i) {
2430 if (strcmp(sym->
name, varname) == 0) {
2443 std::string
s = symvar->
name;
2453 int sym_index = symvar->
u.
rng.index;
2464 throw std::runtime_error(
"Not implemented.");
2467 int sym_index = symvar->
u.
rng.index;
2487 auto _pyname_tracker = nb::borrow(pyname);
2489 char*
n =
name.c_str();
2496 int isptr = (strncmp(
n,
"_ref_", 5) == 0);
2498 char* mname = mechsym->
name;
2499 int mnamelen = strlen(mname);
2500 int bufsz = strlen(
n) + mnamelen + 2;
2501 std::vector<char>
buf(bufsz);
2503 strcpy(
buf.data(), isptr ?
n + 5 :
n);
2505 std::snprintf(
buf.data(), bufsz,
"%s_%s", isptr ?
n + 5 :
n, mname);
2508 if (sym && sym->
type == RANGEVAR) {
2520 if (px.is_invalid_handle()) {
2532 }
else if (strcmp(
n,
"__dict__") == 0) {
2533 nb::dict out_dict{};
2535 for (
int i = 0;
i <
cnt; ++
i) {
2538 strcpy(
buf.data(),
s->name);
2540 out_dict[
buf.data()] = nb::none();
2544 out_dict[it.first.c_str()] = nb::none();
2548 bool found_func{
false};
2557 pymf->pymech_ =
self;
2562 result = nb::steal(PyObject_GenericGetAttr((
PyObject*)
self, pyname));
2565 return result.release().ptr();
2575 PyErr_SetString(PyExc_ReferenceError,
"nrn.Mechanism can't access a deleted section");
2580 auto _pyname_tracker = nb::borrow(pyname);
2582 char*
n =
name.c_str();
2583 if (!
name.is_valid()) {
2588 int isptr = (strncmp(
n,
"_ref_", 5) == 0);
2590 char* mname = mechsym->
name;
2591 int mnamelen = strlen(mname);
2592 int bufsz = strlen(
n) + mnamelen + 2;
2593 std::vector<char>
buf(bufsz);
2595 strcpy(
buf.data(), isptr ?
n + 5 :
n);
2597 std::snprintf(
buf.data(), bufsz,
"%s_%s", isptr ?
n + 5 :
n, mname);
2605 if (pd.is_invalid_handle()) {
2608 }
else if (!pd.holds<
double*>()) {
2609 PyErr_SetString(PyExc_ValueError,
"can't assign value to opaque pointer");
2611 }
else if (!PyArg_Parse(
value,
"d", pd.get<
double*>())) {
2612 PyErr_SetString(PyExc_ValueError,
"must be a double");
2617 err = PyObject_GenericSetAttr((
PyObject*)
self, pyname,
value);
2634 char*
n =
name.c_str();
2649 PyArg_ParseTuple(args,
"|d", &x);
2650 auto segargs = nb::steal(Py_BuildValue(
"(O,d)",
self, x));
2678 if (ix < 0 || ix >=
rv_len(
self)) {
2679 PyErr_SetString(PyExc_IndexError, r->
sym_->
name);
2695 if (d.is_invalid_handle()) {
2714 PyErr_SetString(PyExc_ReferenceError,
"nrn.RangeVar can't access a deleted section");
2718 if (ix < 0 || ix >=
rv_len(
self)) {
2719 PyErr_SetString(PyExc_IndexError, r->
sym_->
name);
2724 if (d.is_invalid_handle()) {
2732 if (!PyArg_Parse(
value,
"d", &x)) {
2733 PyErr_SetString(PyExc_ValueError,
"bad value");
2743 if (d.holds<
double*>()) {
2744 if (!PyArg_Parse(
value,
"d", d.get<
double*>())) {
2745 PyErr_SetString(PyExc_ValueError,
"bad value");
2749 PyErr_SetString(PyExc_ValueError,
"can't assign value to opaque pointer");
2767 "Section name (same as hoc secname())"},
2771 "Section name (same as hoc secname())"},
2775 "Returns True if the section's membrane has this density mechanism.\nThis "
2776 "is not for point processes."},
2780 "childSection.connect(parentSection, [parentX], [childEnd]) "
2781 "or\nchildSection.connect(parentSegment, [childEnd])"},
2785 "section.insert(densityMechanismName) e.g. soma.insert('hh')"},
2789 "section.uninsert(densityMechanismName) e.g. soma.insert('hh')"},
2793 "section.push() makes it the currently accessed section. Should end with "
2794 "a corresponding hoc.pop_section()"},
2798 "iterate over segments. Includes x=0 and x=1 zero-area nodes in the "
2803 "Return the object that owns the Section. Possibly None."},
2807 "sec1.same(sec2) returns True if sec1 and sec2 wrap the same NEURON "
2809 {
"hoc_internal_name",
2812 "Hoc accepts this name wherever a section is syntactically valid."},
2816 "disconnect from the parent section."},
2820 "Return the nrn.Segment specified by the connect method. Possibly None."},
2824 "Return the nrn.Segment this section connects to which is closer to the "
2825 "root. Possibly None. (same as parentseg unless parentseg.x == "
2826 "parentseg.sec.orientation()"},
2830 "Returns 0.0 or 1.0 depending on the x value closest to parent."},
2834 "Return list of child sections. Possibly an empty list"},
2838 "Return list of sections in the subtree rooted at this section (including this section)."},
2842 "Return list of all sections with a path to this section (including this section). The list "
2843 "has the important property that sections are in root to leaf order, depth-first traversal."},
2844 {
"n3d", (PyCFunction)
NPySecObj_n3d_safe, METH_NOARGS,
"Returns the number of 3D points."},
2848 "Returns the x coordinate of the ith 3D point."},
2852 "Returns the y coordinate of the ith 3D point."},
2856 "Returns the z coordinate of the ith 3D point."},
2860 "Returns the arc position of the ith 3D point."},
2864 "Returns the diam of the ith 3D point."},
2868 "Returns True or False depending on whether a spine exists at the ith 3D point."},
2873 "Clears all 3D points. Optionally takes a buffer size."},
2877 "Insert the point (so it becomes the i'th point) to section. If i is equal to sec.n3d(), the "
2878 "point is appended (equivalent to sec.pt3dadd())"},
2882 "Change the i'th 3-d point info. If only two args then the second arg is the diameter and the "
2883 "location is unchanged."},
2887 "Add the 3d location and diameter point (or points in the second form) at the end of the "
2888 "current pt3d list. Assume that successive additions increase the arc length monotonically."},
2892 "Returns True if using a logical connection point, else False. With first arg 0 sets to no "
2893 "logical connection point. With first arg 1 and x, y, z arguments, sets the logical "
2894 "connection point. Return value includes the result of any setting."},
2898 "Returns True if Section created from Python, False if created from HOC."},
2902 "Returns dict of info about Section contents."},
2909 "seg.point_processes() returns list of POINT_PROCESS instances in the "
2914 "seg.node_index() returns index of v, rhs, etc. in the _actual arrays of "
2915 "the appropriate NrnThread."},
2919 "Segment area (um2) (same as h.area(sec(x), sec=sec))"},
2923 "Segment resistance to parent segment (Megohms) (same as h.ri(sec(x), "
2925 {
"volume", (PyCFunction)
seg_volume_safe, METH_NOARGS,
"Segment volume (um3)"},
2929 {
"x", T_DOUBLE, offsetof(
NPySegObj,
x_), 0,
"location in the section (segment containing x)"},
2930 {
"sec", T_OBJECT_EX, offsetof(
NPySegObj, pysec_), 0,
"Section"},
2937 "Mechanism name (same as hoc suffix for density mechanism)"},
2941 "Returns True if an ion mechanism"},
2945 "Returns the segment of the Mechanism instance"},
2953 "Returns the Mechanism for this instance"},
2961 "Returns nrn.Mechanism of the RangeVariable instance"},
2970 PyErr_SetString(PyExc_TypeError,
"Section access unspecified");
2982 {
"cas",
nrnpy_cas_safe, METH_VARARGS,
"Return the currently accessed section."},
2983 {
"allsec",
nrnpy_forall_safe, METH_VARARGS,
"Return iterator over all sections."},
2987 "Specify the nrn.Section.psection callback."},
3009 PyObject* modules = PyImport_GetModuleDict();
3010 if ((m = nb::borrow(PyDict_GetItemString(modules,
"nrn"))) && PyModule_Check(m.ptr())) {
3059 err = PyDict_SetItemString(modules,
"_neuron_section", m.ptr());
3061 m = nb::steal(PyModule_Create(&
nrnmodule));
3102 err = PyDict_SetItemString(modules,
"nrn", m.ptr());
double nrn_section_orientation(Section *sec)
const char * secname(Section *sec)
name of section (for use in error messages)
void nrn_change_nseg(Section *sec, int n)
void mech_uninsert1(Section *sec, Symbol *s)
void nrn_pushsec(Section *sec)
double nrn_arc_position(Section *sec, Node *node)
int has_membrane(char *mechanism_name, Section *sec)
Prop * nrn_mechanism(int type, Node *nd)
double nrn_ra(Section *sec)
void nrn_rangeconst(Section *sec, Symbol *s, neuron::container::data_handle< double > pd, int op)
double section_length(Section *sec)
neuron::container::generic_data_handle nrnpy_rangepointer(Section *sec, Symbol *s, double d, int *err, int idx)
return nullptr if failure instead of hoc_execerror and return pointer to the 0 element if an array
double nrn_connection_position(Section *sec)
Section * nrn_noerr_access(void)
return 0 if no accessed section
void nrn_disconnect(Section *sec)
Node * node_exact(Section *sec, double x)
like node_index but give proper node when x is 0 or 1 as well as in between
void mech_insert1(Section *sec, int type)
int nrn_at_beginning(Section *sec)
static neuron::unique_cstr as_ascii(PyObject *python_string)
static void set_pyerr(PyObject *type, const char *message)
Symbol * hoc_table_lookup(const char *, Symlist *)
void hoc_push_frame(Symbol *sp, int narg)
void hoc_push_ndim(int d)
void hoc_execerr_ext(const char *fmt,...)
printf style specification of hoc_execerror message.
Object * nrn_nmodlrandom_wrap(Prop *prop, Symbol *sym)
Symbol * hoc_install(const char *, int, double, Symlist **)
bool is_array(const Symbol &sym)
void move(Item *q1, Item *q2, Item *q3)
void hoc_execerror(const char *s1, const char *s2)
handle_interface< non_owning_identifier< storage > > handle
Non-owning handle to a Mechanism instance.
int Sprintf(char(&buf)[N], const char *fmt, Args &&... args)
Redirect sprintf to snprintf if the buffer size can be deduced.
static convert_cxx_exceptions_trait< F, Args... >::return_type convert_cxx_exceptions(F f, Args &&... args)
static std::unordered_map< Symbol *, Info > funcs
void nrn_pt3dclear(Section *, int)
void nrn_area_ri(Section *sec)
void stor_pt3d(Section *, double x, double y, double z, double d)
void section_ref(Section *)
int can_change_morph(Section *)
void section_unref(Section *)
void sec_free(hoc_Item *)
void nrn_diam_change(Section *)
void nrn_length_change(Section *, double)
int const size_t const size_t n
std::vector< Memb_func > memb_func
std::unordered_map< int, NPyDirectMechFuncs > nrn_mech2funcs_map
Symbol * nrnpy_pyobj_sym_
int nrn_is_hocobj_ptr(PyObject *po, neuron::container::data_handle< double > &pd)
PyObject * nrn_hocobj_handle(neuron::container::data_handle< double > d)
Object * nrnpy_po2ho(PyObject *po)
PyObject * nrnpy_ho2po(Object *o)
static PyTypeObject * pseg_of_sec_iter_type
static PyObject * NPySecObj_pt3dadd_safe(NPySecObj *self, PyObject *args)
Section *(* nrnpy_o2sec_p_)(Object *)
static int NPyMechObj_init_safe(NPyMechObj *self, PyObject *args, PyObject *kwds)
static PyObject * NPySecObj_pt3dstyle(NPySecObj *self, PyObject *args)
static PyObject * NPyRangeVar_new_safe(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * NPySecObj_pt3dinsert(NPySecObj *self, PyObject *args)
Object *(* nrnpy_pysec_cell_p_)(Section *)
static PyObject * pysec_wholetree(NPySecObj *const self)
PyObject * nrnpy_cas(PyObject *self, PyObject *args)
void nrn_pt3dremove(Section *sec, int i0)
static PyObject * NPySegObj_new_safe(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * pysec_wholetree_safe(NPySecObj *const self)
static PyObject * NPySecObj_pt3dremove(NPySecObj *self, PyObject *args)
static PyObject * pysec_richcmp(NPySecObj *self, PyObject *other, int op)
short * nrn_is_artificial_
static PyMethodDef NPyMechFunc_methods[]
static PyObject * nrnmodule_
static void o2loc2(Object *o, Section **psec, double *px)
static PyObject * nrnpy_set_psection(PyObject *self, PyObject *args)
static PyObject * var_of_mech_next(NPyVarOfMechIter *self)
static neuron::container::data_handle< double > var_pval(NPyMechObj *pymech, Symbol *symvar, int index)
static PyObject * pysec_orientation_safe(NPySecObj *self)
static Symbol * var_find_in_mech(Symbol *mech, const char *varname)
static PyObject * seg_of_section_iter(NPySecObj *self)
static PyTypeObject * pmech_of_seg_iter_generic_type
static PyObject * pysec_subtree1(PyObject *const sl, Section *const sec)
static PyTypeObject * pmech_generic_type
static PyObject * pysec_orientation(NPySecObj *self)
static PyObject * pysec_trueparentseg(NPySecObj *self)
void nrn_pt3dinsert(Section *sec, int i0, double x, double y, double z, double d)
static int NPySegObj_contains(PyObject *segment, PyObject *obj)
static PyObject * seg_point_processes_safe(NPySegObj *self)
static void NPySecObj_dealloc(NPySecObj *self)
static PyMethodDef NPySegObj_methods[]
static PyObject * pysec_same(NPySecObj *self, PyObject *args)
static Object * seg_from_sec_x(Section *, double x)
PyObject * NPySecObj_new_safe(PyTypeObject *type, PyObject *args, PyObject *kwds)
static int NPySecObj_contains_safe(PyObject *sec, PyObject *obj)
static PyObject * NPySecObj_insert(NPySecObj *self, PyObject *args)
static PyObject * pysec_parentseg(NPySecObj *self)
PyTypeObject * psection_type
static PyObject * mech_of_segment_iter(NPySegObj *self)
static PyTypeObject * opaque_pointer_type
static PyObject * NPySecObj_spine3d(NPySecObj *self, PyObject *args)
static int mech_setattro_safe(NPyMechObj *self, PyObject *pyname, PyObject *value)
static PyObject * NPyMechObj_name(NPyMechObj *self)
static PyObject * pysec_richcmp_safe(NPySecObj *self, PyObject *other, int op)
static int rv_setitem_safe(PyObject *self, Py_ssize_t ix, PyObject *value)
static PyObject * NPySecObj_insert_safe(NPySecObj *self, PyObject *args)
static bool lappendsec(PyObject *const sl, Section *const s)
static PyObject * build_python_value(const neuron::container::generic_data_handle &dh)
static void NPyMechOfSegIter_dealloc_safe(NPyMechOfSegIter *self)
static PyObject * allseg_of_sec_next_safe(NPyAllSegOfSecIter *self)
nb::object obj_get_segment(nb::object py_obj)
static PyObject * pysec_children(NPySecObj *const self)
static PyObject * NPyMechObj_name_safe(NPyMechObj *self)
static PyObject * NPySecObj_uninsert(NPySecObj *self, PyObject *args)
static PyObject * rv_getitem_safe(PyObject *self, Py_ssize_t ix)
static PyObject * section_getattro(NPySecObj *self, PyObject *pyname)
static PyObject * NPySecObj_pt3dclear_safe(NPySecObj *self, PyObject *args)
static PyObject * NPyMechFunc_name(NPyMechFunc *self)
void(* nrnpy_o2loc2_p_)(Object *, Section **, double *)
static void o2loc(Object *, Section **, double *)
static int NPySegObj_contains_safe(PyObject *segment, PyObject *obj)
static void NPyMechFunc_dealloc(NPyMechFunc *self)
static PyObject * NPySecObj_pt3dchange(NPySecObj *self, PyObject *args)
PyObject * nrnpy_forall_safe(PyObject *self, PyObject *args)
static PyObject * NPySecObj_pt3dchange_safe(NPySecObj *self, PyObject *args)
PyObject * nrnpy_newsecobj(PyObject *, PyObject *args, PyObject *kwds)
static PyObject * pyseg_repr(PyObject *p)
static PyObject * NPySecObj_connect(NPySecObj *self, PyObject *args)
static PyObject * NPyMechObj_segment_safe(NPyMechObj *self)
static PyObject * pysec2cell_safe(NPySecObj *self)
static Py_ssize_t rv_len(PyObject *self)
static PyObject * segment_getattro_safe(NPySegObj *self, PyObject *pyname)
static PyObject * NPyMechObj_new_safe(PyTypeObject *type, PyObject *args, PyObject *kwds)
static int NPyMechObj_init(NPyMechObj *self, PyObject *args, PyObject *kwds)
static PyObject * mech_of_segment_iter_safe(NPySegObj *self)
static PyObject * pysec_subtree(NPySecObj *const self)
static PyObject * nrnpy_psection
static PyObject * pysec2cell(NPySecObj *)
static int section_setattro(NPySecObj *self, PyObject *pyname, PyObject *value)
static PyObject * node_index1_safe(NPySegObj *self)
static int segment_setattro(NPySegObj *self, PyObject *pyname, PyObject *value)
Object *(* nrnpy_seg_from_sec_x)(Section *, double x)
static void NPySegOfSecIter_dealloc_safe(NPySegOfSecIter *self)
static PyObject * pyseg_richcmp_safe(NPySegObj *self, PyObject *other, int op)
static PyObject * pysec_disconnect(NPySecObj *self)
static PyObject * NPyMechFunc_name_safe(NPyMechFunc *self)
static PyObject * NPySecObj_push(NPySecObj *self, PyObject *)
static bool striptrail(char *buf, int sz, const char *n, const char *m)
static PyObject * pysec_repr(PyObject *p)
static PyObject * NPySecObj_pt3dadd(NPySecObj *self, PyObject *args)
static PyObject * NPyRangeVar_mech_safe(NPyRangeVar *self)
static void remake_pmech_types()
static PyObject * rv_getitem(PyObject *self, Py_ssize_t ix)
static void NPySegObj_dealloc_safe(NPySegObj *self)
static PyObject * pysec_subtree_safe(NPySecObj *const self)
static PyObject * newpyseghelp(Section *sec, double x)
static PyObject * NPySecObj_pt3dstyle_safe(NPySecObj *self, PyObject *args)
void simpleconnectsection()
void(* nrnpy_o2loc_p_)(Object *, Section **, double *)
cTemplate ** nrn_pnt_template_
static PyMemberDef NPyMechObj_members[]
static PyObject * NPySecObj_arc3d(NPySecObj *self, PyObject *args)
static PyTypeObject * pallseg_of_sec_iter_type
static PyTypeObject * psegment_type
neuron::container::generic_data_handle * nrnpy_setpointer_helper(PyObject *pyname, PyObject *mech)
static Section * o2sec(Object *)
static PyObject * NPyMechFunc_call_safe(NPyMechFunc *self, PyObject *args)
static PyObject * NPySecObj_psection_safe(NPySecObj *self)
static void NPyAllSegOfSecIter_dealloc_safe(NPyAllSegOfSecIter *self)
static void NPyMechFunc_dealloc_safe(NPyMechFunc *self)
static PyObject * NPySecObj_uninsert_safe(NPySecObj *self, PyObject *args)
PyObject * NPyAllSegOfSecIter_new_safe(PyTypeObject *type, PyObject *args, PyObject *kwds)
static Section * find_root_section(Section *sec)
void nrn_pt3dchange2(Section *sec, int i, double x, double y, double z, double diam)
static PyObject * NPySecObj_y3d_safe(NPySecObj *self, PyObject *args)
static PyObject * NPyMechObj_is_ion_safe(NPyMechObj *self)
static PyObject * NPySecObj_connect_safe(NPySecObj *self, PyObject *args)
static PyObject * is_pysec(NPySecObj *self)
static double interpolate(double x0, double x1, double y0, double y1, double xnew)
static Object ** pp_get_segment(void *vptr)
static Prop * mech_of_segment_prop(Prop *p)
static PyMethodDef NPyMechObj_methods[]
static PyObject * NPyMechFunc_call(NPyMechFunc *self, PyObject *args)
static void NPySegObj_dealloc(NPySegObj *self)
static PyObject * NPyMechObj_segment(NPyMechObj *self)
static PyObject * NPySecObj_diam3d_safe(NPySecObj *self, PyObject *args)
static NPyRangeVar * rvnew(Symbol *sym, NPySecObj *sec, double x)
static PyObject * pyseg_richcmp(NPySegObj *self, PyObject *other, int op)
static int NPySegObj_init(NPySegObj *self, PyObject *, PyObject *)
static PyObject * segment_getattro(NPySegObj *self, PyObject *pyname)
static PyObject * NPySecObj_call(NPySecObj *self, PyObject *args)
static PyObject * seg_of_sec_next_safe(NPySegOfSecIter *self)
static PyObject * NPySecObj_has_membrane_safe(NPySecObj *self, PyObject *args)
static PyObject * NPySecObj_x3d_safe(NPySecObj *self, PyObject *args)
void nrn_pt3dstyle1(Section *sec, double x, double y, double z)
static void NPySegOfSecIter_dealloc(NPySegOfSecIter *self)
static PyObject * pymech_repr(PyObject *p)
static PyObject * pymech_repr_safe(PyObject *p)
static PyObject * seg_area(NPySegObj *self)
static PyObject * NPySegObj_new(PyTypeObject *type, PyObject *args, PyObject *)
static int NpySObj_contains(PyObject *s, PyObject *obj, const char *string)
static PyObject * pysec_children_safe(NPySecObj *const self)
static neuron::container::generic_data_handle var_dparam(NPyMechObj *pymech, Symbol *symvar, int index)
int(* nrnpy_pysec_cell_equals_p_)(Section *, Object *)
static PyObject * pysec_disconnect_safe(NPySecObj *self)
static PyObject * pysec_parentseg_safe(NPySecObj *self)
static PyObject * NPySecObj_arc3d_safe(NPySecObj *self, PyObject *args)
int nrn_pointer_assign(Prop *prop, Symbol *sym, PyObject *value)
static PyObject * hoc_internal_name(NPySecObj *self)
void nrn_pt3dchange1(Section *sec, int i, double d)
static PyMethodDef NPySecObj_methods[]
static PyObject * NPySecObj_has_membrane(NPySecObj *self, PyObject *args)
PyObject * nrnpy_nrn(void)
static PyObject * hoc_internal_name_safe(NPySecObj *self)
PyObject * NPyAllSegOfSecIter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject * nrnpy_newsecobj_safe(PyObject *self, PyObject *args, PyObject *kwds)
static Py_ssize_t rv_len_safe(PyObject *self)
static PyObject * var_of_mech_next_safe(NPyVarOfMechIter *self)
static void NPyAllSegOfSecIter_dealloc(NPyAllSegOfSecIter *self)
static PyObject * mech_of_seg_next_safe(NPyMechOfSegIter *self)
static PyObject * NPySecObj_psection(NPySecObj *self)
static PyMemberDef NPySegObj_members[]
static PyObject * NPySecObj_push_safe(NPySecObj *self, PyObject *args)
static PyObject * NPySecObj_name(NPySecObj *self)
static PyObject * seg_point_processes(NPySegObj *self)
static PyObject * NPySecObj_diam3d(NPySecObj *self, PyObject *args)
static void NPySecObj_dealloc_safe(NPySecObj *self)
static PyObject * seg_of_sec_next(NPySegOfSecIter *self)
static PyObject * seg_volume_safe(NPySegObj *self)
static PyObject * NPySecObj_n3d(NPySecObj *self)
static void NPyVarOfMechIter_dealloc_safe(NPyVarOfMechIter *self)
static PyObject * pysec_repr_safe(PyObject *p)
static PyObject * NPyRangeVar_name_safe(NPyRangeVar *self)
static void NPyMechOfSegIter_dealloc(NPyMechOfSegIter *self)
static int pysec_cell_equals(Section *, Object *)
static PyObject * NPySecObj_call_safe(NPySecObj *self, PyObject *args)
static PyObject * NPyMechFunc_mech_safe(NPyMechFunc *self)
static PyObject * build_python_reference(const neuron::container::generic_data_handle &dh)
static int ob_is_seg(Object *)
static PyObject * pysec_trueparentseg_safe(NPySecObj *self)
static neuron::container::generic_data_handle get_rangevar(NPyMechObj *pymech, Symbol *symvar, int index)
static PyObject * NPySecObj_name_safe(NPySecObj *self)
static PyObject * seg_area_safe(NPySegObj *self)
static void NPyRangeVar_dealloc(NPyRangeVar *self)
static PyObject * seg_ri(NPySegObj *self)
static int mech_setattro(NPyMechObj *self, PyObject *pyname, PyObject *value)
static PyObject * pymechfunc_repr(PyObject *p)
static void NPyMechObj_dealloc(NPyMechObj *self)
static long pysec_hash_safe(PyObject *self)
static PyObject * section_getattro_safe(NPySecObj *self, PyObject *pyname)
static char * pysec_name(Section *)
static PyObject * NPySecObj_x3d(NPySecObj *self, PyObject *args)
static NPyMechObj * new_pymechobj()
static int NPySecObj_init_safe(NPySecObj *self, PyObject *args, PyObject *kwds)
static void NPyVarOfMechIter_dealloc(NPyVarOfMechIter *self)
static long pysec_hash(PyObject *self)
static PyTypeObject * pvar_of_mech_iter_generic_type
static int NPyRangeVar_init(NPyRangeVar *self, PyObject *args, PyObject *kwds)
static int rv_setitem(PyObject *self, Py_ssize_t ix, PyObject *value)
static void rv_noexist(Section *sec, const char *n, double x, int err)
int hocobj_pushargs(PyObject *, std::vector< neuron::unique_cstr > &)
static PyObject * mech_getattro_safe(NPyMechObj *self, PyObject *pyname)
static PyObject * NPyMechObj_is_ion(NPyMechObj *self)
static PyObject * NPySecObj_spine3d_safe(NPySecObj *self, PyObject *args)
static void rangevars_add(Symbol *sym)
static PyObject * var_of_mech_iter_safe(NPyMechObj *self)
static PyObject * is_pysec_safe(NPySecObj *self)
static double scaled_frustum_volume(double length, double d0, double d1)
static PyMethodDef nrnpy_methods[]
static PyObject * pysec_same_safe(NPySecObj *self, PyObject *args)
static long pyseg_hash_safe(PyObject *self)
static PyObject * pymechfunc_repr_safe(PyObject *p)
static NPyOpaquePointer * opaque_pointer_new()
static PyObject * NPySecObj_z3d(NPySecObj *self, PyObject *args)
static PyObject * allseg_of_sec_iter_safe(NPyAllSegOfSecIter *self)
static PyObject * node_index1(NPySegObj *self)
static PyObject * seg_of_section_iter_safe(NPySecObj *self)
static PyObject * mech_getattro(NPyMechObj *self, PyObject *pyname)
char *(* nrnpy_pysec_name_p_)(Section *)
static int NPySecObj_init(NPySecObj *self, PyObject *args, PyObject *kwds)
static PyObject * NPySecObj_n3d_safe(NPySecObj *self)
static PyObject * mech_of_seg_next(NPyMechOfSegIter *self)
static PyObject * NPySecObj_y3d(NPySecObj *self, PyObject *args)
static PyObject * NPyMechObj_new(PyTypeObject *type, PyObject *args, PyObject *)
static PyObject * pyseg_repr_safe(PyObject *p)
static PyObject * NPySecObj_z3d_safe(NPySecObj *self, PyObject *args)
static void nrnpy_reg_mech(int)
static PyObject * pysec_subtree_impl(Section *sec)
static PyObject * seg_ri_safe(NPySegObj *self)
static PyObject * seg_volume(NPySegObj *self)
void nrn_pt3dstyle0(Section *sec)
int(* nrnpy_ob_is_seg)(Object *)
static PyObject * NPyRangeVar_name(NPyRangeVar *self)
void(* nrnpy_reg_mech_p_)(int)
static PyObject * allseg_safe(NPySecObj *self)
static PyTypeObject * pmechfunc_generic_type
static PyObject * allseg_of_sec_iter(NPyAllSegOfSecIter *self)
static PyObject * NPySecObj_pt3dinsert_safe(NPySecObj *self, PyObject *args)
static PyObject * NPySecObj_pt3dclear(NPySecObj *self, PyObject *args)
static void NPyMechObj_dealloc_safe(NPyMechObj *self)
static int NPySecObj_contains(PyObject *sec, PyObject *obj)
static Pt3d * get_pt3d_from_python_args(NPySecObj *self, PyObject *args)
static int section_setattro_safe(NPySecObj *self, PyObject *pyname, PyObject *value)
PyObject * nrn_ptr_richcmp(void *self_ptr, void *other_ptr, int op)
static PyObject * var_of_mech_iter(NPyMechObj *self)
static int NPyAllSegOfSecIter_init_safe(NPyAllSegOfSecIter *self, PyObject *args, PyObject *kwds)
PyTypeObject * hocobject_type
static int segment_setattro_safe(NPySegObj *self, PyObject *pyname, PyObject *value)
static long pyseg_hash(PyObject *self)
static int arg_bisect_arc3d(Section *sec, int npt3d, double x)
PyObject * NPySecObj_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static int NPyRangeVar_init_safe(NPyRangeVar *self, PyObject *args, PyObject *kwds)
static PyMethodDef NPyRangeVar_methods[]
static PyObject * NPyRangeVar_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject * nrnpy_cas_safe(PyObject *self, PyObject *args)
static PyObject * allseg(NPySecObj *self)
static PyTypeObject * range_type
static int NPyAllSegOfSecIter_init(NPyAllSegOfSecIter *self, PyObject *args, PyObject *)
NPySecObj * newpysechelp(Section *sec)
static Object * pysec_cell(Section *)
static void NPyRangeVar_dealloc_safe(NPyRangeVar *self)
static PyObject * NPyMechFunc_mech(NPyMechFunc *self)
static PyObject * nrnpy_set_psection_safe(PyObject *self, PyObject *args)
static PyObject * NPyRangeVar_mech(NPyRangeVar *self)
static PyObject * allseg_of_sec_next(NPyAllSegOfSecIter *self)
static PyType_Spec nrnpy_MechOfSegIterType_spec
static PyType_Spec nrnpy_VarOfMechIterType_spec
static PyType_Spec nrnpy_AllSegOfSecIterType_spec
static PyType_Spec nrnpy_SectionType_spec
static PyType_Spec nrnpy_SegOfSecIterType_spec
static struct PyModuleDef nrnsectionmodule
static PyType_Spec nrnpy_MechanismType_spec
static PyType_Spec nrnpy_RangeType_spec
static struct PyModuleDef nrnmodule
static PyType_Spec nrnpy_MechFuncType_spec
static PyType_Spec nrnpy_SegmentType_spec
static PyType_Spec nrnpy_OpaquePointerType_spec
Object * nrnpy_pyobject_in_obj(PyObject *po)
PyObject * nrnpy_hoc2pyobject(Object *ho)
int nrnpy_ho_eq_po(Object *ho, PyObject *po)
#define CHECK_SEC_INVALID(sec)
#define CHECK_PROP_INVALID(propid)
#define PyString_FromString
static double cell(void *v)
void nrnpy_pysecname2sec_add(Section *sec)
void nrnpy_pysecname2sec_remove(Section *sec)
Object ** hoc_temp_objptr(Object *)
Symlist * hoc_built_in_symlist
PyObject_HEAD NPySecObj * pysec_
PyObject_HEAD NPyMechObj * pymech_
neuron::container::non_owning_identifier_without_container prop_id_
PyObject_HEAD NPySegObj * pyseg_
PyObject_HEAD NPyMechObj * pymech_
PyObject_HEAD NPyMechObj * pymech_
PyObject_HEAD NPyMechObj * pymech_
PyObject_HEAD Section * sec_
PyObject_HEAD NPySecObj * pysec_
PyObject_HEAD NPySecObj * pysec_
PyObject_HEAD NPyMechObj * pymech_
A point process is computed just like regular mechanisms.
auto param_handle_legacy(int legacy_index)
struct Symbol::@45::@46 rng
Non-template stable handle to a generic value.
bool holds() const
Check if this handle refers to the specific type.
T get() const
Explicit conversion to any T.
A non-owning permutation-stable identifier for an entry in a container.