-
Notifications
You must be signed in to change notification settings - Fork 24
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
Treat transducers as iterator transforms at surface syntax #319
Conversation
Codecov Report
@@ Coverage Diff @@
## master #319 +/- ##
==========================================
- Coverage 90.68% 90.56% -0.12%
==========================================
Files 24 25 +1
Lines 1471 1495 +24
==========================================
+ Hits 1334 1354 +20
- Misses 137 141 +4
Continue to review full report at Codecov.
|
Benchmark resultJudge resultBenchmark Report for /home/runner/work/Transducers.jl/Transducers.jlJob Properties
ResultsA ratio greater than
Benchmark Group ListHere's a list of all the benchmark groups executed by this job:
Julia versioninfoTarget
Baseline
Target resultBenchmark Report for /home/runner/work/Transducers.jl/Transducers.jlJob Properties
ResultsBelow is a table of this job's results, obtained by running the benchmarks.
Benchmark Group ListHere's a list of all the benchmark groups executed by this job:
Julia versioninfo
Baseline resultBenchmark Report for /home/runner/work/Transducers.jl/Transducers.jlJob Properties
ResultsBelow is a table of this job's results, obtained by running the benchmarks.
Benchmark Group ListHere's a list of all the benchmark groups executed by this job:
Julia versioninfo
Runtime information
|
Multi-thread benchmark resultJudge resultBenchmark Report for /home/runner/work/Transducers.jl/Transducers.jlJob Properties
ResultsA ratio greater than
Benchmark Group ListHere's a list of all the benchmark groups executed by this job:
Julia versioninfoTarget
Baseline
Target resultBenchmark Report for /home/runner/work/Transducers.jl/Transducers.jlJob Properties
ResultsBelow is a table of this job's results, obtained by running the benchmarks.
Benchmark Group ListHere's a list of all the benchmark groups executed by this job:
Julia versioninfo
Baseline resultBenchmark Report for /home/runner/work/Transducers.jl/Transducers.jlJob Properties
ResultsBelow is a table of this job's results, obtained by running the benchmarks.
Benchmark Group ListHere's a list of all the benchmark groups executed by this job:
Julia versioninfo
Runtime information
|
Benchmark resultJudge resultBenchmark Report for /home/runner/work/Transducers.jl/Transducers.jlJob Properties
ResultsA ratio greater than
Benchmark Group ListHere's a list of all the benchmark groups executed by this job:
Julia versioninfoTarget
Baseline
Target resultBenchmark Report for /home/runner/work/Transducers.jl/Transducers.jlJob Properties
ResultsBelow is a table of this job's results, obtained by running the benchmarks.
Benchmark Group ListHere's a list of all the benchmark groups executed by this job:
Julia versioninfo
Baseline resultBenchmark Report for /home/runner/work/Transducers.jl/Transducers.jlJob Properties
ResultsBelow is a table of this job's results, obtained by running the benchmarks.
Benchmark Group ListHere's a list of all the benchmark groups executed by this job:
Julia versioninfo
Runtime information
|
Multi-thread benchmark resultJudge resultBenchmark Report for /home/runner/work/Transducers.jl/Transducers.jlJob Properties
ResultsA ratio greater than
Benchmark Group ListHere's a list of all the benchmark groups executed by this job:
Julia versioninfoTarget
Baseline
Target resultBenchmark Report for /home/runner/work/Transducers.jl/Transducers.jlJob Properties
ResultsBelow is a table of this job's results, obtained by running the benchmarks.
Benchmark Group ListHere's a list of all the benchmark groups executed by this job:
Julia versioninfo
Baseline resultBenchmark Report for /home/runner/work/Transducers.jl/Transducers.jlJob Properties
ResultsBelow is a table of this job's results, obtained by running the benchmarks.
Benchmark Group ListHere's a list of all the benchmark groups executed by this job:
Julia versioninfo
Runtime information
|
Co-authored-by: Jan Weidner <jw3126@gmail.com>
Thanks! |
Co-authored-by: Jan Weidner <jw3126@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do like this PR. While mathematically equivalent transforming reduction functions seems more confusing then transforming iterators for the human brain. Especially if you don't know/care about the implementation. I also appreciate how you managed to make this change only minimally breaking. And the docs are awesome, too. Thanks a lot for this great package! I really hope that over time more of it moves upstream into julia.
Thanks a lot! I've been agonising over the pros and cons of different approaches. It really helps to have your input! For example, initially, I thought to defer defining
Exactly my thought! I'm convinced more and more that hiding transducers from the high-level API is the way to go. It would also make "lowering" something like |
@@ -383,7 +383,7 @@ Composition of transducers. | |||
@inline Base.:∘(g::Transducer, f::Composition) = g ∘ f.inner ∘ f.outer | |||
@inline Base.:∘(f::Transducer, ::IdentityTransducer) = f | |||
@inline Base.:∘(::IdentityTransducer, f::Transducer) = f | |||
@inline Base.:∘(::IdentityTransducer, ::IdentityTransducer) = IdentityTransducer() | |||
@inline Base.:∘(f::IdentityTransducer, ::IdentityTransducer) = f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am curious, why you did this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally no reason 😅. I just wrote it this way in #323 and carried it over while solving the merge conflict (a bit hoping that it'd be close enough for the diff viewer to pretty-print it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification. I thought maybe this works around some compiler quirk that I should know about.
The `_to_` in the URL is interpreted as emphasis in Julia's markdown parser and it's rendered incorrectly in TerminalLoggers.jl.
While trying to use this branch in various downstreams, I realized that the default deprecation message unhelpful because it recommends julia> using Transducers
julia> foldl(+, Filter(isodd) |> Map(inv), 1:5)
┌ Warning: `f::Transducer |> g::Transducer` is deprecated. Use `xs |> f |> g |> collect` instead of `collect(f |> g, xs)`. For more information, see https://juliafolds.github.io/Transducers.jl/dev/howto/upgrade-to-ixf/
│ caller = top-level scope at REPL[2]:1
└ @ Core REPL[2]:1
┌ Warning: `f::Transducer |> g::Transducer` is deprecated. Instead of
│
│ collect(Filter(f) |> Map(g), xs)
│ foldl(+, Filter(f) |> Map(g), xs)
│
│ it's now recommended to use `|>` with input collection
│
│ xs |> Filter(f) |> Map(g) |> collect
│ foldl(+, xs |> Filter(f) |> Map(g))
│
│ If there is no input collection; e.g.,
│
│ foldl(right, GroupBy(key, Filter(f) |> Map(g), push!!), xs)
│
│ use `opcompose` instead:
│
│ foldl(right, GroupBy(key, opcompose(Map(f), Filter(g)), push!!), xs)
│
│ For more information, see:
│ https://juliafolds.github.io/Transducers.jl/dev/howto/upgrade-to-ixf/
└ @ Transducers ~/.julia/dev/Transducers/src/deprecated.jl:12
1.5333333333333332
julia> foldl(+, Filter(isodd) |> Map(inv), 1:5) # no long depwarn for the second time
┌ Warning: `f::Transducer |> g::Transducer` is deprecated. Use `xs |> f |> g |> collect` instead of `collect(f |> g, xs)`. For more information, see https://juliafolds.github.io/Transducers.jl/dev/howto/upgrade-to-ixf/
│ caller = top-level scope at REPL[2]:1
└ @ Core REPL[2]:1
1.5333333333333332 (Preview of the upgrade guide: https://juliafolds.github.io/Transducers.jl/previews/PR319/howto/upgrade-to-ixf/) |
close #67
0.4.XX
with appropriate version numberCommit Message
Treat transducers as iterator transforms at surface syntax (#319)
This patch implements the idea discussed in #67. That is to say,
is now written as
or
or even (not recommended)
Above syntax are all compatible with the view that
xf(itr)
is aniterator transformation. OTOH,
xf'
(adjoint(::Transducer)
) is nowthe "classic" transducer; i.e., reducing function transformation.
This makes it easy to use transducers with other "reducing function
combinators" like
TeeRF
:This PR only deprecates
::Transducer |> ::Transducer
to helpmigration from the old syntax.