hunk ./Makefile 2 - runhaskell Setup configure --user --enable-benchmarks + runhaskell Setup configure --user --enable-tests --enable-benchmarks hunk ./Makefile 5 + ./dist/build/test/test hunk ./carray.cabal 68 +test-suite test + main-is: tests.hs + ghc-options: -Wall + hs-source-dirs: tests + type: exitcode-stdio-1.0 + default-language: Haskell98 + build-depends: + QuickCheck >=2.4 && <2.8, + ix-shapable, + carray, + array, + base + hunk ./tests/tests.hs 3 -import Control.Arrow +import qualified Test.QuickCheck as QC hunk ./tests/tests.hs 5 + (Arbitrary, arbitrary, vector, + CoArbitrary, coarbitrary, + Property, (==>)) +import Control.Arrow hunk ./tests/tests.hs 13 -import Data.Binary hunk ./tests/tests.hs 18 -import System.Random +-- import System.Random hunk ./tests/tests.hs 28 + +instance + (Ix i, CoArbitrary i, Storable e, CoArbitrary e) => + CoArbitrary (CArray i e) where hunk ./tests/tests.hs 42 + +instance + (Ix i, CoArbitrary i, CoArbitrary e, IArray UArray e) => + CoArbitrary (UArray i e) where hunk ./tests/tests.hs 131 - conf = Config { configMaxTest = n - , configMaxFail = 1000 - , configSize = (+ 3) . (`div` 2) - , configEvery = \n args -> let s = show n in s ++ [ '\b' | _ <- s] - } - mycheck (s,a) = printf "%-25s: " s >> check conf a + args = QC.stdArgs {QC.maxSuccess = n} + mycheck (s,a) = printf "%-25s: " s >> QC.quickCheckWith args a hunk ./tests/tests.hs 13 -import Data.List hunk ./tests/tests.hs 16 -import System.IO hunk ./tests/tests.hs 71 +(=|=) :: + (Model x1 y1, Model x y, Eq y) => + (x1 -> x) -> (y1 -> y) -> x1 -> Bool + +(=||=) :: + (Model x1 y1, Model x y, Eq y) => + (x2 -> x1 -> x) -> (x2 -> y1 -> y) -> x2 -> x1 -> Bool + +(=|||=) :: + (Model x2 y2, Model x y, Eq y) => + (x3 -> x2 -> x1 -> x) -> (x3 -> y2 -> x1 -> y) -> x3 -> x2 -> x1 -> Bool + +eq4 :: + (Model x4 y4, Model x3 y3, Model x2 y2, Model x1 y1, Model x y, Eq y) => + (x4 -> x3 -> x2 -> x1 -> x) -> + (y4 -> y3 -> y2 -> y1 -> y) -> + x4 -> x3 -> x2 -> x1 -> Bool + +eq5 :: + (Model x5 y5, Model x4 y4, Model x3 y3, Model x2 y2, Model x1 y1, Model x y, Eq y) => + (x5 -> x4 -> x3 -> x2 -> x1 -> x) -> + (y5 -> y4 -> y3 -> y2 -> y1 -> y) -> + x5 -> x4 -> x3 -> x2 -> x1 -> Bool + + +infix 1 =|=, =||=, =|||= + hunk ./tests/tests.hs 102 -infix 1 =|= -infix 1 =||= - hunk ./tests/tests.hs 116 +transposeArray :: CArray (Int,Int) Double -> CArray (Int,Int) Double + + +type Test2D = CArray (Int,Int) Double -> Bool + +prop_flatten_flatten, prop_reshape_flatten, prop_rank, + prop_shape_size, prop_size, prop_shape_stride_last, prop_transpose :: Test2D + hunk ./tests/tests.hs 142 +prop_amap :: (Int -> Double) -> CArray Int Int -> Bool hunk ./tests/tests.hs 152 +prop_accum :: (Int -> Acc -> Int) -> CArray Int Int -> [(Int, Acc)] -> Property hunk ./tests/tests.hs 157 +type Transform = CArray Int Int -> CArray Int Int + +prop_composeAssoc :: + Transform -> Transform -> Transform -> CArray Int Int -> Bool hunk ./tests/tests.hs 162 - where types = [f,g,h] :: [CArray Int Int -> CArray Int Int] hunk ./tests/tests.hs 163 +main :: IO () hunk ./tests/tests.hs 71 -(=|=) :: - (Model x1 y1, Model x y, Eq y) => - (x1 -> x) -> (y1 -> y) -> x1 -> Bool - hunk ./tests/tests.hs 79 -eq4 :: - (Model x4 y4, Model x3 y3, Model x2 y2, Model x1 y1, Model x y, Eq y) => - (x4 -> x3 -> x2 -> x1 -> x) -> - (y4 -> y3 -> y2 -> y1 -> y) -> - x4 -> x3 -> x2 -> x1 -> Bool - -eq5 :: - (Model x5 y5, Model x4 y4, Model x3 y3, Model x2 y2, Model x1 y1, Model x y, Eq y) => - (x5 -> x4 -> x3 -> x2 -> x1 -> x) -> - (y5 -> y4 -> y3 -> y2 -> y1 -> y) -> - x5 -> x4 -> x3 -> x2 -> x1 -> Bool - hunk ./tests/tests.hs 80 -infix 1 =|=, =||=, =|||= +infix 1 =||=, =|||= hunk ./tests/tests.hs 82 -f =|= g = \a -> - model (f a) == g (model a) hunk ./tests/tests.hs 86 -eq4 f g = \a b c d -> - model (f a b c d) == g (model a) (model b) (model c) (model d) -eq5 f g = \a b c d e -> - model (f a b c d e) == g (model a) (model b) (model c) (model d) (model e) hunk ./carray.cabal 2 -version: 0.1.5.3 +version: 0.1.6 hunk ./carray.cabal 26 - tag: 0.1.5.3 + tag: 0.1.6 hunk ./carray.cabal 45 - binary >=0.5 && <0.8 + binary >=0.5 && <0.8, + QuickCheck >=2.4 && <2.8 + hunk ./carray.cabal 77 - QuickCheck >=2.4 && <2.8, + QuickCheck, hunk ./src/Data/Array/CArray/Base.hs 52 +import qualified Test.QuickCheck as QC +import Test.QuickCheck (Arbitrary, arbitrary, CoArbitrary, coarbitrary,) hunk ./src/Data/Array/CArray/Base.hs 540 + + +instance + (Ix i, Arbitrary i, Storable e, Arbitrary e) => + Arbitrary (CArray i e) where + arbitrary = do + a <- QC.arbitrary + b <- QC.arbitrary + let rng = (min a b, max a b) + fmap (listArray rng) $ QC.vector (rangeSize rng) + +instance + (Ix i, CoArbitrary i, Storable e, CoArbitrary e) => + CoArbitrary (CArray i e) where + coarbitrary a = coarbitrary (assocs a) hunk ./tests/tests.hs 4 -import Test.QuickCheck - (Arbitrary, arbitrary, vector, - CoArbitrary, coarbitrary, - Property, (==>)) +import Test.QuickCheck (Property, (==>)) hunk ./tests/tests.hs 15 -instance (Ix i, Arbitrary i, Storable e, Arbitrary e) => Arbitrary (CArray i e) where - arbitrary = do - a <- arbitrary - b <- arbitrary - let l = min a b - u = max a b - es <- vector (rangeSize (l,u)) - return $ listArray (l,u) es - -instance - (Ix i, CoArbitrary i, Storable e, CoArbitrary e) => - CoArbitrary (CArray i e) where - coarbitrary a = coarbitrary (assocs a) - -instance (Ix i, Arbitrary i, Arbitrary e, IArray UArray e) => Arbitrary (UArray i e) where - arbitrary = do - a <- arbitrary - b <- arbitrary - let l = min a b - u = max a b - es <- vector (rangeSize (l,u)) - return $ listArray (l,u) es - -instance - (Ix i, CoArbitrary i, CoArbitrary e, IArray UArray e) => - CoArbitrary (UArray i e) where - coarbitrary a = coarbitrary (assocs a) hunk ./tests/tests.hs 5 -import Control.Arrow -import Text.Show.Functions +import Control.Arrow ((&&&), (***)) +import Text.Show.Functions () hunk ./tests/tests.hs 8 + (CArray, flatten, ixmapWithInd, rank, reshape, shape, size, sliceWith) hunk ./tests/tests.hs 11 -import Foreign.Storable -import Text.Printf + (IArray, Ix, UArray, + accum, amap, bounds, elems, inRange, ixmap, listArray, rangeSize) +import Foreign.Storable (Storable) +import Text.Printf (printf) hunk ./tests/tests.hs 1 -{-# OPTIONS_GHC -fglasgow-exts #-} -{-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses, FunctionalDependencies, NoMonomorphismRestriction, UndecidableInstances #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MultiParamTypeClasses #-} hunk ./tests/tests.hs 20 +-- cf. storablevector/test hunk ./tests/tests.hs 66 +transposeArray :: CArray (Int,Int) Double -> CArray (Int,Int) Double hunk ./tests/tests.hs 70 -transposeArray :: CArray (Int,Int) Double -> CArray (Int,Int) Double - hunk ./tests/tests.hs 117 - x <- getArgs - let n = if null x then 100 else read . head $ x - args = QC.stdArgs {QC.maxSuccess = n} - mycheck (s,a) = printf "%-25s: " s >> QC.quickCheckWith args a + args <- getArgs + n <- case args of [] -> return 100; str:_ -> readIO str + let mycheck (s,a) = + printf "%-25s: " s >> + QC.quickCheckWith (QC.stdArgs {QC.maxSuccess = n}) a hunk ./src/Data/Array/CArray/Base.hs 45 -import Control.Applicative -import Control.Monad -import Data.Ix -import Data.Ix.Shapable hunk ./src/Data/Array/CArray/Base.hs 46 -import Data.Array.MArray () -import Data.Array.IArray () + (bounds, elems, listArray, unsafeAt, assocs, (!), + numElements, getNumElements, showsIArray, + unsafeFreeze, unsafeThaw, + unsafeRead, unsafeWrite, + unsafeArray, unsafeReplace, unsafeAccum, + unsafeAccumArray, unsafeNewArray_) +import Data.Array.MArray + (MArray(getBounds, newArray, newArray_), freeze, thaw) +import Data.Array.IArray (IArray) +import Data.Ix.Shapable (Shapable, shape, sShape, shapeToStride, size) +import Data.Ix (Ix, rangeSize, range, inRange, index) + hunk ./src/Data/Array/CArray/Base.hs 61 -import Data.Binary -import Data.Complex -import Data.List -import System.IO.Unsafe (unsafePerformIO) +import Data.Binary (Binary, get, put) + +import System.IO.Unsafe (unsafePerformIO) hunk ./src/Data/Array/CArray/Base.hs 65 + (Storable, sizeOf, alignment, peek, peekElemOff, pokeElemOff) hunk ./src/Data/Array/CArray/Base.hs 67 -import Foreign.Ptr -import Foreign.Marshal.Array (copyArray, withArray) -import Data.Word () + (ForeignPtr, withForeignPtr, castForeignPtr, touchForeignPtr) +import Foreign.Marshal.Array (copyArray, withArray) +import Foreign.Ptr (plusPtr, alignPtr, castPtr) hunk ./src/Data/Array/CArray/Base.hs 71 -import Data.Generics (Data(..), Typeable(..)) +import Data.Word (Word8, Word) +import Data.Generics (Data(..), Typeable) hunk ./src/Data/Array/CArray/Base.hs 76 +import Data.Complex (Complex, magnitude) +import Data.List (zipWith4, foldl') +import Control.Monad (replicateM, forM_, (>=>)) +import Control.Applicative (liftA2) + + hunk ./src/Data/Array/CArray/Base.hs 284 -{-# INLINE cmpCArray #-} +{-# INLINE [1] cmpCArray #-} hunk ./carray.cabal 5 - A C-compatible array library. - . - Provides both an immutable and mutable (in the IO monad) interface. - Includes utilities for multi-dimensional arrays, slicing and norms. - Memory is 16-byte aligned by default to enable use of SIMD instructions. - . + A C-compatible array library. + . + Provides both an immutable and mutable (in the IO monad) interface. + Includes utilities for multi-dimensional arrays, slicing and norms. + Memory is 16-byte aligned by default to enable use of SIMD instructions. hunk ./carray.cabal 62 - exposed-modules: Data.Array.CArray - Data.Array.IOCArray - Data.Array.CArray.Base + exposed-modules: + Data.Array.CArray + Data.Array.IOCArray + Data.Array.CArray.Base hunk ./carray.cabal 20 - tests/tests.hs hunk ./src/Data/Array/CArray/Base.hs 98 - sequence_ [pokeElemOff a i e0 | i <- [0 .. n - 1]] + forM_ [0 .. n - 1] $ \i -> pokeElemOff a i e0 hunk ./src/Data/Array/CArray/Base.hs 240 - marr <- newArray lu default_elem - sequence_ [unsafeWrite marr i e | (i, e) <- ies] - unsafeFreezeIOCArray marr + marr <- newArray lu default_elem + mapM_ (uncurry $ unsafeWrite marr) ies + unsafeFreezeIOCArray marr hunk ./src/Data/Array/CArray/Base.hs 249 - sequence_ [unsafeWrite marr i e | (i, e) <- ies] + mapM_ (uncurry $ unsafeWrite marr) ies hunk ./src/Data/Array/CArray/Base.hs 258 - sequence_ [do + forM_ ies $ \(i, new) -> do hunk ./src/Data/Array/CArray/Base.hs 261 - | (i, new) <- ies] hunk ./src/Data/Array/CArray/Base.hs 269 - sequence_ [do + forM_ ies $ \(i, new) -> do hunk ./src/Data/Array/CArray/Base.hs 272 - | (i, new) <- ies] hunk ./tests/tests.hs 85 -ca_tests = [ ("flatten flatten" , prop_flatten_flatten) - , ("reshape flatten" , prop_reshape_flatten) - , ("rank" , prop_rank) - , ("shape size" , prop_shape_size) - , ("size" , prop_size) - , ("shape stride last" , prop_shape_stride_last) - , ("transpose^2" , prop_transpose) - ] +ca_tests = + ("flatten flatten" , prop_flatten_flatten) : + ("reshape flatten" , prop_reshape_flatten) : + ("rank" , prop_rank) : + ("shape size" , prop_shape_size) : + ("size" , prop_size) : + ("shape stride last" , prop_shape_stride_last) : + ("transpose^2" , prop_transpose) : + [] hunk ./carray.cabal 57 - build-depends: base >=4 && <5, syb >=0.1 && <0.5 + build-depends: base >=4 && <5, syb >=0.1 && <0.6