packages feed

tdigest 0.2.1 → 0.2.1.1

raw patch · 11 files changed

+97/−156 lines, 11 filesdep −doctestdep ~basedep ~base-compatdep ~semigroupssetup-changed

Dependencies removed: doctest

Dependency ranges changed: base, base-compat, semigroups, tasty, transformers

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+## 0.2.1.1++- `build-type: Simple`+ ## 0.2.1  - Add size, valid, validate, and debugPrint for NonEmpty
− Setup.hs
@@ -1,33 +0,0 @@-{-# LANGUAGE CPP #-}-{-# OPTIONS_GHC -Wall #-}-module Main (main) where--#ifndef MIN_VERSION_cabal_doctest-#define MIN_VERSION_cabal_doctest(x,y,z) 0-#endif--#if MIN_VERSION_cabal_doctest(1,0,0)--import Distribution.Extra.Doctest ( defaultMainWithDoctests )-main :: IO ()-main = defaultMainWithDoctests "doctests"--#else--#ifdef MIN_VERSION_Cabal--- If the macro is defined, we have new cabal-install,--- but for some reason we don't have cabal-doctest in package-db------ Probably we are running cabal sdist, when otherwise using new-build--- workflow-#warning You are configuring this package without cabal-doctest installed. \-         The doctests test-suite will not work as a result. \-         To fix this, install cabal-doctest before configuring.-#endif--import Distribution.Simple--main :: IO ()-main = defaultMain--#endif
src/Data/TDigest/Internal.hs view
@@ -12,7 +12,7 @@  {-# INLINE assert #-} assert :: Bool -> String -> a -> a-assert _ _ = \x -> x+assert _ _ = id {- assert False msg _ = error msg assert True  _   x = x
src/Data/TDigest/Postprocess.hs view
@@ -19,9 +19,9 @@     I.Affine (..)     ) where -import Prelude ()-import Prelude.Compat-import qualified Data.List.NonEmpty  as NE+import qualified Data.List.NonEmpty as NE+import           Prelude ()+import           Prelude.Compat  import qualified Data.TDigest.Postprocess.Internal as I 
src/Data/TDigest/Postprocess/Internal.hs view
@@ -26,7 +26,7 @@     Affine (..),     ) where -import Data.Foldable           (toList)+import Data.Foldable           (toList, traverse_) import Data.Functor.Compose    (Compose (..)) import Data.Functor.Identity   (Identity (..)) import Data.List.NonEmpty      (NonEmpty (..), nonEmpty)@@ -36,7 +36,7 @@ import Prelude () import Prelude.Compat -import qualified Data.List.NonEmpty  as NE+import qualified Data.List.NonEmpty as NE  import Data.TDigest.Internal @@ -169,7 +169,7 @@  -- | Validate that list of 'HistBin' is a valid "histogram". validateHistogram :: Foldable f => f HistBin -> Either String (f HistBin)-validateHistogram bs = traverse validPair (pairs $ toList bs) >> pure bs+validateHistogram bs = traverse_ validPair (pairs $ toList bs) >> pure bs   where     validPair (lb@(HistBin _ lmax _ lwt lcw), rb@(HistBin rmin _ _ _ rcw)) = do         check (lmax == rmin)     "gap between bins"
src/Data/TDigest/Tree/Internal.hs view
@@ -195,7 +195,7 @@             Nil -> case mrw of                 Nothing     -> node' s nx nw (tw + newW) Nil r                 Just rw     -> balanceL nx nw (go cum newX rw True Nil) r-            Node _ _ _ _ _ _+            Node {}                 | lmax < newX && abs (newX - x) < abs (newX - lmax) {- && newX < x -} -> case mrw of                     Nothing -> node' s nx nw (tw + nw - w) l r                     -- in this two last LT cases, we have to recalculate size@@ -210,7 +210,7 @@             Nil -> case mrw of                 Nothing     -> node' s nx nw (tw + newW) l Nil                 Just rw     -> balanceR nx nw l (go (cum + totalWeight l + nw) newX rw True Nil)-            Node _ _ _ _ _ _+            Node {}                 | rmin > newX && abs (newX - x) < abs (newX - rmin) {- && newX > x -} -> case mrw of                     Nothing -> node' s nx nw (tw + newW) l r                     -- in this two last GT cases, we have to recalculate size@@ -236,7 +236,7 @@                      $ w + newW - thr             in if diff < 0 -- i.e. there is room                 then (newW, Nothing)-                else (thr - w, Just $ diff)+                else (thr - w, Just diff)          -- the change of current node         (nx, nw) = {- traceShowId $ traceShow (newX, newW, x, dw, mrw) $ -} combinedCentroid x w x dw@@ -349,8 +349,7 @@         v <- toMVector td         -- sort by cumulative weight         VHeap.sortBy (comparing snd) v-        f <- VU.unsafeFreeze v-        pure f+        VU.unsafeFreeze v  toMVector     :: forall comp s. KnownNat comp
src/Data/TDigest/Tree/Postprocess.hs view
@@ -25,6 +25,9 @@  import qualified Data.TDigest.Postprocess as PP +-- $setup+-- >>> import Data.TDigest.Tree+ ------------------------------------------------------------------------------- -- Quantile -------------------------------------------------------------------------------
src/Data/TDigest/Vector/Internal.hs view
@@ -176,7 +176,7 @@ emptyTDigest = TDigest 0 mempty 0 mempty True  combineTDigest :: forall comp. KnownNat comp => TDigest comp -> TDigest comp -> TDigest comp-combineTDigest (TDigest tw d _ b dir) (TDigest tw' d' _ b' dir') = +combineTDigest (TDigest tw d _ b dir) (TDigest tw' d' _ b' dir') =     TDigest (tw + tw') newD 0 [] (dir /= dir')   where     newD = VU.fromList@@ -235,9 +235,9 @@     | not (bs == length b) =         Left $ "Buffer lenght don't match: " ++ show (bs, length b)     | not (tw == bs + round dw) =-        Left $ "Total weight doesn't match"+        Left "Total weight doesn't match"     | dl /= sortBy (comparing fst) dl =-        Left $ "Data buffer isn't ordered"+        Left "Data buffer isn't ordered"     | otherwise = Right td   where     dl :: [Centroid]
src/Data/TDigest/Vector/Postprocess.hs view
@@ -26,6 +26,9 @@  import qualified Data.TDigest.Postprocess as PP +-- $setup+-- >>> import Data.TDigest.Vector+ ------------------------------------------------------------------------------- -- Quantile -------------------------------------------------------------------------------
tdigest.cabal view
@@ -1,84 +1,86 @@-cabal-version:  >= 1.10-name:           tdigest-version:        0.2.1--synopsis:       On-line accumulation of rank-based statistics-description:    A new data structure for accurate on-line accumulation of rank-based statistics such as quantiles and trimmed means.-                .-                See original paper: "Computing extremely accurate quantiles using t-digest" by Ted Dunning and Otmar Ertl-                for more details <https://github.com/tdunning/t-digest/blob/07b8f2ca2be8d0a9f04df2feadad5ddc1bb73c88/docs/t-digest-paper/histo.pdf>.-category:       Numeric+cabal-version:      >=1.10+name:               tdigest+version:            0.2.1.1+synopsis:           On-line accumulation of rank-based statistics+description:+  A new data structure for accurate on-line accumulation of rank-based statistics such as quantiles and trimmed means.+  .+  See original paper: "Computing extremely accurate quantiles using t-digest" by Ted Dunning and Otmar Ertl+  for more details <https://github.com/tdunning/t-digest/blob/07b8f2ca2be8d0a9f04df2feadad5ddc1bb73c88/docs/t-digest-paper/histo.pdf>. -homepage:       https://github.com/futurice/haskell-tdigest#readme-bug-reports:    https://github.com/futurice/haskell-tdigest/issues-author:         Oleg Grenrus <oleg.grenrus@iki.fi>-maintainer:     Oleg Grenrus <oleg.grenrus@iki.fi>-license:        BSD3-license-file:   LICENSE-tested-with:    GHC==7.8.4, GHC==7.10.3, GHC==8.0.1, GHC==8.0.2, GHC==8.2.2, GHC==8.4.1-build-type:     Custom+category:           Numeric+homepage:           https://github.com/phadej/haskell-tdigest#readme+bug-reports:        https://github.com/phadej/haskell-tdigest/issues+author:             Oleg Grenrus <oleg.grenrus@iki.fi>+maintainer:         Oleg Grenrus <oleg.grenrus@iki.fi>+license:            BSD3+license-file:       LICENSE+tested-with:+  GHC ==7.8.4+   || ==7.10.3+   || ==8.0.2+   || ==8.2.2+   || ==8.4.4+   || ==8.6.5+   || ==8.8.4+   || ==8.10.3 +build-type:         Simple extra-source-files:-    README.md-    CHANGELOG.md+  README.md+  CHANGELOG.md  source-repository head-  type: git-  location: https://github.com/futurice/haskell-tdigest--custom-setup-  setup-depends:-    base          >=4.7 && <5,-    Cabal         >=1.14,-    cabal-doctest >=1.0.6 && <1.1+  type:     git+  location: https://github.com/phadej/haskell-tdigest+  subdir:   tdigest  library-  hs-source-dirs:-      src-  ghc-options: -Wall+  default-language: Haskell2010+  hs-source-dirs:   src+  ghc-options:      -Wall    -- GHC boot libraries   build-depends:-      base                >=4.7      && <4.12-    , deepseq             >=1.3.0.2  && <1.5-    , binary              >=0.7.1.0  && <0.10-    , transformers        >=0.3      && <0.6+      base          >=4.7     && <4.15+    , binary        >=0.7.1.0 && <0.10+    , deepseq       >=1.3.0.2 && <1.5+    , transformers  >=0.3     && <0.6 -  if !impl(ghc >= 8.0)-    build-depends:-      semigroups          >=0.18.4   && <0.19+  if !impl(ghc >=8.0)+    build-depends: semigroups >=0.18.4 && <0.20    -- other dependencies   build-depends:-      base-compat         >=0.10.1   && <0.11-    , reducers            >=3.12.2   && <3.13-    , semigroupoids       >=5.2.2    && <5.4-    , vector              >=0.12.0.1 && <0.13-    , vector-algorithms   >=0.7.0.1  && <0.8+      base-compat        >=0.10.1   && <0.12+    , reducers           >=3.12.2   && <3.13+    , semigroupoids      >=5.2.2    && <5.4+    , vector             >=0.12.0.1 && <0.13+    , vector-algorithms  >=0.7.0.1  && <0.9    exposed-modules:-      Data.TDigest-      Data.TDigest.NonEmpty-      Data.TDigest.Postprocess-      Data.TDigest.Tree-      Data.TDigest.Tree.NonEmpty-      Data.TDigest.Tree.Postprocess-      Data.TDigest.Vector-      Data.TDigest.Vector.NonEmpty-      Data.TDigest.Vector.Postprocess+    Data.TDigest+    Data.TDigest.NonEmpty+    Data.TDigest.Postprocess+    Data.TDigest.Tree+    Data.TDigest.Tree.NonEmpty+    Data.TDigest.Tree.Postprocess+    Data.TDigest.Vector+    Data.TDigest.Vector.NonEmpty+    Data.TDigest.Vector.Postprocess    -- Internal modules are exposed, but aren't under PVP contract.   exposed-modules:-      Data.TDigest.Internal-      Data.TDigest.Postprocess.Internal-      Data.TDigest.Tree.Internal-      Data.TDigest.Vector.Internal-  default-language: Haskell2010+    Data.TDigest.Internal+    Data.TDigest.Postprocess.Internal+    Data.TDigest.Tree.Internal+    Data.TDigest.Vector.Internal+   other-extensions:-      DataKinds-      KindSignatures-      MultiParamTypeClasses-      ScopedTypeVariables+    DataKinds+    KindSignatures+    MultiParamTypeClasses+    ScopedTypeVariables  test-suite tdigest-tests   default-language: Haskell2010@@ -86,26 +88,14 @@   main-is:          Tests.hs   ghc-options:      -Wall -threaded   hs-source-dirs:   tests-   build-depends:-    base,-    tdigest,-    base-compat,-    deepseq,-    binary,-    semigroups,-    vector,-    vector-algorithms,-    tasty            >=0.11.0.4 && <1.2,-    tasty-quickcheck >=0.8.4    && <0.11--test-suite doctests-  default-language: Haskell2010-  type:             exitcode-stdio-1.0-  main-is:          doctests.hs-  ghc-options:      -Wall -threaded-  hs-source-dirs:   tests--  build-depends:-    base,-    doctest        >=0.11.1 && <0.17+      base+    , base-compat+    , binary+    , deepseq+    , semigroups+    , tasty              >=0.11.0.4 && <1.4+    , tasty-quickcheck   >=0.8.4    && <0.11+    , tdigest+    , vector+    , vector-algorithms
− tests/doctests.hs
@@ -1,25 +0,0 @@--------------------------------------------------------------------------------- |--- Module      :  Main (doctests)--- Copyright   :  (C) 2012-14 Edward Kmett--- License     :  BSD-style (see the file LICENSE)--- Maintainer  :  Edward Kmett <ekmett@gmail.com>--- Stability   :  provisional--- Portability :  portable------ This module provides doctests for a project based on the actual versions--- of the packages it was built with. It requires a corresponding Setup.lhs--- to be added to the project-------------------------------------------------------------------------------module Main where--import Build_doctests (flags, pkgs, module_sources)-import Data.Foldable (traverse_)-import Test.DocTest--main :: IO ()-main = do-    traverse_ putStrLn args-    doctest args-  where-    args = flags ++ pkgs ++ module_sources