]> gitweb.michael.orlitzky.com - spline3.git/blobdiff - src/Grid.hs
Bump dependencies, and move some Arbitrary code from Values.hs to Grid.hs to avoid...
[spline3.git] / src / Grid.hs
index 953c6a3d56f35978638f50d730814920c2a256dc..269b37cec68d5c2f6211971dc1af32316b86c7ae 100644 (file)
@@ -19,7 +19,8 @@ import Test.QuickCheck ((==>),
                         Arbitrary(..),
                         Gen,
                         Property,
-                        choose)
+                        choose,
+                        vectorOf)
 import Assertions (assertAlmostEqual, assertTrue)
 import Comparisons ((~=))
 import Cube (Cube(Cube),
@@ -49,7 +50,12 @@ data Grid = Grid { function_values :: Values3D }
 
 instance Arbitrary Grid where
     arbitrary = do
-      fvs <- arbitrary :: Gen Values3D
+      x_dim <- choose (1, 27)
+      y_dim <- choose (1, 27)
+      z_dim <- choose (1, 27)
+      elements <- vectorOf (x_dim * y_dim * z_dim) (arbitrary :: Gen Double)
+      let new_shape = (R.Z R.:. x_dim R.:. y_dim R.:. z_dim)
+      let fvs = R.fromListUnboxed new_shape elements
       return $ Grid fvs