1.1.1.2. PyRates.pyrates.backend.fortran
1.1.1.2.1. pyrates.backend.fortran module
Fortran backend. Contains all fortran-based internal function definitions and links to fortran functions.
1.1.1.2.2. pyrates.backend.fortran.fortran_backend module
Wraps fortran such that it’s low-level functions can be used by PyRates to create and simulate a compute graph.
- class pyrates.backend.fortran.fortran_backend.FortranBackend(ops: Dict[str, str] | None = None, imports: List[str] | None = None, **kwargs)[source]
Bases:
BaseBackend- add_var_update(lhs: ComputeVar, rhs: str, lhs_idx: str | None = None, rhs_shape: tuple | None = ())[source]
- clear() None[source]
Removes all layers, variables and operations from graph. Deletes build directory.
Also removes the auto-07p artefacts generated by
_generate_auto_files: everyc.<scenario>file in the build dir, plus any pycobi-styles.<name>/b.<name>/d.<name>/.lab/.datoutput files matchingself._fname. Previously onlyc.ivpwas removed, which orphaned all the otherc.*files once we started generating multiple scenarios.
- create_index_str(idx: str | int | tuple, separator: str = ',', apply: bool = True, **kwargs) Tuple[str, dict][source]
- generate_func(func_name: str, to_file: bool = True, func_args: tuple = (), state_vars: tuple = (), **kwargs)[source]
- generate_func_head(func_name: str, state_var: str = 'y', return_var: str = 'dy', func_args: list | None = None, add_hist_func: bool | None = None)[source]
Generate the function header for the RHS file.
add_hist_funcWhether to include the
histcallable in the generated function signature. IfNone(default), falls back to the backend’sadd_hist_argconstructor flag — making that flag the single source of truth. Callers that already know whether the model is a DDE (e.g.ComputeGraph.to_func) pass the resolved bool explicitly and skip the fallback.
- linebreak_end = '&'
- linebreak_start = ' & '
- n1 = 62
- n2 = 72
1.1.1.2.3. pyrates.backend.fortran.fortran_funcs module
Contains fortran function definitions that may be used for PyRates model equations.
- pyrates.backend.fortran.fortran_funcs.get_interp_def(idx: int, out_shape: tuple | str = '', dtype: str = 'real') tuple[source]
- pyrates.backend.fortran.fortran_funcs.get_sigmoid_def(idx: int, out_shape: tuple | str = '', dtype: str = 'real') tuple[source]
- pyrates.backend.fortran.fortran_funcs.get_sign_def(idx: int, out_shape: tuple | str = '', dtype: str = 'real') tuple[source]
- pyrates.backend.fortran.fortran_funcs.sigmoid(x)