Skip to content

Commit

Permalink
put fold! method in separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
joergbuchwald committed Jul 15, 2021
1 parent cb6a26c commit 54324c8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
1 change: 1 addition & 0 deletions src/ExperimentalDesign.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ include("random.jl")
include("kl_exchange.jl")
include("custom_show.jl")
include("categorical.jl")
include("fold.jl")

end
34 changes: 0 additions & 34 deletions src/design.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,40 +97,6 @@ end
"""
$(TYPEDSIGNATURES)
```jldoctest
julia> fold!(PlackettBurman(2))
8×3 DataFrame
│ Row │ factor1 │ factor2 │ dummy1 │
│ │ Int64 │ Int64 │ Int64 │
├─────┼─────────┼─────────┼────────┤
│ 1 │ 1 │ 1 │ 1 │
│ 2 │ 1 │ -1 │ -1 │
│ 3 │ -1 │ -1 │ 1 │
│ 4 │ -1 │ 1 │ -1 │
│ 5 │ -1 │ -1 │ -1 │
│ 6 │ -1 │ 1 │ 1 │
│ 7 │ 1 │ 1 │ -1 │
│ 8 │ 1 │ -1 │ 1 │
```
"""
function fold!(design::AbstractScreeningDesign)
mirror_matrix = deepcopy(design.matrix)
if mirror_matrix[1,1] isa Symbol
for col in names(mirror_matrix)
replace!(mirror_matrix[col], :low => :high, :high => :low)
end
else
for col in names(mirror_matrix)
replace!(mirror_matrix[col], 1 => -1, -1 => 1)
end
end
append!(design.matrix, mirror_matrix)
end

"""
$(TYPEDSIGNATURES)
```jldoctest
julia> PlackettBurman(4)
PlackettBurman
Expand Down
33 changes: 33 additions & 0 deletions src/fold.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
$(TYPEDSIGNATURES)
```jldoctest
julia> fold!(PlackettBurman(2))
8×3 DataFrame
│ Row │ factor1 │ factor2 │ dummy1 │
│ │ Int64 │ Int64 │ Int64 │
├─────┼─────────┼─────────┼────────┤
│ 1 │ 1 │ 1 │ 1 │
│ 2 │ 1 │ -1 │ -1 │
│ 3 │ -1 │ -1 │ 1 │
│ 4 │ -1 │ 1 │ -1 │
│ 5 │ -1 │ -1 │ -1 │
│ 6 │ -1 │ 1 │ 1 │
│ 7 │ 1 │ 1 │ -1 │
│ 8 │ 1 │ -1 │ 1 │
```
"""
function fold!(design::AbstractScreeningDesign)
mirror_matrix = deepcopy(design.matrix)
if mirror_matrix[1,1] isa Symbol
for col in names(mirror_matrix)
replace!(mirror_matrix[col], :low => :high, :high => :low)
end
else
for col in names(mirror_matrix)
replace!(mirror_matrix[col], 1 => -1, -1 => 1)
end
end
append!(design.matrix, mirror_matrix)
end

0 comments on commit 54324c8

Please sign in to comment.