Skip to content

Commit a39fde6

Browse files
authored
Merge pull request #5 from devmotion/dw/unused_typeparameter
Fix unused type parameter
2 parents 6db939c + e755344 commit a39fde6

File tree

5 files changed

+30
-12
lines changed

5 files changed

+30
-12
lines changed

Project.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,18 @@ version = "1.0"
77
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
88
GLM = "38e38edf-8417-5370-95a0-9cbb8c7f171a"
99
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
10-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1110

1211
[compat]
12+
Aqua = "0.8"
13+
Dates = "<0.0.1, 1"
1314
GLM = "^1"
15+
LinearAlgebra = "<0.0.1, 1"
16+
Test = "<0.0.1, 1"
1417
julia = "^1.4"
18+
19+
[extras]
20+
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
21+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
22+
23+
[targets]
24+
test = ["Aqua", "Test"]

src/0_Structs_And_Enums.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ struct FunctionEvaluationResult{T<:Real,R}
1313
function FunctionEvaluationResult(Input::Vector{T}, Output_::Missing, Error_::Symbol, Other_Output_::Union{Missing,NamedTuple} = missing) where T<:Real
1414
return new{T,T}(Input, Output_, Other_Output_, Error_)
1515
end
16-
function FunctionEvaluationResult(Input::Vector{T}, Output::Vector{R}, Error_::Symbol, Other_Output_::Union{Missing,NamedTuple} = missing) where T<:Real where R<:Real
17-
return new{T,R}(Input, convert(Array{Union{Missing,R},1}, Output), Other_Output_, Error_)
18-
end
19-
function FunctionEvaluationResult(Input::Vector{T}, Output::Vector{Union{Missing,R}}, Error_::Symbol, Other_Output_::Union{Missing,NamedTuple} = missing) where T<:Real where R<:Real
20-
return new{T,R}(Input, Output, Other_Output_, Error_)
21-
end
22-
function FunctionEvaluationResult(Input::Vector{T}, Output::Vector{Missing}, Error_::Symbol, Other_Output_::Union{Missing,NamedTuple} = missing) where T<:Real
23-
return new{T,T}(Input, Output, Other_Output_, Error_)
16+
function FunctionEvaluationResult(Input::Vector{T}, Output::Vector{R}, Error_::Symbol, Other_Output_::Union{Missing,NamedTuple} = missing) where T<:Real where R<:Union{Missing,<:Real}
17+
if R === Missing
18+
return new{T,T}(Input, Output, Other_Output_, Error_)
19+
elseif R <: Real
20+
return new{T,R}(Input, convert(Array{Union{Missing,R},1}, Output), Other_Output_, Error_)
21+
else
22+
return new{T,nonmissingtype(R)}(Input, Output, Other_Output_, Error_)
23+
end
2424
end
2525
end
2626

src/1_MainFunctions.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ function fixed_point(func::Function, Inputs::Real;
158158
MaxIter = MaxIter, MaxM = MaxM, ExtrapolationPeriod = ExtrapolationPeriod, Dampening = Dampening, PrintReports = PrintReports, ReportingSigFig = ReportingSigFig,
159159
ReplaceInvalids = ReplaceInvalids, ConditionNumberThreshold = ConditionNumberThreshold, quiet_errors = quiet_errors)
160160
end
161-
function fixed_point(func::Function, Inputs::Array{T, 2}; Outputs::Array{R,2} = Array{T,2}(undef,size(Inputs)[1],0),
161+
function fixed_point(func::Function, Inputs::Array{T, 2}; Outputs::Array{<:Real,2} = Array{T,2}(undef,size(Inputs)[1],0),
162162
Algorithm::Symbol = :Anderson, ConvergenceMetric::Function = supnorm(input, output) = maximum(abs.(output .- input)),
163163
ConvergenceMetricThreshold::Real = 1e-10, MaxIter::Integer = Integer(1000), MaxM::Integer = Integer(10), ExtrapolationPeriod::Integer = Integer(7), Dampening::Real = AbstractFloat(1.0),
164-
PrintReports::Bool = false, ReportingSigFig::Integer = Integer(10), ReplaceInvalids::Symbol = :NoAction, ConditionNumberThreshold::Real = 1e3, quiet_errors::Bool = false, other_outputs::Union{Missing,NamedTuple} = missing) where T<:Real where R<:Real
164+
PrintReports::Bool = false, ReportingSigFig::Integer = Integer(10), ReplaceInvalids::Symbol = :NoAction, ConditionNumberThreshold::Real = 1e3, quiet_errors::Bool = false, other_outputs::Union{Missing,NamedTuple} = missing) where T<:Real
165165
# This code first tests if the input point is a fixed point. Then if it is not a while loop runs to try to find a fixed point.
166166
if (ConditionNumberThreshold < 1) error("ConditionNumberThreshold must be at least 1.") end
167167
SimpleStartIndex = Integer(size(Outputs)[2])
@@ -181,7 +181,7 @@ function fixed_point(func::Function, Inputs::Array{T, 2}; Outputs::Array{R,2} =
181181
end
182182
end
183183
LengthOfArray = size(Inputs)[1]
184-
output_type = promote_type(T,R)
184+
output_type = promote_type(T,eltype(Outputs))
185185
final_other_output = other_outputs
186186
# Do an initial run if no runs have been done:
187187
if isempty(Outputs)

test/Aqua.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
using Test
2+
@testset "Aqua" begin
3+
using FixedPointAcceleration
4+
import Aqua
5+
Aqua.test_all(FixedPointAcceleration)
6+
end

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ using FixedPointAcceleration
22
using Test
33

44
# Run tests
5+
println("Auto QUality Assurance")
6+
include("Aqua.jl")
57
println("Test putting together iterates with jumps")
68
include("TestPuttingInputsAndOutputsTogether.jl")
79
println("Test simple Scalar function")

0 commit comments

Comments
 (0)