Skip to content

Commit

Permalink
Few missing methods for FreeParameter (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyatt-aws authored Feb 13, 2023
1 parent 3bc15ff commit e0d581f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Braket.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ fixed value later by supplying a mapping to a [`Circuit`](@ref).
"""
struct FreeParameter
name::Symbol
FreeParameter(name::Symbol) = new(name)
FreeParameter(name::String) = new(Symbol(name))
end
Base.copy(fp::FreeParameter) = fp
Base.show(io::IO, fp::FreeParameter) = print(io, string(fp.name))

include("compiler_directive.jl")
Expand Down
3 changes: 3 additions & 0 deletions test/free_parameter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ using Braket, Test
new_circ = circ(theta=2.0, alpha=1.0, phi=0.2)
non_para_circ = Circuit() |> (ci->H(ci, 0)) |> (ci->Rx(ci, 1, 1.0)) |> (ci->Ry(ci, 0, 2.0)) |> Probability |> (ci->apply_gate_noise!(ci, BitFlip(0.2))) |> (ci->apply_gate_noise!(ci, PhaseFlip(0.1)))
@test new_circ == non_para_circ
b = FreeParameter("b")
@test b.name == :b
@test copy(b) === b
end

0 comments on commit e0d581f

Please sign in to comment.