Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
name = "ValueShapes"
uuid = "136a8f8c-c49b-4edb-8b98-f3d64d48be8f"
version = "0.11.5"
version = "0.11.6"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197"
ArraysOfArrays = "65a8f2f4-9b39-5baf-92e2-a9cc46fdf018"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
ElasticArrays = "fdbdab4c-e67f-52f5-8c3f-e7b388dad3d4"
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
TypedTables = "9d95f2ec-7b3d-5a63-8d20-e2491e220bb9"

[weakdeps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
ChangesOfVariables = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0"
InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112"
Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6"
ZygoteRules = "700de1a5-db45-46bc-99cf-38207098b444"

[extensions]
ValueShapesAdaptExt = "Adapt"
ValueShapesChainRulesCoreExt = "ChainRulesCore"
ValueShapesChangesOfVariablesExt = "ChangesOfVariables"
ValueShapesInverseFunctionsExt = "InverseFunctions"
ValueShapesMooncakeExt = "Mooncake"
ValueShapesZygoteRulesExt = "ZygoteRules"

Expand Down
18 changes: 0 additions & 18 deletions ext/ValueShapesAdaptExt.jl

This file was deleted.

14 changes: 0 additions & 14 deletions ext/ValueShapesInverseFunctionsExt.jl

This file was deleted.

2 changes: 2 additions & 0 deletions src/ValueShapes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ using ArraysOfArrays
using Distributions
using ElasticArrays
using FillArrays
using InverseFunctions
using Random
using Statistics
using StatsBase

import Adapt
import IntervalSets
import Tables
import TypedTables
Expand Down
10 changes: 10 additions & 0 deletions src/named_tuple_shape.jl
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,11 @@ Base.isapprox(A::ShapedAsNT, B::ShapedAsNT; kwargs...) = isapprox(_data(A), _dat
Base.copy(A::ShapedAsNT) = ShapedAsNT(copy(_data(A)),_valshape(A))


function Adapt.adapt_structure(to, x::ShapedAsNT)
ShapedAsNT(Adapt.adapt(to, _data(x)), _valshape(x))
end


# Required for accumulation during automatic differentiation:
function Base.:(+)(A::ShapedAsNT{names}, B::ShapedAsNT{names}) where names
@argcheck _valshape(A) == _valshape(B)
Expand Down Expand Up @@ -638,6 +643,11 @@ end
@inline Tables.rows(A::ShapedAsNTArray) = A


function Adapt.adapt_structure(to, x::ShapedAsNTArray)
ShapedAsNTArray(Adapt.adapt(to, _data(x)), _elshape(x))
end


const _AnySNTArray{names} = ShapedAsNTArray{<:Union{NamedTuple{names},ShapedAsNT{names}}}


Expand Down
4 changes: 4 additions & 0 deletions src/value_shape.jl
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,10 @@ const _InvValueShape = Base.Fix2{typeof(unshaped),<:AbstractValueShape}
Base.Broadcast.broadcasted(unshaped, xs, Ref(inv_vs.x))
end


InverseFunctions.inverse(vs::AbstractValueShape) = Base.Fix2(unshaped, vs)
InverseFunctions.inverse(inv_vs::_InvValueShape) = inv_vs.x

const _BroadcastValueShape = Base.Fix1{typeof(broadcast),<:AbstractValueShape}
const _BroadcastInvValueShape = Base.Fix1{typeof(broadcast),<:_InvValueShape}
const _BroadcastUnshaped = Base.Fix1{typeof(broadcast),typeof(unshaped)}
Expand Down
Loading