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

[WIP] Backport 8.2: Python 3.13 support #3319

Draft
wants to merge 20 commits into
base: release/8.2
Choose a base branch
from
Draft
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
Formatting
JCGoran committed Jan 24, 2025
commit f482ade199b4a0294f2eb275a4e0b139846c616e
1 change: 0 additions & 1 deletion docs/domains/hocdomain.py
Original file line number Diff line number Diff line change
@@ -1617,7 +1617,6 @@ def resolve_any_xref(
multiple_matches = len(matches) > 1

for name, obj in matches:

if multiple_matches and obj.aliased:
# Skip duplicated matches
continue
1 change: 0 additions & 1 deletion docs/parse_rst.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@


class ParseRst(object):

help_dictionary = {}

def __init__(self, rst_path, out_file):
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -211,7 +211,6 @@ def run(self, *args, **kw):
the CMake building, sets the extension build environment and collects files.
"""
for ext in self.extensions:

if isinstance(ext, CMakeAugmentedExtension):
if ext.cmake_done:
continue
2 changes: 0 additions & 2 deletions share/lib/python/neuron/doc.py
Original file line number Diff line number Diff line change
@@ -207,7 +207,6 @@ def get_docstring(objtype, symbol):
f.close()

if (objtype, symbol) == ("", ""):

return doc_h

# are we asking for help on a class, e.g. h.Vector
@@ -229,7 +228,6 @@ def get_docstring(objtype, symbol):
if full_name in _help_dict:
return _get_from_help_dict(full_name)
else:

return default_member_doc_template % (
objtype,
symbol,
2 changes: 0 additions & 2 deletions share/lib/python/neuron/rxd/geometry3d/FullJoinMorph.py
Original file line number Diff line number Diff line change
@@ -22,7 +22,6 @@


def find_parent_seg(join, sdict, objects):

if not join:
return None
elif join[0] not in objects:
@@ -65,7 +64,6 @@ def sort_spheres_last(item):


def fullmorph(source, dx, soma_step=100, mesh_grid=None, relevant_pts=None):

"""Input: object source; arguments to pass to ctng
Output: all voxels with SA and volume associated, categorized by segment"""
source = list(source)
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ def verts_in(f, voxel, surf, g):
verts = get_verts(voxel, g)
ins = 0
distlist = []
for (x, y, z) in verts:
for x, y, z in verts:
if (
g["xlo"] <= x <= g["xhi"]
and g["ylo"] <= y <= g["yhi"]
@@ -173,7 +173,8 @@ def find_endpoints(f, surf, include_ga, row, guesses, g):

def voxelize(grid, Object, corners=None, include_ga=False):
"""return a list of all voxels (i,j,k) that contain part of the object
Other returned elements: set of surface voxels, possibly_missed for error handling"""
Other returned elements: set of surface voxels, possibly_missed for error handling
"""
# include_ga is whether to include grid-adjacent voxels in the surface, even if entirely within the surface

yes_voxels = set()
3 changes: 3 additions & 0 deletions share/lib/python/neuron/rxd/gui.py
Original file line number Diff line number Diff line change
@@ -1204,6 +1204,7 @@ def map(self):

_the_species_editor = _SpeciesEditor()


# this is a way of faking the Singleton pattern
def SpeciesEditor():
if not _the_species_editor.is_mapped:
@@ -1249,6 +1250,7 @@ def map(self):

_the_species_pane = _SpeciesPane()


# this is a way of faking the Singleton pattern
def SpeciesPane():
_the_species_pane = _SpeciesPane()
@@ -1700,6 +1702,7 @@ def map(self):

_the_reaction_pane = _ReactionPane()


# this is a way of faking the Singleton pattern
def ReactionPane():
if not _the_reaction_pane.is_mapped:
6 changes: 3 additions & 3 deletions share/lib/python/neuron/rxd/node.py
Original file line number Diff line number Diff line change
@@ -71,15 +71,15 @@ def _remove(start, stop):

# remove _node_flux
newflux = {"index": [], "type": [], "source": [], "scale": [], "region": []}
for (i, idx) in enumerate(_node_fluxes["index"]):
for i, idx in enumerate(_node_fluxes["index"]):
if idx not in dels:
for key in _node_fluxes:
newflux[key].append(_node_fluxes[key][i])
_node_fluxes = newflux
_has_node_fluxes = _node_fluxes["index"] != []

# remove _node_flux
for (i, idx) in enumerate(_node_fluxes["index"]):
for i, idx in enumerate(_node_fluxes["index"]):
if idx in dels:
for lst in _node_fluxes.values():
del lst[i]
@@ -108,7 +108,7 @@ def _replace(old_offset, old_nseg, new_offset, new_nseg):
_states = numpy.delete(_states, list(range(start, stop)))

# update _node_flux index
for (i, idx) in enumerate(_node_fluxes["index"]):
for i, idx in enumerate(_node_fluxes["index"]):
if idx in dels:
j = int(((idx + 0.5) / new_nseg) * old_nseg)
_node_fluxes["index"][i] = j
1 change: 0 additions & 1 deletion share/lib/python/neuron/rxd/region.py
Original file line number Diff line number Diff line change
@@ -447,7 +447,6 @@ def _parse_tortuosity(self, value, is_permeability=False):
return parsed_value, ecs_permeability

def _parse_volume_fraction(self, volume_fraction):

if numpy.isscalar(volume_fraction):
alpha = float(volume_fraction)
alpha = alpha
7 changes: 2 additions & 5 deletions share/lib/python/neuron/rxd/rxd.py
Original file line number Diff line number Diff line change
@@ -608,7 +608,6 @@ def _update_node_data(force=False, newspecies=False):
or _structure_change_count.value != last_structure_change_cnt
or force
):

last_diam_change_cnt = _diam_change_count.value
last_structure_change_cnt = _structure_change_count.value
# if not species._has_3d:
@@ -663,9 +662,7 @@ def _matrix_to_rxd_sparse(m):

# TODO: make sure this does the right thing when the diffusion constant changes between two neighboring nodes
def _setup_matrices():

with initializer._init_lock:

# update _node_fluxes in C
_include_flux()

@@ -1462,7 +1459,7 @@ def localize_index(creg, rate):
continue
fxn_string += "\n\trate = %s;" % rate_str
summed_mults = collections.defaultdict(lambda: 0)
for (mult, sp) in zip(r._mult, r._sources + r._dests):
for mult, sp in zip(r._mult, r._sources + r._dests):
summed_mults[creg._species_ids.get(sp()._id)] += mult
for idx in sorted([k for k in summed_mults if k is not None]):
operator = "+=" if species_ids_used[idx][region_id] else "="
@@ -2007,7 +2004,7 @@ def _windows_remove_dlls():
kernel32.FreeLibrary.argtypes = [ctypes.c_void_p]
else:
kernel32 = ctypes.windll.kernel32
for (dll_ptr, filepath) in zip(_windows_dll, _windows_dll_files):
for dll_ptr, filepath in zip(_windows_dll, _windows_dll_files):
dll = dll_ptr()
if dll:
handle = dll._handle
2 changes: 1 addition & 1 deletion share/lib/python/neuron/rxd/section1d.py
Original file line number Diff line number Diff line change
@@ -67,7 +67,7 @@ def remove(self, rxdsec):

def add_values(mat, i, js, vals):
mat_i = mat[i]
for (j, val) in zip(js, vals):
for j, val in zip(js, vals):
if val == 0:
continue
if j in mat_i:
5 changes: 2 additions & 3 deletions share/lib/python/neuron/rxd/species.py
Original file line number Diff line number Diff line change
@@ -1507,7 +1507,6 @@ def _import_concentration(self):
self._states[i] = getattr(seg, stateo)

def _semi_compile(self, reg, instruction):

self._isalive()
if self._species:
sp = _defined_species[self._species][self._region]()
@@ -1523,7 +1522,6 @@ def _semi_compile(self, reg, instruction):

@property
def d(self):

self._isalive()
return self._d

@@ -2283,7 +2281,8 @@ def _import_concentration(self, init=True):
def nodes(self):
"""A NodeList of all the nodes corresponding to the species.

This can then be further restricted using the callable property of NodeList objects."""
This can then be further restricted using the callable property of NodeList objects.
"""

from . import rxd

Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
hour = 60 * minute
h.dt = 1 * minute


# def run_sim():
def declare_parameters(**kwargs):
"""enables clean declaration of parameters in top namespace"""
1 change: 1 addition & 0 deletions share/lib/python/neuron/rxdtests/tests/hh.py
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@
# extracellular
ecs = rxd.Extracellular(-100, -100, -100, 100, 100, 100, dx=100)


# Who?
def init(ics, ecs):
return lambda nd: ecs if isinstance(nd, rxd.node.NodeExtracellular) else ics
1 change: 1 addition & 0 deletions share/lib/python/neuron/rxdtests/tests/hh_cvode.py
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@
# extracellular
ecs = rxd.Extracellular(-100, -100, -100, 100, 100, 100, dx=100)


# Who?
def init(ics, ecs):
return lambda nd: ecs if isinstance(nd, rxd.node.NodeExtracellular) else ics
1 change: 1 addition & 0 deletions share/lib/python/neuron/rxdtests/tests/hh_param.py
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@
# extracellular
ecs = rxd.Extracellular(-100, -100, -100, 100, 100, 100, dx=33)


# Who?
def init(ics, ecs):
return lambda nd: ecs if isinstance(nd, rxd.node.NodeExtracellular) else ics
1 change: 1 addition & 0 deletions share/lib/python/neuron/rxdtests/tests/hh_param_cvode.py
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@
# extracellular
ecs = rxd.Extracellular(-100, -100, -100, 100, 100, 100, dx=33)


# Who?
def init(ics, ecs):
return lambda nd: ecs if isinstance(nd, rxd.node.NodeExtracellular) else ics
2 changes: 0 additions & 2 deletions share/lib/python/neuron/tests/test_all.py
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@


def suite():

suite = unittest.TestSuite()
suite.addTest(test_vector.suite())
suite.addTest(test_neuron.suite())
@@ -22,7 +21,6 @@ def suite():


if __name__ == "__main__":

# unittest.main()
runner = unittest.TextTestRunner(verbosity=2)
runner.run(suite())
1 change: 0 additions & 1 deletion share/lib/python/neuron/tests/test_neuron.py
Original file line number Diff line number Diff line change
@@ -281,7 +281,6 @@ def suite():


if __name__ == "__main__":

# unittest.main()
runner = unittest.TextTestRunner(verbosity=2)
runner.run(suite())
2 changes: 0 additions & 2 deletions share/lib/python/neuron/tests/test_vector.py
Original file line number Diff line number Diff line change
@@ -102,13 +102,11 @@ def testNumpyInteraction(self):
pass



def suite():
return unittest.defaultTestLoader.loadTestsFromTestCase(VectorTestCase)


if __name__ == "__main__":

# unittest.main()
runner = unittest.TextTestRunner(verbosity=2)
runner.run(suite())
1 change: 1 addition & 0 deletions test/cover/checkresult.py
Original file line number Diff line number Diff line change
@@ -42,6 +42,7 @@ def __call__(self, key, value, tol=0.0):
if type(value) == type(h.Vector): # actually hoc.HocObject
# Convert to list to keep the `equal` method below simple
value = list(value)

# Hand-rolled comparison that uses `tol` for arithmetic values
# buried inside lists of lists.
def equal(a, b):
1 change: 1 addition & 0 deletions test/cover/test_netcvode.py
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
cv = h.CVode()
pc = h.ParallelContext()


# remove address info from cv.debug_event output
def debug_event_filter(s):
s = re.sub(r"cvode_0x[0-9abcdef]* ", "cvode_0x... ", s)
4 changes: 0 additions & 4 deletions test/gjtests/test_par_gj.py
Original file line number Diff line number Diff line change
@@ -61,9 +61,7 @@ def mkcells(pc, ngids):
assert nranks <= ngids

for gid in range(ngids):

if gid % nranks == myrank:

cell = MyCell()
nc = h.NetCon(cell.soma(0.5)._ref_v, None, sec=cell.soma)
pc.set_gid2node(gid, myrank)
@@ -101,7 +99,6 @@ def mkgjs(pc, ngids):

ggid = 2e6 ## gap junction id range is intended to not overlap with gid range
for gid in range(0, ngids, 2):

# source gid: all even gids
src = gid
# destination gid: all odd gids
@@ -128,7 +125,6 @@ def mkgjs(pc, ngids):


def main():

parser = argparse.ArgumentParser(description="Parallel transfer test.")
parser.add_argument(
"--sparse-partrans",
1 change: 0 additions & 1 deletion test/parallel_tests/test_bas.py
Original file line number Diff line number Diff line change
@@ -335,7 +335,6 @@ def compare_dicts(dict1, dict2):


def test_bas():

# h.execute1(...) does not call mpi_abort on failure
assert h.execute1("1/0") == 0
assert h.execute1("2/0", 0) == 0 # no error message printed
1 change: 0 additions & 1 deletion test/pynrn/test_fast_imem.py
Original file line number Diff line number Diff line change
@@ -256,7 +256,6 @@ def print_fast_imem():


def test_fastimem_corenrn():

if not coreneuron_available():
return

1 change: 1 addition & 0 deletions test/pynrn/test_hoc_po.py
Original file line number Diff line number Diff line change
@@ -164,6 +164,7 @@ def test_2():

# BBSaveState for mixed (hoc and python cells) Ring.


# some helpers copied from ../parallel_tests/test_bas.py
def subprocess_run(cmd):
subprocess.run(cmd, shell=True).check_returncode()
1 change: 0 additions & 1 deletion test/pynrn/test_nrnste.py
Original file line number Diff line number Diff line change
@@ -51,7 +51,6 @@ def model():


def test_ste():

m1 = model()
# one state ste with two self transitions
var = m1["s"](0.5)._ref_v
2 changes: 1 addition & 1 deletion test/pynrn/test_partrans.py
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@ def expect_error(callable, args, sec=None):
ks.gmax(0)
ks.erev(0)


# Cell with enough nonsense stuff to exercise transfer possibilities.
class Cell:
def __init__(self):
@@ -186,7 +187,6 @@ def check_values():


def test_partrans():

# no transfer targets or sources.
mkmodel(4)
run()
1 change: 0 additions & 1 deletion test/pynrn/test_template_err.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@


def test_template_err():

h(
"""
begintemplate TestTemplateErr1
2 changes: 1 addition & 1 deletion test/rxd/3d/test_soma_outlines.py
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ def __init__(self, shift=(0, 0, 0)):
for i in range(sec.n3d())
]
sec.pt3dclear()
for (x, y, z, diam) in pts:
for x, y, z, diam in pts:
sec.pt3dadd(x + sx, y + sy, z + sz, diam)

yield (h, rxd, data, save_path, Cell)

Unchanged files with check annotations Beta

private:
FileChooser* fc_;
enum { N, R, W, A };
int chooser_type_;

Check warning on line 48 in src/ivoc/ocfile.h

GitHub Actions / ubuntu-22.04 - cmake (-DNRN_ENABLE_CORENEURON=ON -DNRN_ENABLE_INTERVIEWS=OFF -DCORENRN_SANITIZERS=undefined)

private field 'chooser_type_' is not used [-Wunused-private-field]
CopyString filename_;
CopyString dirname_;
FILE* file_;
int BBSLocal::upkint() {
int i;
if (!taking_ || taking_->upkint(&i))

Check warning on line 60 in src/parallel/bbslocal.cpp

GitHub Actions / ubuntu-22.04 - cmake (-DNRN_ENABLE_CORENEURON=ON -DNRN_ENABLE_INTERVIEWS=OFF -DCORENRN_SANITIZERS=undefined)

variable 'i' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]
perror("upkint");
return i;
}
double BBSLocal::upkdouble() {
double x;
if (!taking_ || taking_->upkdouble(&x)) {

Check warning on line 67 in src/parallel/bbslocal.cpp

GitHub Actions / ubuntu-22.04 - cmake (-DNRN_ENABLE_CORENEURON=ON -DNRN_ENABLE_INTERVIEWS=OFF -DCORENRN_SANITIZERS=undefined)

variable 'x' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]
perror("upkdouble");
}
return x;
char* BBSLocal::upkstr() {
int len;
char* s;
if (!taking_ || taking_->upkint(&len)) {

Check warning on line 82 in src/parallel/bbslocal.cpp

GitHub Actions / ubuntu-22.04 - cmake (-DNRN_ENABLE_CORENEURON=ON -DNRN_ENABLE_INTERVIEWS=OFF -DCORENRN_SANITIZERS=undefined)

variable 'len' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]
perror("upkstr length");
}
s = new char[len + 1];
char* BBSLocal::upkpickle(size_t* n) {
int len;
char* s;
if (!taking_ || taking_->upkint(&len)) {

Check warning on line 95 in src/parallel/bbslocal.cpp

GitHub Actions / ubuntu-22.04 - cmake (-DNRN_ENABLE_CORENEURON=ON -DNRN_ENABLE_INTERVIEWS=OFF -DCORENRN_SANITIZERS=undefined)

variable 'len' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]
perror("upkpickle length");
}
s = new char[len];
MessageItem* link();
private:
int type_;

Check warning on line 48 in src/parallel/bbslsrv.h

GitHub Actions / ubuntu-22.04 - cmake (-DNRN_ENABLE_CORENEURON=ON -DNRN_ENABLE_INTERVIEWS=OFF -DCORENRN_SANITIZERS=undefined)

private field 'type_' is not used [-Wunused-private-field]
MessageItem* first_;
MessageItem* last_;
MessageItem* unpack_;
double signed_distance(double px, double py, double pz);
private:
double axisx, axisy, axisz, cx, cy, cz, h, rra, rrb, conelength;

Check warning on line 553 in src/nrniv/geometry3d.cpp

GitHub Actions / ubuntu-22.04 - cmake (-DNRN_ENABLE_CORENEURON=ON -DNRN_ENABLE_INTERVIEWS=OFF -DCORENRN_SANITIZERS=undefined)

private field 'cx' is not used [-Wunused-private-field]

Check warning on line 553 in src/nrniv/geometry3d.cpp

GitHub Actions / ubuntu-22.04 - cmake (-DNRN_ENABLE_CORENEURON=ON -DNRN_ENABLE_INTERVIEWS=OFF -DCORENRN_SANITIZERS=undefined)

private field 'cy' is not used [-Wunused-private-field]

Check warning on line 553 in src/nrniv/geometry3d.cpp

GitHub Actions / ubuntu-22.04 - cmake (-DNRN_ENABLE_CORENEURON=ON -DNRN_ENABLE_INTERVIEWS=OFF -DCORENRN_SANITIZERS=undefined)

private field 'cz' is not used [-Wunused-private-field]
double side1, side2, x0, y0, z0, r0, axislength;
};
mode = 2;
Object* o = *hoc_objgetarg(1);
my_origin_sec = (Section*) 0;
if (nrnpy_o2loc2_p_) {

Check warning on line 249 in src/nrnoc/solve.cpp

GitHub Actions / ubuntu-22.04 - cmake (-DNRN_ENABLE_CORENEURON=ON -DNRN_ENABLE_INTERVIEWS=OFF -DCORENRN_SANITIZERS=undefined)

variable 'd_origin' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
(*nrnpy_o2loc2_p_)(o, &my_origin_sec, &d_origin);
}
if (!my_origin_sec) {