nrn-patch


Namenrn-patch JSON
Version 6.0.4 PyPI version JSON
download
home_pageNone
SummaryQuality of life patch for the NEURON simulator.
upload_time2025-07-31 17:39:40
maintainerNone
docs_urlNone
authorNone
requires_python<4,>=3.10
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Build Status](https://github.com/dbbs-lab/bsb/actions/workflows/main.yml/badge.svg)](https://github.com/dbbs-lab/bsb/actions/workflows/main.yml)
[![Documentation Status](https://readthedocs.org/projects/patch/badge/?version=latest)](https://patch.readthedocs.io/en/latest/?badge=latest)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![codecov](https://codecov.io/gh/Helveg/patch/branch/master/graph/badge.svg)](https://codecov.io/gh/Helveg/patch)


![Drop in replacement](patch.gif)

_*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

``` python
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)
```


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "nrn-patch",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Robin De Schepper <robin@alexandria.sc>",
    "download_url": "https://files.pythonhosted.org/packages/02/cc/b9a3e84ff44bf744459b95e92f0194c442ba1ebf4e705b557926b125b86a/nrn_patch-6.0.4.tar.gz",
    "platform": null,
    "description": "[![Build Status](https://github.com/dbbs-lab/bsb/actions/workflows/main.yml/badge.svg)](https://github.com/dbbs-lab/bsb/actions/workflows/main.yml)\n[![Documentation Status](https://readthedocs.org/projects/patch/badge/?version=latest)](https://patch.readthedocs.io/en/latest/?badge=latest)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![codecov](https://codecov.io/gh/Helveg/patch/branch/master/graph/badge.svg)](https://codecov.io/gh/Helveg/patch)\n\n\n![Drop in replacement](patch.gif)\n\n_*No ducks were punched during the construction of this monkey patch._\n\n# Installation\n\n```\npip install nrn-patch\n```\n\n## Minimal requirements\n\n* Python 3.8+\n* NEURON 9.0+\n\n# Philosophy\n\nPythonic reinvention of the NEURON Python interface:\n\n  - **Drop-in replacement:** No breaking changes between Patch and NEURON. All\n    your code works as is. Patch automagically fixes bugs and reduces\n    complexity in NEURON by having an opinion, and adds new convenient methods.\n  - **Loud errors:** silent failures and gotchas are caught and raise\n    loud errors; so that when it runs, it runs.\n  - **Strong referencing:** Objects connected to each other will never disappear\n    until you disconnect them.\n  - **Demystified:** The simplest form of each instruction does the most obvious thing.\n    Patch frequently replaces 5 or more undocumented mystical voodoo steps by 1 clearly named function.\n  - **Just add water:** Serial or parallel, doesn't matter, `p.run()` will run your\n    simulation with no extra steps. No `load_file`, `finitialize`, `fadvance`, `run`,\n    `continuerun`, `tstop`, `set_maxstep`, `setup_transfer`, `setgid2node`, `gid_connect`,\n    `cell`, `outputcell`, `psolve` required.\n\n# Basic usage\n\nUse it like you would use NEURON. The wrapper doesn't make any changes to the interface,\nit just patches up some of the more frequent and ridiculous gotchas.\n\nPatch supplies a new interpreter `p`, the `PythonHocInterpreter` which wraps the\nstandard HOC interpreter `h` provided by NEURON. Any objects returned will either be\n`PythonHocObject`'s wrapping their corresponding NEURON object, or whatever NEURON\nreturns.\n\nWhen using just Patch the difference between NEURON and Patch objects is handled\ntransparently, but if you wish to mix interpreters you can transform all Patch objects\nback to NEURON objects with `obj.__neuron__()`, or the `transform` function.\n\n## Example\n\n``` python\nfrom patch import p\nimport glia as g\n\nsection = p.Section()\npoint_process = g.insert(section, \"AMPA\")\npoint_process.stimulate(start=10, number=5, interval=10, weight=0.04)\n```\n\n`.stimulate` creates both the `NetCon` and `NetStim`, and sets their properties, and\nstores references to eachother so that Python doesn't garbage collect anything\nuntil we're done with it.\n\nEven when you forget to set values, the Patch defaults have a visible effect.\nHere we forget to set the duration of a voltage clamp, but by default it will\nbe active the first 100ms of the simulation, so that you can see that the voltage\nclamp is in fact inserted and working, but you forgot to set the duration:\n\n```\nsection.vclamp(holding=-70, voltage=20)\n```\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Quality of life patch for the NEURON simulator.",
    "version": "6.0.4",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2986a59ad2ff4b3e2896f2af881ef12abb7c8e53afb7771f67bf2ce5001b0b05",
                "md5": "b8b996b6868a79de10ace9ae7de6dc90",
                "sha256": "404ef9e03ae4ed577443851f055d0ed0f9a6ce7be43634cdc28b763ff3501e23"
            },
            "downloads": -1,
            "filename": "nrn_patch-6.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b8b996b6868a79de10ace9ae7de6dc90",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.10",
            "size": 23011,
            "upload_time": "2025-07-31T17:39:38",
            "upload_time_iso_8601": "2025-07-31T17:39:38.220918Z",
            "url": "https://files.pythonhosted.org/packages/29/86/a59ad2ff4b3e2896f2af881ef12abb7c8e53afb7771f67bf2ce5001b0b05/nrn_patch-6.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "02ccb9a3e84ff44bf744459b95e92f0194c442ba1ebf4e705b557926b125b86a",
                "md5": "1071309d3500c53ac137fca768ca004a",
                "sha256": "4fcd752249ad3e4def628da7e2ded9f70303f59c628d20c76dec4b30c4e729d5"
            },
            "downloads": -1,
            "filename": "nrn_patch-6.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "1071309d3500c53ac137fca768ca004a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.10",
            "size": 21246,
            "upload_time": "2025-07-31T17:39:40",
            "upload_time_iso_8601": "2025-07-31T17:39:40.199017Z",
            "url": "https://files.pythonhosted.org/packages/02/cc/b9a3e84ff44bf744459b95e92f0194c442ba1ebf4e705b557926b125b86a/nrn_patch-6.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-31 17:39:40",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "nrn-patch"
}
        
Elapsed time: 1.26484s