Skip to content

feat: add temperature conversion helpers - #69

Open
tsah-baz wants to merge 1 commit into
mainfrom
test/prlc-7-nomerger
Open

feat: add temperature conversion helpers#69
tsah-baz wants to merge 1 commit into
mainfrom
test/prlc-7-nomerger

Conversation

@tsah-baz

@tsah-baz tsah-baz commented Aug 4, 2026

Copy link
Copy Markdown

Adds python temperature conversion helpers with absolute-zero validation.

Testing: exercised by hand.

@baz-reviewer-dev

baz-reviewer-dev Bot commented Aug 4, 2026

Copy link
Copy Markdown

Comment thread python/temperature.py
Comment on lines +5 to +7
if celsius < ABSOLUTE_ZERO_C:
raise ValueError("below absolute zero")
return celsius * 9 / 5 + 32

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Non-finite temperatures bypass validation

celsius < ABSOLUTE_ZERO_C doesn't catch NaN or infinities, so celsius_to_fahrenheit and celsius_to_kelvin accept invalid inputs and propagate them through — should we validate finiteness explicitly in both functions?

Severity

Want Baz to fix this for you? Activate Fixer

Prompt for AI Agents
Before applying, verify this suggestion against the current code. In
python/temperature.py around lines 5-7 in `celsius_to_fahrenheit` and lines 10-13 in
`celsius_to_kelvin`, the current guard only checks `celsius < ABSOLUTE_ZERO_C`, which
does not reject NaN and lets infinities through (NaN makes the comparison false; ±inf
passes). Refactor both functions to explicitly validate that `celsius` is a finite real
number (e.g., reject `math.isnan` and `math.isinf`) before performing the absolute-zero
check and conversion. Ensure the same finiteness validation logic is applied
consistently to both entry points and raises ValueError when the input is not finite.

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