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

Fix broadcast issue #196

Merged
merged 6 commits into from
May 30, 2017
Merged

Fix broadcast issue #196

merged 6 commits into from
May 30, 2017

Conversation

bshall
Copy link
Contributor

@bshall bshall commented May 29, 2017

Fix for #191

@c42f
Copy link
Member

c42f commented May 29, 2017

I think we can get away with something a bit simpler than this. Here's what I had:

@inline broadcast_sizes(a::StaticArray, as...) = (Size(a), broadcast_sizes(as...)...)
@inline broadcast_sizes(a::Number, as...) = (Size(), broadcast_sizes(as...)...)
@inline broadcast_sizes() = ()

@bshall
Copy link
Contributor Author

bshall commented May 29, 2017

Yeah, that is better.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.008%) to 83.255% when pulling 6652793 on bshall:broadcast-fix into 92d6d7f on JuliaArrays:master.

@c42f
Copy link
Member

c42f commented May 29, 2017

The failed test here isn't your fault, I restarted it.

Do you want to finish this one off by cleaning up a little and adding tests?

@bshall
Copy link
Contributor Author

bshall commented May 29, 2017

Yeah, I'm happy to do that. I'll make your change and add some tests.

@c42f
Copy link
Member

c42f commented May 29, 2017

Awesome, thanks a lot! I had started messing with tests, but hadn't done much.

…mit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Mon May 29 15:24:14 2017 +0200
#
# On branch broadcast-fix
# Your branch is ahead of 'origin/broadcast-fix' by 1 commit.
# (use "git push" to publish your local commits)
#
# Changes to be committed:
#	modified: src/broadcast.jl
#
# Untracked files:
#	test/broadcast.jl
#
@coveralls
Copy link

Coverage Status

Coverage increased (+0.09%) to 83.341% when pulling f90e612 on bshall:broadcast-fix into 92d6d7f on JuliaArrays:master.

@bshall
Copy link
Contributor Author

bshall commented May 29, 2017

Okay, so I've added a bunch of tests and found some issues/inconsistencies with broadcast from Base. I've listed those here #197, #198, #199 and #200 and I've added (commented out) test cases for them. Let me know if you'd like me to add anything else.

Oh, I also made a small change to the broadcast! function so it returns dest as well (just to be consistent).

@coveralls
Copy link

Coverage Status

Coverage increased (+0.09%) to 83.341% when pulling e2a393b on bshall:broadcast-fix into 92d6d7f on JuliaArrays:master.

Copy link
Member

@c42f c42f left a comment

Choose a reason for hiding this comment

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

Great effort on the tests here. There's some minor cleanups which I've put in the line notes. Certainly optional, but would be nice to have.

@test sin.(α) === broadcast(sin, α)
@test sin.(3.2) === broadcast(sin, 3.2) == sin(3.2)
@test factorial.(3) === broadcast(factorial, 3)
@test atan2.(x, y) === broadcast(atan2, x, y)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need all of these - julia's syntax lowering pass does the conversion between the dot notation and broadcast, and this package has no control over it.

@@ -147,5 +146,6 @@ end
return quote
@_inline_meta
@inbounds $(Expr(:block, exprs...))
return dest
Copy link
Member

Choose a reason for hiding this comment

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

Good move

@test broadcast_sizes(ones(t), ones(t), 1) === (Size(t), Size(t), Size())
@test broadcast_sizes(1, ones(t), 1) === (Size(), Size(t), Size())
@test broadcast_sizes(ones(t), 1, 1) === (Size(t), Size(), Size())
@test broadcast_sizes(1, 1, ones(t)) === (Size(), Size(), Size(t))
Copy link
Member

Choose a reason for hiding this comment

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

Might be also worth checking that these are @inferred

@test broadcast_sizes(ones(t), 1, 1) === (Size(t), Size(), Size())
@test broadcast_sizes(1, 1, ones(t)) === (Size(), Size(), Size(t))
end
@test broadcast((a,b,c)->0, SVector(1,1), 0, 0) == SVector(0, 0)
Copy link
Member

Choose a reason for hiding this comment

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

Could do with a comment See #191 perhaps?

@testset "2x2 StaticMatrix with 1x2 StaticMatrix" begin
m1 = @SMatrix [1 2; 3 4]
m2 = @SMatrix [1 4]
# @test @inferred(broadcast(+, m1, m2)) === @SMatrix [2 6; 4 8] #197
Copy link
Member

Choose a reason for hiding this comment

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

All the places where tests are currently commented out (because they're broken) you can use @test_broken instead. This runs the test and verifies that it is, indeed, broken - so we won't forget to add them back in later when these issues are fixed.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 83.294% when pulling 8eb2868 on bshall:broadcast-fix into 92d6d7f on JuliaArrays:master.

@bshall
Copy link
Contributor Author

bshall commented May 30, 2017

Great. Thanks for the feedback. I think I've made all the changes you suggested.

@c42f c42f merged commit dbd5111 into JuliaArrays:master May 30, 2017
bshall added a commit to bshall/StaticArrays.jl that referenced this pull request May 30, 2017
oschulz pushed a commit to oschulz/StaticArrays.jl that referenced this pull request Apr 4, 2023
…iaArrays#196)

* implement specialization of Base.dataids to speed-up broadcast

* dataids should return a tuple of UInts

Co-authored-by: Pietro Vertechi <pietro.vertechi@protonmail.com>

* add explicit test of dataids

Co-authored-by: Pietro Vertechi <pietro.vertechi@protonmail.com>
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.

3 participants