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

Wishlist: API and documentation for extending broadcast #20740

Closed
timholy opened this issue Feb 22, 2017 · 12 comments
Closed

Wishlist: API and documentation for extending broadcast #20740

timholy opened this issue Feb 22, 2017 · 12 comments
Assignees
Labels
broadcast Applying a function over a collection docs This change adds or pertains to documentation

Comments

@timholy
Copy link
Member

timholy commented Feb 22, 2017

We have extensive documentation on the array interface, specifically how to extend getindex and setindex! for arbitrary array types. In 0.6, julia's broadcasting is more awesome and central than ever; it would seem appropriate to have some discussion about how one should go about specializing broadcasting behavior. An example of a package that's about to take a do-it-yourself plunge is JuliaImages/ImageMetadata.jl#14; if you follow that link, you'll see that there was at least one very cool surprise lurking for the unwary.

@ararslan ararslan added docs This change adds or pertains to documentation broadcast Applying a function over a collection labels Feb 22, 2017
@andreasnoack
Copy link
Member

I'm also wondering if we could restructure the broadcast code to detect the right return type for non-base arrays such that custom <:AbstractArray, the developer should mainly implement _broadcast! and some promote_containertype methods. Right now it seems as if you'll have to implemental a broadcast_c method which is very similar to the base version, e.g. https://github.com/JuliaParallel/DistributedArrays.jl/blob/e5b4612b4f0e95ad28359958a34aa1b94f4193ac/src/mapreduce.jl#L26-L36 and https://github.com/JuliaStats/DataArrays.jl/blob/2a83487bb7cbf570bb6679eb5995ce3545c2869c/src/broadcast.jl

@Sacha0
Copy link
Member

Sacha0 commented Feb 22, 2017

Agreed, chances are we should restructure broadcast's container type promotion mechanism altogether with various types of extension in mind. Ref. recent discussion in #20007, #20009, #20102, towards the end of #16961 (particularly #16961 (comment), which contains a few other refs), and #19787. Best!

@andreasnoack
Copy link
Member

@Sacha0 Thanks for keeping track of the previous discussions. It is really useful to have the references.

@Sacha0
Copy link
Member

Sacha0 commented Feb 22, 2017

My pleasure. I hope to write up some thoughts whenever the time is right. Best!

@StefanKarpinski
Copy link
Member

I suspect the time is now since we're entering 0.6 feature freeze :)

@andyferris
Copy link
Member

Yes, I was hoping to understand this better so I can make the StaticArrays implementation more compatible.

@KristofferC
Copy link
Member

As someone who is also a fan of the AbstractArray interface, a guide on what to do to get broadcasting work smoothly with custom types would be very appreciated.

@Sacha0
Copy link
Member

Sacha0 commented Jun 5, 2017

Ref. to related discussion 746dbb0#commitcomment-22403175

@Sacha0
Copy link
Member

Sacha0 commented Jun 29, 2017

Perhaps should receive a 1.0 tag?

@Sacha0
Copy link
Member

Sacha0 commented Jun 29, 2017

(Crossref #22060.)

@tkelman
Copy link
Contributor

tkelman commented Jun 29, 2017

the issue of container type promotion seems a bit separate from the fusion issue? may touch similar parts of the base code though

@Sacha0 Sacha0 added this to the 1.0 milestone Jun 29, 2017
@simonbyrne simonbyrne changed the title Wishlist: documentation for extending broadcast Wishlist: API and documentation for extending broadcast Jul 6, 2017
@JeffBezanson
Copy link
Member

Similar to #22060, can evolve over 1.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
broadcast Applying a function over a collection docs This change adds or pertains to documentation
Projects
None yet
Development

No branches or pull requests

10 participants