packages feed

PrimitiveArray-Pretty 0.0.0.1 → 0.0.0.2

raw patch · 3 files changed

+75/−34 lines, 3 filesdep +diagrams-contribdep +filepathdep ~basedep ~diagramsdep ~diagrams-libPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies added: diagrams-contrib, filepath

Dependency ranges changed: base, diagrams, diagrams-lib, diagrams-postscript, diagrams-svg, log-domain, split, test-framework, test-framework-quickcheck2, test-framework-th

API changes (from Hackage documentation)

+ Diagrams.TwoD.ProbabilityGrid: EPS :: RenderChoice
+ Diagrams.TwoD.ProbabilityGrid: FSfull :: FillStyle
+ Diagrams.TwoD.ProbabilityGrid: FSopacityLinear :: FillStyle
+ Diagrams.TwoD.ProbabilityGrid: FSopacityLog :: FillStyle
+ Diagrams.TwoD.ProbabilityGrid: FWfill :: FillWeight
+ Diagrams.TwoD.ProbabilityGrid: SVG :: RenderChoice
+ Diagrams.TwoD.ProbabilityGrid: data FillStyle
+ Diagrams.TwoD.ProbabilityGrid: data RenderChoice
+ Diagrams.TwoD.ProbabilityGrid: gridFile :: [RenderChoice] -> String -> FillWeight -> FillStyle -> Int -> Int -> [String] -> [String] -> [Log Double] -> IO ()
+ Diagrams.TwoD.ProbabilityGrid: instance Data.Data.Data Diagrams.TwoD.ProbabilityGrid.FillStyle
+ Diagrams.TwoD.ProbabilityGrid: instance Data.Data.Data Diagrams.TwoD.ProbabilityGrid.FillWeight
+ Diagrams.TwoD.ProbabilityGrid: instance Data.Data.Data Diagrams.TwoD.ProbabilityGrid.RenderChoice
+ Diagrams.TwoD.ProbabilityGrid: instance GHC.Classes.Eq Diagrams.TwoD.ProbabilityGrid.FillStyle
+ Diagrams.TwoD.ProbabilityGrid: instance GHC.Classes.Eq Diagrams.TwoD.ProbabilityGrid.FillWeight
+ Diagrams.TwoD.ProbabilityGrid: instance GHC.Classes.Eq Diagrams.TwoD.ProbabilityGrid.RenderChoice
+ Diagrams.TwoD.ProbabilityGrid: instance GHC.Show.Show Diagrams.TwoD.ProbabilityGrid.FillStyle
+ Diagrams.TwoD.ProbabilityGrid: instance GHC.Show.Show Diagrams.TwoD.ProbabilityGrid.FillWeight
+ Diagrams.TwoD.ProbabilityGrid: instance GHC.Show.Show Diagrams.TwoD.ProbabilityGrid.RenderChoice
- Diagrams.TwoD.ProbabilityGrid: epsGridFile :: String -> FillWeight -> Int -> Int -> [String] -> [String] -> [Log Double] -> IO ()
+ Diagrams.TwoD.ProbabilityGrid: epsGridFile :: String -> FillWeight -> FillStyle -> Int -> Int -> [String] -> [String] -> [Log Double] -> IO ()
- Diagrams.TwoD.ProbabilityGrid: grid :: (Renderable (Text Double) b, Renderable (Path V2 Double) b) => FillWeight -> t -> Int -> [String] -> [String] -> [Log Double] -> QDiagram b V2 Double Any
+ Diagrams.TwoD.ProbabilityGrid: grid :: (Renderable (Text Double) b, Renderable (Path V2 Double) b) => FillWeight -> FillStyle -> t -> Int -> [String] -> [String] -> [Log Double] -> QDiagram b V2 Double Any
- Diagrams.TwoD.ProbabilityGrid: gridSquare :: (Monoid m, Semigroup m, TrailLike (QDiagram b V2 Double m)) => FillWeight -> Log Double -> QDiagram b V2 Double m
+ Diagrams.TwoD.ProbabilityGrid: gridSquare :: (Monoid m, Semigroup m, TrailLike (QDiagram b V2 Double m)) => FillWeight -> FillStyle -> Log Double -> QDiagram b V2 Double m
- Diagrams.TwoD.ProbabilityGrid: svgGridFile :: FilePath -> FillWeight -> Int -> Int -> [String] -> [String] -> [Log Double] -> IO ()
+ Diagrams.TwoD.ProbabilityGrid: svgGridFile :: FilePath -> FillWeight -> FillStyle -> Int -> Int -> [String] -> [String] -> [Log Double] -> IO ()

Files

Diagrams/TwoD/ProbabilityGrid.hs view
@@ -3,33 +3,50 @@  module Diagrams.TwoD.ProbabilityGrid where -import Data.List (genericLength)-import Data.List.Split (chunksOf)-import Diagrams.Backend.Postscript-import Diagrams.Backend.SVG-import Diagrams.Prelude-import Diagrams.TwoD-import Diagrams.TwoD.Text-import Numeric.Log+import           Data.Data+import           Data.List (genericLength)+import           Data.List.Split (chunksOf)+import           Data.Typeable+import           Debug.Trace+import           Diagrams.Backend.Postscript hiding (EPS)+import           Diagrams.Backend.SVG hiding (SVG)+import           Diagrams.Prelude+import           Diagrams.TwoD+import           Diagrams.TwoD.Text+import           Numeric.Log+import qualified Diagrams.Backend.Postscript as DBP+import qualified Diagrams.Backend.SVG as DBS+import           System.FilePath (replaceExtension)    -- | Fill weight for our grid. If the fill weight is @logarithmic@, then -- the line length is @1 / (1 + log value)@ otherwise it is @value@. -data FillWeight = FWlog | FWlinear+data FillWeight = FWlog | FWlinear | FWfill+  deriving (Eq,Show,Data,Typeable) +data FillStyle = FSopacityLog | FSopacityLinear | FSfull+  deriving (Eq,Show,Data,Typeable)+ -- | A single square in our grid.  -- gridSquare :: FillWeight -> Log Double gridSquare   :: (Monoid m, Semigroup m, TrailLike (QDiagram b V2 Double m))-  => FillWeight -> Log Double -> QDiagram b V2 Double m-gridSquare (fw :: FillWeight) (v :: Log Double) = g `beneath` (z # scale s)+  => FillWeight -> FillStyle -> Log Double -> QDiagram b V2 Double m+gridSquare fw fs v+  | s >= 0.001 = g `beneath` (z # scale s)+  | otherwise  = g   where s = case fw of               FWlog     -> 1 / (1 - ln v)               FWlinear  -> exp $ ln v-        z = square 1 # lw 0 # fc blue # centerXY+              FWfill    -> 1+        o = case fs of+              FSopacityLog    -> 1 / (1 - ln v)+              FSopacityLinear -> exp $ ln v+              FSfull          -> 1.0 :: Double+        z = square 1 # lw 0 # ((if fs==FSfull then fc else fcA . flip withOpacity o) blue) # centerXY         g = square 1 # lc black  -- | Draw the actual grid.@@ -38,30 +55,45 @@   :: ( Renderable (Diagrams.TwoD.Text.Text Double) b      , Renderable (Path V2 Double) b)   => FillWeight+  -> FillStyle   -> t   -> Int   -> [String]   -> [String]   -> [Log Double]   -> QDiagram b V2 Double Any-grid (fw :: FillWeight) n m (ns :: [String]) (ms :: [String]) (vs :: [Log Double])+grid fw fs n m (ns :: [String]) (ms :: [String]) (vs :: [Log Double])   | null ns && null ms = grd   | otherwise =  (grd ||| ns') === ms'   where ns' = if null ns then mempty else vcat $ map (\t -> (square 1) `beneath` (text t # scale (0.9 / genericLength t))) ns         ms' = if null ms then mempty else hcat $ map (\t -> (square 1) `beneath` (text t # scale (0.9 / genericLength t))) ms-        grd = vcat $ map hcat $ map (map (gridSquare fw)) $ chunksOf m $ vs+        grd = vcat $ map hcat $ map (map (gridSquare fw fs)) $ chunksOf m $ vs  -- | Render as @svg@. -svgGridFile :: FilePath -> FillWeight -> Int -> Int -> [String] -> [String] -> [Log Double] -> IO ()-svgGridFile fname fw n m ns ms vs = renderPretty fname size $ g+svgGridFile :: FilePath -> FillWeight -> FillStyle -> Int -> Int -> [String] -> [String] -> [Log Double] -> IO ()+svgGridFile fname fw fs n m ns ms vs = renderPretty fname size $ g   where size = ((*100) . fromIntegral) <$> mkSizeSpec2D (Just m) (Just n) -- Nothing Nothing -- n n-        g = grid fw n m ns ms vs+        g = grid fw fs n m ns ms vs  -- | Render as @eps@. -epsGridFile :: String -> FillWeight -> Int -> Int -> [String] -> [String] -> [Log Double] -> IO ()-epsGridFile fname fw n m ns ms vs = renderDia Postscript (PostscriptOptions fname size EPS) g+epsGridFile :: String -> FillWeight -> FillStyle -> Int -> Int -> [String] -> [String] -> [Log Double] -> IO ()+epsGridFile fname fw fs n m ns ms vs = renderDia Postscript (PostscriptOptions fname size DBP.EPS) g   where size = ((*100) . fromIntegral) <$> mkSizeSpec2D (Just m) (Just n)-        g = grid fw n m ns ms vs+        g = grid fw fs n m ns ms vs++data RenderChoice+  = SVG+  | EPS+  deriving (Eq,Show,Data,Typeable)++-- | Choose a renderer with appropriate file name suffix++gridFile :: [RenderChoice] -> String -> FillWeight -> FillStyle -> Int -> Int -> [String] -> [String] -> [Log Double] -> IO ()+gridFile cs fname fw fs n m ns ms vs = go cs+  where go [] = return ()+        go (c:cs) = case c of+          SVG -> svgGridFile (fname ++ ".svg") fw fs n m ns ms vs >> go cs+          EPS -> epsGridFile (fname ++ ".eps") fw fs n m ns ms vs >> go cs 
PrimitiveArray-Pretty.cabal view
@@ -1,5 +1,5 @@ Name:           PrimitiveArray-Pretty-Version:        0.0.0.1+Version:        0.0.0.2 License:        BSD3 License-file:   LICENSE Maintainer:     choener@bioinf.uni-leipzig.de@@ -11,7 +11,7 @@ Category:       Data Build-type:     Simple Cabal-version:  >=1.10.0-tested-with:    GHC == 7.8.4, GHC == 7.10.3+tested-with:    GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.1 Synopsis:       Pretty-printing for primitive arrays Description:                 <http://www.bioinf.uni-leipzig.de/Software/gADP/ generalized Algebraic Dynamic Programming>@@ -34,17 +34,20 @@ Library   Exposed-modules:     Diagrams.TwoD.ProbabilityGrid-  build-depends: base                     >= 4.7    &&  < 4.9-               , diagrams                 >= 1.3    &&  < 1.4-               , diagrams-lib             >= 1.3    &&  < 1.4-               , diagrams-svg             >= 1.3    &&  < 1.4-               , diagrams-postscript      >= 1.3    &&  < 1.4-               , log-domain               >= 0.10   &&  < 0.11-               , split                    >= 0.2    &&  < 0.3+  build-depends: base                     >= 4.7    &&  < 5.0+               , diagrams                 >= 1.3+               , diagrams-contrib         >= 1.3+               , diagrams-lib             >= 1.3+               , diagrams-svg             >= 1.3+               , diagrams-postscript      >= 1.3+               , filepath+               , log-domain               >= 0.10+               , split                    >= 0.2   default-extensions: BangPatterns-                    , TypeFamilies+                    , DeriveDataTypeable                     , FlexibleContexts                     , ScopedTypeVariables+                    , TypeFamilies   default-language:     Haskell2010   ghc-options:@@ -67,11 +70,12 @@   default-extensions: CPP                     , TemplateHaskell   build-depends: base-               , PrimitiveArray-Pretty                , QuickCheck-               , test-framework               >= 0.8  && < 0.9-               , test-framework-quickcheck2   >= 0.3  && < 0.4-               , test-framework-th            >= 0.2  && < 0.3+               , test-framework               >= 0.8+               , test-framework-quickcheck2   >= 0.3+               , test-framework-th            >= 0.2+               --+               , PrimitiveArray-Pretty   
changelog.md view
@@ -1,3 +1,8 @@+0.0.0.2+-------++- added full and opacity fill style+ 0.0.0.1 -------