From: Michael Orlitzky Date: Fri, 2 Sep 2011 13:09:23 +0000 (-0400) Subject: Limit the size of arbitrary Values3D, and prevent empty dimensions. X-Git-Tag: 0.0.1~183 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=000641ad447f7b841157cf02386edfdd368ab1ea;p=spline3.git Limit the size of arbitrary Values3D, and prevent empty dimensions. --- 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