Configuration#

Using the command line you can see the available options using the --help flag. For example

!gotranx --help
                                                                                
 Usage: gotranx [OPTIONS] COMMAND [ARGS]...                                     
                                                                                
╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --version                     Show version                                   │
│ --license                     Show license                                   │
│ --install-completion          Install completion for the current shell.      │
│ --show-completion             Show completion for the current shell, to copy │
│                               it or customize the installation.              │
│ --help                        Show this message and exit.                    │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────╮
│ convert                                                                      │
│ cellml2ode                                                                   │
│ ode2cellml                                                                   │
│ ode2py                                                                       │
│ ode2c                                                                        │
│ ode2julia                                                                    │
│ ode2cytozoo                                                                  │
│ ode2mtk                                                                      │
│ list-schemes                                                                 │
│ inspect                                                                      │
│ ode2md                                                                       │
│ ode2ufl                                                                      │
╰──────────────────────────────────────────────────────────────────────────────╯

or more specifically

!gotranx ode2py --help
                                                                                
 Usage: gotranx ode2py [OPTIONS] [fname]                                        
                                                                                
╭─ Arguments ──────────────────────────────────────────────────────────────────╮
│   fname      <file>                                                          │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --outname         -o                      <str>            Output name       │
│ --remove-unused                                            Remove unused     │
│                                                            variables         │
│ --remove-singul…      --no-remove-sin…                     Replace a small   │
│                                                            neighborhood of   │
│                                                            every removable   │
│                                                            singularity (e.g. │
│                                                            x/(exp(x) - 1) at │
│                                                            x = 0) with a     │
│                                                            truncated Taylor  │
│                                                            series            │
│                                                            [default:         │
│                                                            remove-singulari… │
│ --version                                                  Show version      │
│ --license                                                  Show license      │
│ --config          -c                      <path>           Read              │
│                                                            configuration     │
│                                                            options from a    │
│                                                            configuration     │
│                                                            file              │
│ --verbose         -v                                       Verbose output    │
│ --scheme                                  <explicit_euler  Numerical scheme  │
│                                           |generalized_ru  for solving the   │
│                                           sh_larsen|forwa  ODE               │
│                                           rd_explicit_eul                    │
│                                           er|forward_gene                    │
│                                           ralized_rush_la                    │
│                                           rsen|hybrid_rus                    │
│                                           h_larsen>                          │
│ --stiff-states    -s                      <str>            Stiff states for  │
│                                                            the hybrid rush   │
│                                                            larsen scheme     │
│ --delta                                   <float>          Delta value for   │
│                                                            the rush larsen   │
│                                                            schemes           │
│                                                            [default: 1e-08]  │
│ --cse                 --no-cse                             Factor out        │
│                                                            subexpressions    │
│                                                            shared by the     │
│                                                            linearized        │
│                                                            expressions in    │
│                                                            the rush larsen   │
│                                                            schemes. --no-cse │
│                                                            inlines them      │
│                                                            instead, emitting │
│                                                            no temporaries    │
│                                                            [default: cse]    │
│ --format          -f                      <black|ruff|non  Formatter for the │
│                                           e>               output code       │
│                                                            [default: black]  │
│ --backend         -b                      <numpy|jax>      Backend for the   │
│                                                            generated code    │
│                                                            [default: numpy]  │
│ --shape           -S                      <dynamic|single  Shape of the      │
│                                           |multiple>       output arrays     │
│                                                            [default:         │
│                                                            dynamic]          │
│ --help                                                     Show this message │
│                                                            and exit.         │
╰──────────────────────────────────────────────────────────────────────────────╯

Specify configurations in pyproject.toml#

It is also possible to specify the options in your pyproject.toml, e.g

# pyproject.toml

[tool.gotranx]
verbose = true
delta = 1e-6
scheme = [
    "explicit_euler",
    "generalized_rush_larsen",
    "hybrid_rush_larsen",
]
stiff_states = [
    "m",
    "h",
    "j",
]
cse = true
remove_singularities = true

[tool.gotranx.python]
format = "ruff"

[tool.gotranx.c]
format = "clang-format"

This will override any arguments passed from the command line. If you want to specify another configuration file, you can also pass the --config (or -c) flag where you specify a configuration file, e.g

gotranx ode2py file.ode -c folder/pyproject.toml

Options#

General options (under tool.gotranx)#

  • verbose (boolean, default: false): If True display more logging

  • scheme (list[str], default: []): Which schemes to include, see

!gotranx list-schemes
                                     Scheme                                     
┏━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Name                    ┃ Key                     ┃ Extra args               ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ Explicit Euler          │ explicit_euler          │ []                       │
│ Generalized Rush Larsen │ generalized_rush_larsen │ ['delta', 'cse']         │
│ Hybrid Rush Larsen      │ hybrid_rush_larsen      │ ['delta',                │
│                         │                         │ 'stiff_states', 'cse']   │
└─────────────────────────┴─────────────────────────┴──────────────────────────┘
  • delta (float, default: 1e-8): Tolerance for zero division check in Rush-Larsen schemes

  • stiff_states: (list[str], default: []): List of states where to apply the Rush-Larsen scheme for Hybrid Rush Larsen

  • cse (bool, default: true): Factor out subexpressions shared by the linearized expressions in the Rush-Larsen schemes, using one common-subexpression elimination pass across all states at once. false inlines them instead, which emits no temporaries at all but costs far more operations — worth it only on the vectorized numpy backend, where every temporary is a live array

  • remove_singularities (bool, default: true): Replace a small neighborhood of every removable singularity – a gate rate like (V + 10)/(exp((V + 10)/10) - 1) at V = -10, or a GHK flux at v = 0 – with a truncated Taylor series. Without it the generated code divides by zero at exactly that point (numpy warns and returns nan; numba crashes), and the Rush-Larsen linearization is wrong by an O(1) amount, possibly with the wrong sign, in a neighborhood of it. false emits the expressions exactly as written. Must be a boolean: "false" is rejected rather than read as a truthy string

Python specific options (under tool.gotranx.python)#

  • format (str, default: black). Formatter to use for the python code

import gotranx

print(gotranx.codegen.PythonFormat._member_names_)
['black', 'ruff', 'none']
  • backend (str, default: numpy). Backend to use for the python code

import gotranx

print(gotranx.cli.gotran2py.Backend._member_names_)
['numpy', 'jax']

C specific options (under tool.gotranx.c)#

  • format (str, default: clang-format). Formatter to use for the C code

import gotranx

print(gotranx.codegen.CFormat._member_names_)
['clang_format', 'none']
  • to (str, default .h). Whether to save the C code to a .c or .h file

CytoZoo specific options (under tool.gotranx.cytozoo)#

  • model_name (str, default: the ODE’s name in PascalCase). Name of the generated Julia struct. Must be a valid Julia identifier – an ODE named e.g. 1962_noble pascal-cases to 1962Noble, which is rejected rather than emitted as a struct that Julia cannot parse

  • v_name (str, default: v). Name of the state holding the transmembrane potential