Skip to content

Commit fdfa666

Browse files
authored
Add methods in support of PerezHz/TaylorIntegration.jl#192 (#356)
* Add RecursiveArrayTools extension and setindex! dispatch for mixtures * Add RecursiveArrayTools extension and a Base.setindex! for mixtures * Fix in setindex! * Fix test * Add RAT compat entry (found by Aqua)
1 parent 3a7360f commit fdfa666

File tree

6 files changed

+41
-4
lines changed

6 files changed

+41
-4
lines changed

Project.toml

Lines changed: 6 additions & 2 deletions
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.5"
4+
version = "0.17.6"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
@@ -13,18 +13,21 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1313
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
1414
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
1515
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
16+
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
1617

1718
[extensions]
1819
TaylorSeriesIAExt = "IntervalArithmetic"
1920
TaylorSeriesJLD2Ext = "JLD2"
2021
TaylorSeriesSAExt = "StaticArrays"
22+
TaylorSeriesRATExt = "RecursiveArrayTools"
2123

2224
[compat]
2325
Aqua = "0.8"
2426
IntervalArithmetic = "0.15 - 0.20"
2527
JLD2 = "0.4"
2628
LinearAlgebra = "<0.0.1, 1"
2729
Markdown = "<0.0.1, 1"
30+
RecursiveArrayTools = "2, 3"
2831
Requires = "0.5.2, 1"
2932
SparseArrays = "<0.0.1, 1"
3033
StaticArrays = "1"
@@ -36,9 +39,10 @@ Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
3639
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
3740
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
3841
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
42+
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
3943
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
4044
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
4145
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
4246

4347
[targets]
44-
test = ["IntervalArithmetic", "JLD2", "LinearAlgebra", "SparseArrays", "StaticArrays", "Test", "Aqua"]
48+
test = ["IntervalArithmetic", "JLD2", "LinearAlgebra", "RecursiveArrayTools", "SparseArrays", "StaticArrays", "Test", "Aqua"]

ext/TaylorSeriesRATExt.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module TaylorSeriesRATExt
2+
3+
using TaylorSeries
4+
5+
isdefined(Base, :get_extension) ? (import RecursiveArrayTools) : (import ..RecursiveArrayTools)
6+
7+
function RecursiveArrayTools.recursivecopy(a::AbstractArray{<:AbstractSeries, N}) where N
8+
deepcopy(a)
9+
end
10+
11+
end

src/auxiliary.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ getindex(a::Taylor1{T}, u::StepRange{Int,Int}) where {T<:Number} =
8484
view(a.coeffs, u[:] .+ 1)
8585

8686
setindex!(a::Taylor1{T}, x::T, n::Int) where {T<:Number} = a.coeffs[n+1] = x
87+
setindex!(a::Taylor1{T}, x::T, n::Int) where {T<:AbstractSeries} = setindex!(a.coeffs, deepcopy(x), n+1)
8788
setindex!(a::Taylor1{T}, x::T, u::UnitRange{Int}) where {T<:Number} =
8889
a.coeffs[u .+ 1] .= x
8990
function setindex!(a::Taylor1{T}, x::Array{T,1}, u::UnitRange{Int}) where {T<:Number}
@@ -405,4 +406,3 @@ macro isonethread(expr)
405406
end
406407
end)
407408
end
408-

test/mixtures.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,12 @@ using Test
496496
@test two/x == 2/x == 2.0/x
497497
@test (2one(x))/x == 2/x
498498

499+
dq = get_variables()
500+
x = Taylor1(exp.(dq), 5)
501+
x[1] = sin(dq[1]*dq[2])
502+
@test x[1] == sin(dq[1]*dq[2])
503+
@test x[1] !== sin(dq[1]*dq[2])
504+
499505
@testset "Test Base.float overloads for Taylor1 and TaylorN mixtures" begin
500506
q = get_variables(Int)
501507
x1N = Taylor1(q)

test/rat.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This file is part of TaylorSeries.jl, MIT licensed
2+
#
3+
4+
using TaylorSeries, RecursiveArrayTools
5+
6+
using Test
7+
8+
@testset "Tests TaylorSeries RecursiveArrayTools extension" begin
9+
dq = get_variables()
10+
x = Taylor1([0.9+2dq[1],-1.1dq[1], 0.7dq[2], 0.5dq[1]-0.45dq[2],0.9dq[1]])
11+
xx = [x,x]
12+
yy = recursivecopy(xx)
13+
@test yy == xx # yy and xx are equal...
14+
@test yy !== xx # ...but they're not the same object in memory
15+
end

test/runtests.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ testfiles = (
1212
"identities_Euler.jl",
1313
"fateman40.jl",
1414
"staticarrays.jl",
15-
"jld2.jl"
15+
"jld2.jl",
16+
"rat.jl"
1617
)
1718

1819
for file in testfiles

0 commit comments

Comments
 (0)