-
Notifications
You must be signed in to change notification settings - Fork 31
Introduce QuantumToolbox.settings and auto_tidyup
#460
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
654b4cb
Introduce `QuantumToolbox.settings` and `auto_tidyup`
ytdHuang 0d2f79d
fix doctest
ytdHuang f64bda0
fix doctest
ytdHuang c557298
fix type instability
ytdHuang d225aef
minor change
ytdHuang 0a1be54
import `RefValue` from `Base`
ytdHuang 7cd8e0c
change `Settings` to mutable struct
ytdHuang 788c091
remove import of `RefValue`
ytdHuang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # [QuantumToolbox Settings](@id doc:QuantumToolbox-Settings) | ||
|
|
||
| In this section, we introduce the default global settings used throughout the package and show how to modify them. | ||
|
|
||
| All settings are stored in [`QuantumToolbox.settings`](@ref). | ||
|
|
||
| !!! warning "Differences from QuTiP" | ||
| Due to the differences in programming languages, solving algorithms, and many other reasons, these global settings (including their default values and usage) may be very different from those in `Python QuTiP`. | ||
|
|
||
| ## List of settings | ||
|
|
||
| Here, we list out each setting along with the specific functions that will use it. | ||
|
|
||
| - `tidyup_tol::Real = 1e-14` : tolerance for [`tidyup`](@ref) and [`tidyup!`](@ref). | ||
| - `auto_tidyup::Bool = true` : Automatically tidyup during the following situations: | ||
| * Solving for eigenstates, including [`eigenstates`](@ref), [`eigsolve`](@ref), and [`eigsolve_al`](@ref). | ||
| - (to be announced) | ||
|
|
||
| ## Change default settings | ||
|
|
||
| First, we can check the current [`QuantumToolbox.settings`](@ref): | ||
|
|
||
| ```@example settings | ||
| using QuantumToolbox | ||
|
|
||
| QuantumToolbox.settings | ||
| ``` | ||
|
|
||
| Next, one can overwrite the default settings by | ||
|
|
||
| ```@example settings | ||
| QuantumToolbox.settings.tidyup_tol[] = 1e-10 | ||
| QuantumToolbox.settings.auto_tidyup[] = false | ||
|
|
||
| QuantumToolbox.settings | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| Base.@kwdef struct Settings | ||
| tidyup_tol::Ref{Real} = 1e-14 | ||
| auto_tidyup::Ref{Bool} = true | ||
| end | ||
|
|
||
| function Base.show(io::IO, s::Settings) | ||
| println(io, "QuantumToolbox.jl Settings") | ||
| println(io, "--------------------------") | ||
| map(x -> println(io, "$x[] = ", getfield(s, x)[]), fieldnames(Settings)) | ||
| return nothing | ||
| end | ||
|
|
||
| @doc raw""" | ||
| QuantumToolbox.settings | ||
|
|
||
| Contains all the default global settings of QuantumToolbox.jl. | ||
|
|
||
| # List of settings | ||
|
|
||
| - `tidyup_tol::Real = 1e-14` : tolerance for [`tidyup`](@ref) and [`tidyup!`](@ref). | ||
| - `auto_tidyup::Bool = true` : Automatically tidyup. | ||
|
|
||
| For detailed explanation of each settings, see our documentation [here](https://qutip.org/QuantumToolbox.jl/stable/users_guide/settings). | ||
|
|
||
| # Change default settings | ||
|
|
||
| One can overwrite the default global settings by | ||
|
|
||
| ```julia | ||
| using QuantumToolbox | ||
|
|
||
| QuantumToolbox.settings.tidyup_tol[] = 1e-10 | ||
| QuantumToolbox.settings.auto_tidyup[] = false | ||
| ``` | ||
| """ | ||
| const settings = Settings() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.