@@ -4,23 +4,28 @@ using Cassette
44import Cassette: tag, untag, Tagged, metadata, hasmetadata, istagged
55using SparseArrays
66using SparsityDetection
7- import SparsityDetection: abstract_run, HessianSparsityContext, JacobianSparsityContext
7+ import SparsityDetection: abstract_run, HessianSparsityContext,
8+ JacobianSparsityContext, TermCombination, HessInput
9+ using Test
10+
11+ Term (i... ) = TermCombination (Set ([Dict (j=> 1 for j in i)]))
812
913function jactester (f, Y, X, args... )
1014 ctx, val = jacobian_sparsity (f, Y, X, args... ; raw= true )
1115end
1216
13- jactestmeta (args... ) = jactester (args... )[1 ]. metadata[ 1 ]
17+ jactestmeta (args... ) = jactester (args... )[1 ]. metadata
1418jactestval (args... ) = jactester (args... ) |> ((ctx,val),) -> untag (val, ctx)
1519jactesttag (args... ) = jactester (args... ) |> ((ctx,val),) -> metadata (val, ctx)
1620
1721function hesstester (f, X, args... )
18- ctx, val = hessian_sparsity (f, X, args... ; raw= true )
22+ ctx, terms, val = hessian_sparsity (f, X, args... ; raw= true )
1923end
2024
21- hesstestmeta (args... ) = hesstester (args... )[1 ]. metadata[1 ]
22- hesstestval (args... ) = hesstester (args... ) |> ((ctx,val),) -> untag (val, ctx)
23- hesstesttag (args... ) = hesstester (args... ) |> ((ctx,val),) -> metadata (val, ctx)
25+ hesstestmeta (args... ) = hesstester (args... )[1 ]. metadata
26+ hesstestval (args... ) = hesstester (args... ) |> ((ctx,terms,val),) -> untag (val, ctx)
27+ hesstesttag (args... ) = hesstester (args... ) |> ((ctx,terms,val),) -> metadata (val, ctx)
28+ hesstestterms (args... ) = hesstester (args... ) |> ((ctx,terms,val),) -> terms
2429
2530
2631Base. show (io:: IO , :: Type{<:Cassette.Context} ) = print (io, " ctx" )
0 commit comments