Persistence 1.1.2 → 1.1.3
raw patch · 3 files changed
+20/−11 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +6/−0
- Persistence.cabal +1/−1
- Persistence.hs +13/−10
ChangeLog.md view
@@ -13,3 +13,9 @@ ### Changed - Improved documentation for all exposed modules.++## 1.1.3 -- 2018-07-30++### Changed+- Fixed a major bug with persistent homology; high dimensional holes were being detected in low dimensional data sets.+- Persistent homology now filters out bar codes of the form (i, Just i), as they say nothing about the topology of the underlying complexes.
Persistence.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: Persistence-version: 1.1.2+version: 1.1.3 synopsis: Quickly detect clusters and holes in data. description: Persistence is a topological data analysis library motivated by flexibility when it comes to the type of data being analyzed. If you have data that comes with a meaningful function into something of the Ord typeclass, you can use Persistence to detect clusters and holes in the data. You can also use the library to analyze the topology of directed\/undirected weighted\/unweighted graphs, and compare topologies of different data sets. license: BSD3
Persistence.hs view
@@ -150,7 +150,9 @@ if V.null simplices then simplices else mapWithIndex (\i ss -> V.map ((newFaces i) . fst) ss) sortedSimplices - in (numVerts, sortFiltration $ --sort the simplices by filtration index+ sortBoundaries = V.map (V.map (\(i, v, f) -> (i, v, quicksort (\a b -> a < b) f)))++ in (numVerts, sortBoundaries $ sortFiltration $ --sort the simplices by filtration index calcIndices maxIndex (L.tail scales) $ V.map (V.map (\(v, f) -> (0, v, f))) $ simplices) @@ -210,18 +212,19 @@ persistentHomology :: Filtration -> [[BarCode]] persistentHomology (numVerts, allSimplices) = let- --union minus intersection+ --Union minus intersection of ordered vectors. uin :: Ord a => Vector a -> Vector a -> Vector a u `uin` v =- let findAndInsert elem vec =- let (vec1, vec2) = biFilter (\x -> x > elem) vec- in- if V.null vec2 then vec `snoc` elem- else if elem == V.head vec2 then vec1 V.++ V.tail vec2- else vec1 V.++ (elem `cons` vec2)+ let len = V.length v+ findAndInsert i elem vec+ | i == len = vec `snoc` elem+ | elem == x = (V.take i vec) V.++ (V.drop i1 vec)+ | elem > x = (V.take i vec) V.++ (elem `cons` (V.drop i vec))+ | otherwise = findAndInsert i1 elem vec+ where x = vec ! i; i1 = i + 1 in if V.null u then v- else (V.tail u) `uin` (findAndInsert (V.head u) v)+ else (V.tail u) `uin` (findAndInsert 0 (V.head u) v) removeUnmarked marked = V.filter (\x -> existsVec (\y -> y == x) marked) @@ -278,7 +281,7 @@ verts = 0 `range` (numVerts - 1) - in makeInfiniteBarCodes $ makeFiniteBarCodes 1 (V.length allSimplices) [fstCodes] (verts `cons` (fstMarked `cons` V.empty)) (fstSlots `cons` V.empty)+ in L.map (L.filter (\(a,b) -> b /= Just a)) $ makeInfiniteBarCodes $ makeFiniteBarCodes 1 (V.length allSimplices) [fstCodes] (verts `cons` (fstMarked `cons` V.empty)) (fstSlots `cons` V.empty) {- | Return the maximum of minimum distances bewteen the bar codes.