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 <bool> Show version │
│ --license <bool> Show license │
│ --install-completion <bool> Install completion for the current │
│ shell. │
│ --show-completion <bool> Show completion for the current shell, │
│ to copy it or customize the │
│ installation. │
│ --help <bool> Show this message and exit. │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────╮
│ convert │
│ cellml2ode │
│ ode2cellml │
│ ode2py │
│ ode2c │
│ ode2cpp │
│ ode2cuda │
│ 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 <bool> Remove unused │
│ variables │
│ --remove-singul… --no-remove-sin… <bool> 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 <bool> Show version │
│ --license <bool> Show license │
│ --config -c <path> Read │
│ configuration │
│ options from a │
│ configuration │
│ file │
│ --verbose -v <bool> Verbose output │
│ --scheme <list[explicit_ Numerical scheme │
│ euler|generaliz for solving the │
│ ed_rush_larsen| ODE │
│ forward_explici │
│ t_euler|forward │
│ _generalized_ru │
│ sh_larsen|hybri │
│ d_rush_larsen]> │
│ --stiff-states -s <list[str]> Stiff states for │
│ the hybrid rush │
│ larsen scheme │
│ --delta <float> Delta value for │
│ the rush larsen │
│ schemes │
│ [default: 1e-08] │
│ --cse --no-cse <bool> 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 <bool> 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"
[tool.gotranx.cpp]
format = "clang-format"
float_type = "double"
[tool.gotranx.cuda]
format = "clang-format"
float_type = "float"
Without --config, gotranx reads the nearest pyproject.toml that has a [tool.gotranx] table, looking in the current directory and then in each of its parents.
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 loggingscheme(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 schemesstiff_states: (list[str], default: []): List of states where to apply the Rush-Larsen scheme for Hybrid Rush Larsencse(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.falseinlines 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 arrayremove_singularities(bool, default:true): Replace a small neighborhood of every removable singularity – a gate rate like(V + 10)/(exp((V + 10)/10) - 1)atV = -10, or a GHK flux atv = 0– with a truncated Taylor series. Without it the generated code divides by zero at exactly that point (numpy warns and returnsnan; numba crashes), and the Rush-Larsen linearization is wrong by an O(1) amount, possibly with the wrong sign, in a neighborhood of it. A pole inside a branch of aConditionalis guarded within that branch, so a model’s own guard such asConditional(Gt(B, 1e-12), x/B, 0), whose branchx/Bhas a genuine pole, is left as written.falseemits 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.cor.hfile
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_noblepascal-cases to1962Noble, which is rejected rather than emitted as astructthat Julia cannot parsev_name(str, default:v). Name of the state holding the transmembrane potentialsupertype(str, default:AbstractCardiacCellModel). Julia supertype of the generated struct, a bare or dotted name. Any other value must be in scope where the generated file is included. Overrides--supertypeno_potential(bool, default:false). Generate a model without a transmembrane potential, for a part or a model that is not a cardiac cell. Overrides--no-potential, and combining it with an explicitv_name(from the configuration or the command line) is an error