From 96b91eea9e5f75780ae8d63aea257db4cdce44c8 Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Fri, 16 Sep 2022 21:59:14 -0400 Subject: [PATCH 1/3] using StaticArraysCore --- .github/workflows/ci.yml | 2 +- Project.toml | 12 +++++++----- src/DiffResults.jl | 11 +++++++---- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 101d9c9..7a0a1f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: version: - - '1.0' + - '1.6' - '1' - 'nightly' os: diff --git a/Project.toml b/Project.toml index b6700f6..89aaf83 100644 --- a/Project.toml +++ b/Project.toml @@ -1,16 +1,18 @@ name = "DiffResults" uuid = "163ba53b-c6d8-5494-b064-1a9d43ac40c5" -version = "1.0.3" +version = "1.1.0" [deps] -StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" +StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" [compat] -StaticArrays = "0.8, 0.9, 0.10, 0.11, 0.12, 1.0" -julia = "1" +StaticArrays = "1.5.7" +StaticArraysCore = "1.3.0" +julia = "1.6" [extras] +StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Test"] +test = ["Test", "StaticArrays"] diff --git a/src/DiffResults.jl b/src/DiffResults.jl index d689185..1abec61 100644 --- a/src/DiffResults.jl +++ b/src/DiffResults.jl @@ -1,6 +1,6 @@ module DiffResults -using StaticArrays +using StaticArraysCore: StaticArray, similar_type #, Size # Size is not yet in Core package ######### # Types # @@ -76,7 +76,8 @@ shape information. If you want to allocate storage yourself, use the `DiffResult constructor instead. """ JacobianResult(x::AbstractArray) = DiffResult(similar(x), similar(x, length(x), length(x))) -JacobianResult(x::StaticArray) = DiffResult(x, zeros(StaticArrays.similar_type(typeof(x), Size(length(x),length(x))))) +# JacobianResult(x::StaticArray) = DiffResult(x, zeros(similar_type(typeof(x), Size(length(x),length(x))))) +JacobianResult(x::StaticArray) = DiffResult(x, zeros(similar_type(typeof(x), (axes(vec(x))..., axes(vec(x))...)))) """ JacobianResult(y::AbstractArray, x::AbstractArray) @@ -89,7 +90,8 @@ Like the single argument version, `y` and `x` are only used for type and shape information and are not stored in the returned `DiffResult`. """ JacobianResult(y::AbstractArray, x::AbstractArray) = DiffResult(similar(y), similar(y, length(y), length(x))) -JacobianResult(y::StaticArray, x::StaticArray) = DiffResult(y, zeros(StaticArrays.similar_type(typeof(x), Size(length(y),length(x))))) +# JacobianResult(y::StaticArray, x::StaticArray) = DiffResult(y, zeros(similar_type(typeof(x), Size(length(y),length(x))))) +JacobianResult(y::StaticArray, x::StaticArray) = DiffResult(y, zeros(similar_type(typeof(x), (axes(vec(y))..., axes(vec(x))...)))) """ HessianResult(x::AbstractArray) @@ -102,7 +104,8 @@ shape information. If you want to allocate storage yourself, use the `DiffResult constructor instead. """ HessianResult(x::AbstractArray) = DiffResult(first(x), zeros(eltype(x), size(x)), similar(x, length(x), length(x))) -HessianResult(x::StaticArray) = DiffResult(first(x), x, zeros(StaticArrays.similar_type(typeof(x), Size(length(x),length(x))))) +# HessianResult(x::StaticArray) = DiffResult(first(x), x, zeros(similar_type(typeof(x), Size(length(x),length(x))))) +HessianResult(x::StaticArray) = DiffResult(first(x), x, zeros(similar_type(typeof(x), (axes(vec(x))..., axes(vec(x))...)))) ############# # Interface # From efdd7d505ee669c867c6d08c8ef9e6e2b0fa144b Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Wed, 21 Sep 2022 19:52:38 -0400 Subject: [PATCH 2/3] revert clever axes trick now that Size is available Co-authored-by: David Widmann --- Project.toml | 2 +- src/DiffResults.jl | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Project.toml b/Project.toml index 89aaf83..5211d4e 100644 --- a/Project.toml +++ b/Project.toml @@ -7,7 +7,7 @@ StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" [compat] StaticArrays = "1.5.7" -StaticArraysCore = "1.3.0" +StaticArraysCore = "1.4.0" julia = "1.6" [extras] diff --git a/src/DiffResults.jl b/src/DiffResults.jl index 1abec61..c440d50 100644 --- a/src/DiffResults.jl +++ b/src/DiffResults.jl @@ -1,6 +1,6 @@ module DiffResults -using StaticArraysCore: StaticArray, similar_type #, Size # Size is not yet in Core package +using StaticArraysCore: StaticArray, similar_type, Size ######### # Types # @@ -76,8 +76,7 @@ shape information. If you want to allocate storage yourself, use the `DiffResult constructor instead. """ JacobianResult(x::AbstractArray) = DiffResult(similar(x), similar(x, length(x), length(x))) -# JacobianResult(x::StaticArray) = DiffResult(x, zeros(similar_type(typeof(x), Size(length(x),length(x))))) -JacobianResult(x::StaticArray) = DiffResult(x, zeros(similar_type(typeof(x), (axes(vec(x))..., axes(vec(x))...)))) +JacobianResult(x::StaticArray) = DiffResult(x, zeros(similar_type(typeof(x), Size(length(x),length(x))))) """ JacobianResult(y::AbstractArray, x::AbstractArray) @@ -90,8 +89,7 @@ Like the single argument version, `y` and `x` are only used for type and shape information and are not stored in the returned `DiffResult`. """ JacobianResult(y::AbstractArray, x::AbstractArray) = DiffResult(similar(y), similar(y, length(y), length(x))) -# JacobianResult(y::StaticArray, x::StaticArray) = DiffResult(y, zeros(similar_type(typeof(x), Size(length(y),length(x))))) -JacobianResult(y::StaticArray, x::StaticArray) = DiffResult(y, zeros(similar_type(typeof(x), (axes(vec(y))..., axes(vec(x))...)))) +JacobianResult(y::StaticArray, x::StaticArray) = DiffResult(y, zeros(similar_type(typeof(x), Size(length(y),length(x))))) """ HessianResult(x::AbstractArray) @@ -104,8 +102,7 @@ shape information. If you want to allocate storage yourself, use the `DiffResult constructor instead. """ HessianResult(x::AbstractArray) = DiffResult(first(x), zeros(eltype(x), size(x)), similar(x, length(x), length(x))) -# HessianResult(x::StaticArray) = DiffResult(first(x), x, zeros(similar_type(typeof(x), Size(length(x),length(x))))) -HessianResult(x::StaticArray) = DiffResult(first(x), x, zeros(similar_type(typeof(x), (axes(vec(x))..., axes(vec(x))...)))) +HessianResult(x::StaticArray) = DiffResult(first(x), x, zeros(similar_type(typeof(x), Size(length(x),length(x))))) ############# # Interface # From f38c413822158f5795c64a95b31cf2e8c8d59a56 Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Fri, 23 Sep 2022 10:11:12 -0400 Subject: [PATCH 3/3] StaticArrays is tagged --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 5211d4e..0831a68 100644 --- a/Project.toml +++ b/Project.toml @@ -6,7 +6,7 @@ version = "1.1.0" StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" [compat] -StaticArrays = "1.5.7" +StaticArrays = "1.5.8" StaticArraysCore = "1.4.0" julia = "1.6"