-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
iszero vs x==0 and countnz, find etc. #23005
Comments
I've updated the top post with possible solutions |
I guess the root of the problem is that |
I think |
Or perhaps |
isn't that what it is now? |
+1 to the idea of making |
I've only just started reading the issue, but the status quo actual seems best to me. count(iszero, [1, 2, 3, 0]) |
Along the lines of what @vtjnash is proposing, I propose getting rid of the |
I think you mean |
Removing |
Efficient implementation for sparse is roughly |
Fixed by #23485. |
In short
but
But
String
is relatively arbitrarily chosen here. An implication of this is thatbecause
countnz
tests withx != 0
. It could also test with!iszero
but thencountnz([:Julia])
would fail.This came up in #22945 but is kind of separate from the PR so I think it deserves its own issue. There was a previous discussion of this issue in #17623 (comment) but I'm not sure how many people noticed.
Possible solutions I can come up with are
iszero(x) = false
and use!iszero
whenever testing for zero in e.g.countnz
andfind
. This would makecountnz([[0.0]]) == 0
andcountnz([:Julia]) == 1
==
method or make it try to convert the arguments to the same type and use!iszero
incountnz
andfind
. This would makecountnz([[0.0]]) == 0
andcountnz([:julia])
fail, but probably also make a million other things throw.iszero
and==
as they are but use!iszero
incountnz
andfind
. This would makecountnz([[0.0]]) == 0
andcountnz([:julia])
fail.countnz([[0.0]]) == 1
(which I think is the wrong result) andcountnz([:Julia]) == 1
Update: I think we should add this to the milestone for 1.0.
The text was updated successfully, but these errors were encountered: