Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default value of keyword parameter saveat #260

Merged
merged 2 commits into from
Oct 8, 2024

Conversation

ytdHuang
Copy link
Member

@ytdHuang ytdHuang commented Oct 8, 2024

Checklist

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

  • Please read Contributor Covenant Code of Conduct
  • 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.

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

The original default value of saveat is given by

saveat = e_ops isa Nothing ? t_l : [t_l[end]]

This causes ambiguity when user specify e_ops = [], because:

[] isa Nothing # false

Therefore, I change it to

saveat = is_empty_e_ops ? t_l : [t_l[end]]

where is_empty_e_ops is pre-defined as

is_empty_e_ops = isempty(e_ops)

and this works becasue

isempty([]) # ture
isempty(nothing) # true

Copy link

codecov bot commented Oct 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.54%. Comparing base (87ce64e) to head (586b910).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #260      +/-   ##
==========================================
- Coverage   93.16%   92.54%   -0.63%     
==========================================
  Files          31       31              
  Lines        2327     2321       -6     
==========================================
- Hits         2168     2148      -20     
- Misses        159      173      +14     

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

@ytdHuang ytdHuang marked this pull request as draft October 8, 2024 07:40
@ytdHuang ytdHuang marked this pull request as ready for review October 8, 2024 07:42
Copy link
Member

@albertomercurio albertomercurio left a comment

Choose a reason for hiding this comment

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

LGTM!

@albertomercurio
Copy link
Member

Oh, wait, the code quality failed

@albertomercurio
Copy link
Member

But it failed for other reasons. Strange.

@albertomercurio
Copy link
Member

Ok, it is a problem related to the new release of Julia v1.11.0. Let's merge it

@albertomercurio albertomercurio merged commit bdedbda into qutip:main Oct 8, 2024
9 of 11 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