Skip to content

Commit

Permalink
Add methods in support of PerezHz/TaylorIntegration.jl#192 (#356)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
PerezHz committed Apr 23, 2024
1 parent 3a7360f commit fdfa666
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 4 deletions.
8 changes: 6 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TaylorSeries"
uuid = "6aa5eb33-94cf-58f4-a9d0-e4b2c4fc25ea"
repo = "https://github.com/JuliaDiff/TaylorSeries.jl.git"
version = "0.17.5"
version = "0.17.6"

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

[extensions]
TaylorSeriesIAExt = "IntervalArithmetic"
TaylorSeriesJLD2Ext = "JLD2"
TaylorSeriesSAExt = "StaticArrays"
TaylorSeriesRATExt = "RecursiveArrayTools"

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

[targets]
test = ["IntervalArithmetic", "JLD2", "LinearAlgebra", "SparseArrays", "StaticArrays", "Test", "Aqua"]
test = ["IntervalArithmetic", "JLD2", "LinearAlgebra", "RecursiveArrayTools", "SparseArrays", "StaticArrays", "Test", "Aqua"]
11 changes: 11 additions & 0 deletions ext/TaylorSeriesRATExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module TaylorSeriesRATExt

using TaylorSeries

isdefined(Base, :get_extension) ? (import RecursiveArrayTools) : (import ..RecursiveArrayTools)

function RecursiveArrayTools.recursivecopy(a::AbstractArray{<:AbstractSeries, N}) where N
deepcopy(a)
end

end
2 changes: 1 addition & 1 deletion src/auxiliary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ getindex(a::Taylor1{T}, u::StepRange{Int,Int}) where {T<:Number} =
view(a.coeffs, u[:] .+ 1)

setindex!(a::Taylor1{T}, x::T, n::Int) where {T<:Number} = a.coeffs[n+1] = x
setindex!(a::Taylor1{T}, x::T, n::Int) where {T<:AbstractSeries} = setindex!(a.coeffs, deepcopy(x), n+1)
setindex!(a::Taylor1{T}, x::T, u::UnitRange{Int}) where {T<:Number} =
a.coeffs[u .+ 1] .= x
function setindex!(a::Taylor1{T}, x::Array{T,1}, u::UnitRange{Int}) where {T<:Number}
Expand Down Expand Up @@ -405,4 +406,3 @@ macro isonethread(expr)
end
end)
end

6 changes: 6 additions & 0 deletions test/mixtures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,12 @@ using Test
@test two/x == 2/x == 2.0/x
@test (2one(x))/x == 2/x

dq = get_variables()
x = Taylor1(exp.(dq), 5)
x[1] = sin(dq[1]*dq[2])
@test x[1] == sin(dq[1]*dq[2])
@test x[1] !== sin(dq[1]*dq[2])

@testset "Test Base.float overloads for Taylor1 and TaylorN mixtures" begin
q = get_variables(Int)
x1N = Taylor1(q)
Expand Down
15 changes: 15 additions & 0 deletions test/rat.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file is part of TaylorSeries.jl, MIT licensed
#

using TaylorSeries, RecursiveArrayTools

using Test

@testset "Tests TaylorSeries RecursiveArrayTools extension" begin
dq = get_variables()
x = Taylor1([0.9+2dq[1],-1.1dq[1], 0.7dq[2], 0.5dq[1]-0.45dq[2],0.9dq[1]])
xx = [x,x]
yy = recursivecopy(xx)
@test yy == xx # yy and xx are equal...
@test yy !== xx # ...but they're not the same object in memory
end
3 changes: 2 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ testfiles = (
"identities_Euler.jl",
"fateman40.jl",
"staticarrays.jl",
"jld2.jl"
"jld2.jl",
"rat.jl"
)

for file in testfiles
Expand Down

6 comments on commit fdfa666

@lbenet
Copy link
Member

@lbenet lbenet commented on fdfa666 Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/105475

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.17.6 -m "<description of version>" fdfa666f7e81ca2ff606d4a7336ba1e1b6056950
git push origin v0.17.6

Also, note the warning: Version 0.17.6 skips over 0.17.5
This can be safely ignored. However, if you want to fix this you can do so. Call register() again after making the fix. This will update the Pull request.

@PerezHz
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About the skipped version: I bumped the patch version in #355 but was it not registered (we didn't agree explicitly on it either). One way out of this could be to pause this version registration PR, register 0.17.5, and then re-trigger this one. (not sure if 0.17.5 can be reigistered after 0.17.6).

@lbenet
Copy link
Member

@lbenet lbenet commented on fdfa666 Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/105475

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.17.6 -m "<description of version>" fdfa666f7e81ca2ff606d4a7336ba1e1b6056950
git push origin v0.17.6

@lbenet
Copy link
Member

@lbenet lbenet commented on fdfa666 Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uuups... Sorry, completely forgot about #355.... It is solved now...

Please sign in to comment.