Skip to content

Commit

Permalink
Merge branch 'master' into leite/dat_files_use_vec
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdonline authored Dec 4, 2024
2 parents 0f55dd6 + 9e5dd3d commit 1033a0c
Show file tree
Hide file tree
Showing 71 changed files with 1,072 additions and 1,112 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ jobs:
env:
DISPLAY: ${{ ':0' }}
MUSIC_INSTALL_DIR: /opt/MUSIC
MUSIC_VERSION: 1.2.0
# hash of commit containing mpi4py 4 fix
MUSIC_VERSION: '13f312338dcccebfe74d391b1b24f1b6d816ac6c'

steps:

Expand All @@ -58,10 +59,10 @@ jobs:
run: |
python3 -m venv music-venv
source music-venv/bin/activate
python3 -m pip install 'mpi4py<4' cython numpy setuptools
python3 -m pip install mpi4py cython numpy setuptools
sudo mkdir -p $MUSIC_INSTALL_DIR
sudo chown -R $USER $MUSIC_INSTALL_DIR
curl -L -o MUSIC.zip https://github.com/INCF/MUSIC/archive/refs/tags/${MUSIC_VERSION}.zip
curl -L -o MUSIC.zip https://github.com/INCF/MUSIC/archive/${MUSIC_VERSION}.zip
unzip MUSIC.zip && mv MUSIC-* MUSIC && cd MUSIC
./autogen.sh
./configure --with-python-sys-prefix --prefix=$MUSIC_INSTALL_DIR --disable-anysource
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/neuron-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ jobs:
PY_MIN_VERSION: ${{ matrix.config.python_min_version || '3.9' }}
PY_MAX_VERSION: ${{ matrix.config.python_max_version || '3.12' }}
MUSIC_INSTALL_DIR: /opt/MUSIC
MUSIC_VERSION: 1.2.1
# hash of commit containing mpi4py 4 fix
MUSIC_VERSION: '13f312338dcccebfe74d391b1b24f1b6d816ac6c'

strategy:
matrix:
Expand Down Expand Up @@ -207,10 +208,10 @@ jobs:
run: |
python3 -m venv music-venv
source music-venv/bin/activate
python3 -m pip install 'mpi4py<4' cython numpy setuptools
python3 -m pip install mpi4py cython numpy setuptools
sudo mkdir -p $MUSIC_INSTALL_DIR
sudo chown -R $USER $MUSIC_INSTALL_DIR
curl -L -o MUSIC.zip https://github.com/INCF/MUSIC/archive/refs/tags/${MUSIC_VERSION}.zip
curl -L -o MUSIC.zip https://github.com/INCF/MUSIC/archive/${MUSIC_VERSION}.zip
unzip MUSIC.zip && mv MUSIC-* MUSIC && cd MUSIC
./autogen.sh
# on some systems MPI library detection fails, provide exact flags/compilers
Expand Down
2 changes: 1 addition & 1 deletion ci/win_install_deps.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ mingw-w64-x86_64-ninja ^
mingw-w64-x86_64-ncurses ^
mingw-w64-x86_64-readline ^
mingw-w64-x86_64-python3 ^
mingw-w64-x86_64-python3-setuptools ^
mingw-w64-x86_64-python-setuptools ^
mingw-w64-x86_64-python3-packaging ^
mingw-w64-x86_64-python3-pip ^
mingw64/mingw-w64-x86_64-dlfcn ^
Expand Down
2 changes: 1 addition & 1 deletion cmake/NeuronFileLists.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ set(HEADER_FILES_TO_INSTALL
nrnoc/options.h
nrnoc/section_fwd.hpp
nrnoc/treeset.h
oc/classreg.h
oc/hoc.h
oc/hoc_membf.h
oc/hocassrt.h
oc/hocdec.h
oc/hocgetsym.h
Expand Down
2 changes: 1 addition & 1 deletion external/CLI11
Submodule CLI11 updated 198 files
2 changes: 1 addition & 1 deletion external/catch2
Submodule catch2 updated 133 files
2 changes: 1 addition & 1 deletion nrn_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ setuptools<=70.3.0
scikit-build
matplotlib
ipython
mpi4py<4 # MUSIC not compatible with MPI 4
mpi4py
find_libpython
-r packaging/python/build_requirements.txt
-r packaging/python/test_requirements.txt
34 changes: 22 additions & 12 deletions share/lib/python/neuron/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
Note that python threads are not used if nrniv is launched instead of Python
"""


from neuron import h

from contextlib import contextmanager
import threading
import time
import atexit

# recursive, especially in case stop/start pairs called from doNotify code.
_lock = threading.RLock()
Expand Down Expand Up @@ -48,9 +47,10 @@ def process_events():
_lock.acquire()
try:
h.doNotify()
except:
print("Exception in gui thread")
_lock.release()
except Exception as e:
print(f"Exception in gui thread: {e}")
finally:
_lock.release()


class Timer:
Expand Down Expand Up @@ -86,30 +86,40 @@ def end(self):

class LoopTimer(threading.Thread):
"""
a Timer that calls f every interval
A Timer that calls a function at regular intervals.
"""

def __init__(self, interval, fun):
"""
@param interval: time in seconds between call to fun()
@param fun: the function to call on timer update
"""
self.started = False
self.interval = interval
self.fun = fun
self._running = threading.Event()
threading.Thread.__init__(self, daemon=True)

def run(self):
h.nrniv_bind_thread(threading.current_thread().ident)
self.started = True
while True:
self._running.set()
while self._running.is_set():
self.fun()
time.sleep(self.interval)

def stop(self):
"""Stop the timer thread and wait for it to terminate."""
self._running.clear()
self.join()

if h.nrnversion(9) == "2": # launched with python (instead of nrniv)

if h.nrnversion(9) == "2": # Launched with Python (instead of nrniv)
timer = LoopTimer(0.1, process_events)
timer.start()

def cleanup():
if timer.started:
timer.stop()

atexit.register(cleanup)

while not timer.started:
time.sleep(0.001)

Expand Down
14 changes: 8 additions & 6 deletions share/lib/python/neuron/rxd/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
_concentration_node = 0
_molecule_node = 1

_floor = numpy.floor


def _get_data():
return (_volumes, _surface_area, _diffs)
Expand Down Expand Up @@ -650,9 +652,9 @@ def satisfies(self, condition):
x, y, z = condition
mesh = self._r._mesh_grid
return (
int((x - mesh["xlo"]) / mesh["dx"]) == self._i
and int((y - mesh["ylo"]) / mesh["dy"]) == self._j
and int((z - mesh["zlo"]) / mesh["dz"]) == self._k
_floor((x - mesh["xlo"]) / mesh["dx"]) == self._i
and _floor((y - mesh["ylo"]) / mesh["dy"]) == self._j
and _floor((z - mesh["zlo"]) / mesh["dz"]) == self._k
)
# check for a position condition so as to provide a more useful error
checked_for_normalized_position = False
Expand Down Expand Up @@ -885,8 +887,8 @@ def satisfies(self, condition):
x, y, z = condition
r = self._regionref()
return (
int((x - r._xlo) / r._dx[0]) == self._i
and int((y - r._ylo) / r._dx[1]) == self._j
and int((z - r._zlo) / r._dx[2]) == self._k
_floor((x - r._xlo) / r._dx[0]) == self._i
and _floor((y - r._ylo) / r._dx[1]) == self._j
and _floor((z - r._zlo) / r._dx[2]) == self._k
)
raise RxDException(f"unrecognized node condition: {condition}")
2 changes: 1 addition & 1 deletion src/ivoc/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,7 @@ static Member_func gr_members[] = {{"plot", gr_plot},
{"gif", ivoc_gr_gif},
{"menu_remove", ivoc_gr_menu_remove},
{"line_info", gr_line_info},
{0, 0}};
{nullptr, nullptr}};

static void* gr_cons(Object* ho) {
TRY_GUI_REDIRECT_OBJ("Graph", NULL);
Expand Down
6 changes: 2 additions & 4 deletions src/ivoc/grglyph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ static Object** g_gif(void* v) {

static Symbol* sggl_;

Member_func members[] = {{0, 0}};

Member_ret_obj_func objmembers[] = {{"path", g_new_path},
{"m", g_move_to},
{"l", g_line_to},
Expand All @@ -197,7 +195,7 @@ Member_ret_obj_func objmembers[] = {{"path", g_new_path},
{"erase", g_erase},
{"gif", g_gif},
{"circle", g_circle},
{0, 0}};
{nullptr, nullptr}};

static void* cons(Object* o) {
TRY_GUI_REDIRECT_OBJ("Glyph", NULL);
Expand All @@ -213,7 +211,7 @@ static void destruct(void* v) {
}

void GrGlyph_reg() {
class2oc("Glyph", cons, destruct, members, objmembers, NULL);
class2oc("Glyph", cons, destruct, nullptr, objmembers, nullptr);
sggl_ = hoc_lookup("Glyph");
}

Expand Down
2 changes: 1 addition & 1 deletion src/ivoc/ivocrand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ static Member_func r_members[] = {{"MCellRan4", r_MCellRan4},
{nullptr, nullptr}};

void Random_reg() {
class2oc("Random", r_cons, r_destruct, r_members, NULL, NULL);
class2oc("Random", r_cons, r_destruct, r_members, nullptr, nullptr);
random_play_list_ = new RandomPlayList;
}

Expand Down
6 changes: 3 additions & 3 deletions src/ivoc/ivocvect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3737,7 +3737,7 @@ static Member_func v_members[] = {

{"scale", v_scale},

{0, 0}};
{nullptr, nullptr}};

static Member_ret_obj_func v_retobj_members[] = {{"c", v_c},
{"cl", v_cl},
Expand Down Expand Up @@ -3813,11 +3813,11 @@ static Member_ret_obj_func v_retobj_members[] = {{"c", v_c},
{"to_python", v_to_python},
{"as_numpy", v_as_numpy},

{0, 0}};
{nullptr, nullptr}};

static Member_ret_str_func v_retstr_members[] = {{"label", v_label},

{0, 0}};
{nullptr, nullptr}};

extern int hoc_araypt(Symbol*, int);

Expand Down
6 changes: 3 additions & 3 deletions src/ivoc/matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ static Member_func m_members[] = {
{"printf", m_printf},
{"fprint", m_fprint},
{"scanf", m_scanf},
{0, 0}};
{nullptr, nullptr}};

static Member_ret_obj_func m_retobj_members[] = {
// returns Vector
Expand Down Expand Up @@ -687,7 +687,7 @@ static Member_ret_obj_func m_retobj_members[] = {
{"set", m_set},
{"to_vector", m_to_vector},
{"from_vector", m_from_vector},
{0, 0}};
{nullptr, nullptr}};

static void* m_cons(Object* o) {
int i = 1, j = 1, storage_type = Matrix::MFULL;
Expand Down Expand Up @@ -729,7 +729,7 @@ void Matrix_reg();
#endif

void Matrix_reg() {
class2oc("Matrix", m_cons, m_destruct, m_members, m_retobj_members, NULL);
class2oc("Matrix", m_cons, m_destruct, m_members, m_retobj_members, nullptr);
nrn_matrix_sym = hoc_lookup("Matrix");
// now make the x variable an actual double
Symbol* sx = hoc_table_lookup("x", nrn_matrix_sym->u.ctemplate->symtable);
Expand Down
4 changes: 2 additions & 2 deletions src/ivoc/mlinedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ static const char** v_text(void* v) {
}


static Member_func members[] = {{"readonly", readonly}, {"map", map}, {0, 0}};
static Member_func members[] = {{"readonly", readonly}, {"map", map}, {nullptr, nullptr}};

static Member_ret_str_func retstr_members[] = {{"text", v_text}, {0, 0}};
static Member_ret_str_func retstr_members[] = {{"text", v_text}, {nullptr, nullptr}};

static void* cons(Object*) {
TRY_GUI_REDIRECT_OBJ("TextEditor", NULL);
Expand Down
4 changes: 2 additions & 2 deletions src/ivoc/mymath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static Member_func members[] = {{"d2line", distance_to_line},
{"d2line_seg", distance_to_line_segment},
{"inside", inside},
{"feround", feround},
{0, 0}};
{nullptr, nullptr}};

static void* cons(Object*) {
return NULL;
Expand All @@ -73,7 +73,7 @@ static void* cons(Object*) {
static void destruct(void*) {}

void GUIMath_reg() {
class2oc("GUIMath", cons, destruct, members, NULL, NULL);
class2oc("GUIMath", cons, destruct, members, nullptr, nullptr);
}

double MyMath::anint(double x) {
Expand Down
6 changes: 3 additions & 3 deletions src/ivoc/ocbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,14 +426,14 @@ static Member_func members[] = {{"intercept", intercept}, // #if HAVE
{"dialog", dialog}, // #if HAVE_IV ok
{"priority", ses_pri},
{"size", b_size},
{0, 0}};
{nullptr, nullptr}};

void HBox_reg() {
class2oc("HBox", hcons, destruct, members, NULL, NULL);
class2oc("HBox", hcons, destruct, members, nullptr, nullptr);
}

void VBox_reg() {
class2oc("VBox", vcons, destruct, members, NULL, NULL);
class2oc("VBox", vcons, destruct, members, nullptr, nullptr);
}
#if HAVE_IV
OcGlyphContainer::OcGlyphContainer()
Expand Down
4 changes: 2 additions & 2 deletions src/ivoc/ocdeck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ static Member_func members[] = {{"flip_to", flip_to},
{"remove_last", remove_last},
{"remove", remove},
{"move_last", move_last},
{0, 0}};
{nullptr, nullptr}};

void OcDeck_reg() {
class2oc("Deck", cons, destruct, members, NULL, NULL);
class2oc("Deck", cons, destruct, members, nullptr, nullptr);
}
#if HAVE_IV
OcDeck::OcDeck()
Expand Down
8 changes: 5 additions & 3 deletions src/ivoc/ocfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,14 @@ Member_func f_members[] = {{"ropen", f_ropen},
{"mktemp", f_mktemp},
{"unlink", f_unlink},
{"flush", f_flush},
{0, 0}};
{nullptr, nullptr}};

static Member_ret_str_func f_retstr_members[] = {{"getname", f_get_name}, {"dir", f_dir}, {0, 0}};
static Member_ret_str_func f_retstr_members[] = {{"getname", f_get_name},
{"dir", f_dir},
{nullptr, nullptr}};

void OcFile_reg() {
class2oc("File", f_cons, f_destruct, f_members, NULL, f_retstr_members);
class2oc("File", f_cons, f_destruct, f_members, nullptr, f_retstr_members);
file_class_sym_ = hoc_lookup("File");
}

Expand Down
2 changes: 1 addition & 1 deletion src/ivoc/oclist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ OcList::~OcList() {

void OcList_reg() {
// printf("Oclist_reg\n");
class2oc("List", l_cons, l_destruct, l_members, l_retobj_members, NULL);
class2oc("List", l_cons, l_destruct, l_members, l_retobj_members, nullptr);
list_class_sym_ = hoc_lookup("List");
}

Expand Down
4 changes: 2 additions & 2 deletions src/ivoc/ocpointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static const char** pname(void* v) {

static Member_func members[] = {{"val", 0}, // will be changed below
{"assign", assign}, // will call assign_stmt if it exists
{0, 0}};
{nullptr, nullptr}};

static Member_ret_str_func s_memb[] = {{"s", pname}, {nullptr, nullptr}};

Expand Down Expand Up @@ -108,7 +108,7 @@ static void steer_val(void* v) {
}

void OcPointer_reg() {
class2oc("Pointer", cons, destruct, members, NULL, s_memb);
class2oc("Pointer", cons, destruct, members, nullptr, s_memb);
// now make the val variable an actual double
Symbol* sv = hoc_lookup("Pointer");
Symbol* sx = hoc_table_lookup("val", sv->u.ctemplate->symtable);
Expand Down
Loading

0 comments on commit 1033a0c

Please sign in to comment.