statistics 0.14.0.0 → 0.14.0.1
raw patch · 7 files changed
+80/−20 lines, 7 filesdep +base-orphansdep ~basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: base-orphans
Dependency ranges changed: base
API changes (from Hackage documentation)
- Statistics.Resampling: instance (Data.Data.Data (v a), Data.Data.Data a, Data.Typeable.Internal.Typeable v) => Data.Data.Data (Statistics.Resampling.Bootstrap v a)
- Statistics.Types: instance (Data.Data.Data (e a), Data.Data.Data a, Data.Typeable.Internal.Typeable e) => Data.Data.Data (Statistics.Types.Estimate e a)
Files
- Statistics/Internal.hs +1/−0
- Statistics/Resampling.hs +10/−3
- Statistics/Test/Types.hs +21/−4
- Statistics/Types.hs +28/−8
- changelog.md +5/−0
- statistics.cabal +4/−2
- tests/Tests/Serialization.hs +11/−3
Statistics/Internal.hs view
@@ -25,6 +25,7 @@ import Control.Applicative import Control.Monad import Text.Read+import Data.Orphans ()
Statistics/Resampling.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveFoldable #-} {-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE DeriveFunctor #-}@@ -37,7 +38,7 @@ import Data.Aeson (FromJSON, ToJSON) import Control.Applicative import Control.Concurrent (forkIO, newChan, readChan, writeChan)-import Control.Monad (forM_, forM, replicateM, replicateM_)+import Control.Monad (forM_, forM, replicateM, replicateM_, liftM2) import Control.Monad.Primitive (PrimMonad(..)) import Data.Binary (Binary(..)) import Data.Data (Data, Typeable)@@ -82,9 +83,15 @@ { fullSample :: !a , resamples :: v a }- deriving (Eq, Read, Show, Typeable, Data, Generic, Functor, T.Foldable, T.Traversable)+ deriving (Eq, Read, Show , Generic, Functor, T.Foldable, T.Traversable+#if __GLASGOW_HASKELL >= 708+ , Typeable, Data+#endif+ ) -instance (Binary a, Binary (v a)) => Binary (Bootstrap v a)+instance (Binary a, Binary (v a)) => Binary (Bootstrap v a) where+ get = liftM2 Bootstrap get get+ put (Bootstrap fs rs) = put fs >> put rs instance (FromJSON a, FromJSON (v a)) => FromJSON (Bootstrap v a) instance (ToJSON a, ToJSON (v a)) => ToJSON (Bootstrap v a)
Statistics/Test/Types.hs view
@@ -8,8 +8,9 @@ ) where import Control.DeepSeq (NFData(..))+import Control.Monad (liftM3) import Data.Aeson (FromJSON, ToJSON)-import Data.Binary (Binary)+import Data.Binary (Binary (..)) import Data.Data (Typeable, Data) import GHC.Generics @@ -21,7 +22,11 @@ | NotSignificant -- ^ Data is compatible with hypothesis deriving (Eq,Ord,Show,Typeable,Data,Generic) -instance Binary TestResult+instance Binary TestResult where+ get = do+ sig <- get+ if sig then return Significant else return NotSignificant+ put = put . (== Significant) instance FromJSON TestResult instance ToJSON TestResult instance NFData TestResult@@ -40,7 +45,9 @@ } deriving (Eq,Ord,Show,Typeable,Data,Generic,Functor) -instance (Binary d) => Binary (Test d)+instance (Binary d) => Binary (Test d) where+ get = liftM3 Test get get get+ put (Test sign stat distr) = put sign >> put stat >> put distr instance (FromJSON d) => FromJSON (Test d) instance (ToJSON d) => ToJSON (Test d) instance (NFData d) => NFData (Test d) where@@ -65,7 +72,17 @@ -- ^ Test if second sample is larger than first. deriving (Eq,Ord,Show,Typeable,Data,Generic) -instance Binary PositionTest+instance Binary PositionTest where+ get = do+ i <- get+ case (i :: Int) of+ 0 -> return SamplesDiffer+ 1 -> return AGreater+ 2 -> return BGreater+ _ -> fail "Invalid PositionTest"+ put SamplesDiffer = put (0 :: Int)+ put AGreater = put (1 :: Int)+ put BGreater = put (2 :: Int) instance FromJSON PositionTest instance ToJSON PositionTest instance NFData PositionTest
Statistics/Types.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeFamilies #-}@@ -62,7 +63,7 @@ , Weights ) where -import Control.Monad ((<=<))+import Control.Monad ((<=<), liftM2, liftM3) import Control.DeepSeq (NFData(..)) import Data.Aeson (FromJSON(..), ToJSON) import Data.Binary (Binary(..))@@ -70,8 +71,13 @@ import Data.Maybe (fromMaybe) import Data.Vector.Unboxed (Unbox) import Data.Vector.Unboxed.Deriving (derivingUnbox)-import GHC.Generics (Generic)+import GHC.Generics (Generic) +#if __GLASGOW_HASKELL__ == 704+import qualified Data.Vector.Generic+import qualified Data.Vector.Generic.Mutable+#endif+ import Statistics.Internal import Statistics.Types.Internal import Statistics.Distribution@@ -317,9 +323,15 @@ -- ^ Point estimate. , estError :: !(e a) -- ^ Confidence interval for estimate.- } deriving (Eq, Read, Show, Typeable, Data, Generic)+ } deriving (Eq, Read, Show, Generic+#if __GLASGOW_HASKELL >= 708+ , Typeable, Data+#endif+ ) -instance (Binary (e a), Binary a) => Binary (Estimate e a)+instance (Binary (e a), Binary a) => Binary (Estimate e a) where+ get = liftM2 Estimate get get+ put (Estimate ep ee) = put ep >> put ee instance (FromJSON (e a), FromJSON a) => FromJSON (Estimate e a) instance (ToJSON (e a), ToJSON a) => ToJSON (Estimate e a) instance (NFData (e a), NFData a) => NFData (Estimate e a) where@@ -336,7 +348,9 @@ } deriving (Eq, Read, Show, Typeable, Data, Generic) -instance Binary a => Binary (NormalErr a)+instance Binary a => Binary (NormalErr a) where+ get = fmap NormalErr get+ put = put . normalError instance FromJSON a => FromJSON (NormalErr a) instance ToJSON a => ToJSON (NormalErr a) instance NFData a => NFData (NormalErr a) where@@ -357,7 +371,9 @@ } deriving (Read,Show,Eq,Typeable,Data,Generic) -instance Binary a => Binary (ConfInt a)+instance Binary a => Binary (ConfInt a) where+ get = liftM3 ConfInt get get get+ put (ConfInt l u cl) = put l >> put u >> put cl instance FromJSON a => FromJSON (ConfInt a) instance ToJSON a => ToJSON (ConfInt a) instance NFData a => NFData (ConfInt a) where@@ -445,7 +461,9 @@ } deriving (Eq, Read, Show, Typeable, Data, Generic) -instance Binary a => Binary (UpperLimit a)+instance Binary a => Binary (UpperLimit a) where+ get = liftM2 UpperLimit get get+ put (UpperLimit l cl) = put l >> put cl instance FromJSON a => FromJSON (UpperLimit a) instance ToJSON a => ToJSON (UpperLimit a) instance NFData a => NFData (UpperLimit a) where@@ -462,7 +480,9 @@ -- ^ Confidence level for which limit was calculated } deriving (Eq, Read, Show, Typeable, Data, Generic) -instance Binary a => Binary (LowerLimit a)+instance Binary a => Binary (LowerLimit a) where+ get = liftM2 LowerLimit get get+ put (LowerLimit l cl) = put l >> put cl instance FromJSON a => FromJSON (LowerLimit a) instance ToJSON a => ToJSON (LowerLimit a) instance NFData a => NFData (LowerLimit a) where
changelog.md view
@@ -1,3 +1,8 @@+## Changes in 0.14.0.1++ * Restored compatibility with GHC 7.4 & 7.6++ ## Changes in 0.14.0.0 Breaking update. It seriously changes parts of API. It adds new data types for
statistics.cabal view
@@ -1,5 +1,5 @@ name: statistics-version: 0.14.0.0+version: 0.14.0.1 synopsis: A library of statistical types, data, and functions description: This library provides a number of common functions and types useful@@ -44,7 +44,8 @@ tests/Tests/Math/gen.py tests/utils/Makefile tests/utils/fftw.c-+tested-with: GHC==7.6.3, GHC==7.8.3, GHC==7.10.3, GHC==8.0.1+ library exposed-modules: Statistics.Autocorrelation@@ -103,6 +104,7 @@ build-depends: aeson >= 0.6.0.0, base >= 4.4 && < 5,+ base-orphans >= 0.6 && <0.7, binary >= 0.5.1.0, deepseq >= 1.1.0.2, erf,
tests/Tests/Serialization.hs view
@@ -39,8 +39,8 @@ , serializationTests (T :: T (PValue Double)) , serializationTests (T :: T (NormalErr Double)) , serializationTests (T :: T (ConfInt Double))- , serializationTests (T :: T (Estimate NormalErr Double))- , serializationTests (T :: T (Estimate ConfInt Double))+ , serializationTests' "T (Estimate NormalErr Double)" (T :: T (Estimate NormalErr Double))+ , serializationTests' "T (Estimate ConfInt Double)" (T :: T (Estimate ConfInt Double)) , serializationTests (T :: T (LowerLimit Double)) , serializationTests (T :: T (UpperLimit Double)) -- Distributions@@ -66,11 +66,19 @@ serializationTests :: (Eq a, Typeable a, Binary a, Show a, Read a, ToJSON a, FromJSON a, Arbitrary a) => T a -> Test-serializationTests t = testGroup ("Tests for: " ++ typeName t)+serializationTests t = serializationTests' (typeName t) t++-- Not all types are Typeable, unfortunately+serializationTests'+ :: (Eq a, Binary a, Show a, Read a, ToJSON a, FromJSON a, Arbitrary a)+ => String -> T a -> Test+serializationTests' name t = testGroup ("Tests for: " ++ name) [ testProperty "show/read" (p_showRead t) , testProperty "binary" (p_binary t) , testProperty "aeson" (p_aeson t) ]++ p_binary :: (Eq a, Binary a) => T a -> a -> Bool p_binary _ a = a == (decode . encode) a