Skip to content

Adjust sports heat stress risk scale#304

Merged
FedericoTartarini merged 12 commits intomasterfrom
development
Apr 16, 2026
Merged

Adjust sports heat stress risk scale#304
FedericoTartarini merged 12 commits intomasterfrom
development

Conversation

@FedericoTartarini
Copy link
Copy Markdown
Collaborator

@FedericoTartarini FedericoTartarini commented Apr 14, 2026

This pull request updates the sports_heat_stress_risk model to improve the accuracy and clarity of its risk level calculation and recommendations. The main changes are a shift of the risk level scale from 0.0–3.0 to 1.0–4.0, updated logic for wind speed handling, improved documentation, and comprehensive updates to the test suite to match the new logic.

Sports Heat Stress Risk Model Updates

  • The risk level scale for risk_level_interpolated is now 1.0–4.0 (was 0.0–3.0), with corresponding updates to thresholds, recommendations, and documentation. [1] [2] [3] [4]
  • The model now enforces a sport-specific minimum air speed: if the input vr is lower than sport.vr, it is clamped to sport.vr for calculations. [1] [2] [3]

Documentation and Example Updates

  • All relevant docstrings, parameter descriptions, and usage examples have been updated to reflect the new risk level scale and air speed handling. [1] [2] [3] [4]

Test Suite Adjustments

  • All tests for sports_heat_stress_risk have been updated to expect the new risk level scale and logic, including new tests for the air speed clamping behavior. [1] [2] [3] [4] [5] [6] [7] [8] [9]

Versioning and Metadata

  • Project version bumped to 3.9.2 in all relevant files, and the changelog has been updated to summarize these changes. [1] [2] [3] [4] [5]
  • Minor dependency management update: pydantic moved from dev-packages to main packages in Pipfile. [1] [2]

Summary by CodeRabbit

  • Bug Fixes

    • Heat-stress risk scale shifted from 0.0–3.0 to 1.0–4.0; risk categories and recommendation thresholds updated accordingly.
    • Wind-speed input now enforces sport-specific minimums so reported risk reflects effective airflow.
  • Documentation

    • Updated changelog, README and docs to reflect new version, risk scale, examples and minimum Python requirement.
  • Tests

    • Updated and added tests to validate the new risk scale and wind-speed clamping behaviour.
  • Chores

    • Package version bumped to 3.9.2.

Copilot AI review requested due to automatic review settings April 14, 2026 06:43
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

Warning

Rate limit exceeded

@FedericoTartarini has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 23 minutes and 20 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 23 minutes and 20 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1de7e212-b2f9-4204-a6de-0d7c92ffdfbc

📥 Commits

Reviewing files that changed from the base of the PR and between 0d2fcf8 and 346eb1e.

⛔ Files ignored due to path filters (1)
  • Pipfile.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • Pipfile
  • docs/requirements.txt
  • pythermalcomfort/models/sports_heat_stress_risk.py
  • tests/test_sports_heat_stress_risk.py

Walkthrough

This release updates the pythermalcomfort package from version 3.9.1 to 3.9.2, implementing two key algorithmic changes to the sports_heat_stress_risk function: enforcing sport-specific minimum air speed via clamping, and shifting the interpolated risk scale from 0.0–3.0 to 1.0–4.0 with corresponding recommendation threshold adjustments.

Changes

Cohort / File(s) Summary
Version & Release Management
.bumpversion.toml, setup.py, docs/conf.py, pythermalcomfort/__init__.py
Bumped version string from 3.9.1 to 3.9.2 across build configuration, package metadata, and Sphinx documentation config.
Core Risk Calculation
pythermalcomfort/models/sports_heat_stress_risk.py
Modified sports_heat_stress_risk to clamp input vr to sport minimum (np.maximum(vr, sport.vr)), shifted risk scale from 0.0–3.0 to 1.0–4.0 in _calc_risk_single_value, and adjusted recommendation thresholds in _get_recommendation to align with new scale (boundaries now at <2.0, <3.0, <4.0).
Documentation Updates
CHANGELOG.rst, pythermalcomfort/classes_input.py, pythermalcomfort/classes_return.py
Added changelog entry documenting risk scale shift and vr clamping behaviour; updated SportsHeatStressInputs.vr docstring to document clamping; updated SportsHeatStressRisk.risk_level_interpolated docstring to reflect new 1.0–4.0 scale with revised risk categories.
Dependencies
Pipfile
Reordered pydantic = "*" entry in [dev-packages] section (no version or constraint changes).
Test Suite
tests/test_sports_heat_stress_risk.py
Updated expected risk values across scalar and array tests to reflect new 1.0–4.0 scale; added new test test_sports_heat_stress_risk_array_clamps_vr_to_sport_minimum to verify elementwise vr clamping; revised range validations from [0, 3] to [1, 4] and adjusted recommendation/risk-bin thresholds throughout.

Sequence Diagram(s)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarises the main change: adjusting the sports heat stress risk scale from 0.0–3.0 to 1.0–4.0, which is the primary modification across the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 96.43% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch development

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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pythermalcomfort/models/sports_heat_stress_risk.py`:
- Line 153: The docstring examples for sports_heat_stress_risk currently never
exercise the vr clamp; add at least one minimal runnable example in the
sports_heat_stress_risk docstring that passes vr < sport.vr (use the Sports
enum, e.g. sport=Sports.RUNNING) so the function uses sport.vr as the minimum;
update the example input to show vr below the sport.vr threshold and include the
expected printed/returned result to demonstrate the clamped behavior (adjust the
examples at the locations around the existing examples to include this case).
- Around line 156-158: The example threshold prints are inconsistent with the
implemented midpoint logic (t_high is computed as the midpoint between t_medium
and t_extreme in the block around lines 331-336); re-run the example to capture
real values for result.t_medium, result.t_high and result.t_extreme and update
the three printed sample outputs so they mathematically match (i.e., t_high ≈
(t_medium + t_extreme)/2), and while here add applicability limits and a minimal
runnable example to the relevant model function/class docstring that
demonstrates creating the model, calling it, and reading
result.t_medium/result.t_high/result.t_extreme so the examples are accurate and
executable.

In `@tests/test_sports_heat_stress_risk.py`:
- Around line 22-23: The inline comment for the parametrized test case with
tuple (35, 35, 50, 0.5, Sports.RUNNING, 2.1) is incorrect: it labels the case as
"extreme risk" while the expected value 2.1 corresponds to the moderate band;
update the comment to say "moderate risk" (or otherwise make the comment
consistent with the expected 2.1 value) so the inline description matches the
test expectation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3400adc7-ffa4-47cb-9275-252997d88ac1

📥 Commits

Reviewing files that changed from the base of the PR and between 356bbd3 and b4bfd59.

⛔ Files ignored due to path filters (1)
  • Pipfile.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • .bumpversion.toml
  • CHANGELOG.rst
  • Pipfile
  • docs/conf.py
  • pythermalcomfort/__init__.py
  • pythermalcomfort/classes_input.py
  • pythermalcomfort/classes_return.py
  • pythermalcomfort/models/sports_heat_stress_risk.py
  • setup.py
  • tests/test_sports_heat_stress_risk.py

Comment thread pythermalcomfort/models/sports_heat_stress_risk.py
Comment thread pythermalcomfort/models/sports_heat_stress_risk.py
Comment thread tests/test_sports_heat_stress_risk.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the sports_heat_stress_risk model to use a 1.0–4.0 risk scale (instead of 0.0–3.0), clamps input air speed to a sport-specific minimum (sport.vr), and aligns documentation/tests and project versioning with the new behavior.

Changes:

  • Shifted risk_level_interpolated scaling and updated recommendation thresholds to match 1.0–4.0.
  • Enforced a sport-specific minimum relative air speed by clamping vr to max(vr, sport.vr) during calculation.
  • Updated docstrings, tests, changelog, and version metadata to reflect the revised model behavior.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pythermalcomfort/models/sports_heat_stress_risk.py Updates risk scaling, recommendation mapping, and clamps vr to sport.vr.
pythermalcomfort/classes_return.py Updates returned model documentation for the new 1.0–4.0 risk scale.
pythermalcomfort/classes_input.py Documents that vr < sport.vr is accepted and clamped by the model function.
tests/test_sports_heat_stress_risk.py Updates expectations for the new risk scale and adds a test for vr clamping behavior.
CHANGELOG.rst Adds a 3.9.2 entry describing the risk scale and vr clamping changes.
setup.py Bumps package version to 3.9.2.
pythermalcomfort/__init__.py Bumps __version__ to 3.9.2.
docs/conf.py Bumps documentation version/release to 3.9.2.
.bumpversion.toml Bumps current_version to 3.9.2.
Pipfile Moves pydantic into runtime packages.
Pipfile.lock Updates the lockfile to match dependency/version changes.

Comment thread pythermalcomfort/models/sports_heat_stress_risk.py Outdated
Comment thread pythermalcomfort/models/sports_heat_stress_risk.py
Comment thread tests/test_sports_heat_stress_risk.py Outdated
Comment thread tests/test_sports_heat_stress_risk.py Outdated
Comment thread Pipfile Outdated
@FedericoTartarini FedericoTartarini merged commit 6837e71 into master Apr 16, 2026
4 of 5 checks passed
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.

3 participants