Skip to content

Commit

Permalink
Merge pull request #27 from JuliaReach/schillic/coverage
Browse files Browse the repository at this point in the history
Increase test coverage
  • Loading branch information
schillic authored Dec 3, 2023
2 parents 1961255 + 18359e4 commit 759b358
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Architecture/AbstractNeuralNetwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Return a list of the layers of a neural network.
The list of layers.
"""
function layers(::AbstractNeuralNetwork) end
function layers(::AbstractNeuralNetwork) end # COV_EXCL_LINE

"""
dim_in(N::AbstractNeuralNetwork)
Expand Down
4 changes: 1 addition & 3 deletions src/FileFormats/MAT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,14 @@ function read_MAT(filename::String; act_key::String,
end

# convert to a Vector
_vec(A::Vector) = A
_vec(A::AbstractMatrix) = vec(A)
_vec(A::Number) = [A]

# convert to a Matrix
_mat(A::Matrix) = A
_mat(A::Number) = hcat(A)
function _mat(A::Array{<:Number,4})
# weights are sometimes stored as a multi-dimensional array with two flat
# dimensions
# weights may be stored as 4-dimensional array with two flat dimensions
s = size(A)
if s[3] == 1 && s[4] == 1
return reshape(A, s[1], s[2])
Expand Down
7 changes: 7 additions & 0 deletions test/FileFormats/MAT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ file = joinpath(@__DIR__, "sample_MAT2.mat")
# parse file
N = read_MAT(file; act_key="act_fcns")

# alternative file with 4D weights but invalid dimensions
file = joinpath(@__DIR__, "sample_MAT_invalid.mat")

# parse file
@test_throws ArgumentError read_MAT(file; act_key="act_fcns")


@test length(N.layers) == 4

# alternative file with nested dictionary
Expand Down
Binary file added test/FileFormats/sample_MAT_invalid.mat
Binary file not shown.

0 comments on commit 759b358

Please sign in to comment.