Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gempyor API docstring refurbishment #468

Merged
merged 18 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 40 additions & 12 deletions flepimop/gempyor_pkg/src/gempyor/calibrate.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
"""
Facilitates the calibration of the model using the `emcee` MCMC sampler.
Provides CLI options for users to specify simulation paramters.
emprzy marked this conversation as resolved.
Show resolved Hide resolved

Functions:
calibrate: Reads a configuration file for simulation settings.

"""

#!/usr/bin/env python
import click
from gempyor import model_info, file_paths, config, inference_parameter
Expand Down Expand Up @@ -113,18 +122,37 @@
# @profile_options
# @profile()
def calibrate(
config_filepath,
project_path,
nwalkers,
niter,
nsamples,
nthin,
ncpu,
input_run_id,
prefix,
resume,
resume_location,
):
config_filepath: str,
emprzy marked this conversation as resolved.
Show resolved Hide resolved
project_path: str,
nwalkers: int,
niter: int,
nsamples: int,
nthin: int | None,
ncpu: int,
input_run_id: int | None,
prefix: str | None,
resume: bool,
resume_location: str | None,
) -> None:
"""
Calibrate using an `emcee` sampler to initialize a model based on a config.

Args:
config_filepath: Path to the configuration file.
project_path: Path to the project directory.
nwalkers: Number of walkers (MCMC chains) to run.
niter: Number of MCMC iterations to perform.
nsamples: Number of samples to select from final MCMC chain.
nthin: How often to save samples.
ncpu: Number of CPU cores to use for parallelization.
input_run_id: Run ID. Will be auto-generated if not provdied.
prefix: A prefix for output files.
resume: Whether or not to resume a previous calibration run.
resume_location: Path to the location of the saved state to resume from.

Returns:
None
"""
# Choose a run_id
if input_run_id is None:
base_run_id = pathlib.Path(config_filepath).stem.replace("config_", "")
Expand Down
3 changes: 2 additions & 1 deletion flepimop/gempyor_pkg/src/gempyor/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
)
@click.pass_context
def patch(ctx: click.Context = mock_context, **kwargs) -> None:
"""Merge configuration files
"""
Merge configuration files.
This command will merge multiple config files together by overriding the top level
keys in config files. The order of the config files is important, as the last file
Expand Down
Loading
Loading