Skip to content

Commit

Permalink
Merge branch 'master' into arith_object_flux
Browse files Browse the repository at this point in the history
  • Loading branch information
rgourdine committed Mar 16, 2024
2 parents 798c640 + 17be061 commit aa8c8e4
Show file tree
Hide file tree
Showing 102 changed files with 2,411 additions and 3,181 deletions.
3 changes: 1 addition & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ jobs:
310) pyenv_py_ver="3.10" ;;
311) pyenv_py_ver="3.11" ;;
312) pyenv_py_ver="3.12" ;;
*) echo "Error: pyenv python version not specified!" && exit 1;;
*) echo "Error: pyenv python version not specified or not supported." && exit 1;;
esac
cd /opt/circleci/.pyenv/plugins/python-build/../.. && git fetch --all && git checkout -B master origin/master && cd -
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install $pyenv_py_ver --force
pyenv global $pyenv_py_ver
export PYTHON_EXE=$(which python)
Expand Down
4 changes: 3 additions & 1 deletion .github/ISSUE_TEMPLATE/release-patch.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Pre-release
- [ ] Update semantic version in `CMakeLists.txt`
- [ ] Update changelog below and agree on it with everyone; then commit it to `docs/changelog` in the cherrypicks PR (copy structure as-is)
- [ ] Update `docs/index.rst` accordingly with the new `.pkg` and `.exe` links for `PKG installer` and `Windows Installer`
- [ ] Activate ReadtheDocs for the cherry-pick branch and ensure the documentation builds (when logged in, go to [the versions page](https://readthedocs.org/projects/nrn/versions/) and set the version for your branch to Active and Hidden)
- [ ] Run a test wheel build WITHOUT upload on the cherry-pick branch to ensure all the wheels build ([see details](https://nrn.readthedocs.io/en/latest/install/python_wheels.html#publishing-the-wheels-on-pypi-via-azure))

Sanity checks
---
Expand All @@ -33,7 +35,7 @@ Releasing
- [ ] Build release wheels but WITHOUT upload ([see details](https://nrn.readthedocs.io/en/latest/install/python_wheels.html#publishing-the-wheels-on-pypi-via-azure))
- [ ] Create, test and upload manual artifacts
- [ ] MacOS package installer (manual task, ask Michael)
- [ ] arm64 wheels (manual task, check with Alex or Pramod)
- [ ] arm64 wheels (manual task, check with Erik, Goran or Pramod)
- [ ] aarch64 wheels (use existing `release/x.y-aarch64` branch for this, see [guide](https://nrn.readthedocs.io/en/latest/install/python_wheels.html#publishing-the-wheels-on-pypi-via-circleci))
- [ ] Publish the `x.y.z` wheels on PyPI; see [wheel publishing instructions](https://nrn.readthedocs.io/en/latest/install/python_wheels.html#publishing-the-wheels-on-pypi-via-azure)
- [ ] Once wheels are published, activate the `x.y.z` tag on ReadTheDocs
Expand Down
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Sanity checks
- [ ] Create `release/x.y` branch and make sure GitHub, Azure and CircleCI builds pass
- [ ] Run [nrn-build-ci](https://github.com/neuronsimulator/nrn-build-ci/actions/workflows/build-neuron.yml) for the respective Azure build; see [Azure drop guide](https://github.com/neuronsimulator/nrn-build-ci#azure-wheels-testing---manual-workflow)
- [ ] Activate ReadTheDocs build for `release/x.y` & make it hidden. Check docs are fine after build is done.
- [ ] Run a test wheel build WITHOUT upload for `release/x.y` to ensure all the wheels build ([see details](https://nrn.readthedocs.io/en/latest/install/python_wheels.html#publishing-the-wheels-on-pypi-via-azure))
- [ ] Run BBP Simulation Stack & other relevant tests


Expand All @@ -32,7 +33,7 @@ Releasing
- [ ] Build release wheels but WITHOUT upload ([see details](https://nrn.readthedocs.io/en/latest/install/python_wheels.html#publishing-the-wheels-on-pypi-via-azure))
- [ ] Create, test and upload manual artifacts
- [ ] MacOS package installer (manual task, ask Michael)
- [ ] arm64 wheels (manual task, check with Alex or Pramod)
- [ ] arm64 wheels (manual task, check with Erik, Goran or Pramod)
- [ ] aarch64 wheels (create a `release/x.y-aarch64` branch for this, see [guide](https://nrn.readthedocs.io/en/latest/install/python_wheels.html#publishing-the-wheels-on-pypi-via-circleci))
- [ ] Publish the `x.y.z` wheels on Pypi; see [wheel publishing instructions](https://nrn.readthedocs.io/en/latest/install/python_wheels.html#publishing-the-wheels-on-pypi-via-azure)
- [ ] Once wheels are published, activate the `x.y.z` tag on ReadTheDocs
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: NEURON Code Coverage

concurrency:
group: ${{ github.workflow }}#${{ github.ref }}
# Don't cancel on master, creating a PR when a push workflow is already going will cancel the push workflow in favour of the PR workflow
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.run_id || github.event.number && github.head_ref || github.ref_name }}
cancel-in-progress: true

on:
Expand Down Expand Up @@ -110,7 +111,7 @@ jobs:
python -m pip install --upgrade pip -r nrn_requirements.txt
python -m pip install --upgrade -r external/nmodl/requirements.txt
python -m pip install --upgrade -r ci_requirements.txt
- name: Build & Test
id: build-test
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: NEURON Documentation

concurrency:
group: ${{ github.workflow }}#${{ github.ref }}
# Don't cancel on master, creating a PR when a push workflow is already going will cancel the push workflow in favour of the PR workflow
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.run_id || github.event.number && github.head_ref || github.ref_name }}
cancel-in-progress: true

on:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/external.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: External CIs

concurrency:
group: ${{ github.workflow }}#${{ github.ref }}
# Don't cancel on master, creating a PR when a push workflow is already going will cancel the push workflow in favour of the PR workflow
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.run_id || github.event.number && github.head_ref || github.ref_name }}
cancel-in-progress: true

on:
Expand Down
24 changes: 23 additions & 1 deletion .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: Check formatting

concurrency:
group: ${{ github.workflow }}#${{ github.ref }}
# Don't cancel on master, creating a PR when a push workflow is already going will cancel the push workflow in favour of the PR workflow
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.run_id || github.event.number && github.head_ref || github.ref_name }}
cancel-in-progress: true

on:
Expand All @@ -27,3 +28,24 @@ jobs:
- name: Check formatting
working-directory: ${{runner.workspace}}/nrn
run: external/coding-conventions/bin/format -v --dry-run

# If formatting fails, apply formatting and push changes.
# This will trigger another workflow run, which will cancel the current one.
- name: Apply formatting
working-directory: ${{runner.workspace}}/nrn
if: failure() && github.event_name == 'pull_request'
run: |
# Checkout PR
gh pr checkout ${{ github.event.pull_request.number }}
# Apply formatting
external/coding-conventions/bin/format -v
# Commit & push changes
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -u :/
git commit -a -m "Fix formatting"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23 changes: 6 additions & 17 deletions .github/workflows/neuron-ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: NEURON CI

concurrency:
group: ${{ github.workflow }}#${{ github.ref }}
# Don't cancel on master, creating a PR when a push workflow is already going will cancel the push workflow in favour of the PR workflow
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.run_id || github.event.number && github.head_ref || github.ref_name }}
cancel-in-progress: true

on:
Expand Down Expand Up @@ -89,7 +90,7 @@ jobs:

steps:
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v1
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version : ${{(matrix.config.python_dynamic || matrix.config.build_mode == 'setuptools') && env.DYNAMIC_PYTHON_CMAKE_VERSION || env.DESIRED_CMAKE_VERSION}}

Expand Down Expand Up @@ -196,23 +197,11 @@ jobs:
cat matrix.json
echo -----
# Workaround for https://github.com/actions/cache/issues/92
- name: Checkout cache action
uses: actions/checkout@v4
with:
repository: actions/cache
ref: v3
path: tmp/actions/cache

- name: Make actions/cache@v3 run even on failure
run: |
sed -i'.bak' -e '/ post-if: /d' tmp/actions/cache/action.yml
- name: Restore compiler cache
uses: ./tmp/actions/cache
uses: actions/cache@v4
with:
path: |
${{runner.workspace}}/ccache
path: ${{runner.workspace}}/ccache
save-always: true
key: ${{matrix.os}}-${{hashfiles('matrix.json')}}-${{github.ref}}-${{github.sha}}
restore-keys: |
${{matrix.os}}-${{hashfiles('matrix.json')}}-${{github.ref}}-
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: Windows Installer

concurrency:
group: ${{ github.workflow }}#${{ github.ref }}
# Don't cancel on master, creating a PR when a push workflow is already going will cancel the push workflow in favour of the PR workflow
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.run_id || github.event.number && github.head_ref || github.ref_name }}
cancel-in-progress: true

on:
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ if(NRN_ENABLE_CORENEURON)
get_property(CORENRN_LIB_LINK_FLAGS GLOBAL PROPERTY CORENRN_LIB_LINK_FLAGS)
get_property(CORENRN_NEURON_LINK_FLAGS GLOBAL PROPERTY CORENRN_NEURON_LINK_FLAGS)
get_property(CORENRN_ENABLE_SHARED GLOBAL PROPERTY CORENRN_ENABLE_SHARED)
get_property(CORENRN_NMODL_BINARY GLOBAL PROPERTY CORENRN_NMODL_BINARY)
# NEURON tests that link against CoreNEURON need to depend on it.
set(CORENEURON_TARGET_TO_DEPEND coreneuron-for-tests)

Expand Down
12 changes: 8 additions & 4 deletions bin/nrnivmodl.in
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ mdir="$PWD"

# construct file to be included by makefile to specify mod to c rule when
# executed in $MODSUBDIR (child folder of launch location folder)
# Since $(PWD) may contain spaces in the path name, use the relative path.
# Otherwise, it is very difficult to pass around paths with spaces in
# makefiles. However, to help the user know where things are, when
# compiling use the full path to *.cpp
MODMAKE=makemod2c_inc
> "$MODMAKE"
for i in "${files[@]}" ; do
Expand All @@ -170,13 +174,13 @@ for i in "${files[@]}" ; do
f=${f// /\\ }
f=${f//:/\\:}
echo "\
./${base_name// /\\ }.cpp: ${f}.mod
${base_name// /\\ }.cpp: ${f}.mod \$(NOCMODL)
@printf \" -> \$(C_GREEN)NMODL\$(C_RESET) \$<\\\n\"
(cd \"$dir_name\"; @NRN_NOCMODL_SANITIZER_ENVIRONMENT_STRING@ MODLUNIT=\$(NRNUNITS) \$(NOCMODL) \"$base_name.mod\" -o \"$mdir\" $UserNMODLFLAGS)
./${base_name// /\\ }.o: ./${base_name// /\\ }.cpp
@printf \" -> \$(C_GREEN)Compiling\$(C_RESET) \$<\\\n\"
\$(CXXCOMPILE) -I\"$dir_name\" \$(INCLUDES) @CMAKE_CXX_COMPILE_OPTIONS_PIC@ -c \$< -o \$@
./${base_name// /\\ }.o: ${base_name// /\\ }.cpp
@printf \" -> \$(C_GREEN)Compiling\$(C_RESET) ${PWD}/\$<\\\n\"
\$(CXXCOMPILE) -I\"$dir_name\" \$(INCLUDES) @CMAKE_CXX_COMPILE_OPTIONS_PIC@ -c \"${PWD}/\$<\" -o \$@
" >> "$MODMAKE"
done

Expand Down
6 changes: 3 additions & 3 deletions bin/nrnivmodl_makefile_cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,20 @@ C_GREEN := \033[32m
# Take the main and link with nrnmech.
# RPATH is set for DESTDIR_RPATH and coreneuron lib
special: $(mech_lib)
@printf " => $(C_GREEN)LINKING$(C_RESET) executable $(special) LDFLAGS are: $(LDFLAGS)\n"
@printf " => $(C_GREEN)LINKING$(C_RESET) executable \"${PWD}/$(special)\" LDFLAGS are: $(LDFLAGS)\n"
$(CXX_LINK_EXE) -I $(incdir) -I $(incdir)/nrncvode -DAUTO_DLOPEN_NRNMECH=0 $(datadir)/nrnmain.cpp -o $(special) \
-L$(OBJS_DIR) -l$(mech_libname) $(NRNLIB_FLAGS) -l$(mech_libname) $(extra_lib_link) -Wl,-rpath,'$(DESTDIR_RPATH)' -Wl,-rpath,$(libdir) $(LDFLAGS) $(EXTRA_LDFLAGS)

$(mech_lib): $(mech_lib_type)

mech_lib_shared: mod_func.o $(mod_objs) build_always
@printf " => $(C_GREEN)LINKING$(C_RESET) shared library $(mech_lib)\n"
@printf " => $(C_GREEN)LINKING$(C_RESET) shared library \"${PWD}/$(mech_lib)\"\n"
$(CXX_LINK_SHARED) -I $(incdir) -o ${mech_lib} ${_SONAME} \
$(mod_func_o) $(mod_objs) $(NRNLIB_FLAGS) $(NRNLIB_RPATH_FLAGS) $(LDFLAGS)
rm -f $(OBJS_DIR)/.libs/libnrnmech.so ; mkdir -p $(OBJS_DIR)/.libs ; cp $(mech_lib) $(OBJS_DIR)/.libs/libnrnmech.so

mech_lib_static: mod_func.o $(mod_objs) build_always
@printf " => $(C_GREEN)LINKING$(C_RESET) static library $(mech_lib)\n"
@printf " => $(C_GREEN)LINKING$(C_RESET) static library \"${PWD}/$(mech_lib)\"\n"
ar cq ${mech_lib} $(mod_func_o) $(mod_objs) $(cobjs);

mod_func.o: mod_func.cpp
Expand Down
4 changes: 2 additions & 2 deletions bin/nrnpyenv.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def nrnpylib_mswin():
f = os.popen(cmd)
nrn_pylib = None
for line in f:
if re.search('ython[a-zA-Z0-9_.]*\.dll', line):
if re.search(r'ython[a-zA-Z0-9_.]*\.dll', line):
nrn_pylib = '/'.join(line.split(os.path.sep)).strip()
nrnpylib_provenance="cygcheck"
return nrn_pylib
Expand Down Expand Up @@ -474,7 +474,7 @@ def nrnpylib_linux():
if re.search(r'libpython.*\.so', line):
print ("# from lsof: %s" % line)
nrn_pylib = line.strip()
nrnpylib_provenance = 'lsof search for libpython.*\.so'
nrnpylib_provenance = r'lsof search for libpython.*\.so'
return nrn_pylib
else: # figure it out from the os path
p = os.path.sep.join(os.__file__.split(os.path.sep)[:-1])
Expand Down
Binary file added docs/python/images/rangevarplotrxd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/python/modelspec/programmatic/hocmech.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ HOC-based Mechanisms
Syntax:
``h.make_mechanism("suffix", "Template", "parm1 parm2 parm3 ...")``

``h.make_pointprocess("Name", "Template", "parm1 parm2 parm3 ...")``
``h.make_pointprocess("Template", "parm1 parm2 parm3 ...")``

Description:
Installs the HOC (in particular, *not* Python) class called "Template" as a density membrane mechanism
called "suffix" or a POINT_PROCESS called Name. If the third argument exists it must be a space
called "suffix" or a POINT_PROCESS called "Template". If the last argument exists it must be a space
separated list of public variables in the Template which are to be
treated as PARAMETERs. Public variables not in this list are treated as
ASSIGNED variables. The new mechanism is used in exactly the same
Expand Down
17 changes: 17 additions & 0 deletions docs/python/programming/mechstan.rst
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,23 @@ MechanismStandard (Parameter Control)
----


.. method:: MechanismStandard.is_array


Syntax:
.. code-block::
python
bool = ms.is_array(index)
Description:
Returns True if the variable associated with the index is an array.


----



.. method:: MechanismStandard.name

Expand Down
32 changes: 31 additions & 1 deletion docs/python/visualization/rvarplt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,37 @@ RangeVarPlot
rvp... #specify range begin and end
imp... #specify impedance computation
g = h.Graph()
g.addobject(rvp)
g.addobject(rvp)
Example (plotting a rxd species):
.. code-block::
python
from neuron import h
from neuron import rxd
import matplotlib.pyplot as plt
dend1 = h.Section("dend1")
dend1.nseg =4
cyt1 = rxd.Region(dend1.wholetree(), nrn_region="i")
ca1 = rxd.Species(cyt1, name="ca1", charge=2, initial=1e-12)
ca1.nodes(dend1(0.1))[0].include_flux(40)
ca1.nodes(dend1(0.4))[0].include_flux(-25)
ca1.nodes(dend1(0.7))[0].include_flux(70)
h.finitialize(-65)
h.dt /= 512
h.load_file("stdrun.hoc")
h.continuerun(0.025)
a_1 = h.RangeVarPlot(ca1, dend1(0), dend1(1))
a_1.plot(plt)
plt.show()
.. image:: ../images/rangevarplotrxd.png
:align: center

----

Expand Down
2 changes: 1 addition & 1 deletion external/iv
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ def setup_package():
else "node-and-date"
},
cmdclass=dict(build_ext=CMakeAugmentedBuilder, docs=Docs),
install_requires=["numpy>=1.9.3", "packaging", "find_libpython"],
install_requires=["numpy>=1.9.3", "packaging", "find_libpython", "setuptools"],
tests_require=["flake8", "pytest"],
setup_requires=["wheel", "setuptools_scm"]
+ maybe_docs
Expand Down
3 changes: 3 additions & 0 deletions share/lib/python/neuron/rxd/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,9 @@ def volume(self):
def segment(self):
return self._sec._sec(self.x)

def _in_seg(self, segment):
return segment == self.segment

@property
def surface_area(self):
"""The surface area of the compartment in square microns.
Expand Down
27 changes: 27 additions & 0 deletions share/lib/python/neuron/tests/utils/coreneuron_available.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Check if coreneuron is enabled in the current installation
# and loadable at runtime. This may not be the case if we
# build static library of the coreneuron.

from neuron import config, h


def coreneuron_available():
if not config.arguments["NRN_ENABLE_CORENEURON"]:
return False
# But can it be loaded?
cvode = h.CVode()
pc = h.ParallelContext()
h.finitialize()
result = 0
import sys
from io import StringIO

original_stderr = sys.stderr
sys.stderr = StringIO()
try:
pc.nrncore_run("--tstop 1 --verbose 0")
result = 1
except Exception as e:
pass
sys.stderr = original_stderr
return result
2 changes: 1 addition & 1 deletion src/coreneuron/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ else()
FILES ${NMODL_PROJECT_BINARY_DIR}/share/nmodl/nrnunits.lib
DESTINATION share/nmodl
COMPONENT nrnunits)

endif()
set_property(GLOBAL PROPERTY CORENRN_NMODL_BINARY "${CORENRN_NMODL_BINARY}")

# set correct arguments for nmodl for cpu/gpu target
set(CORENRN_NMODL_FLAGS
Expand Down
Loading

0 comments on commit aa8c8e4

Please sign in to comment.