Skip to content

Commit

Permalink
Merge branch 'master' into flense-DOS
Browse files Browse the repository at this point in the history
  • Loading branch information
mgeplf committed May 6, 2024
2 parents e1a894d + d99cbb5 commit 38b8867
Show file tree
Hide file tree
Showing 25 changed files with 251 additions and 243 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ on:
env:
PY_MIN_VERSION: '3.8'
PY_MID_VERSION: '3.10'
PY_MAX_VERSION: '3.11'
PY_MAX_VERSION: '3.12'

jobs:
coverage:
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
run: |
python3 -m venv music-venv
source music-venv/bin/activate
python3 -m pip install mpi4py "cython<3" numpy
python3 -m pip install mpi4py "cython<3" 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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
- release/**

env:
DEFAULT_PY_VERSION: '3.11'
DEFAULT_PY_VERSION: '3.12'

jobs:
documentation:
Expand Down
38 changes: 29 additions & 9 deletions .github/workflows/neuron-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
DESIRED_CMAKE_VERSION: 3.17
DYNAMIC_PYTHON_CMAKE_VERSION: 3.18
PY_MIN_VERSION: ${{ matrix.config.python_min_version || '3.8' }}
PY_MAX_VERSION: ${{ matrix.config.python_max_version || '3.11' }}
PY_MAX_VERSION: ${{ matrix.config.python_max_version || '3.12' }}
MUSIC_INSTALL_DIR: /opt/MUSIC
MUSIC_VERSION: 1.2.1

Expand All @@ -49,7 +49,7 @@ jobs:
config:
- { matrix_eval : "CC=gcc-9 CXX=g++-9", build_mode: "setuptools"}
- { matrix_eval : "CC=gcc-10 CXX=g++-10", build_mode: "cmake", music: ON}
- { matrix_eval : "CC=gcc-10 CXX=g++-10", build_mode: "cmake", python_dynamic: ON}
- { matrix_eval : "CC=gcc-10 CXX=g++-10", build_mode: "cmake", python_dynamic: ON}
- { matrix_eval : "CC=gcc-9 CXX=g++-9" , build_mode: "cmake", cmake_option: "-DNRN_ENABLE_CORENEURON=ON"}
- { matrix_eval : "CC=gcc-9 CXX=g++-9", build_mode: "cmake", cmake_option: "-DNRN_ENABLE_MPI=OFF -DNRN_ENABLE_INTERVIEWS=OFF -DNRN_ENABLE_CORENEURON=ON"}
- { matrix_eval : "CC=gcc-10 CXX=g++-10", build_mode: "cmake", cmake_option: "-DNRN_ENABLE_PYTHON=OFF -DNRN_ENABLE_RX3D=OFF -DNRN_ENABLE_CORENEURON=ON"}
Expand Down Expand Up @@ -114,9 +114,14 @@ jobs:
brew install openmpi
brew install --cask xquartz
echo "$(brew --prefix)/opt/flex/bin:$(brew --prefix)/opt/bison/bin" >> $GITHUB_PATH
# Core https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
echo CMAKE_BUILD_PARALLEL_LEVEL=3 >> $GITHUB_ENV
echo CTEST_PARALLEL_LEVEL=3 >> $GITHUB_ENV
# Core https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
if [[ "${{matrix.os}}" == "macOS-13" ]]; then
echo CMAKE_BUILD_PARALLEL_LEVEL=4 >> $GITHUB_ENV
echo CTEST_PARALLEL_LEVEL=4 >> $GITHUB_ENV
else
echo CMAKE_BUILD_PARALLEL_LEVEL=3 >> $GITHUB_ENV
echo CTEST_PARALLEL_LEVEL=3 >> $GITHUB_ENV
fi
echo CI_OS_NAME=osx >> $GITHUB_ENV
shell: bash

Expand All @@ -130,9 +135,9 @@ jobs:
if [[ "${{matrix.os}}" == "ubuntu-20.04" ]]; then
sudo apt-get install g++-7 g++-8
fi
# Core https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
echo CMAKE_BUILD_PARALLEL_LEVEL=2 >> $GITHUB_ENV
echo CTEST_PARALLEL_LEVEL=2 >> $GITHUB_ENV
# Core https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
echo CMAKE_BUILD_PARALLEL_LEVEL=4 >> $GITHUB_ENV
echo CTEST_PARALLEL_LEVEL=4 >> $GITHUB_ENV
echo CI_OS_NAME=linux >> $GITHUB_ENV
shell: bash

Expand Down Expand Up @@ -171,12 +176,27 @@ jobs:
python -m pip install --upgrade -r external/nmodl/requirements.txt
python -m pip install --upgrade -r ci_requirements.txt
- name: Install a new automake
# A new automake is needed for python 3.12 because it generate a python script
# called py-compile and the original one is not supporting this version of python
# Once ubuntu got a newer version of automake we can remove this part.
if: matrix.config.music == 'ON' && startsWith(matrix.os, 'ubuntu')
run: |
curl -L -o automake.tar.xz https://ftp.gnu.org/gnu/automake/automake-1.16.5.tar.xz
tar -xf automake.tar.xz
cd automake-1.16.5/
./configure --prefix=/usr/
make -j
sudo make -j install
automake --version
working-directory: ${{runner.temp}}

- name: Setup MUSIC@${{ env.MUSIC_VERSION }}
if: matrix.config.music == 'ON'
run: |
python3 -m venv music-venv
source music-venv/bin/activate
python3 -m pip install mpi4py "cython<3" numpy
python3 -m pip install mpi4py "cython<3" 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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Set up Python3
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'

- name: Download Dependencies
run: |
Expand Down
1 change: 1 addition & 0 deletions .sanitizers/undefined.supp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ shift-base:nrnRan4int
unsigned-integer-overflow:_philox4x32bumpkey(r123array2x32)
unsigned-integer-overflow:coreneuron::nrnran123_deletestream(coreneuron::nrnran123_State*, bool)
unsigned-integer-overflow:coreneuron::nrnran123_newstream3(unsigned int, unsigned int, unsigned int, bool)
unsigned-integer-overflow:Py_INCREF(_object*)
vptr:NetCon::disconnect(ivObservable*)
vptr:ObjObservable::object()
vptr:PreSyn::disconnect(ivObservable*)
1 change: 1 addition & 0 deletions cmake/MacroHelper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ macro(nocmodl_mod_to_cpp modfile_basename)
COMMAND ${CMAKE_COMMAND} -E ${REMOVE_CMAKE_COMMAND}
${PROJECT_SOURCE_DIR}/${modfile_basename}.cpp
DEPENDS nocmodl ${PROJECT_SOURCE_DIR}/${modfile_basename}.mod
${PROJECT_BINARY_DIR}/share/nrn/lib/nrnunits.lib
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/src/nrniv)
endmacro()

Expand Down
2 changes: 1 addition & 1 deletion external/nmodl
Submodule nmodl updated 1 files
+1 −1 requirements.txt
2 changes: 1 addition & 1 deletion nrn_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ bokeh<3
ipython
cython<3
packaging
pytest
pytest<=8.1.1 # potential bug from 8.2.0 due to parallelism?
pytest-cov
mpi4py
numpy
Expand Down
20 changes: 18 additions & 2 deletions share/lib/python/neuron/rxd/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,14 @@ def __repr__(self):
def _short_repr(self):
return "Extracellular"

def volume(self, index):
def volume(self, index=None):
"""Returns the volume of the voxel at a given index"""
if index is None:
if numpy.isscalar(self.alpha):
vol = self._nx * self._ny * self._nz * numpy.prod(self._dx) * self.alpha
else:
vol = numpy.sum(self.alpha) * numpy.prod(self._dx)
return vol
if numpy.isscalar(self.alpha):
return numpy.prod(self._dx) * self.alpha
return numpy.prod(self._dx) * self.alpha[index]
Expand Down Expand Up @@ -1000,6 +1006,16 @@ def secs(self, value):
else:
raise RxDException("Cannot set secs now; model already instantiated")

def volume(self, index):
def volume(self, index=None):
"""Returns the volume of the voxel at a given index"""
initializer._do_init()
if index is None:
vol = 0
if hasattr(self, "_vol") and any(self._secs3d):
vol += numpy.sum(self._vol)
if hasattr(self, "_geometry") and any(self._secs1d):
vol += numpy.sum(
[self._geometry.volumes1d(sec) for sec in self._secs1d]
)
return vol
return self._vol[index]
26 changes: 14 additions & 12 deletions share/lib/python/neuron/rxd/rxd.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,25 +905,27 @@ def _setup_matrices():
num_3d_indices_per_1d_seg = numpy.asarray(
num_3d_indices_per_1d_seg, dtype=numpy.int64
)
hybrid_grid_ids.append(-1)
hybrid_grid_ids = numpy.asarray(hybrid_grid_ids, dtype=numpy.int64)

hybrid_indices3d = numpy.asarray(hybrid_indices3d, dtype=numpy.int64)
rates = numpy.asarray(rates, dtype=float)
volumes1d = numpy.asarray(volumes1d, dtype=float)
volumes3d = numpy.asarray(volumes3d, dtype=float)
dxs = numpy.asarray(grids_dx, dtype=float)
set_hybrid_data(
num_1d_indices_per_grid,
num_3d_indices_per_grid,
hybrid_indices1d,
hybrid_indices3d,
num_3d_indices_per_1d_seg,
hybrid_grid_ids,
rates,
volumes1d,
volumes3d,
dxs,
)
if hybrid_grid_ids.size > 1:
set_hybrid_data(
num_1d_indices_per_grid,
num_3d_indices_per_grid,
hybrid_indices1d,
hybrid_indices3d,
num_3d_indices_per_1d_seg,
hybrid_grid_ids,
rates,
volumes1d,
volumes3d,
dxs,
)

# TODO: Replace this this to handle 1d/3d hybrid models
"""
Expand Down
7 changes: 4 additions & 3 deletions src/nrniv/nrnpy.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include <string_view>
#include <vector>
/**
* Declarations of global symbols in NEURON that have to be populated with python-version-specific
* values when dynamic Python is enabled. These are set by the nrnpython_reg_real function, and
Expand All @@ -24,7 +25,7 @@ namespace neuron::python {
struct impl_ptrs {
Object* (*callable_with_args)(Object*, int narg){};
double (*call_func)(Object*, int, int*){};
char* (*call_picklef)(char*, std::size_t size, int narg, std::size_t* retsize){};
std::vector<char> (*call_picklef)(const std::vector<char>&, int narg){};
void (*call_python_with_section)(Object*, Section*){};
void (*cmdtool)(Object*, int type, double x, double y, int kd){};
int (*guigetstr)(Object*, char**){};
Expand All @@ -43,9 +44,9 @@ struct impl_ptrs {
Object* (*mpi_alltoall_type)(int, int){};
double (*object_to_double)(Object*){};
void* (*opaque_obj2pyobj)(Object*){};
Object* (*pickle2po)(char*, std::size_t size){};
Object* (*pickle2po)(const std::vector<char>&){};
Object* (*po2ho)(PyObject*){};
char* (*po2pickle)(Object*, std::size_t* size){};
std::vector<char> (*po2pickle)(Object*){};
double (*praxis_efun)(Object* pycallable, Object* hvec){};
int (*pysame)(Object* o1, Object* o2){};
void (*py2n_component)(Object*, Symbol*, int, int){};
Expand Down
Loading

0 comments on commit 38b8867

Please sign in to comment.