Repository navigation
Add complete source references to petrolib docstrings - #162
Merged
Merged
Conversation
Two-layer provenance so every docstring source resolves to a full journal citation: - Functions and classes whose docstrings had no source tag (195 defs in the newer modules: acoustic_geomech, em_dielectric, nuclear, integrity_drilling, inversion_numerics/*, wellbore_geometry, depth_correction, depth_matching, borehole_image, units, constants, and parts of data_qc_io) gain a "Sources: srcYYYY_MM/<module>" line, derived from which article files actually delegate to them (callers scanned across all srcYYYY_MM directories; listings capped at 8 plus a count; 95 defs with no direct article caller are left untagged). - Every module whose docstrings carry source tags (36 modules) gains a References section in the module docstring with the complete citation per tag: title, authors, year, Petrophysics volume/issue/pages where the article header states them, DOI (or the pre-DOI note for issues before SPWLA DOI assignment), with volume/issue/date filled from the plan's directory table when the header lacks them. Bare-directory mentions get issue-level citations. Citations are extracted from the article files' own headers; formal "Reference:"/"Based on:" blocks are preferred verbatim when present. Docstring-only change: ruff check/format clean, mypy clean (45 files), 252 tests pass. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B2BX1XL8422gebCU1oVoQC
ingehap
marked this pull request as ready for review
July 10, 2026 10:34
This was referenced Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Every docstring source in
petrolibnow resolves to a complete journal citation, in two layers:Per-function/class
Sources:tags (195 new). The newer modules (acoustic_geomech, em_dielectric, nuclear, integrity_drilling, the inversion_numerics package, wellbore_geometry, depth_correction, depth_matching, borehole_image, units, constants, and parts of data_qc_io) had no source tags at all. Their provenance was recovered from the delegation graph: a corpus scan of allsrcYYYY_MMdirectories mapped everypetrolib.<module>.<function>call site, and each previously untagged public function/class gained aSources: srcYYYY_MM/<module>line listing the article files that delegate to it (capped at 8 + "and N more articles" —inversion_numerics.fitting.fit_linetops out at 41 callers). 95 definitions with no direct article caller (internal helpers reached via sibling wrappers, canon-completion functions) are left untagged, per "if possible".Module-level References sections (36 modules). Every module whose docstrings carry source tags gains a References section in the module docstring giving the complete citation for each tag: title, authors, year, Petrophysics volume/issue/pages, and DOI. Citations are extracted from the article files' own headers; formal
Reference:/Based on:blocks are used verbatim when present; volume/issue/date come from the plan's directory table when a header lacks them; pre-2017 issues carry the honest "DOI: none assigned (this issue predates SPWLA DOI assignment)" note. Bare-directory mentions in prose (e.g. "src2016_10 uses signed cos") get issue-level citations.Example entry:
This keeps function docstrings readable (shorthand tags as before) while making every tag resolvable to a full reference within the same file — the same pattern as a keyed bibliography.
Verification
Docstring-only change — no code paths touched:
ruff check+ruff format --checkclean (all wrapped ≤ 100 columns);python3 -m mypy petrolibclean (45 source files);python3 -m pytest tests/petrolib: 252 passed;🤖 Generated with Claude Code
https://claude.ai/code/session_01B2BX1XL8422gebCU1oVoQC
Generated by Claude Code