diff --git a/src/HordeAd/Core/Ast.hs b/src/HordeAd/Core/Ast.hs index 7b73240b2..38a3708cb 100644 --- a/src/HordeAd/Core/Ast.hs +++ b/src/HordeAd/Core/Ast.hs @@ -790,7 +790,7 @@ instance Boolean AstBool where b ||* c = AstB2 OrOp b c --- * Boolean definitions and instances +-- * Boolean definitions class Boolean (BoolOf f) => IfF (f :: TensorType ty) where ifF :: (GoodScalar r, HasSingletonDict y) diff --git a/test/simplified/TestAdaptorSimplified.hs b/test/simplified/TestAdaptorSimplified.hs index 49f4e080a..b352ae64f 100644 --- a/test/simplified/TestAdaptorSimplified.hs +++ b/test/simplified/TestAdaptorSimplified.hs @@ -166,6 +166,7 @@ testTrees = , testCase "2emptyArgs0" testEmptyArgs0 , testCase "2emptyArgs1" testEmptyArgs1 , testCase "2emptyArgs4" testEmptyArgs4 + , testCase "2filterPositiveFail" testFilterPositiveFail , testCase "2blowupPP" fblowupPP , testCase "2blowupLetPP" fblowupLetPP , blowupTests @@ -1884,6 +1885,25 @@ testEmptyArgs4 = (\t -> rbuild [2, 5, 11, 0] (const $ emptyArgs t)) (Flip $ OR.fromList [1] [0.24])) +filterPositiveFail :: ADReady ranked + => ranked Double 1 -> ranked Double 1 +filterPositiveFail v = + let l = runravelToList v + -- l2 = filter (\x -> x >= 0) l + -- Could not deduce ‘Ord (ranked Double 0)’ + -- l2 = filter (\x -> x >=. 0) l + -- Could not deduce ‘BoolOf ranked ~ Bool’ + l2 = take 3 l -- the most I can do + in rfromList l2 + +testFilterPositiveFail :: Assertion +testFilterPositiveFail = + assertEqualUpToEpsilon' 1e-10 + (OR.fromList [5] [1.0,1.0,1.0,0.0,0.0]) + (rev' @Double @1 + filterPositiveFail + (Flip $ OR.fromList [5] [0.24, 52, -0.5, 0.33, 0.1])) + -- Catastrophic loss of sharing prevented. fblowup :: forall ranked r. (ADReady ranked, GoodScalar r, Differentiable r) => Int -> ranked r 1 -> ranked r 0