- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Fixed broken exception in TriDiag LU and added tests #11146
Conversation
👍 |
@kshyatt, you are truly the best |
Perhaps I am missing something, but I find it surprising that such typos are not found during function compilation. Consider the following REPL session:
|
I want to preface this by saying I don't mean to single anyone out - I've made lots of "oops lol" typos. But I think it's interesting that this bug, and the bug in #11144 made it into Julia and sat "quietly" for so long, since they are immediate show-stoppers. In particular the bug in #11144 would have been caught with a proof-of-concept test, and this one would have been noticed if a requirement to demonstrate the exception being thrown was in place. Should Julia require that, when feasible, new functions have a proof-of-concept test and a test for each exception the function can throw? |
Tests are failing because of slightly out-of-bounds numerical results! Grrrrr. This passed locally. |
I would be fine with relaxing those bounds somewhat. Ref: JuliaLang/LinearAlgebra.jl#67 |
I managed to reproduce the problem on a Linux machine I have access to, the problem was that in my test for the exception-throwing, I forgot to convert |
@kshyatt I've generally not been very careful about hitting the exception branches in the tests. The handy |
@kshyatt you can pretty much assume that any error branch in the linear algebra code is currently untested. |
I should point out that the age of the linear algebra code is pretty much proportional to the coverage. Code that was written more recently has much better branch coverage so things are improving! |
@jakebolewski @andreasnoack Sounds like a good weeknight project to me. Writing error tests was really useful for CUSPARSE and CUBLAS functions to avoid the "segfaults ... segfaults everywhere" condition. |
@kshyatt I have a branch that makes the linear algebra code much more amenable to running code coverage (I don't remember the name, it will be jcb/something) rebasing it and running coverage again will be fruitful if you want to systematically go through these. All the tests used to pass, maybe we should just rebase and merge it (the only problem is that the diff is huge). |
@jakebolewski Perhaps the aptly-named |
most likely :-) |
@StefanKarpinski I find your answer unsatisfying (so let me explain my thinking a bit more, and perhaps you or somebody could elaborate?). Is it not possible, in principle, for julia to recognize at the moment Assuming it can be tested for, there is the additional question of whether it is the "right" thing to do. But I can think of relatively few instances in which a user would want to e.g. call |
@garrison globals are evil, but people seem to find them useful. |
@garrison, it can be tested for and work has been done towards static analysis tools to find these kinds of issues – see Lint.jl and TypeCheck.jl. Integrating these sorts of checks into Julia itself is something that I think is a very good idea and a promising avenue of future development. As to when using as-yet-undefined globals is useful, consider, for example, mutually recursive function declarations. |
@ihnorton :-) @StefanKarpinski Thanks, that is very helpful, and I am happy to see the existing work that is being done. The case of mutually-recursive function declarations is an important one that I had not considered. But I don't think it would actually "fail" the check I propose. If |
The erroneous exception error is easy to introduce, also #5593 , I guess there are more instances. |
Indeed, it might be worth writing a list of all the mistakes in spelling exception names we can think of and running a |
@kshyatt I was thinking of running |
"IOError" in sparse/umfpack.jl: There are some expressions of the form Finally I think |
Fixed broken exception in TriDiag LU and added tests
I backported the bugfix and one of the added tests in 9f5c560, unfortunately there are too many missing methods on release-0.3 to add any of the other new tests. Separate PR's against release-0.3 might be necessary if anyone wants to rectify that. |
lufact
forTridiagonal
matrices was attempting to throwDimentionsMismatch
, an exception type that doesn't exist. This bug was introduced in d193ce6. I added some tests for the Tridiagonal LU factorization as well, as well as missingldiv
tests forVector
s.