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 ───────────────────────────────────────────────────────────────────╮
 cellml2ode                                                                   
 convert                                                                      
 inspect                                                                      
 list-schemes                                                                 
 ode2c                                                                        
 ode2py                                                                       
╰──────────────────────────────────────────────────────────────────────────────╯

or more specifically

!gotranx ode2py --help
                                                                                
 Usage: gotranx ode2py [OPTIONS] [FNAME]                                        
                                                                                
╭─ Arguments ──────────────────────────────────────────────────────────────────╮
   fname      [FNAME]  [default: None]                                        
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────────────────────╮
 --outname        -o      TEXT                      Output name               
                                                    [default: None]           
 --remove-unused                                    Remove unused variables   
 --version                                          Show version              
 --license                                          Show license              
 --config         -c      PATH                      Read configuration        
                                                    options from a            
                                                    configuration file        
                                                    [default: None]           
 --verbose        -v                                Verbose output            
 --scheme                 [explicit_euler|generali  Numerical scheme for      
                          zed_rush_larsen|forward_  solving the ODE           
                          explicit_euler|forward_g                            
                          eneralized_rush_larsen|h                            
                          ybrid_rush_larsen]                                  
 --stiff-states   -s      TEXT                      Stiff states for the      
                                                    hybrid rush larsen scheme 
 --delta                  FLOAT                     Delta value for the rush  
                                                    larsen schemes            
                                                    [default: 1e-08]          
 --format         -f      [black|ruff|none]         Formatter for the output  
                                                    code                      
                                                    [default: black]          
 --backend        -b      [numpy|jax]               Backend for the generated 
                                                    code                      
                                                    [default: numpy]          
 --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",
]

[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']                │
│ Hybrid Rush Larsen       hybrid_rush_larsen       ['delta',                │
│                                                   'stiff_states']          │
└─────────────────────────┴─────────────────────────┴──────────────────────────┘
  • 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

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