utils

Utility functions for SCRIBE.

scribe.utils.git_root(current_path=None)[source]

Finds the root directory of a Git repository.

Parameters:

current_path (str, optional) – The starting path. If None, uses the current working directory.

Returns:

The path to the Git root directory, or None if not found.

Return type:

str

scribe.utils.use_cpu()[source]

Context manager to temporarily force JAX computations to run on CPU.

This is useful when you want to ensure specific computations run on CPU rather than GPU/TPU, for example when running out of GPU memory.

Returns:

Yields control back to the context block

Return type:

None

Example

>>> # Force posterior sampling to run on CPU
>>> with use_cpu():
...     results.get_ppc_samples(n_samples=100)
scribe.utils.numpyro_to_scipy(distribution)[source]

Get the corresponding scipy.stats distribution for a numpyro.distributions.Distribution.

Parameters:

distribution (numpyro.distributions.Distribution) – The numpyro distribution to convert

Returns:

The corresponding scipy.stats distribution

Return type:

scipy.stats.rv_continuous