Skip to content

tests: Check results of nebulosity estimation when no convergence - #487

Open
lou-qui wants to merge 9 commits into
mainfrom
test-nebulosity-no-convergence
Open

tests: Check results of nebulosity estimation when no convergence#487
lou-qui wants to merge 9 commits into
mainfrom
test-nebulosity-no-convergence

Conversation

@lou-qui

@lou-qui lou-qui commented Jul 2, 2026

Copy link
Copy Markdown
Member

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

lou-qui added 2 commits July 2, 2026 11:11
Signed-off-by: lou-qui <184963772+lou-qui@users.noreply.github.com>
Signed-off-by: lou-qui <184963772+lou-qui@users.noreply.github.com>
@lou-qui lou-qui self-assigned this Jul 2, 2026
Copilot AI review requested due to automatic review settings July 2, 2026 09:13
def test_nebulosity__no_solution() -> None:
pass
def test_nebulosity__no_solution(caplog: pytest.LogCaptureFixture) -> None:
with caplog.at_level(logging.WARNING):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For now running this tests causes warnings to appear in the logs, it might be useful to prevent that so as not to pollute the logs with useless messages? Do you have any idea how to do that?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would prefer verify a warning and not to test the logs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I suggest to fill the gap in thermohl itself.
In mechaphlowers we think that logger output is very fragile and should be used minimum possible.

Is it possible to warn in thermohl and catch it in mechaphlowers ? But catching warning code is not easy.

A simpler way could be to return 2 values: the result and a convergence flag. It passes the convergence information allowing to the caller to warn or raise with a simple if else. This is my suggestion.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I added a convergence flag in thermohl (see phlowers/thermohl#169). Now waiting for a new release of thermohl, then I can adapt the code here in mechaphlowers.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

New version of thermohl released and used in mechaphlowers!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds coverage for ThermalEngine.nebulosity() behavior when the underlying nebulosity estimation does not converge, and updates the API docstring to describe the expected boundary behavior.

Changes:

  • Replaces the previously skipped test_nebulosity__no_solution with assertions for the non-convergent case (including warning capture).
  • Adds expectations that the result clamps to boundary nebulosities (0 / 8) when no solution is found.
  • Updates ThermalEngine.nebulosity() docstring to document the clamp behavior.

Reviewed changes

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

File Description
test/core/models/cable/test_thermal.py Adds an active regression test for the “no convergence” nebulosity estimation path and checks returned boundary values + warning logging.
src/mechaphlowers/core/models/cable/thermal.py Documents the clamp-to-boundaries behavior when no nebulosity yields the requested radiation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/mechaphlowers/core/models/cable/thermal.py Outdated
Comment thread test/core/models/cable/test_thermal.py Outdated
Comment thread test/core/models/cable/test_thermal.py Outdated
Comment thread test/core/models/cable/test_thermal.py Outdated
Comment thread test/core/models/cable/test_thermal.py Outdated
@sonarqubecloud

sonarqubecloud Bot commented Jul 2, 2026

Copy link
Copy Markdown

def test_nebulosity__no_solution() -> None:
pass
def test_nebulosity__no_solution(caplog: pytest.LogCaptureFixture) -> None:
with caplog.at_level(logging.WARNING):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would prefer verify a warning and not to test the logs.

def test_nebulosity__no_solution() -> None:
pass
def test_nebulosity__no_solution(caplog: pytest.LogCaptureFixture) -> None:
with caplog.at_level(logging.WARNING):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I suggest to fill the gap in thermohl itself.
In mechaphlowers we think that logger output is very fragile and should be used minimum possible.

Is it possible to warn in thermohl and catch it in mechaphlowers ? But catching warning code is not easy.

A simpler way could be to return 2 values: the result and a convergence flag. It passes the convergence information allowing to the caller to warn or raise with a simple if else. This is my suggestion.

lou-qui and others added 7 commits August 26, 2026 14:12
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: lou-qui <184963772+lou-qui@users.noreply.github.com>
Signed-off-by: lou-qui <184963772+lou-qui@users.noreply.github.com>
Signed-off-by: lou-qui <184963772+lou-qui@users.noreply.github.com>
Signed-off-by: lou-qui <184963772+lou-qui@users.noreply.github.com>
Signed-off-by: lou-qui <184963772+lou-qui@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

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