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

[WIP] constructors for Array from zeros/ones #24389

Closed
wants to merge 1 commit into from

Conversation

Sacha0
Copy link
Member

@Sacha0 Sacha0 commented Oct 29, 2017

This pull request provides constructors for Array from zeros/ones, for example Array(zeros, dims) and Vector{T}(ones, n). In other words, this pull request explores #11557 (comment). Best!

@Sacha0 Sacha0 added arrays [a, r, r, a, y, s] triage This should be discussed on a triage call labels Oct 29, 2017
@Sacha0 Sacha0 changed the title constructors for Array from zeros/ones [WIP] constructors for Array from zeros/ones Oct 30, 2017
@martinholters
Copy link
Member

Wasn't the idea to have Array(possibly_shapeless_iterator, dims) constructors and make zeros and ones iterable? Of course, this PR in a way special-cases that and might still be a reasonable optimization even if go with that general approach.

@Sacha0
Copy link
Member Author

Sacha0 commented Nov 2, 2017

Yes, that's roughly the idea :). Establishing a beachhead to explore this direction for ones/zeros was this pull request's aim. Having since explored other approaches locally, I am not certain this approach is best. More to come after some other work. Best!

@fredrikekre fredrikekre mentioned this pull request Nov 2, 2017
@StefanKarpinski
Copy link
Member

I think we might want to generalize "possibly shapeless iterator" to "thing that provides a mapping from indices to values", which includes iterators as a special case where the indices are implied by counting as iteration happens. In this case the I object provides a natural mapping from pairs of indices to values, yielding ones on the diagonals and zeros off of it.

@Sacha0
Copy link
Member Author

Sacha0 commented Nov 2, 2017

I think we might want to generalize "possibly shapeless iterator" to "thing that provides a mapping from indices to values", which includes iterators as a special case where the indices are implied by counting as iteration happens. In this case the I object provides a natural mapping from pairs of indices to values, yielding ones on the diagonals and zeros off of it.

Through working with eye/ones/zeros/junk over the last week, my thoughts have evolved in that direction as well :). Responding more completely in #11557. Best!

@JeffBezanson
Copy link
Member

We have to be careful with that. For example, if an index-less iterator is taken too seriously to have indices 1:n, it would not initialize an OffsetArray with indices -n:-1.

@Sacha0
Copy link
Member Author

Sacha0 commented Nov 2, 2017

We have to be careful with that. For example, if an index-less iterator is taken too seriously to have indices 1:n, it would not initialize an OffsetArray with indices -n:-1.

Ref. the last paragraph in #11557 (comment) :).

@Sacha0 Sacha0 removed the triage This should be discussed on a triage call label Nov 16, 2017
@Sacha0
Copy link
Member Author

Sacha0 commented Nov 18, 2017

Closing for the reasons given in #24595. Thanks all!

@Sacha0 Sacha0 closed this Nov 18, 2017
@Sacha0 Sacha0 deleted the arrayoz branch November 18, 2017 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays [a, r, r, a, y, s]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants