Skip to content

Commit 03e3bad

Browse files
committed
Add tests for get_structure_mat and get_structure_vec
1 parent 6d422b7 commit 03e3bad

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/Utilities.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Base.:(==)(a::PDCP, b::PDCP) where {PDCP <: PairedDataContainerProcessor} =
8181

8282
function get_structure_vec(structure_vecs, name = nothing)
8383
if isnothing(name)
84-
if size(structure_vecs) == 1
84+
if length(structure_vecs) == 1
8585
return only(values(structure_vecs))
8686
elseif isempty(structure_vecs)
8787
throw(ArgumentError("Please provide a structure vector."))

test/Utilities/runtests.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,25 @@ end
4949
# Seed for pseudo-random number generator
5050
rng = Random.MersenneTwister(4154)
5151

52+
# Tests for get_structure_vec and get_structure_mat
53+
structure_vecs = Dict("a" => [1, 2, 3], "b" => [4, 5, 6])
54+
structure_mats = Dict("c" => [1 2; 3 4], "d" => [5 6; 7 8])
55+
@test Utilities.get_structure_vec(structure_vecs, "a") == [1, 2, 3]
56+
@test Utilities.get_structure_vec(structure_vecs, "b") == [4, 5, 6]
57+
@test Utilities.get_structure_mat(structure_mats, "c") == [1 2; 3 4]
58+
@test Utilities.get_structure_mat(structure_mats, "d") == [5 6; 7 8]
59+
@test_throws ArgumentError Utilities.get_structure_vec(structure_vecs, "c")
60+
@test_throws ArgumentError Utilities.get_structure_mat(structure_mats, "a")
61+
@test_throws ArgumentError Utilities.get_structure_vec(structure_vecs)
62+
@test_throws ArgumentError Utilities.get_structure_mat(structure_mats)
63+
64+
structure_vecs = Dict("a" => [1, 2, 3])
65+
@test Utilities.get_structure_vec(structure_vecs) == [1, 2, 3]
66+
@test Utilities.get_structure_vec(structure_vecs, "a") == [1, 2, 3]
67+
structure_mats = Dict("c" => [1 2; 3 4])
68+
@test Utilities.get_structure_mat(structure_mats) == [1 2; 3 4]
69+
@test Utilities.get_structure_mat(structure_mats, "c") == [1 2; 3 4]
70+
5271
# quick build tests and test getters
5372
zs = zscore_scale()
5473
mm = minmax_scale()

0 commit comments

Comments
 (0)