Skip to content
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

RFC: Export iszero #19950

Merged
merged 3 commits into from
Jan 10, 2017
Merged

RFC: Export iszero #19950

merged 3 commits into from
Jan 10, 2017

Conversation

ararslan
Copy link
Member

@ararslan ararslan commented Jan 9, 2017

As mentioned by @stevengj in #19947, introduced in #17623.

@tkelman
Copy link
Contributor

tkelman commented Jan 9, 2017

if it's exported, it needs to be documented and the docs should be in the stdlib, if they aren't yet

@ararslan
Copy link
Member Author

ararslan commented Jan 9, 2017

The web UI is cumbersome for this stuff, particularly for editing multiple files, so I'll improve this a little later. I can also add a testset for it.

@kshyatt kshyatt added needs docs Documentation for this change is required needs tests Unit tests are required for this change labels Jan 9, 2017
@stevengj stevengj mentioned this pull request Jan 9, 2017
@ararslan
Copy link
Member Author

Now with 200% more docs and tests!

@tkelman tkelman removed needs docs Documentation for this change is required needs tests Unit tests are required for this change labels Jan 10, 2017
@ararslan
Copy link
Member Author

Does this need a NEWS item?

@stevengj
Copy link
Member

Yes, a NEWS item would be good.

@stevengj
Copy link
Member

stevengj commented Jan 10, 2017

(I was thinking that iszero(A::Array{T}) could probably be made faster when T is one of the basic numeric types, since then you just need to search for a nonzero byte and could probably arrange it to use SIMD instructions on 256-bit chunks, but it's maybe not worth the trouble.)

@ararslan
Copy link
Member Author

That would be pretty neat. I could take a crack at that at some point, but it would probably be better as a separate PR so that this and #19949 can be merged in time for 0.6.

@@ -159,6 +159,8 @@ Library improvements
* `logging` can be used to redirect `info`, `warn`, and `error` messages
either universally or on a per-module/function basis ([#16213]).

* `iszero` is now exported from `Base` ([#19950]).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes that people already know what this function is.

New `iszero(x)` function to quickly check whether `x` is zero (or is all zeros, for an array) ([#19950]).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much, much better. I've gone with that. Thanks!

@ararslan
Copy link
Member Author

Actually, perhaps that optimization could be made in any/all, since the array-reducing method for iszero is just all(iszero, x).

@stevengj stevengj merged commit 512339b into JuliaLang:master Jan 10, 2017
@ararslan ararslan deleted the patch-1 branch January 10, 2017 22:08

@testset "iszero" begin
# Numeric scalars
for T in Iterators.flatten(subtypes.([AbstractFloat, Signed, Unsigned]))
Copy link
Contributor

@tkelman tkelman Jan 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these types should probably just be written out - there's a type SOE.Sgnd defined in the core test that causes a failure here if it runs in the same worker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants