Skip to content

Commit

Permalink
Add rng to random_state
Browse files Browse the repository at this point in the history
  • Loading branch information
goerz committed Jan 6, 2024
1 parent de57999 commit 0602846
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
4 changes: 4 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ version = "0.1.3+dev"
[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
QuantumControlBase = "f10a33bc-5a64-497c-be7b-6f86b4f0c2aa"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[compat]
LinearAlgebra = "1"
QuantumControlBase = ">=0.8.4"
Random = "1"
SparseArrays = "1"
julia = "1.9"
10 changes: 9 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using QuantumGradientGenerators
using Documenter
using DocumenterInterLinks
using Pkg

DocMeta.setdocmeta!(
Expand All @@ -25,7 +26,14 @@ makedocs(;
format=Documenter.HTML(;
prettyurls=true,
canonical="https://juliaquantumcontrol.github.io/QuantumGradientGenerators.jl",
assets=String[],
assets=[
asset(
"https://juliaquantumcontrol.github.io/QuantumControl.jl/dev/assets/topbar/topbar.css"
),
asset(
"https://juliaquantumcontrol.github.io/QuantumControl.jl/dev/assets/topbar/topbar.js"
),
],
footer="[$NAME.jl]($GITHUB) v$VERSION docs powered by [Documenter.jl](https://github.com/JuliaDocs/Documenter.jl)."
),
pages=["Home" => "index.md", "API" => "api.md",]
Expand Down
7 changes: 4 additions & 3 deletions src/gradgen_operator.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Random: GLOBAL_RNG
import QuantumControlBase.QuantumPropagators: _exp_prop_convert_operator
import QuantumControlBase.QuantumPropagators.Controls: get_controls
import QuantumControlBase.QuantumPropagators.SpectralRange: random_state
Expand Down Expand Up @@ -28,10 +29,10 @@ function get_controls(O1::GradgenOperator)
end


function random_state(H::GradgenOperator)
state = random_state(H.G)
function random_state(H::GradgenOperator; rng=GLOBAL_RNG, _...)
state = random_state(H.G; rng)
num_controls = length(H.control_deriv_ops)
grad_states = [random_state(H.G) for i eachindex(H.control_deriv_ops)]
grad_states = [random_state(H.G; rng) for i eachindex(H.control_deriv_ops)]
return GradVector{num_controls,typeof(state)}(state, grad_states)
end

Expand Down
3 changes: 2 additions & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[deps]
Coverage = "a2441757-f6aa-5fb2-8edb-039e3f45d037"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DocumenterInterLinks = "d12716ef-a0f6-4df4-a9f1-a5a34e75c656"
GRAPE = "6b52fcaf-80fe-489a-93e9-9f92080510be"
GRAPELinesearchAnalysis = "290eba36-e2d8-4488-81b6-f66cc44f2186"
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
Expand All @@ -16,5 +17,5 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[compat]
julia = "1.9"
Documenter = "1.1"
julia = "1.9"

0 comments on commit 0602846

Please sign in to comment.