PrimitiveArray-Pretty (empty) → 0.0.0.1
raw patch · 7 files changed
+210/−0 lines, 7 filesdep +PrimitiveArray-Prettydep +QuickCheckdep +basesetup-changed
Dependencies added: PrimitiveArray-Pretty, QuickCheck, base, diagrams, diagrams-lib, diagrams-postscript, diagrams-svg, log-domain, split, test-framework, test-framework-quickcheck2, test-framework-th
Files
- Diagrams/TwoD/ProbabilityGrid.hs +67/−0
- LICENSE +30/−0
- PrimitiveArray-Pretty.cabal +81/−0
- README.md +18/−0
- Setup.hs +2/−0
- changelog.md +4/−0
- tests/properties.hs +8/−0
+ Diagrams/TwoD/ProbabilityGrid.hs view
@@ -0,0 +1,67 @@++-- | Probability grid square drawing routines.++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++++-- | 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++-- | 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)+ where s = case fw of+ FWlog -> 1 / (1 - ln v)+ FWlinear -> exp $ ln v+ z = square 1 # lw 0 # fc blue # centerXY+ g = square 1 # lc black++-- | Draw the actual grid.++grid+ :: ( Renderable (Diagrams.TwoD.Text.Text Double) b+ , Renderable (Path V2 Double) b)+ => FillWeight+ -> t+ -> Int+ -> [String]+ -> [String]+ -> [Log Double]+ -> QDiagram b V2 Double Any+grid (fw :: FillWeight) 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++-- | 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+ where size = ((*100) . fromIntegral) <$> mkSizeSpec2D (Just m) (Just n) -- Nothing Nothing -- n n+ g = grid fw 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+ where size = ((*100) . fromIntegral) <$> mkSizeSpec2D (Just m) (Just n)+ g = grid fw n m ns ms vs+
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright Christian Hoener zu Siederdissen 2016++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Christian Hoener zu Siederdissen nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ PrimitiveArray-Pretty.cabal view
@@ -0,0 +1,81 @@+Name: PrimitiveArray-Pretty+Version: 0.0.0.1+License: BSD3+License-file: LICENSE+Maintainer: choener@bioinf.uni-leipzig.de+author: Christian Hoener zu Siederdissen, 2016+copyright: Christian Hoener zu Siederdissen, 2016+homepage: https://github.com/choener/PrimitiveArray-Pretty+bug-reports: https://github.com/choener/PrimitiveArray-Pretty/issues+Stability: Experimental+Category: Data+Build-type: Simple+Cabal-version: >=1.10.0+tested-with: GHC == 7.8.4, GHC == 7.10.3+Synopsis: Pretty-printing for primitive arrays+Description:+ <http://www.bioinf.uni-leipzig.de/Software/gADP/ generalized Algebraic Dynamic Programming>+ .+ A Pretty-printer for Primitive Arrays.+ .+ The idea is not so much to provide pretty-printing for single+ arrays, but rather to allow for simple prettyfication of+ typical array data. In particular we want to have simplified+ pretty-printing of Inside/Outside combinations of arrays.++++extra-source-files:+ README.md+ changelog.md++++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+ default-extensions: BangPatterns+ , TypeFamilies+ , FlexibleContexts+ , ScopedTypeVariables+ default-language:+ Haskell2010+ ghc-options:+ -O2+ -funbox-strict-fields++++test-suite properties+ type:+ exitcode-stdio-1.0+ main-is:+ properties.hs+ ghc-options:+ -threaded -rtsopts -with-rtsopts=-N+ hs-source-dirs:+ tests+ default-language:+ Haskell2010+ 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++++source-repository head+ type: git+ location: git://github.com/choener/PrimitiveArray-Pretty+
+ README.md view
@@ -0,0 +1,18 @@+[](https://travis-ci.org/choener/PrimitiveArray-Pretty)++# PrimitiveArray-Pretty++[*generalized Algebraic Dynamic Programming Homepage*](http://www.bioinf.uni-leipzig.de/Software/gADP/)++Prettyprinting for tables that holds probability information. Currently mostly+useful for pretty-printing the result of Inside-Outside calculations.++++#### Contact++Christian Hoener zu Siederdissen +Leipzig University, Leipzig, Germany +choener@bioinf.uni-leipzig.de +http://www.bioinf.uni-leipzig.de/~choener/ +
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ changelog.md view
@@ -0,0 +1,4 @@+0.0.0.1+-------++- initial checkin
+ tests/properties.hs view
@@ -0,0 +1,8 @@++module Main where++++main :: IO ()+main = return ()+