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

keys(::Generator) pass through #34678

Merged
merged 3 commits into from
Dec 27, 2020
Merged

keys(::Generator) pass through #34678

merged 3 commits into from
Dec 27, 2020

Conversation

rapus95
Copy link
Contributor

@rapus95 rapus95 commented Feb 5, 2020

Let keys pass through to allow lightweigth/lazy find* and arg* functions
Fixes #34674

@fredrikekre fredrikekre added the needs tests Unit tests are required for this change label Feb 5, 2020
@rapus95
Copy link
Contributor Author

rapus95 commented Feb 7, 2020

@fredrikekre
What would be the intended tests here?
is that already enough?

@test keys(x^2 for x in 1:10) == keys(1:10)

@KlausC
Copy link
Contributor

KlausC commented Mar 18, 2020

As a test maybe more illustrative:

@test keys(x^2 for x in -1:0.5:1) == 1:5

I propose to put that into test/functional.jl

@StefanKarpinski
Copy link
Sponsor Member

Triage finds it a little weird but approves since it makes find work and doesn't seem harmful. Would be good to add @KlausC's test and a NEWS entry, however. A use case would also be good.

mbauman
mbauman previously approved these changes May 14, 2020
@mbauman mbauman dismissed their stale review May 14, 2020 17:14

needs tests!

Let keys pass through to allow lightweigth/lazy find* and arg* functions
@rapus95
Copy link
Contributor Author

rapus95 commented May 14, 2020

@mbauman sure, got interrupted by something else after rebasing such an old branch for the first time 😇
For the NEWS entry, into which section should this go?

Edit: for the usecase:

julia> findmax(map(x->x^2, 20:30))
(900, 11)

julia> findmax(x^2 for x in 20:30)
ERROR: MethodError: no method matching keys(::Base.Generator{UnitRange{Int64},var"#7#8"})

After this change, the latter produces the same result as the eager map variant:

julia> findmax(x^2 for x in 20:30)
(900, 11)

By that it allows to findmax without allocating the whole intermediate map output and thus becomes lazy aswell.

Co-authored-by: Matt Bauman <[email protected]>
@thofma
Copy link
Contributor

thofma commented May 14, 2020

Kind of fixes #23680

Instead of indmin I just have to use findmin.

@rapus95
Copy link
Contributor Author

rapus95 commented May 15, 2020

@thofma once this lands, you can just use indmin again since keys for Generator won't be missing anymore.

@rapus95
Copy link
Contributor Author

rapus95 commented Jun 6, 2020

@mbauman well since I guess 1.5 is already pinned now (branched away from master), but to not to add it to the wrong news file, this'll go into 1.6, won't it? (so I can add a news entry straight to the 1.6 news file)

I'd put it into the "standard library changes" section.

@tkf
Copy link
Member

tkf commented Jun 7, 2020

I think keys, values and getindex should satisfy the invariance

isequal(collect(values(A)), [A[k] for k in keys(A)])

So, I'm against this patch unless values and getindex are defined for Generator. See #36175.

@rapus95
Copy link
Contributor Author

rapus95 commented Nov 9, 2020

bump for 1.6 👀

@rapus95
Copy link
Contributor Author

rapus95 commented Nov 10, 2020

@fredrikekre would you remove the "needs test" label please. (Since there already is one). And can you add it to a 1.6 milestone? (so that it won't go unnoticed upon freezing, especially since triage already accepted the standalone and #37648 holds the getindex for generators)

@rapus95 rapus95 requested a review from mbauman November 17, 2020 03:29
@StefanKarpinski StefanKarpinski added status:triage This should be discussed on a triage call and removed needs tests Unit tests are required for this change labels Dec 1, 2020
@oscardssmith
Copy link
Member

oscardssmith commented Dec 17, 2020

Rerunning ci, then good to merge in my view.

@oscardssmith oscardssmith reopened this Dec 17, 2020
@oscardssmith oscardssmith added the status:merge me PR is reviewed. Merge when all tests are passing label Dec 17, 2020
@oscardssmith
Copy link
Member

@StefanKarpinski me closing and re-opening doesn't seem to have trigered CI. Can you make it re-run?

@rapus95
Copy link
Contributor Author

rapus95 commented Dec 17, 2020

StefanKarpinski me closing and re-opening doesn't seem to have trigered CI. Can you make it re-run?

@oscardssmith To me it seems like buildbot was triggered and currently is only missing tester_macos64 and tester_win32. analyzegc_linux64 and package_freebsd64 failed, the rest completed successfully.

@oscardssmith
Copy link
Member

oh yeah. Sorry for the noise. It might be worth rebasing this onto master so we can get a fully green CI.

@musm
Copy link
Contributor

musm commented Dec 17, 2020

This looks like it still has a triage label, was this approved? Typically, the triage label would be removed before we allow a PR to be merged.

@oscardssmith
Copy link
Member

Triage approved back in March. I think it was re-added to consider back-porting once merged, but I'm not sure.

@musm
Copy link
Contributor

musm commented Dec 17, 2020

To be sure, it would be best to hold off then until triage-reapproves and once the requested review is approved.

@JeffBezanson
Copy link
Sponsor Member

Triage is ok with this again. I came around since it basically seems consistent with axes, which we already define here. We don't want to backport it but it can be merged on master.

@JeffBezanson JeffBezanson removed the status:triage This should be discussed on a triage call label Dec 17, 2020
@rapus95
Copy link
Contributor Author

rapus95 commented Dec 17, 2020

Ok that's fine, then we should be able to discuss the long-term meaning of Generator and thus, if we also want to include the other issues/PRs (#37648, #34368) which would lead to a smoother feature addition in 1.7

@simeonschaub
Copy link
Member

Thank you for the contribution! Sorry this took so long. In the future, also feel free to bump PRs every once in a while, because otherwise things sometimes get forgotten.

@simeonschaub simeonschaub merged commit 5d2fcdb into JuliaLang:master Dec 27, 2020
@DilumAluthge DilumAluthge removed the status:merge me PR is reviewed. Merge when all tests are passing label Jan 11, 2021
rapus95 added a commit to rapus95/julia that referenced this pull request Feb 21, 2021
ElOceanografo pushed a commit to ElOceanografo/julia that referenced this pull request May 4, 2021
* keys(::Generator) pass-through

Let keys pass through to allow lightweigth/lazy find* and arg* functions

* Update test/functional.jl

Co-authored-by: Matt Bauman <[email protected]>

Co-authored-by: Matt Bauman <[email protected]>
Co-authored-by: Simeon Schaub <[email protected]>
ElOceanografo pushed a commit to ElOceanografo/julia that referenced this pull request May 4, 2021
antoine-levitt pushed a commit to antoine-levitt/julia that referenced this pull request May 9, 2021
@nalimilan nalimilan added the domain:search & find The find* family of functions label Sep 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:search & find The find* family of functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

keys(::Generator) for find* and arg*