friday 0.2.3.0 → 0.2.3.1
raw patch · 7 files changed
+80/−6 lines, 7 filesdep ~primitivePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: primitive
API changes (from Hackage documentation)
Files
- changelog +5/−0
- friday.cabal +4/−2
- src/Vision/Primitive/Shape.hs +2/−2
- test/Test.hs +2/−0
- test/Test/Utils.hs +15/−0
- test/Test/Vision/Image.hs +11/−2
- test/Test/Vision/Primitive.hs +41/−0
changelog view
@@ -1,5 +1,10 @@ -*-change-log-*- +v0.2.4.0 TDB++v0.2.3.1 December 2016+ * Merge fix for storable instance+ v0.2.3.0 December 2016 * Add Contour Tracing (Vision.Image.Contour) * Add pointer to friday-juicypixels
friday.cabal view
@@ -2,7 +2,7 @@ -- +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.2.3.0+version: 0.2.3.1 synopsis: A functional image processing library for Haskell. homepage: https://github.com/RaphaelJ/friday license: LGPL-3@@ -65,7 +65,7 @@ Vision.Image.RGBA Vision.Image.RGBA.Specialize Vision.Image.RGBA.Type- Vision.Image.RGB + Vision.Image.RGB Vision.Image.RGB.Specialize Vision.Image.RGB.Type Vision.Image.Threshold@@ -93,6 +93,8 @@ main-is: Test.hs other-modules: Test.Vision.Histogram Test.Vision.Image+ Test.Vision.Primitive+ Test.Utils ghc-options: -Wall -O2 -rtsopts hs-source-dirs: test/ default-language: Haskell2010
src/Vision/Primitive/Shape.hs view
@@ -222,12 +222,12 @@ peek !ptr = do let !ptr' = castPtr ptr- (:.) <$> peek (castPtr $! ptr' `plusPtr` 1) <*> peek ptr'+ (:.) <$> peek (castPtr $! ptr' `plusPtr` sizeOf (undefined :: Int)) <*> peek ptr' {-# INLINE peek #-} poke !ptr (sh :. n) = do let !ptr' = castPtr ptr- poke (castPtr $! ptr' `plusPtr` 1) sh >> poke ptr' n+ poke (castPtr $! ptr' `plusPtr` sizeOf n) sh >> poke ptr' n {-# INLINE poke #-} -- | Helper for index construction.
test/Test.hs view
@@ -2,9 +2,11 @@ import qualified Test.Vision.Image as I import qualified Test.Vision.Histogram as H+import qualified Test.Vision.Primitive as P main :: IO () main = defaultMain [ testGroup "Images" I.tests , testGroup "Histograms" H.tests+ , testGroup "Primitives" P.tests ]
+ test/Test/Utils.hs view
@@ -0,0 +1,15 @@++module Test.Utils+( propStorableRoundtrip+) where++import Foreign (Storable, with, peek)++import Test.QuickCheck (Property)+import Test.QuickCheck.Monadic (monadicIO, run, assert)++propStorableRoundtrip :: (Eq a, Storable a) => a -> Property+propStorableRoundtrip a = monadicIO $ do+ a' <- run . with a $ peek+ assert $ a' == a+
test/Test/Vision/Image.hs view
@@ -14,12 +14,13 @@ import Data.Vector.Storable (Storable, replicateM) import Test.Framework (Test, testGroup) import Test.Framework.Providers.QuickCheck2 (testProperty)-import Test.QuickCheck (Arbitrary (..), choose)+import Test.QuickCheck (Arbitrary (..), choose, Property)+import Test.Utils (propStorableRoundtrip) import Vision.Image ( MaskedImage (..), Image (..), Interpolable, FromFunction (..) , ImageChannel, Manifest (..), Delayed (..)- , Grey, GreyPixel (..), HSVPixel+ , Grey, GreyPixel (..), HSVPixel (..) , RGBA, RGBAPixel (..), RGBADelayed , RGB, RGBPixel (..), InterpolMethod (..) , convert, resize, horizontalFlip, verticalFlip@@ -46,6 +47,9 @@ instance Arbitrary RGBPixel where arbitrary = RGBPixel <$> arbitrary <*> arbitrary <*> arbitrary +instance Arbitrary HSVPixel where+ arbitrary = HSVPixel <$> arbitrary <*> arbitrary <*> arbitrary+ tests :: [Test] tests = [ testGroup "Conversions identities" [@@ -66,6 +70,11 @@ testProperty "Grey" (propVerticalFlip :: Grey -> Bool) , testProperty "RGBA" (propVerticalFlip :: RGBA -> Bool) , testProperty "RGB" (propVerticalFlip :: RGB -> Bool)+ ]+ , testGroup "Storable can roundtrip" [+ testProperty "HSVPixel" $ (propStorableRoundtrip :: HSVPixel -> Property)+ , testProperty "RGBPixel" $ (propStorableRoundtrip :: RGBPixel -> Property)+ , testProperty "RGBAPixel" $ (propStorableRoundtrip :: RGBAPixel -> Property) ] ]
+ test/Test/Vision/Primitive.hs view
@@ -0,0 +1,41 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE TypeOperators #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}++module Test.Vision.Primitive+( tests+) where++#if __GLASGOW_HASKELL__ < 710+import Control.Applicative ((<*>), (<$>))+#endif++import Test.Framework (Test, testGroup)+import Test.Framework.Providers.QuickCheck2 (testProperty)+import Test.QuickCheck (Arbitrary (..), Property)+import Test.Utils (propStorableRoundtrip)++import Vision.Primitive++instance Arbitrary Z where+ arbitrary = return Z++instance (Arbitrary t, Arbitrary h) => Arbitrary (t :. h) where+ arbitrary = (:.) <$> arbitrary <*> arbitrary++tests :: [Test]+tests =+ [ testGroup "Storable can roundtrip"+ [ testProperty "DIM0" $ (propStorableRoundtrip :: DIM0 -> Property)+ , testProperty "DIM1" $ (propStorableRoundtrip :: DIM1 -> Property)+ , testProperty "DIM2" $ (propStorableRoundtrip :: DIM2 -> Property)+ , testProperty "DIM3" $ (propStorableRoundtrip :: DIM3 -> Property)+ , testProperty "DIM4" $ (propStorableRoundtrip :: DIM4 -> Property)+ , testProperty "DIM5" $ (propStorableRoundtrip :: DIM5 -> Property)+ , testProperty "DIM6" $ (propStorableRoundtrip :: DIM6 -> Property)+ , testProperty "DIM7" $ (propStorableRoundtrip :: DIM7 -> Property)+ , testProperty "DIM8" $ (propStorableRoundtrip :: DIM8 -> Property)+ , testProperty "DIM9" $ (propStorableRoundtrip :: DIM9 -> Property)+ ]+ ]+