Open pehkawn opened 3 years ago
The issue lies with the fact that the eigenvalues of A is not equal to the values in the solution matrix. E.g. -128.49322764802145 is not equal to -128.493. The assertion needs to be updated to reflect this. Either
@assert isapprox(A_diag,
[-128.493 0.0 0.0 0.0 0.0;
0.0 -55.8878 0.0 0.0 0.0;
0.0 0.0 42.7522 0.0 0.0;
0.0 0.0 0.0 87.1611 0.0;
0.0 0.0 0.0 0.0 542.468],
rtol = 1e-6)
or alternatively
@assert round.(A_diag, RoundNearestTiesUp, sigdigits=6) ==
[-128.493 0.0 0.0 0.0 0.0;
0.0 -55.8878 0.0 0.0 0.0;
0.0 0.0 42.7522 0.0 0.0;
0.0 0.0 0.0 87.1611 0.0;
0.0 0.0 0.0 0.0 542.468]
I've addressed this in #87, amongst other things
While working through some of the tutorials I've been encountering
AssertionError
when checking my answer against the provided solution. For the most part, I belive the error occurs due to a difference in the number of decimals returned from my code compared to the provided solution. In these cases, the issue has been resolved by replacing==
with≈
(\approx
) in the assertion line. However, this does not work in exercise 11.2 in tutorial 12. The exercise is to diagonalize an eigenvector and subsequently asserting it against a provided "solution" matrix. However, running the assertion line returns anAssertionError
, when asserting both equality (==
) and approximate equality (≈
).I've been reading through my code multiple times now, and I am at a loss at what causes the
AssertionError
. The values in my diagonal matrix (A_diag
) are seemingly identical to the solution matrix, and setting the statement to approximately equal (\approx
) renders the same error. My assumption is that I can count out decimal error here, so what may cause the error? Also, even if the assertion renders the statements unequal, why would this will return an error and notFALSE
?My code example:
FYI: I also posted this issue on StackOverflow.