From c0d48591fd658aaf6cd471a0f431c9fbaa185181 Mon Sep 17 00:00:00 2001 From: Luis Benet Date: Thu, 17 May 2018 14:25:22 -0500 Subject: [PATCH] Make more versatile get_variables (#166) --- src/parameters.jl | 11 +++++++---- test/manyvariables.jl | 6 ++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/parameters.jl b/src/parameters.jl index 7d716c9a..64f08fb6 100644 --- a/src/parameters.jl +++ b/src/parameters.jl @@ -48,15 +48,18 @@ function set_variable_names(varnames::Vector{T}) where {T<:AbstractString} nothing end """ - get_variables(;order=get_order()) + get_variables(T::Type, [order::Int=get_order()]) -Return a `TaylorN` vector with each entry representing an +Return a `TaylorN{T}` vector with each entry representing an independent variable. It takes the default `_params_TaylorN_` values if `set_variables` hasn't been changed with the exception that `order` can be explicitely established by the user without changing internal values -for `num_vars` or `variable_names`. +for `num_vars` or `variable_names`. Ommiting `T` defaults to `Float64`. """ -get_variables(;order::Integer=get_order()) = [TaylorN(i,order=order) for i in 1:get_numvars()] +get_variables(T::Type, order::Int=get_order()) = + [TaylorN(T, i, order=order) for i in 1:get_numvars()] +get_variables(order::Int=get_order()) = + [TaylorN(Float64, i, order=order) for i in 1:get_numvars()] """ set_variables([T::Type], names::String; [order=get_order(), numvars=-1]) diff --git a/test/manyvariables.jl b/test/manyvariables.jl index 716f1b1c..44b52395 100644 --- a/test/manyvariables.jl +++ b/test/manyvariables.jl @@ -44,8 +44,10 @@ end @test get_numvars() == 2 @test get_variables()[1].order == get_order() - @test get_variables(order=2)[1].order == 2 - @test get_variables(order=3)[1] == TaylorN(1,order=3) + @test get_variables(2)[1].order == 2 + @test get_variables(3)[1] == TaylorN(1, order=3) + @test get_variables(Int, 3)[1] == TaylorN(Int, 1, order=3) + @test length(get_variables()) == get_numvars() x, y = set_variables("x y", order=6) @test x.order == 6