From a9868d60485d1d635e74d94ad73f30b6e28a4761 Mon Sep 17 00:00:00 2001 From: Yaroslav Kharkov Date: Tue, 13 Aug 2024 12:16:08 -0400 Subject: [PATCH] Respond to PR comments --- src/mps_utils.jl | 10 +++++----- test/runtests.jl | 6 ------ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/mps_utils.jl b/src/mps_utils.jl index b85dc2c..ddc183c 100644 --- a/src/mps_utils.jl +++ b/src/mps_utils.jl @@ -57,16 +57,16 @@ function parse_protocol(ahs_program, τ::Float64, n_τ_steps::Int) values_Ω = ahs_program["hamiltonian"]["drivingFields"][1]["amplitude"]["time_series"]["values"] n_atoms = length(ahs_program["setup"]["ahs_register"]["sites"]) + # Supporting both localDetuning and shiftingFields naming conventions - loc_detuning_key = "" - if "shiftingFields" ∈ keys(ahs_program["hamiltonian"]) - loc_detuning_key = "shiftingFields" + loc_detuning_key = if "shiftingFields" ∈ keys(ahs_program["hamiltonian"]) + "shiftingFields" elseif "localDetuning" ∈ keys(ahs_program["hamiltonian"]) - loc_detuning_key = "localDetuning" + "localDetuning" end # Check if local detuning or shifting fields were found, otherwise assign zeros - if !isempty(loc_detuning_key) + if !(loc_detuning_key === nothing) values_local_detuning = ahs_program["hamiltonian"][loc_detuning_key][1]["magnitude"]["time_series"]["values"] time_points_loc_detuning = ahs_program["hamiltonian"][loc_detuning_key][1]["magnitude"]["time_series"]["times"] pattern = ahs_program["hamiltonian"][loc_detuning_key][1]["magnitude"]["pattern"] diff --git a/test/runtests.jl b/test/runtests.jl index f472eac..ac39591 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,8 +3,6 @@ using Test using JSON3 @testset "BraketAHS.jl: Non-empty local detunings" begin - # Write your tests here. - json_str = """{"setup":{"ahs_register":{"sites":[["0.0","0.0"],["5.499999999999999856993733449161965e-6","0.0"],["0.0","5.499999999999999856993733449161965e-6"],["5.499999999999999856993733449161965e-6","5.499999999999999856993733449161965e-6"]],"filling":[1,1,1,1]}},"braketSchemaHeader":{"name":"braket.ir.ahs.program","version":"1"},"hamiltonian":{"shiftingFields":[{"magnitude":{"pattern":["0.0","0.0","0.0","0.0"],"time_series":{"values":["0.0","0.0"],"times":["0.0","3.999999999999999818992447303545035e-6"]}}}],"drivingFields":[{"phase":{"pattern":"uniform","time_series":{"values":["0.0","0.0"],"times":["0.0","3.999999999999999818992447303545035e-6"]}},"detuning":{"pattern":"uniform","time_series":{"values":["-3.15e7","-3.15e7","3.15e7","3.15e7"],"times":["0.0","9.999999999999999547481118258862587e-8","3.899999999999999929396754527743951e-6","3.999999999999999818992447303545035e-6"]}},"amplitude":{"pattern":"uniform","time_series":{"values":["0.0","6.3e6","6.3e6","0.0"],"times":["0.0","9.999999999999999547481118258862587e-8","3.899999999999999929396754527743951e-6","3.999999999999999818992447303545035e-6"]}}}]}} """ ahs_json = JSON3.read(json_str) @@ -30,8 +28,6 @@ using JSON3 mps_density = result["density"][:, end] expected_density = [0.49558400861051327,0.4955839949350386,0.49558370707943783,0.49558323080865946] @test isapprox(mps_density, expected_density; atol=1e-7) - # add apprx cmoparison isapprox(array1, array2; atol=tolerance) - end @testset "BraketAHS.jl: Empty local detunings" begin @@ -60,6 +56,4 @@ end mps_density = result["density"][:, end] expected_density = [0.49558400861051327,0.4955839949350386,0.49558370707943783,0.49558323080865946] @test isapprox(mps_density, expected_density; atol=1e-7) - # add apprx cmoparison isapprox(array1, array2; atol=tolerance) - end