Skip to content

Commit d8c8645

Browse files
committed
include tests
1 parent ef3f2b9 commit d8c8645

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

src/Core/Module_inclusion/set_Modules.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ create_module_specifics("Module1Name", module_list, specifics, values)
123123
```
124124
"""
125125
function create_module_specifics(name::Union{String,SubString},
126-
module_list::Vector{Dict{String,AbstractString}},
126+
module_list::Vector{Any},
127127
own_module::Module,
128128
specifics::Dict{String,String},
129129
values::Tuple)
@@ -143,7 +143,7 @@ end
143143
# Returns: the function itself
144144
"""
145145
function create_module_specifics(name::Union{String,SubString},
146-
module_list::Vector{Dict{String,AbstractString}},
146+
module_list::Vector{Any},
147147
own_module::Module,
148148
specifics::Dict{String,String})
149149
for m in module_list
@@ -159,7 +159,7 @@ function create_module_specifics(name::Union{String,SubString},
159159
end
160160
# only module
161161
function create_module_specifics(name::Union{String,SubString},
162-
module_list::Vector{Dict{String,AbstractString}},
162+
module_list::Vector{Any},
163163
own_module::Module,
164164
get_model_name::String)
165165
for m in module_list

src/Support/Helpers.jl

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -681,13 +681,13 @@ end
681681
"""
682682
check_inf_or_nan(array, msg)
683683
684-
Checks if the sum of the array is finite. If not, an error is raised.
684+
Checks if the sum of an array is finite and has only numbers. If not, an error is raised.
685685
686686
# Arguments
687687
- `array`: The array to check.
688688
- `msg`: The error message to raise.
689689
# Returns
690-
- `Bool`: `true` if the sum of the array is finite, `false` otherwise.
690+
- `Bool`: `true` if the scalar is finite and has only numbers, `false` otherwise.
691691
"""
692692
function check_inf_or_nan(array::AbstractArray{T},
693693
msg::String) where {T<:Union{Int64,Float64}}
@@ -701,15 +701,25 @@ function check_inf_or_nan(array::AbstractArray{T},
701701
end
702702
return false
703703
end
704+
"""
705+
check_inf_or_nan(scalar, msg)
706+
707+
Checks if a scalar is finite and a number. If not, an error is raised.
704708
705-
function check_inf_or_nan(array::T,
709+
# Arguments
710+
- `scalar`: The scalar to check.
711+
- `msg`: The error message to raise.
712+
# Returns
713+
- `Bool`: `true` if the scalar is finite, `false` otherwise.
714+
"""
715+
function check_inf_or_nan(scalar::T,
706716
msg::String) where {T<:Union{Int64,Float64}}
707-
if isnan(sum(array))
708-
@error "Field ''$msg'' has NaN elements."
717+
if isnan(scalar)
718+
@error "Scalar Value ''$msg'' is NaN."
709719
return true
710720
end
711-
if !isfinite(sum(array))
712-
@error "Field ''$msg'' is infinite."
721+
if !isfinite(scalar)
722+
@error "Scalar value ''$msg'' is infinite."
713723
return true
714724
end
715725
return false

test/unit_tests/Core/Module_inclusion/ut_set_Modules.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#
33
# SPDX-License-Identifier: BSD-3-Clause
44
module MockModule
5-
struct TestType end
65
get_name() = "existing_function"
76
call_function(args...) = sum(args)
87
end
@@ -65,9 +64,8 @@ end
6564

6665
filename::AbstractString = "MockModule.jl"
6766

68-
module_list = [
69-
Dict{String,AbstractString}("File" => filename,
70-
"Module Name" => "MockModule"),
67+
module_list::Vector{Any} = [Dict(("File" => filename,
68+
"Module Name" => "MockModule")),
7169
]
7270

7371
specifics = Dict("Name" => "get_name",

test/unit_tests/Support/ut_helpers.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,13 @@ end
289289
@test PeriLab.Solver_Manager.Helpers.check_inf_or_nan(a, "a") == false
290290
a[1, 1] = 1 / 0
291291
@test PeriLab.Solver_Manager.Helpers.check_inf_or_nan(a, "Testing infinite test vector")
292+
a[1, 1] = NaN
293+
@test PeriLab.Solver_Manager.Helpers.check_inf_or_nan(a, "Testing infinite test vector")
292294
a = 0
293295
@test PeriLab.Solver_Manager.Helpers.check_inf_or_nan(a, "a") == false
294296
a = NaN
297+
@test PeriLab.Solver_Manager.Helpers.check_inf_or_nan(a, "a")
298+
a = 1/0
295299
@test PeriLab.Solver_Manager.Helpers.check_inf_or_nan(a, "a") == true
296300
end
297301
@testset "get_matrix_style" begin

0 commit comments

Comments
 (0)