Skip to content

Commit

Permalink
Merge f30b86c into 68e2cf9
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsch committed Dec 11, 2020
2 parents 68e2cf9 + f30b86c commit 0c05f24
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PersistenceDiagramsBase"
uuid = "b1ad91c1-539c-4ace-90bd-ea06abc420fa"
authors = ["mtsch <matijacufar@gmail.com>"]
version = "0.1.0"
version = "0.1.1"

[deps]
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
Expand Down
1 change: 1 addition & 0 deletions src/PersistenceDiagramsBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export PersistenceDiagram,
birth,
death,
persistence,
midlife,
dim,
threshold,
birth_simplex,
Expand Down
9 changes: 5 additions & 4 deletions src/diagrams.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""
PersistenceDiagram{P<:PersistenceInterval} <: AbstractVector{P}
PersistenceDiagram <: AbstractVector{PersistenceInterval}
Type for representing persistence diagrams. Behaves exactly like a vector of
`PersistenceInterval`s, but is can have metadata attached to it and supports pretty printing
and plotting.
`PersistenceInterval`s, but can have additional metadata attached to it. It supports pretty
printing and plotting.
Can be used as a table with any function that uses the
[`Tables.jl`](https://github.com/JuliaData/Tables.jl) interface.
[`Tables.jl`](https://github.com/JuliaData/Tables.jl) interface. Note that using it as a
table will only keep interval endpoints and the `dim` and `threshold` attributes.
# Example
Expand Down
13 changes: 10 additions & 3 deletions src/intervals.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
PersistenceInterval
The type that represents a persistence interval. It behaves exactly like a `Tuple{Float64,
Float64}`, but can have meta data attached to it. The metadata is accessible
with `getproperty`.
Type for representing persistence intervals. It behaves exactly like a `Tuple{Float64,
Float64}`, but can have meta data attached to it. The metadata is accessible with
`getproperty` or the dot syntax.
# Example
Expand Down Expand Up @@ -63,6 +63,13 @@ Get the persistence of `interval`, which is equal to `death - birth`.
"""
persistence(int::PersistenceInterval) = death(int) - birth(int)

"""
midlife(interval)
Get the midlife of the `interval`, which is equal to `(birth + death)/2`.
"""
midlife(int::PersistenceInterval) = (birth(int) + death(int))/2

Base.isfinite(int::PersistenceInterval) = isfinite(death(int))

###
Expand Down

0 comments on commit 0c05f24

Please sign in to comment.