@@ -11,21 +11,21 @@ open GraphBLAS.FSharp.Backend.Objects
1111open GraphBLAS.FSharp .Backend .Quotes
1212
1313let logger =
14- Log.create " Vector .containsNonZero.Tests"
14+ Log.create " ClArray .containsNonZero.Tests"
1515
1616let context = defaultContext.ClContext
1717
1818let q = defaultContext.Queue
1919
20- let correctnessGenericTest < 'a when 'a : struct and 'a : equality > isZero containsNonZero ( array : 'a []) =
20+ let correctnessGenericTest < 'a when 'a : struct and 'a : equality > isZero exists ( array : 'a []) =
2121
2222 if array.Length > 0 then
2323 let vector = createVectorFromArray Dense array isZero
2424
2525 let result =
2626 match vector.ToDevice context with
2727 | ClVector.Dense clArray ->
28- let resultCell = containsNonZero q clArray
28+ let resultCell = exists q clArray
2929 let result = Array.zeroCreate 1
3030
3131 let res =
@@ -35,6 +35,8 @@ let correctnessGenericTest<'a when 'a: struct and 'a: equality> isZero containsN
3535
3636 res.[ 0 ]
3737
38+ | _ -> failwith " Unsupported vector format"
39+
3840 $" The results should be the same, vector : {vector}"
3941 |> Expect.equal result ( Array.exists ( not << isZero) array)
4042
@@ -46,52 +48,40 @@ let testFixtures =
4648 let getCorrectnessTestName datatype =
4749 sprintf " Correctness on %s , %A " datatype Dense
4850
49- [ let containsNonZeroInt =
51+ [ let exists =
5052 ClArray.exists context wgSize Predicates.isSome
5153
52- correctnessGenericTest< int> ((=) 0 ) containsNonZeroInt
54+ correctnessGenericTest< int> ((=) 0 ) exists
5355 |> testPropertyWithConfig config ( getCorrectnessTestName " int" )
5456
55- let containsNonZeroByte =
56- ClArray.exists context wgSize Predicates.isSome
57-
58- correctnessGenericTest< byte> ((=) 0 uy) containsNonZeroByte
59- |> testPropertyWithConfig config ( getCorrectnessTestName " byte" )
60-
61- let containsNonZeroFloat =
62- ClArray.exists context wgSize Predicates.isSome
63-
64- correctnessGenericTest< float> ((=) 0.0 ) containsNonZeroFloat
65- |> testPropertyWithConfig config ( getCorrectnessTestName " float" )
66-
67- let containsNonZeroBool =
68- ClArray.exists context wgSize Predicates.isSome
69-
70- correctnessGenericTest< bool> ((=) false ) containsNonZeroBool
71- |> testPropertyWithConfig config ( getCorrectnessTestName " bool" )
72-
73- let containsNonZeroInt =
74- ClArray.exists context wgSize Predicates.isSome
75-
76- correctnessGenericTest< int> ((=) 0 ) containsNonZeroInt ( Array.create 1000 0 )
57+ correctnessGenericTest< int> ((=) 0 ) exists ( Array.create 1000 0 )
7758 |> testPropertyWithConfig config ( getCorrectnessTestName " int zeros" )
7859
79- let containsNonZeroByte =
60+ let exists =
8061 ClArray.exists context wgSize Predicates.isSome
8162
82- correctnessGenericTest< byte> ((=) 0 uy) containsNonZeroByte ( Array.create 1000 0 uy)
63+ correctnessGenericTest< byte> ((=) 0 uy) exists
64+ |> testPropertyWithConfig config ( getCorrectnessTestName " byte" )
65+
66+ correctnessGenericTest< byte> ((=) 0 uy) exists ( Array.create 1000 0 uy)
8367 |> testPropertyWithConfig config ( getCorrectnessTestName " byte zeros" )
8468
85- let containsNonZeroFloat =
69+ let exists =
8670 ClArray.exists context wgSize Predicates.isSome
8771
88- correctnessGenericTest< float> ((=) 0.0 ) containsNonZeroFloat ( Array.create 1000 0.0 )
72+ correctnessGenericTest< float> ((=) 0.0 ) exists
73+ |> testPropertyWithConfig config ( getCorrectnessTestName " float" )
74+
75+ correctnessGenericTest< float> ((=) 0.0 ) exists ( Array.create 1000 0.0 )
8976 |> testPropertyWithConfig config ( getCorrectnessTestName " float zeros" )
9077
91- let containsNonZeroBool =
78+ let exists =
9279 ClArray.exists context wgSize Predicates.isSome
9380
94- correctnessGenericTest< bool> ((=) false ) containsNonZeroBool ( Array.create 1000 false )
81+ correctnessGenericTest< bool> ((=) false ) exists
82+ |> testPropertyWithConfig config ( getCorrectnessTestName " bool" )
83+
84+ correctnessGenericTest< bool> ((=) false ) exists ( Array.create 1000 false )
9585 |> testPropertyWithConfig config ( getCorrectnessTestName " bool zeros" ) ]
9686
9787let tests =
0 commit comments