Skip to content

Fix/sports heat stress risk scale#303

Merged
FedericoTartarini merged 3 commits intodevelopmentfrom
fix/sports-heat-stress-risk-scale
Apr 14, 2026
Merged

Fix/sports heat stress risk scale#303
FedericoTartarini merged 3 commits intodevelopmentfrom
fix/sports-heat-stress-risk-scale

Conversation

@yehui-h
Copy link
Copy Markdown
Collaborator

@yehui-h yehui-h commented Apr 14, 2026

  1. fix: bump version to 3.9.2 and update sports heat stress risk scale from 0.0-3.0 to 1.0-4.0
  2. fix: enforce minimum sport air speed in sports_heat_stress_risk

Summary by CodeRabbit

Release Notes – Version 3.9.2

  • New Features

    • Updated sports heat stress risk scale from 0.0–3.0 to 1.0–4.0 with revised risk thresholds and recommendations.
    • Calculations now apply sport-specific minimum air speed thresholds.
  • Chores

    • Version bumped to 3.9.2.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

Warning

Rate limit exceeded

@yehui-h has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 25 minutes and 30 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 25 minutes and 30 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: cd1119e0-3d69-48a3-891f-ed48030efe45

📥 Commits

Reviewing files that changed from the base of the PR and between f8325f4 and 893efd9.

📒 Files selected for processing (1)
  • pythermalcomfort/models/sports_heat_stress_risk.py

Walkthrough

This PR bumps the package version to 3.9.2 and updates the sports_heat_stress_risk function to enforce minimum relative air speed via sport.vr clamping and shifts the risk scale from 0.0–3.0 to 1.0–4.0, updating related tests and documentation accordingly.

Changes

Cohort / File(s) Summary
Version metadata updates
.bumpversion.toml, docs/conf.py, pythermalcomfort/__init__.py, setup.py
Incremented package version from 3.9.1 to 3.9.2 across distribution and documentation configuration files.
Documentation updates
CHANGELOG.rst, pythermalcomfort/classes_input.py, pythermalcomfort/classes_return.py
Added v3.9.2 changelog entry and updated parameter/field documentation for SportsHeatStressInputs.vr and SportsHeatStressRisk.risk_level_interpolated to reflect new risk scale (1.0–4.0) and vr clamping behaviour.
Core functionality
pythermalcomfort/models/sports_heat_stress_risk.py
Implemented vr effective clamping against sport.vr minimum; shifted risk scale endpoints from 0.0–3.0 to 1.0–4.0; updated risk band thresholds in recommendation logic to align with new scale.
Test suite
tests/test_sports_heat_stress_risk.py
Updated assertions across scalar/array test cases to reflect new risk bounds (1.0–4.0); added test for vr clamping to sport minimum; adjusted recommendation threshold expectations and edge-case risk values.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #286 – Directly modifies pythermalcomfort/models/sports_heat_stress_risk.py with additions and updates to the sports heat stress risk function implementation.
  • PR #282 – Modifies the same sports_heat_stress_risk.py module with changes to risk calculation, thresholds, and validation logic.
  • PR #280 – Introduced the sports_heat_stress_risk function; this PR builds upon those changes with risk scale and clamping refinements.

Suggested reviewers

  • FedericoTartarini
🚥 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 directly addresses the main change: updating the sports heat stress risk scale from 0.0–3.0 to 1.0–4.0, which is the primary functional change 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 fix/sports-heat-stress-risk-scale

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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pythermalcomfort/models/sports_heat_stress_risk.py (1)

95-178: 🛠️ Refactor suggestion | 🟠 Major

Add the missing Applicability section.

The updated public docstring still doesn’t spell out the model’s validity bounds. Please add an Applicability section while you’re touching this API doc so callers can see the intended input domain.

As per coding guidelines, pythermalcomfort/models/*.py: Include applicability limits and minimal runnable examples in model function docstrings.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pythermalcomfort/models/sports_heat_stress_risk.py` around lines 95 - 178,
Add an "Applicability" section to the sports_heat_stress_risk docstring
describing the model validity bounds and expected inputs: state supported ranges
for tdb/tr (°C), rh (%), vr (m/s) and minimum sport.vr enforcement, valid met
and clo ranges (from _SportsValues / Sports presets), supported duration ranges,
array broadcasting behavior, and units; also include a one- or two-line minimal
runnable example showing call to sports_heat_stress_risk with numeric inputs and
the returned SportsHeatStressRisk usage (e.g., accessing
.risk_level_interpolated). Ensure you update the docstring inside the
sports_heat_stress_risk function and reference the Sports and _SportsValues
names so callers know where presets and types come from.
🤖 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`:
- Around line 150-156: The example outputs are inconsistent with the
implementation: _calc_risk_single_value() computes t_high as (t_medium +
t_extreme) / 2, so the printed sample values for t_medium, t_high, and t_extreme
in the sports_heat_stress_risk example must be regenerated from an actual call;
update the example lines that print result.t_medium, result.t_high, and
result.t_extreme to reflect the true values returned by sports_heat_stress_risk
(calling sports_heat_stress_risk(tdb=35, tr=35, rh=40, vr=2.0,
sport=Sports.RUNNING)) so t_high equals the midpoint of t_medium and t_extreme
per _calc_risk_single_value().

---

Outside diff comments:
In `@pythermalcomfort/models/sports_heat_stress_risk.py`:
- Around line 95-178: Add an "Applicability" section to the
sports_heat_stress_risk docstring describing the model validity bounds and
expected inputs: state supported ranges for tdb/tr (°C), rh (%), vr (m/s) and
minimum sport.vr enforcement, valid met and clo ranges (from _SportsValues /
Sports presets), supported duration ranges, array broadcasting behavior, and
units; also include a one- or two-line minimal runnable example showing call to
sports_heat_stress_risk with numeric inputs and the returned
SportsHeatStressRisk usage (e.g., accessing .risk_level_interpolated). Ensure
you update the docstring inside the sports_heat_stress_risk function and
reference the Sports and _SportsValues names so callers know where presets and
types come from.
🪄 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: 7e234dfd-557f-42e6-8940-93d99275f8a1

📥 Commits

Reviewing files that changed from the base of the PR and between a292612 and f8325f4.

📒 Files selected for processing (9)
  • .bumpversion.toml
  • CHANGELOG.rst
  • 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
Copy link
Copy Markdown
Collaborator

@FedericoTartarini FedericoTartarini left a comment

Choose a reason for hiding this comment

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

I'm not entirely sure what is the best way of updating the version moving forward whether it is better that I update the version once I push it to main or whether in each pull request we should update the version number let me know what you think is the best approach.

Perhaps if we update it in the Pull request to development then I'm not entirely sure it is going to be deployed when we push it to main. I need to check the GitHub action.

Comment thread pythermalcomfort/models/sports_heat_stress_risk.py Outdated
@yehui-h
Copy link
Copy Markdown
Collaborator Author

yehui-h commented Apr 14, 2026

I'm not entirely sure what is the best way of updating the version moving forward whether it is better that I update the version once I push it to main or whether in each pull request we should update the version number let me know what you think is the best approach.

Perhaps if we update it in the Pull request to development then I'm not entirely sure it is going to be deployed when we push it to main. I need to check the GitHub action.

  1. For developers using this in other projects, the most important thing is whether PyPI already has a released version that includes the change, and whether their dependency constraints allow that version to be installed.

  2. If they are not installing from PyPI but directly from a GitHub tag or branch, then the corresponding tag, commit, or branch version becomes what matters most.

  3. Currently, this project is automatically published to PyPI via GitHub Actions "build-test-publish.yml" when a commit is pushed to the master branch.

@yehui-h
Copy link
Copy Markdown
Collaborator Author

yehui-h commented Apr 14, 2026

Once it has been merged into development, it can then be merged into master and deployed, so that I can use it properly in SMA app.

@FedericoTartarini FedericoTartarini merged commit b4bfd59 into development Apr 14, 2026
4 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.

2 participants