Skip to content

CTNG cleanup - #3564

Merged
ramcdougal merged 37 commits into
masterfrom
ctngcleanup
May 20, 2026
Merged

CTNG cleanup#3564
ramcdougal merged 37 commits into
masterfrom
ctngcleanup

Conversation

@ramcdougal

@ramcdougal ramcdougal commented Aug 10, 2025

Copy link
Copy Markdown
Member

Removed legacy code, updated to Cython3, refactored large functions, updated string formatting to use f-strings.

@ramcdougal ramcdougal added wip rxd reaction-diffusion cython labels Aug 10, 2025
@ramcdougal
ramcdougal marked this pull request as draft August 10, 2025 16:09
@github-actions

Copy link
Copy Markdown
Contributor

✔️ 71d0c5f -> artifacts URL

@github-actions

Copy link
Copy Markdown
Contributor

✔️ 6287d70 -> artifacts URL

@azure-pipelines

Copy link
Copy Markdown

✔️ 6287d70 -> Azure artifacts URL

@github-actions

Copy link
Copy Markdown
Contributor

✔️ 8a96a8b -> artifacts URL

@github-actions

Copy link
Copy Markdown
Contributor

✔️ 6b95fe3 -> artifacts URL

@github-actions

Copy link
Copy Markdown
Contributor

✔️ ece47a1 -> artifacts URL

@github-actions

Copy link
Copy Markdown
Contributor

✔️ 529a0e8 -> artifacts URL

@github-actions

Copy link
Copy Markdown
Contributor

✔️ 5d91d74 -> artifacts URL

@ramcdougal

Copy link
Copy Markdown
Member Author

The rationale for all this is that cleaning up the code will make it easier to work on it further. In particular, the mesh creation for CTNG could be done in parallel (although this is a little complicated by the flood fill approach, but we could definitely do it for the surface voxels).

@ramcdougal ramcdougal removed the wip label Aug 12, 2025

@nrnhines nrnhines left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I fully understand but this approval allows you to keep moving forward :)

Comment thread share/lib/python/neuron/rxd/geometry3d/ctng.pyx Outdated
Comment thread share/lib/python/neuron/rxd/geometry3d/ctng.pyx Outdated
Comment thread share/lib/python/neuron/rxd/geometry3d/ctng.pyx
Comment thread share/lib/python/neuron/rxd/geometry3d/triangularMesh.py
Comment thread share/lib/python/neuron/rxd/geometry3d/surface.py Outdated
Comment thread share/lib/python/neuron/rxd/geometry3d/surfaces.pyx Outdated
Comment thread share/lib/python/neuron/rxd/geometry3d/triangularMesh.py Outdated
@github-actions

Copy link
Copy Markdown
Contributor

✔️ 624b572 -> artifacts URL

@azure-pipelines

Copy link
Copy Markdown

✔️ 624b572 -> Azure artifacts URL

@github-actions

Copy link
Copy Markdown
Contributor

✔️ d6ccecd -> artifacts URL

@azure-pipelines

Copy link
Copy Markdown

✔️ d6ccecd -> Azure artifacts URL

@github-actions

Copy link
Copy Markdown
Contributor

✔️ 2bbe75b -> artifacts URL

@azure-pipelines

Copy link
Copy Markdown

✔️ 2bbe75b -> Azure artifacts URL

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

✔️ 1f59aca -> artifacts URL

@github-actions

Copy link
Copy Markdown
Contributor

✔️ 7a98c1d -> artifacts URL

@azure-pipelines

Copy link
Copy Markdown

✔️ 7a98c1d -> Azure artifacts URL

@ramcdougal
ramcdougal enabled auto-merge (squash) May 20, 2026 16:27
@sonarqubecloud

Copy link
Copy Markdown

@azure-pipelines

Copy link
Copy Markdown

✔️ 6a20b49 -> Azure artifacts URL

@github-actions

Copy link
Copy Markdown
Contributor

✔️ 6a20b49 -> artifacts URL

@ramcdougal
ramcdougal merged commit 4c45e7d into master May 20, 2026
44 checks passed
@ramcdougal
ramcdougal deleted the ctngcleanup branch May 20, 2026 18:48
@ramcdougal ramcdougal mentioned this pull request Jul 6, 2026
61 tasks
nrnhines added a commit that referenced this pull request Jul 21, 2026
* Fix Python extension library name (#3679)

When generating the name of the NEURON Python libraries (like `hoc.cp313.so`),
we make use of `CMAKE_LIBRARY_ARCHITECTURE`. On Fedora with the clang compiler,
`CMAKE_LIBRARY_ARCHITECTURE` is set to `x86_64-redhat-linux-gnu`, but Python
does not recognize this extension when importing:

```
$ python -c 'import importlib.machinery;print(importlib.machinery.EXTENSION_SUFFIXES)'
['.cpython-313-x86_64-linux-gnu.so', '.abi3.so', '.so']
```

The solution is to not rely on `CMAKE_LIBRARY_ARCHITECTURE` and just always set
the extension to `${ARCH}-linux-gnu`, which should be importable in Python on
all "reasonable" Linux platforms.

* Bump urllib3 from 2.5.0 to 2.6.0 in /ci (#3681)

* Bump urllib3 from 2.5.0 to 2.6.0 in /ci

Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.5.0 to 2.6.0.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](urllib3/urllib3@2.5.0...2.6.0)

---
updated-dependencies:
- dependency-name: urllib3
  dependency-version: 2.6.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* Ownership

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Goran Jelic-Cizmek <goran.jelic-cizmek@epfl.ch>

* Add NMODL development guide (#3683)

* Bump urllib3 from 2.6.0 to 2.6.3 in /ci (#3693)

* Bump urllib3 from 2.6.0 to 2.6.3 in /ci

Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.6.0 to 2.6.3.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](urllib3/urllib3@2.6.0...2.6.3)

---
updated-dependencies:
- dependency-name: urllib3
  dependency-version: 2.6.3
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* Retrigger CI

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: nrnhines <michael.hines@yale.edu>

* NMODL: Handle `state_discontinuity` call in NET_RECEIVE block (#3592)

* Fix the Neumann BC in the x-direction of fixed step extracellular diffusion. (#3690)


* Update ECS node volume access and testdata.

* Update data for neuron.test_rxd().

* Bump bokeh from 3.7.2 to 3.8.2 in /ci (#3691)

Bumps [bokeh](https://github.com/bokeh/bokeh) from 3.7.2 to 3.8.2.
- [Changelog](https://github.com/bokeh/bokeh/blob/3.8.2/docs/CHANGELOG)
- [Commits](bokeh/bokeh@3.7.2...3.8.2)

---
updated-dependencies:
- dependency-name: bokeh
  dependency-version: 3.8.2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: nrnhines <michael.hines@yale.edu>

* NMODL: Add codegen for implicit `diam` and `area` (#3631)

* Add explicit METHOD to SOLVE if target is a DERIVATIVE block (#3600)

* Add unrolling of FROM iteration variables (#3597)

* NMODL: Generalize MergeInitialBlocksVisitor (#3598)

* Add tests

* Fix name collision when merging top-level blocks (#3701)

---------

Co-authored-by: David McDougall <dam1784@rit.edu>

* link updates to readthedocs (#3718)

* How to contribute to Documentation (#3721)

* Update forum link to NEURON discussion board (#3724)

* Bump tornado from 6.5.1 to 6.5.5 in /ci (#3723)

* ci: add conditional Codecov token for Dependabot branches

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: nrnhines <michael.hines@yale.edu>

* link back to forum (#3726)

* ci: for macosx wheels, try to use system clang. (#3730)

* This allows minimization of MACOSX_DEPLOYMENT_TARGET
Otherwise linkage to libunwind with brew clang requires a deployment target of 14

* wheel build  on macos-15 runners: ensure libomp installed

* Path has specifc paths for brew bison and flex

* fix: make Sprintf interpret %% -> % correctly when no args are passed (#3727)

* FAQ comment about GUI. (#3738)

* NMODL: make v, celsius, and dt available in VERBATIM (#3740)

* more neutral language (#3739)

* Bump minimal python to 3.10 (#3745)

* 1.9 -> 1e9 for large dt (#3754)

* removed link to page that doesn't exist in current docs (#3731)

* CTNG cleanup (#3564)

* refactoring into smaller functions and 2->3 updates

* removed legacy code

* removed voxelize and voxelize2 from cmakelists

* corner_pts a list, removed circular imports

* cython shortcuts and minor cleanups

* don't use bisect

* removed numpy array creation from closest_pt and extreme_pts

* don't need numpy for isnan

* xs,ys,zs are numpy array; using memview; removed unused function

* changed % formatting to f-string

* updated cmake documentation link (#3775)

* Python typo fix (#3776)

comma was period

* fix section pushing examples in C API docs (#3785)

* handle segment iteration when no mechs (#3794)

* Fix Vector.min_ind(i1, i2) bug (#3787)


* test of Vector.min_ind(i1, i2)

* Doc warning for Vector.min_ind with example

* SourceForge link is unreliable in CI due to Cloudflare protection

* fix for file type detection on linux and mac (#3788)

On a mac (running Tahoe), the old expression with the escaped < always evaluated to 0. On Linux, it always evaluated to -1. This meant that the macs always thought files were MorphML and Linux never thought they were.

* rxd handles np.float64 and other numpy.generic types (#3808)

* unwrap numpy objects (preserves floats and ints)
* added a test

* Fix install docs: minimum Python version is 3.10 (#3806)


Fixes  issue #3803

Co-authored-by: Grok <grok@x.ai>

* Retry 3 times when downloading from gnu mirrors (#3809)

Update readline to a more modern version (7.0 => 8.3).

Sometimes the mirrors are not really stable so it failed the creation
of wheels on macos

* Fix buffer overflow in output_spikes_parallel with zero spikes (#3813)

Fix: #3812

When `num_spikes == 0`, `malloc(0)` followed by `strcpy(spike_data, "")` triggers glibc's FORTIFY_SOURCE buffer overflow detection on Linux.

## Fix

- Allocate at least 1 byte: `malloc(num_bytes > 0 ? num_bytes : 1)`
- Use direct assignment `spike_data[0] = '\0'` instead of `strcpy`

## Testing

Reproduces in neurodamus CI (`test_v5_coreneuron_no_lfp_smoke`) on Ubuntu when tstop is too short for any cell to fire.

* neuronapi: recompute 3d-derived diam in nrn_segment_diam_get (#3814)

When a section's geometry is defined by 3d points, NEURON rewrites the
segment diam from those points lazily, gated per-section on recalc_area_.
nrn_segment_diam_get returned the range-variable pointer without checking
that flag, so a diam read after pt3dadd (before define_shape/finitialize)
returned a stale default rather than the 3d-derived value.

Mirror the range-variable read path (nrnpy_nrn.cpp): trigger the pending
per-section recompute via nrn_area_ri before reading. Uses the per-section
recalc_area_ flag and nrn_area_ri (not the global diam_changed/recalc_diam,
which rebuilds the whole solver matrix and asserts !tree_changed).

Adds test/api/segment_diam.cpp: a uniform 3d section reads diam 10 both
before and after finitialize. Documents the behavior in capi.rst.

* neuronapi: fix nrn_symbol_dataptr for top-level runtime scalars (#3815)

nrn_symbol_dataptr returned sym->u.pval for every symbol. For a NOTUSER
runtime scalar (created in HOC by e.g. `x = 42`) that union member holds
an object-data offset, not a pointer, so the returned value was a small
integer that segfaults on dereference. The real storage for such a
scalar is hoc_top_level_data[sym->u.oboff].pval, matching the NOTUSER
branch of eval() in oc/code.cpp.

Return that address for the top-level VAR/NOTUSER case so the result is a
dereferenceable double*, as the name promises; every other symbol is
unchanged. A caller can now read and write `x = 42`-style globals through
the pointer, the same as built-in USERDOUBLE scalars like t.

Adds test/api/global_scalar.cpp: a NOTUSER scalar's dataptr now
dereferences to the stored value and aliases the storage HOC reads
(cross-checked by copying into hoc_ac_), plus a USERDOUBLE round-trip.

* Bump version

* formatting
my attempts to resolve a merge conflict broke formatting

* update website to www.neuronsimulator.org (#3818)

* changelog for 9.0.2

date is listed as TBD

* Fixed a MPI bug with MultiCompartmentReaction which produce membrane currents. (#3736)

* Fixed a MPI bug with MultiCompartmentReaction which produce membrane current.

* Avoid increased memory allocation for rxd currents with MPI due to repeated calls.

* Fix some leaks.

* Remove unnecessary check on num_ecs_species

* Replace NULL with nullptr for flux initialization

* Change reaction_indices to nullptr from NULL

* Update changelog in regard to #3736

* coverage.yml token line same as master.
  - Avoid "Token required because branch is protected"

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: JCGoran <JCGoran@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Goran Jelic-Cizmek <goran.jelic-cizmek@epfl.ch>
Co-authored-by: nrnhines <michael.hines@yale.edu>
Co-authored-by: Adam Newton <adam.newton@yale.edu>
Co-authored-by: David McDougall <dam1784@rit.edu>
Co-authored-by: nikhilmishra145 <144335088+nikhilmishra145@users.noreply.github.com>
Co-authored-by: Nicolas Cornu <me@alkino.fr>
Co-authored-by: Grok <grok@x.ai>
Co-authored-by: Alessandro Cattabiani <cattabiani@users.noreply.github.com>
Co-authored-by: E. Cruz <176174870+ec1dev@users.noreply.github.com>
Co-authored-by: Adam Newton <adam.newton@neurosim.downstate.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cython rxd reaction-diffusion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants