diff --git a/src/interface/generic/cast.jl b/src/interface/generic/cast.jl index 5f73b28a..b0005262 100644 --- a/src/interface/generic/cast.jl +++ b/src/interface/generic/cast.jl @@ -121,7 +121,7 @@ end function cast( sense_route::Pair{A,B}, domain_route::Pair{X,Y}, - data, + data..., ) where {A<:Sense,B<:Sense,X<:Domain,Y<:Domain} - return cast(sense_route, cast(domain_route, data)) + return cast(sense_route, cast(domain_route, data...)...) end diff --git a/src/library/sampleset.jl b/src/library/sampleset.jl index 7fe93f14..5c936b31 100644 --- a/src/library/sampleset.jl +++ b/src/library/sampleset.jl @@ -1,9 +1,8 @@ -function cast(::Pair{D,D}, ψ::Vector{U}) where {U<:Integer,D<:Domain} - return copy(ψ) -end +cast(::Pair{D,D}, x::Integer) where {D<:Domain} = x +cast(::Pair{BoolDomain,SpinDomain}, x::Integer) = (2 * x) - 1 +cast(::Pair{SpinDomain,BoolDomain}, s::Integer) = (s + 1) ÷ 2 -cast(::Pair{BoolDomain,SpinDomain}, x::Integer) = (2 * x) - 1 -cast(::Pair{SpinDomain,BoolDomain}, s::Integer) = (s + 1) ÷ 2 +cast(::Pair{D,D}, ψ::Vector{U}) where {U<:Integer,D<:Domain} = copy(ψ) cast(::Pair{BoolDomain,SpinDomain}, ψ::Vector{U}) where {U<:Integer} = (2 .* ψ) .- 1 cast(::Pair{SpinDomain,BoolDomain}, ψ::Vector{U}) where {U<:Integer} = (ψ .+ 1) .÷ 2 @@ -221,6 +220,10 @@ It was inspired by [^dwave], with a few tweaks. return new{T,U}(data, metadata) end + function SampleSet{T,U}(metadata::Dict{String,Any}) where {T,U} + return new{T,U}(Sample{T,U}[], metadata) + end + function SampleSet{T,U}() where {T,U} return new{T,U}(Sample{T,U}[], Dict{String,Any}()) end