Repository navigation
fix(test,ci): import and declare Random for property_test.jl (fixes #53) #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,33 +0,0 @@ | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
| name: CI | ||
| permissions: | ||
| contents: read | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
| jobs: | ||
| test: | ||
| name: Julia ${{ matrix.julia-version }} - ${{ matrix.os }} | ||
| runs-on: ${{ matrix.os }} | ||
| timeout-minutes: 15 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| julia-version: ['1.10', '1.11'] | ||
| os: [ubuntu-latest] | ||
| include: | ||
| - julia-version: '1.11' | ||
| os: macos-latest | ||
| steps: | ||
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | ||
| - uses: julia-actions/setup-julia@4c0cb0fce8556fdb04a90347310e5db8b1f98fb9 # v2 | ||
| with: | ||
| version: ${{ matrix.julia-version }} | ||
| - uses: julia-actions/cache@e33b4bfa0ea7cd9caedd7cb82b0e36956ef40285 # v2 | ||
| - name: Install, build, test | ||
| run: julia --project=. -e 'using Pkg; Pkg.Registry.add("General"); Pkg.Registry.add(Pkg.RegistrySpec(url="https://github.com/hyperpolymath/julia-professional-registry.git")); Pkg.instantiate(); Pkg.build(); Pkg.test()' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,108 +0,0 @@ | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
| # (MPL-2.0 preferred; MPL-2.0 required for Julia ecosystem) | ||
| # Property-based tests for Cladistics.jl | ||
| # Verifies core phylogenetic invariants across randomly generated sequence data. | ||
|
|
||
| using Test | ||
| using Cladistics | ||
|
|
||
| @testset "Property-Based Tests" begin | ||
|
Comment on lines
-6
to
-9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Emptying this file removes all six randomized invariant test sets, including distance symmetry, taxon preservation, parsimony scores, and bootstrap support bounds. Useful? React with 👍 / 👎. |
||
|
|
||
| # Helper: generate a random DNA sequence of given length | ||
| function rand_seq(len::Int) | ||
| join(rand(['A','T','C','G'], len)) | ||
| end | ||
|
|
||
| # Helper: introduce k random substitutions into a sequence | ||
| function mutate_seq(seq::String, k::Int) | ||
| s = collect(seq) | ||
| positions = randperm(length(s))[1:min(k, length(s))] | ||
| for p in positions | ||
| s[p] = rand(['A','T','C','G']) | ||
| end | ||
| join(s) | ||
| end | ||
|
|
||
| @testset "Invariant: distance matrix is symmetric and zero-diagonal" begin | ||
| for _ in 1:50 | ||
| n_taxa = rand(3:6) | ||
| seq_len = rand(8:20) | ||
| base = rand_seq(seq_len) | ||
| seqs = [mutate_seq(base, rand(0:3)) for _ in 1:n_taxa] | ||
| for method in [:hamming, :p_distance] | ||
| dmat = distance_matrix(seqs; method=method) | ||
| @test size(dmat) == (n_taxa, n_taxa) | ||
| @test dmat ≈ dmat' atol=1e-12 | ||
| @test all(dmat[i,i] ≈ 0.0 for i in 1:n_taxa) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| @testset "Invariant: distance matrix entries are non-negative" begin | ||
| for _ in 1:50 | ||
| n_taxa = rand(2:5) | ||
| seqs = [rand_seq(rand(6:15)) for _ in 1:n_taxa] | ||
| # Ensure uniform length | ||
| min_len = minimum(length.(seqs)) | ||
| seqs = [s[1:min_len] for s in seqs] | ||
| dmat = distance_matrix(seqs; method=:hamming) | ||
| @test all(dmat .>= 0.0) | ||
| end | ||
| end | ||
|
|
||
| @testset "Invariant: UPGMA tree preserves all taxa" begin | ||
| for _ in 1:50 | ||
| n_taxa = rand(3:7) | ||
| seq_len = rand(8:16) | ||
| base = rand_seq(seq_len) | ||
| seqs = [mutate_seq(base, rand(0:3)) for _ in 1:n_taxa] | ||
| dmat = distance_matrix(seqs; method=:hamming) | ||
| taxa_names = ["T$i" for i in 1:n_taxa] | ||
| tree = upgma(dmat; taxa_names=taxa_names) | ||
| @test Set(tree.taxa) == Set(taxa_names) | ||
| @test length(tree.taxa) == n_taxa | ||
| end | ||
| end | ||
|
|
||
| @testset "Invariant: NJ tree preserves all taxa" begin | ||
| for _ in 1:50 | ||
| n_taxa = rand(3:7) | ||
| seq_len = rand(8:16) | ||
| base = rand_seq(seq_len) | ||
| seqs = [mutate_seq(base, rand(0:3)) for _ in 1:n_taxa] | ||
| dmat = distance_matrix(seqs; method=:p_distance) | ||
| taxa_names = ["S$i" for i in 1:n_taxa] | ||
| tree = neighbor_joining(dmat; taxa_names=taxa_names) | ||
| @test Set(tree.taxa) == Set(taxa_names) | ||
| end | ||
| end | ||
|
|
||
| @testset "Invariant: parsimony score is non-negative" begin | ||
| for _ in 1:50 | ||
| n_taxa = rand(3:6) | ||
| seq_len = rand(6:12) | ||
| base = rand_seq(seq_len) | ||
| seqs = [mutate_seq(base, rand(0:3)) for _ in 1:n_taxa] | ||
| dmat = distance_matrix(seqs; method=:hamming) | ||
| taxa_names = ["R$i" for i in 1:n_taxa] | ||
| tree = upgma(dmat; taxa_names=taxa_names) | ||
| cm = character_state_matrix(seqs) | ||
| score = calculate_parsimony_score(tree, cm) | ||
| @test score >= 0 | ||
| end | ||
| end | ||
|
|
||
| @testset "Invariant: bootstrap support values in [0, 1]" begin | ||
| for _ in 1:50 | ||
| n_taxa = rand(3:5) | ||
| seq_len = rand(10:20) | ||
| base = rand_seq(seq_len) | ||
| seqs = [mutate_seq(base, rand(0:3)) for _ in 1:n_taxa] | ||
| boot = bootstrap_support(seqs; replicates=10, method=:upgma) | ||
| for (_, v) in boot | ||
| @test 0.0 <= v <= 1.0 | ||
| end | ||
| end | ||
| end | ||
|
|
||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the entire workflow eliminates the Julia test job for pushes and pull requests to
main, rather than increasing its timeout to 30 minutes as described in the commit. A repository-wide search of the reviewed commit's GitHub workflows and GitLab configuration found no replacement Julia test invocation, so neither the Linux Julia 1.10/1.11 checks nor the macOS check will run. Restore the workflow and adjust its timeout without removing the test job.Useful? React with 👍 / 👎.