-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
sparse.^0 incorrect #77
Comments
Would't it be better to throw an error here instead of an explosion in memory allocation? Regarding your second comment, people (myself included) coming from MATLAB will be annoyed by this for a period until they get used julia's vectors. This is explained under Noteworthy Differences, and I don't think it is feasible to include in error messages for all functions accepting vector arguments. |
It would be a good idea to explicitly check for a zero exponent for sparse.^scalar, maybe others too. sparse.^sparse is also currently mathematically wrong here, I see there's a general issue JuliaLang/julia#4744 about improving error messages. If multiple dispatch fails to find an appropriate method, it could be useful to optionally print a few "Did you mean?" almost-matches in signature. For sparse in particular, it may be reasonable to allow 2-or-higher-dimensional array inputs for specifying indices and values, converted to Vector via [:]. It's a bit surprising that using just semicolons does the same thing as using all commas in an array concatenation, vs Matlab where comma and space are equivalent in this context. Commas seem redundant for this purpose in Julia if they do the same thing as semicolons, except that they aren't allowed for the horizontal-and-vertical case. |
Is there a situation where
I am not up to date with the plans for improvements on the error messages.
I am not sure I understand your proposal, but if it is to allow, a matrix input and the flatten that to a vector and call the vector version, then I think it is better only to have the vector version and let the user do the flattening. It will only cause confusion for MATLAB programmers in a short period.
I have had the same thought and I think it would make more sense if |
Probably not?
It's partly a Julia Studio bug, the error messages in the REPL straight from julia-readline are significantly different and more useful than I was seeing in Studio. I'll try to come up with a simple example and report it on forio's tracker.
You're right, flattening behind the API would allow more valid inputs but could be confusing in its own right. Perhaps another short sentence in the concatenation bullet, "Row matrices created by [x y z] are not valid inputs when a function expects a 1-D vector, unlike many comparable functions in Matlab," in case it's not obvious from the terse error messages and long lists of |
Thanks for catching this embarrassing error. I'll plan to remove the sparse.^sparse method and special case sparse.^0. |
I was going to say this is good as long as none of your nonzero values are NaN, but quoting Wikipedia:
it looks like Matlab's the non-conformant one w.r.t. |
Reasoning about the behaviour NaN can be surprisingly tricky, and quite a few of our numerics issues relate to standards-compliant NaN arithmetic. |
Sparse matrix to elementwise power of 0 is incorrect, ref https://github.com/JuliaLang/julia/blob/c93ed16a093e33fe9e0de153120c821959641bd2/base/sparse/sparsematrix.jl#L579
In Julia:
In Matlab:
Separate comment, but it would be nice if I got a more descriptive error message (or no error at all) from:
Putting commas or semicolons in fixes things, but that's not particularly obvious to a new user.
The text was updated successfully, but these errors were encountered: