Skip to content

feat!: require an explicit fluid_name in encomp.gases (breaking)#27

Merged
wlaur merged 1 commit into
mainfrom
feat/require-gas-fluid-name
Jul 25, 2026
Merged

feat!: require an explicit fluid_name in encomp.gases (breaking)#27
wlaur merged 1 commit into
mainfrom
feat/require-gas-fluid-name

Conversation

@wlaur

@wlaur wlaur commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Breaking change

encomp.gases' seven public functions no longer default fluid_name to "Air", and the parameter is now keyword-only. ideal_gas_density is unaffected (it never had a default).

# before
mass_to_normal_volume(mass)
convert_gas_volume(volume, "N", condition)

# after
mass_to_normal_volume(mass, fluid_name="Air")
convert_gas_volume(volume, "N", condition, fluid_name="Air")

Affected: convert_gas_volume, mass_to_normal_volume, mass_from_normal_volume, mass_to_actual_volume, mass_from_actual_volume, actual_volume_to_normal_volume, normal_volume_to_actual_volume.

Why

This was the last implicit physical identity in the library. The same anti-pattern was already removed from encomp.coolprop.fluid (which requires name=) and convert_volume_mass (which requires a density), and AGENTS.md states the invariant — encomp.gases was the standing exception, flagged by the 1.9.2 holistic review as "an inconsistency of concept".

A guessed fluid does not fail loudly: it returns plausible numbers for the wrong gas. mass_to_normal_volume(Q(1, "kg")) silently answered for air even when the caller meant methane (a ~1.8× difference), which is precisely why the identity may not be defaulted.

Keyword-only rather than positional-with-no-default because a required parameter cannot follow the defaulted condition_* arguments — and it matches the cp.fluid(..., name=...) spelling. It also means the name can never land in a condition parameter by position.

Notes

  • Released as a patch (1.9.4): per README.md, encomp does not follow strict semantic versioning, and breaking changes are called out in the release notes instead.
  • AGENTS.md now records that no exceptions to the invariant remain, so the next review doesn't re-flag it.
  • No docs or README examples called these functions; only the test suite needed updating, plus a new test pinning that the argument is required and keyword-only, and that naming a different gas changes the answer.

Gates

pytest 1190 passed · pyright 0 errors · pyrefly 0 errors · ty clean · ruff clean.

🤖 Generated with Claude Code

BREAKING CHANGE: the seven public functions in encomp.gases no longer default
fluid_name to "Air", and it is now keyword-only. Pass fluid_name="Air" explicitly to
keep the previous behavior:

    mass_to_normal_volume(mass)                      -> mass_to_normal_volume(mass, fluid_name="Air")
    convert_gas_volume(V, "N", condition)            -> convert_gas_volume(V, "N", condition, fluid_name="Air")

This was the last implicit physical identity in the library -- the same anti-pattern
already removed from encomp.coolprop.fluid (which requires name=) and
convert_volume_mass (which requires a density). A guessed fluid does not raise, it
returns plausible numbers for the wrong gas, which is exactly why it may not be
guessed. Keyword-only rather than positional because a required parameter cannot
follow the defaulted condition arguments, and because it matches cp.fluid(name=...).

AGENTS.md records that no exceptions to the invariant remain.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@wlaur
wlaur merged commit a148dc6 into main Jul 25, 2026
21 checks passed
@wlaur
wlaur deleted the feat/require-gas-fluid-name branch July 25, 2026 10:22
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