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

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from

Conversation

emprzy
Copy link
Collaborator

@emprzy emprzy commented Jan 15, 2025

Describe your changes.

This pull request:

  • Adds inline docstring documentation to important (as identified by flepiMoP users) submodules, classes, methods, etc. within gempyor
  • Improves existing docstring documentation, when reasonable to do so
  • Removes some poor documentation, so that when we use Sphinx in the future as a tool for documenting gempyor, it does not propagate poor documentation

As I see it, the gempyor API mainly consists of:

  • ModelInfo class from model_info.py
  • Parameters class from parameters.py, and some associated methods
  • GempyorInference class from inference.py, and some associated methods
  • Compartments class from compartments.py, and some associated methods
  • and two functions from utils.py (read_df and write_df)

Note, before narrowing my focus on guidance from Carl, I also wrote some docstring in two files (calibrate.py and cli.py). I do not think of these as being integral parts of the gempyor API, but because I worked on them in in the same sweep of work that I worked on the others, they are also included in this PR with some docstring improvements.

What does your pull request address? Tag relevant issues.

This pull request addresses GH #462.

@emprzy emprzy changed the base branch from main to dev January 15, 2025 20:19
@emprzy emprzy marked this pull request as ready for review January 22, 2025 20:01
@TimothyWillard TimothyWillard added gempyor Concerns the Python core. high priority High priority. docstring Relating to in-code documentation. next release Marks a PR as a target to include in the next release. quick issue Short or easy fix. labels Jan 23, 2025
@TimothyWillard TimothyWillard added this to the Software Quality milestone Jan 23, 2025
Copy link
Contributor

@TimothyWillard TimothyWillard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, I think an improvement over the current state. A few themes:

  1. What's up with putting the file name as the header of a module docstrings? Seems redundant.
  2. There are some typing signatures that are off, I'd rather have no type signature than an incorrect one so if it's not clear let's leave it for another PR.
  3. There were some docstrings of CLI commands that were edited in ways that I think will look off when using --help, I think we need to be careful about not applying the same docstring style to click commands.

flepimop/gempyor_pkg/src/gempyor/calibrate.py Outdated Show resolved Hide resolved
flepimop/gempyor_pkg/src/gempyor/calibrate.py Outdated Show resolved Hide resolved
Comment on lines 152 to 170
"""
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 (optional): How often to save samples.
ncpu: Number of CPU cores to use for parallelization.
input_run_id (optional): Run ID. Will be auto-generated if not provdied.
prefix (optional): A prefix for output files.
resume: Whether or not to resume a previous calibration run.
resume_location (optional): Path to the location of the saved state to resume from.

Returns:
None
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, this is good docs! However, because this is a click CLI command it's going to look very strange in terminal (try doing flepimop-calibrate --help to see what I mean).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm yes, looks weird. So should I delete the Args and returns section and just leave the description sentence?

flepimop/gempyor_pkg/src/gempyor/calibrate.py Outdated Show resolved Hide resolved
flepimop/gempyor_pkg/src/gempyor/cli.py Outdated Show resolved Hide resolved
flepimop/gempyor_pkg/src/gempyor/inference.py Outdated Show resolved Hide resolved
flepimop/gempyor_pkg/src/gempyor/model_info.py Outdated Show resolved Hide resolved
flepimop/gempyor_pkg/src/gempyor/model_info.py Outdated Show resolved Hide resolved
flepimop/gempyor_pkg/src/gempyor/parameters.py Outdated Show resolved Hide resolved
flepimop/gempyor_pkg/src/gempyor/parameters.py Outdated Show resolved Hide resolved
@emprzy
Copy link
Collaborator Author

emprzy commented Jan 24, 2025

This PR can also be used to address GH #431 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docstring Relating to in-code documentation. gempyor Concerns the Python core. high priority High priority. next release Marks a PR as a target to include in the next release. quick issue Short or easy fix.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature request]: Ensure docstring documentation exists in major sub-modules of gempyor
2 participants