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:
- unicodebool, optional
If True, use unicode suffix. The default is False.
- plain_subscript_template
str, optional The template for plain subscript. The default is
'_%s'.- plain_superscript_template
str, optional The template for plain superscript. The default is
'[%s]'.- latex_subscript_template
str, optional The template for LaTeX subscript. The default is
'_{%s}'.- latex_superscript_template
str, optional 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:
- stringssequence
ofstr The sequence of strings.
- suffixsequence
ofstr The sequence of suffixes. The suffix format can be set by
elisa.util.misc.set_suffix_config().- subscriptbool, optional
If True, add suffix as subscript, otherwise superscript. The default is True.
- latexbool, optional
If True, add suffix following LaTeX format. The default is False.
- unicodebool, optional
If True, add suffix with Unicode string. Defaults to
elisa.util.misc.UNICODE_SUFFIX, which can be set byelisa.util.misc.set_suffix_config().- mathrmbool, optional
If True, add suffix in mathrm when latex is True. The default is False.
- stringssequence
- Returns:
- 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:
- namespace:
dict A dict of non-duplicate names and suffixes in original name order.
- namespace:
- 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, optional The precision of the mid value. The default is 2.
- min_exponent
int, optional The minimum exponent to use scientific notation. The default is 1.
- max_exponent
int, optional The maximum exponent to use scientific notation. The default is 2.
- vmid
- Returns:
strThe 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, optional The string displayed before progress bar when initialization.
- run_str
str, optional The string displayed before progress bar when run.
- update_rate
int, optional The update rate of the progress bar. The default is 50.
- neval
- Returns:
- progress_bar_fori_loop
callable() Factory that adds a progress bar to function input.
- progress_bar_fori_loop
References