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

Make shifting Fields or local Detunings optional. Add tests. #24

Merged
merged 2 commits into from
Aug 13, 2024

Conversation

ykharkov
Copy link
Member

*Resolving Issue #22 *

Description of changes:

  • Support both localDetuning and shiftingFields as input fields in AHS program JSON.
  • Make these fields optional (ignore if not present in AHS JSON)
  • Add test for empty localDetuning or shiftingFields field

@ykharkov ykharkov added the good first issue Good for newcomers label Aug 12, 2024
@ykharkov ykharkov requested a review from kshyatt-aws August 12, 2024 20:27
src/mps_utils.jl Outdated

n_atoms = length(ahs_program["setup"]["ahs_register"]["sites"])
# Supporting both localDetuning and shiftingFields naming conventions
loc_detuning_key = ""
Copy link
Member

Choose a reason for hiding this comment

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

Why not

loc_detuning_key = if "shiftingFields"  keys(ahs_program["hamiltonian"])
        "shiftingFields"
    elseif "localDetuning"  keys(ahs_program["hamiltonian"])
        "localDetuning"
    end

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, fixed

src/mps_utils.jl Outdated
end

# Check if local detuning or shifting fields were found, otherwise assign zeros
if !isempty(loc_detuning_key)
Copy link
Member

Choose a reason for hiding this comment

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

I think you can simplify this with Base.get

test/runtests.jl Outdated
@@ -2,7 +2,7 @@ using BraketAHS: run, save_results
using Test
using JSON3

@testset "BraketAHS.jl" begin
@testset "BraketAHS.jl: Non-empty local detunings" begin
# Write your tests here.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can get rid of this comment lol

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed comment

@ykharkov ykharkov merged commit a9f942d into main Aug 13, 2024
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants