Skip to content

Commit

Permalink
test check_acyclic()
Browse files Browse the repository at this point in the history
  • Loading branch information
alyst committed Jun 27, 2024
1 parent 2982774 commit cf50d8c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/imply/abstract.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function check_acyclic(A::AbstractMatrix)
return UpperTriangular(A)
else
if acyclic
@info "Your model is acyclic, specifying the A Matrix as either Upper or Lower Triangular can have great performance benefits.\n" maxlog =
@warn "Your model is acyclic, specifying the A Matrix as either Upper or Lower Triangular can have great performance benefits.\n" maxlog =
1
end
return A
Expand Down
18 changes: 17 additions & 1 deletion test/unit_tests/matrix_helpers.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
using StructuralEquationModels, Test, Random, SparseArrays, LinearAlgebra
using StructuralEquationModels:
CommutationMatrix, transpose_linear_indices, duplication_matrix, elimination_matrix
CommutationMatrix,
check_acyclic,
transpose_linear_indices,
duplication_matrix,
elimination_matrix

Random.seed!(73721)

Expand Down Expand Up @@ -47,3 +51,15 @@ end
E = elimination_matrix(m)
@test E * vec(A) == A[tril(trues(size(A)))]
end

@testset "check_acyclic()" begin
@test check_acyclic([1 0; 0 1]) isa LowerTriangular{Int, Matrix{Int}}
@test check_acyclic([1 0; 1 1]) isa LowerTriangular{Int, Matrix{Int}}
@test check_acyclic([1.0 1.0; 0.0 1.0]) isa UpperTriangular{Float64, Matrix{Float64}}

A = [0 1; 1 0]
@test check_acyclic(A) === A # returns the input if cyclic

# acyclic, but not u/l triangular
@test_logs (:warn, r"^Your model is acyclic") check_acyclic([0 0 0; 1 0 1; 0 0 0])
end

0 comments on commit cf50d8c

Please sign in to comment.