Skip to main content

Build Status Documentation Status Ruff codecov

Drop in replacement

*No ducks were punched during the construction of this monkey patch.

Installation

pip install nrn-patch

Minimal requirements

  • Python 3.8+
  • NEURON 9.0+

Philosophy

Pythonic reinvention of the NEURON Python interface:

  • Drop-in replacement: No breaking changes between Patch and NEURON. All your code works as is. Patch automagically fixes bugs and reduces complexity in NEURON by having an opinion, and adds new convenient methods.
  • Loud errors: silent failures and gotchas are caught and raise loud errors; so that when it runs, it runs.
  • Strong referencing: Objects connected to each other will never disappear until you disconnect them.
  • Demystified: The simplest form of each instruction does the most obvious thing. Patch frequently replaces 5 or more undocumented mystical voodoo steps by 1 clearly named function.
  • Just add water: Serial or parallel, doesn't matter, p.run() will run your simulation with no extra steps. No load_file, finitialize, fadvance, run, continuerun, tstop, set_maxstep, setup_transfer, setgid2node, gid_connect, cell, outputcell, psolve required.

Basic usage

Use it like you would use NEURON. The wrapper doesn't make any changes to the interface, it just patches up some of the more frequent and ridiculous gotchas.

Patch supplies a new interpreter p, the PythonHocInterpreter which wraps the standard HOC interpreter h provided by NEURON. Any objects returned will either be PythonHocObject's wrapping their corresponding NEURON object, or whatever NEURON returns.

When using just Patch the difference between NEURON and Patch objects is handled transparently, but if you wish to mix interpreters you can transform all Patch objects back to NEURON objects with obj.__neuron__(), or the transform function.

Example

from patch import p
import glia as g

section = p.Section()
point_process = g.insert(section, "AMPA")
point_process.stimulate(start=10, number=5, interval=10, weight=0.04)

.stimulate creates both the NetCon and NetStim, and sets their properties, and stores references to eachother so that Python doesn't garbage collect anything until we're done with it.

Even when you forget to set values, the Patch defaults have a visible effect. Here we forget to set the duration of a voltage clamp, but by default it will be active the first 100ms of the simulation, so that you can see that the voltage clamp is in fact inserted and working, but you forgot to set the duration:

section.vclamp(holding=-70, voltage=20)

Metadata

Release files for nrn-patch 8.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nrn-patch 8.1.0
File Size Uploaded Provenance Actions
nrn_patch-8.1.0.tar.gz 21.3 kB Without provenance Details for nrn_patch-8.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nrn-patch 8.1.0
File Interpreter ABI Platform Actions
nrn_patch-8.1.0-py3-none-any.whl Python 3 none any Details for nrn_patch-8.1.0-py3-none-any.whl

Total release size: 44.3 kB

Release files / nrn_patch-8.1.0.tar.gz

Download URL nrn_patch-8.1.0.tar.gz
Size 21.3 kB
Tags Source
SHA-256 checksum
How to use checksums
559f8c150e6d8c3f25718fbaefda222e8d8468354472b4b29508f15f0dad844b
BLAKE2b-256 checksum
How to use checksums
e84451393f4323f29a3f47a18acf74878503776292bee9e1cda894e6230172dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / nrn_patch-8.1.0-py3-none-any.whl

Download URL nrn_patch-8.1.0-py3-none-any.whl
Size 23.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5a876a2d5f5fe40a6635c2e58a5fb83062aa92a002cfdef195e5fa707d55876a
BLAKE2b-256 checksum
How to use checksums
4ad304746716d21c7a543861e262b4d563f6a50cf508d5e67f3ed69ad2cc20cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for nrn-patch 8.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

8.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page