elisa.util.misc#
Miscellaneous helper functions.
- set_suffix_config(unicode: bool = False, plain_subscript_template: str = '_%s', plain_superscript_template: str = '[%s]', latex_subscript_template: str = '_{%s}', latex_superscript_template: str = '^{%s}') None[source]#
Set suffix configuration.
- Parameters:
unicode (
bool) – If True, use unicode suffix. The default is False.plain_subscript_template (
str) – The template for plain subscript. The default is'_%s'.plain_superscript_template (
str) – The template for plain superscript. The default is'[%s]'.latex_subscript_template (
str) – The template for LaTeX subscript. The default is'_{%s}'.latex_superscript_template (
str) – The template for LaTeX superscript. The default is'^{%s}'.
- add_suffix(strings: str | Sequence[str], suffix: str | Sequence[str], subscript: bool, unicode: bool | None = None, latex: bool = False, mathrm: bool = False) str | list[str][source]#
Add suffix to a sequence of strings.
- Parameters:
suffix (
str|Sequence[str]) – The sequence of suffixes. The suffix format can be set byelisa.util.misc.set_suffix_config().subscript (
bool) – If True, add suffix as subscript, otherwise superscript. The default is True.latex (
bool) – If True, add suffix following LaTeX format. The default is False.unicode (
bool|None) – If True, add suffix with Unicode string. Defaults toelisa.util.misc.UNICODE_SUFFIX, which can be set byelisa.util.misc.set_suffix_config().mathrm (
bool) – If True, add suffix in mathrm when latex is True. The default is False.
- Returns:
The strings with suffix added.
- build_namespace(names: Sequence[str], latex: bool = False, prime: bool = False) dict[str, list[str | int]][source]#
Build a namespace from a sequence of names.
- Parameters:
- Returns:
A dict of non-duplicate names and suffixes in original name order.
- define_fdjvp(fn: Callable[[Array, dict[str, Array]], Array], method: Literal['central', 'forward'] = 'central') Callable[[Array, dict[str, Array]], Array][source]#
Define JVP using finite differences.
- make_pretty_table(fields: Sequence[str], rows: Sequence) PrettyTable[source]#
Make a
prettytable.PrettyTable.
- replace_string(value: T, mapping: dict[str, str]) T[source]#
Replace all strings in value appeared in mapping.
- report_interval(vmid: float, vmin: float, vmax: float, precision: int = 2, min_exponent: int = 1, max_exponent: int = 2) str[source]#
Report parameter interval in \(\LaTeX\) format.
- Parameters:
vmid (
float) – The mid value.vmin (
float) – The lower bound.vmax (
float) – The upper bound.precision (
int) – The precision of the mid value. The default is 2.min_exponent (
int) – The minimum exponent to use scientific notation. The default is 1.max_exponent (
int) – The maximum exponent to use scientific notation. The default is 2.
- Returns:
The interval in \(|LaTeX\) format.
- progress_bar_factory(neval: int, ncores: int, init_str: str | None = None, run_str: str | None = None, update_rate: int = 50) Callable[[Callable], Callable][source]#
Add a progress bar to JAX
fori_loopkernel, see [1] for details.- Parameters:
neval (
int) – The total number of evaluations.ncores (
int) – The number of cores.init_str (
str|None) – The string displayed before progress bar when initialization.run_str (
str|None) – The string displayed before progress bar when run.update_rate (
int) – The update rate of the progress bar. The default is 50.
- Returns:
Factory that adds a progress bar to function input.
References