Skip to content

Use expm1 in n_thermal for stability.#717

Merged
ytdHuang merged 3 commits into
qutip:mainfrom
albertomercurio:dev/patch-2
May 13, 2026
Merged

Use expm1 in n_thermal for stability.#717
ytdHuang merged 3 commits into
qutip:mainfrom
albertomercurio:dev/patch-2

Conversation

@albertomercurio
Copy link
Copy Markdown
Member

Checklist

Thank you for contributing to QuantumToolbox.jl! Please make sure you have finished the following tasks before opening the PR.

  • Please read Contributing to Quantum Toolbox in Julia.
  • Any code changes were done in a way that does not break public API.
  • Appropriate tests were added and tested locally by running: make test.
  • Any code changes should be julia formatted by running: make format.
  • All documents (in docs/ folder) related to code changes were updated and able to build locally by running: make docs.
  • (If necessary) the CHANGELOG.md should be updated (regarding to the code changes) and built by running: make changelog.

Request for a review after you have completed all the tasks. If you have not finished them all, you can also open a Draft Pull Request to let the others know this on-going work.

Description

In the n_thermal function we are currently computing y = exp(x) and then y - 1. This can be directly done with the expm1, which is specifically designed to handle the x <<1 case.

@albertomercurio albertomercurio marked this pull request as ready for review May 12, 2026 08:06
Comment thread src/utilities.jl
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.22%. Comparing base (6cb6ef8) to head (4c4e986).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #717   +/-   ##
=======================================
  Coverage   93.22%   93.22%           
=======================================
  Files          57       57           
  Lines        3912     3914    +2     
=======================================
+ Hits         3647     3649    +2     
  Misses        265      265           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ytdHuang ytdHuang merged commit 95e0442 into qutip:main May 13, 2026
18 of 20 checks passed
@ytdHuang ytdHuang mentioned this pull request May 13, 2026
6 tasks
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