Skip to content

Commit cf50d8c

Browse files
committed
test check_acyclic()
1 parent 2982774 commit cf50d8c

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/imply/abstract.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function check_acyclic(A::AbstractMatrix)
2323
return UpperTriangular(A)
2424
else
2525
if acyclic
26-
@info "Your model is acyclic, specifying the A Matrix as either Upper or Lower Triangular can have great performance benefits.\n" maxlog =
26+
@warn "Your model is acyclic, specifying the A Matrix as either Upper or Lower Triangular can have great performance benefits.\n" maxlog =
2727
1
2828
end
2929
return A

test/unit_tests/matrix_helpers.jl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
using StructuralEquationModels, Test, Random, SparseArrays, LinearAlgebra
22
using StructuralEquationModels:
3-
CommutationMatrix, transpose_linear_indices, duplication_matrix, elimination_matrix
3+
CommutationMatrix,
4+
check_acyclic,
5+
transpose_linear_indices,
6+
duplication_matrix,
7+
elimination_matrix
48

59
Random.seed!(73721)
610

@@ -47,3 +51,15 @@ end
4751
E = elimination_matrix(m)
4852
@test E * vec(A) == A[tril(trues(size(A)))]
4953
end
54+
55+
@testset "check_acyclic()" begin
56+
@test check_acyclic([1 0; 0 1]) isa LowerTriangular{Int, Matrix{Int}}
57+
@test check_acyclic([1 0; 1 1]) isa LowerTriangular{Int, Matrix{Int}}
58+
@test check_acyclic([1.0 1.0; 0.0 1.0]) isa UpperTriangular{Float64, Matrix{Float64}}
59+
60+
A = [0 1; 1 0]
61+
@test check_acyclic(A) === A # returns the input if cyclic
62+
63+
# acyclic, but not u/l triangular
64+
@test_logs (:warn, r"^Your model is acyclic") check_acyclic([0 0 0; 1 0 1; 0 0 0])
65+
end

0 commit comments

Comments
 (0)