From 000641ad447f7b841157cf02386edfdd368ab1ea Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 2 Sep 2011 09:09:23 -0400 Subject: [PATCH] Limit the size of arbitrary Values3D, and prevent empty dimensions. --- src/Values.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Values.hs b/src/Values.hs index dab9e34..8e2b61e 100644 --- a/src/Values.hs +++ b/src/Values.hs @@ -20,7 +20,7 @@ import Data.Array.Repa ( import Data.Array.Repa.IO.Vector (readVectorFromTextFile, writeVectorToTextFile) import System.FilePath () -import Test.QuickCheck (Arbitrary(..), Gen, Positive(..), vectorOf) +import Test.QuickCheck (Arbitrary(..), Gen, choose, vectorOf) import ScaleFactor @@ -33,9 +33,10 @@ type Values3D = Array DIM3 Double instance Arbitrary Values3D where arbitrary = do - (Positive x_dim) <- arbitrary :: Gen (Positive Int) - (Positive y_dim) <- arbitrary :: Gen (Positive Int) - (Positive z_dim) <- arbitrary :: Gen (Positive Int) + -- I declare not to care about empty lists. + 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 = (Z :. x_dim :. y_dim :. z_dim) let three_d = Data.Array.Repa.fromList new_shape elements -- 2.43.2