Skip to content

fix: correct compress() density docstring to kg/m³#124

Merged
PythonFZ merged 1 commit into
mainfrom
fix/compress-density-unit-docstring
Jul 1, 2026
Merged

fix: correct compress() density docstring to kg/m³#124
PythonFZ merged 1 commit into
mainfrom
fix/compress-density-unit-docstring

Conversation

@PythonFZ

@PythonFZ PythonFZ commented Jun 30, 2026

Copy link
Copy Markdown
Member

Summary

molify.compress's docstring documented its density argument as g/cm³, but the function passes that value straight to calculate_box_dimensions, which expects kg/m³ — the same convention already used by pack and calculate_density. A user trusting the docstring would pass 1.0 for water (1 g/cm³) and get a box 1000× too sparse.

The runtime logic was already correct and consistent with the rest of the package; only the docstring was wrong. This standardizes compress on the package-wide kg/m³ convention by fixing the one misleading line.

     density : float
-        The target density in g/cm^3.
+        The target density in kg/m^3.

Verification (TDD)

The existing test_compress / test_compress_freeze already pin the kg/m³ contract. To confirm they genuinely guard it, I temporarily applied the naive density * 1000 "fix":

  • RED: both tests fail (calculate_density → ~1,000,000 instead of 1000).
  • GREEN: with the unmodified (correct) logic, all 454 tests pass.

This demonstrates the kg/m³ contract is real and tested, so the docstring correction now matches verified behavior.

Test Plan

  • uv run pytest → 454 passed
  • Confirmed the rejected ×1000 conversion breaks the suite (RED), proving the contract is guarded

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Clarified the documented density units for compression to use kg/m³ instead of g/cm³.

The compress() docstring documented `density` as g/cm^3, but the
function passes it to calculate_box_dimensions(), which expects kg/m^3
(consistent with pack() and calculate_density()). A caller trusting the
docstring would pass e.g. 1.0 for water and get a box 1000x too sparse.

The runtime logic was already correct; this corrects only the misleading
docstring, standardizing on the package-wide kg/m^3 convention.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a391b7b8-3636-415e-8cec-43f6947b5303

📥 Commits

Reviewing files that changed from the base of the PR and between 32422e3 and e6be7c5.

📒 Files selected for processing (1)
  • src/molify/compress.py

📝 Walkthrough

Walkthrough

The density parameter unit in the compress() function's docstring is corrected from g/cm^3 to kg/m^3. No logic or behavior is changed.

Changes

Docstring Unit Correction

Layer / File(s) Summary
Fix density unit in compress() docstring
src/molify/compress.py
Docstring unit for density parameter updated from g/cm^3 to kg/m^3.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~1 minutes

Poem

A unit was wrong, a small typo astray,
kg/m^3 is the proper display.
The bunny hopped in, corrected the text,
No logic was harmed — what could come next?
🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the docstring fix for compress() density units and matches the main change.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/compress-density-unit-docstring

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@PythonFZ PythonFZ merged commit 2568627 into main Jul 1, 2026
22 checks passed
@PythonFZ PythonFZ deleted the fix/compress-density-unit-docstring branch July 1, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant