diff --git a/src/genetic_operators/crossover/mutation_wrapper.jl b/src/genetic_operators/crossover/mutation_wrapper.jl index 83532eaa..f01b3616 100644 --- a/src/genetic_operators/crossover/mutation_wrapper.jl +++ b/src/genetic_operators/crossover/mutation_wrapper.jl @@ -11,7 +11,7 @@ end function apply!(wrapper::MutationWrapper, target::Individual, targetIndex::Int, pop, parentIndices) @assert length(parentIndices) == 1 - apply!(wrapper.inner, copy!(target, view(pop, parentIndices[1])), targetIndex) + apply!(wrapper.inner, copy!(target, viewer(pop, parentIndices[1])), targetIndex) end Base.show(io::IO, xover::MutationWrapper) = print(io, "MutationWrapper(", xover.inner, ")") diff --git a/test/test_crossover_operators.jl b/test/test_crossover_operators.jl index 2e7032a4..f98779af 100644 --- a/test/test_crossover_operators.jl +++ b/test/test_crossover_operators.jl @@ -62,4 +62,15 @@ context("DiffEvoRandBin1") do end end +context("MutationWrapper") do + ss = symmetric_search_space(2, (0.0, 10.0)) + pop = reshape(collect(1.0:8.0), 2, 4) + gibbs = UniformMutation(ss) + gibbs_wrapper = BlackBoxOptim.MutationWrapper(gibbs) + @fact numchildren(gibbs_wrapper) --> 1 + @fact numparents(gibbs_wrapper) --> 1 + mut_res = BlackBoxOptim.apply!(gibbs_wrapper, [0.0, 0.0], 1, pop, [2]) + @fact sum(mut_res .== BlackBoxOptim.viewer(pop, 2)) --> 0 +end + end