@@ -8,13 +8,23 @@ using Random: Random
88using StableRNGs: StableRNG
99using Test
1010using .. Models: gdemo_default
11- import ForwardDiff, ReverseDiff, Mooncake
11+ import ForwardDiff, ReverseDiff
12+
13+ # Detect if prerelease version, if so, we skip some tests
14+ const IS_PRERELEASE = ! isempty (VERSION . prerelease)
15+ const INCLUDE_MOONCAKE = ! IS_PRERELEASE
16+
17+ if INCLUDE_MOONCAKE
18+ import Pkg
19+ Pkg. add (" Mooncake" )
20+ using Mooncake: Mooncake
21+ end
1222
1323""" Element types that are always valid for a VarInfo regardless of ADType."""
1424const always_valid_eltypes = (AbstractFloat, AbstractIrrational, Integer, Rational)
1525
1626""" A dictionary mapping ADTypes to the element types they use."""
17- const eltypes_by_adtype = Dict (
27+ eltypes_by_adtype = Dict (
1828 Turing. AutoForwardDiff => (ForwardDiff. Dual,),
1929 Turing. AutoReverseDiff => (
2030 ReverseDiff. TrackedArray,
@@ -25,8 +35,10 @@ const eltypes_by_adtype = Dict(
2535 ReverseDiff. TrackedVecOrMat,
2636 ReverseDiff. TrackedVector,
2737 ),
28- Turing. AutoMooncake => (Mooncake. CoDual,),
2938)
39+ if INCLUDE_MOONCAKE
40+ eltypes_by_adtype[Turing. AutoMooncake] = (Mooncake. CoDual,)
41+ end
3042
3143"""
3244 AbstractWrongADBackendError
@@ -177,11 +189,10 @@ end
177189"""
178190All the ADTypes on which we want to run the tests.
179191"""
180- ADTYPES = [
181- Turing. AutoForwardDiff (),
182- Turing. AutoReverseDiff (; compile= false ),
183- Turing. AutoMooncake (; config= nothing ),
184- ]
192+ ADTYPES = [Turing. AutoForwardDiff (), Turing. AutoReverseDiff (; compile= false )]
193+ if INCLUDE_MOONCAKE
194+ push! (ADTYPES, Turing. AutoMooncake (; config= nothing ))
195+ end
185196
186197# Check that ADTypeCheckContext itself works as expected.
187198@testset " ADTypeCheckContext" begin
0 commit comments