• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mtsch / Ripserer.jl / 8545078607

03 Apr 2024 08:26PM UTC coverage: 96.51% (+0.09%) from 96.417%
8545078607

Pull #166

github

web-flow
Merge ed46e50d4 into 3f2d63fae
Pull Request #166: Better homology

245 of 250 new or added lines in 5 files covered. (98.0%)

3 existing lines in 3 files now uncovered.

1770 of 1834 relevant lines covered (96.51%)

3302629.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.33
/src/computation/involuted.jl
1
"""
2
    compute_death_simplices!(matrix::CoboundaryMatrix{true}, verbose, cutoff)
3

4
Fully reduce `matrix`, but only compute (homological) death simplices. Return all death
5
simplices up to the last that produces an interval with persistence greater than `cutoff`.
6

7
Used for involuted homology.
8
"""
9
function compute_death_simplices!(matrix::CoboundaryMatrix{true}, verbose, cutoff)
12✔
10
    columns, apparent = find_apparent_pairs(
12✔
11
        matrix.filtration, matrix.columns_to_reduce, verbose
12
    )
13
    bulk_insert!(matrix.reduced, apparent)
12✔
14
    deaths = simplex_type(matrix.filtration, dim(matrix) + 1)[]
12✔
15
    inf_births = simplex_type(matrix.filtration, dim(matrix))[]
12✔
16
    if isempty(columns)
12✔
NEW
17
        return deaths, inf_births
×
18
    else
19
        dim(matrix) > 1 && sort!(columns; rev=true)
14✔
20
        thresh = typemin(birth(first(columns)))
12✔
21
        for pair in apparent
12✔
22
            if birth(pair[2]) - birth(pair[1]) > cutoff
118✔
NEW
23
                thresh = max(thresh, birth(pair[2]))
×
24
            end
25
            push!(deaths, pair[2])
118✔
26
        end
118✔
27
        if verbose
12✔
NEW
28
            progbar = Progress(length(columns); desc="Precomputing columns...   ")
×
29
        end
30
        for column in columns
12✔
31
            pivot = reduce_column!(matrix, column)
3,899✔
32
            if !isnothing(pivot)
7,758✔
33
                if birth(pivot) - birth(column) > cutoff
3,859✔
34
                    thresh = max(thresh, birth(pivot))
336✔
35
                end
36
                push!(deaths, simplex(pivot))
3,859✔
37
            else
38
                push!(inf_births, column)
40✔
39
            end
40
            verbose && next!(progbar; showvalues=((:simplices, length(deaths)),))
3,899✔
41
        end
3,899✔
42
        return filter!(x -> birth(x) ≤ thresh, deaths), inf_births
3,989✔
43
    end
44
end
45

46
function _ripserer(
9✔
47
    ::Val{:involuted}, filtration, cutoff, verbose, field, dim_max, reps, implicit
48
)
49
    result = PersistenceDiagram[]
9✔
50
    zeroth, to_reduce, to_skip = zeroth_intervals(
9✔
51
        filtration, cutoff, verbose, field, _reps(reps, 0)
52
    )
53
    push!(result, zeroth)
9✔
54
    if dim_max > 0
9✔
55
        comatrix = CoboundaryMatrix{true}(field, filtration, to_reduce, to_skip)
9✔
56
        for dim in 1:dim_max
9✔
57
            columns, inf_births = compute_death_simplices!(comatrix, verbose, cutoff)
12✔
58
            birth_candidates = comatrix.columns_to_reduce
12✔
59
            matrix = BoundaryMatrix{implicit}(
12✔
60
                field, filtration, birth_candidates, columns; infinite_intervals=false
61
            )
62
            diagram = compute_intervals!(matrix, cutoff, verbose, _reps(reps, dim))
12✔
63
            for birth_simplex in inf_births
12✔
64
                push!(
80✔
65
                    diagram.intervals,
66
                    interval(comatrix, birth_simplex, nothing, 0, _reps(reps, dim)),
67
                )
68
            end
40✔
69
            push!(result, diagram)
12✔
70
            if dim < dim_max
12✔
71
                comatrix = next_matrix(comatrix, verbose)
3✔
72
            end
73
        end
15✔
74
    end
75
    return result
9✔
76
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc