Skip to content

Commit 3a7360f

Browse files
authored
Add TaylorN constructor (#355)
* Add TaylorN constructor * Bump patch version * Remove some tests added by mistake * Add test suggested by @lbenet
1 parent 87116db commit 3a7360f

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "TaylorSeries"
22
uuid = "6aa5eb33-94cf-58f4-a9d0-e4b2c4fc25ea"
33
repo = "https://github.com/JuliaDiff/TaylorSeries.jl.git"
4-
version = "0.17.4"
4+
version = "0.17.5"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/constructors.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,5 +211,6 @@ const NumberNotSeries = Union{Real,Complex}
211211
# A `Number` which is not `TaylorN` nor a `HomogeneousPolynomial`
212212
const NumberNotSeriesN = Union{Real,Complex,Taylor1}
213213

214-
## Additional Taylor1 outer constructor ##
214+
## Additional Taylor1 and TaylorN outer constructor ##
215215
Taylor1{T}(x::S) where {T<:Number,S<:NumberNotSeries} = Taylor1([convert(T,x)], 0)
216+
TaylorN{T}(x::S) where {T<:Number,S<:NumberNotSeries} = TaylorN(convert(T, x), TaylorSeries.get_order())

test/manyvariables.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ using Test
66
# using LinearAlgebra
77

88
@testset "Test hash tables" begin
9+
a = TaylorN{Float64}(9//10)
10+
a isa TaylorN{Float64}
11+
@test constant_term(a) == Float64(9//10)
12+
b = TaylorN{Complex{Float64}}(-4//7im)
13+
@test b isa TaylorN{Complex{Float64}}
14+
@test_throws MethodError TaylorN(-4//7im)
915
# Issue #85 is solved!
1016
set_variables("x", numvars=66, order=1)
1117
@test TS._params_TaylorN_.order == get_order() == 1
@@ -791,6 +797,7 @@ end
791797
@test float(HomogeneousPolynomial{Complex{Int}}) == float(HomogeneousPolynomial{Complex{Float64}})
792798
@test float(TaylorN{Complex{Rational}}) == float(TaylorN{Complex{Float64}})
793799
end
800+
794801
end
795802

796803
@testset "Integrate for several variables" begin

0 commit comments

Comments
 (0)