Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/vanilla-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Run test via Pkg.test()

on:
push:
branches:
- master
pull_request:

jobs:
vanilla-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: 1.4
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
env:
JULIA_NUM_THREADS: "2"
CI: "true"
4 changes: 4 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pull_request_rules:
- status-success=Test Julia 1.3
- status-success=Benchmark
- status-success=Documenter
- status-success=vanilla-test
- label=ready-to-merge:squash
- label!=work-in-progress
actions:
Expand All @@ -27,6 +28,7 @@ pull_request_rules:
- status-success=Test Julia 1.3
- status-success=Benchmark
- status-success=Documenter
- status-success=vanilla-test
- label=ready-to-merge:rebase
- label!=work-in-progress
actions:
Expand All @@ -41,6 +43,7 @@ pull_request_rules:
- status-success=Test Julia 1.3
- status-success=Benchmark
- status-success=Documenter
- status-success=vanilla-test
- label=ready-to-merge:merge
- label!=work-in-progress
actions:
Expand All @@ -55,6 +58,7 @@ pull_request_rules:
- status-success=Test Julia 1.3
- status-success=Benchmark
- status-success=Documenter
- status-success=vanilla-test
- label~=ready-to-merge:.*
actions:
review: {}
4 changes: 2 additions & 2 deletions benchmark/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,11 @@ version = "0.1.3-DEV"

[[Transducers]]
deps = ["ArgCheck", "BangBang", "CompositionsBase", "DefineSingletons", "Distributed", "InitialValues", "Logging", "Markdown", "Requires", "Setfield", "SplittablesBase", "Tables"]
git-tree-sha1 = "d9bfa17064d3ea0da8213aa315d55cb8c84b60db"
git-tree-sha1 = "2e635a1e840281ed5bbc1661963beb2fff1739a6"
repo-rev = "master"
repo-url = "https://github.com/JuliaFolds/Transducers.jl.git"
uuid = "28d57a85-8fef-5791-bfe6-a80928e7c999"
version = "0.4.41-DEV"
version = "0.4.44-DEV"

[[UUIDs]]
deps = ["Random", "SHA"]
Expand Down
4 changes: 2 additions & 2 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,11 @@ version = "0.1.3-DEV"

[[Transducers]]
deps = ["ArgCheck", "BangBang", "CompositionsBase", "DefineSingletons", "Distributed", "InitialValues", "Logging", "Markdown", "Requires", "Setfield", "SplittablesBase", "Tables"]
git-tree-sha1 = "d9bfa17064d3ea0da8213aa315d55cb8c84b60db"
git-tree-sha1 = "2e635a1e840281ed5bbc1661963beb2fff1739a6"
repo-rev = "master"
repo-url = "https://github.com/JuliaFolds/Transducers.jl.git"
uuid = "28d57a85-8fef-5791-bfe6-a80928e7c999"
version = "0.4.41-DEV"
version = "0.4.44-DEV"

[[UUIDs]]
deps = ["Random", "SHA"]
Expand Down
7 changes: 7 additions & 0 deletions src/ThreadsX.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ else
@eval const $(Symbol("@spawn")) = $(Symbol("@async"))
end

if isdefined(Transducers, :foldxt)
using Transducers: foldxt
else
foldxt(rf, xf, xs; kw...) = reduce(rf, xf, xs; kw...)
foldxt(rf, xs; kw...) = reduce(rf, Map(identity), xs; kw...)
end

include("utils.jl")
include("basesizes.jl")
include("reduce.jl")
Expand Down
4 changes: 2 additions & 2 deletions src/foreach.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ ThreadsX.foreach(f, array::AbstractArray, arrays::AbstractArray; kw...) =

@inline return_nothing(_...) = nothing

ThreadsX.foreach(f::F, itr; kw...) where {F} = reduce(
ThreadsX.foreach(f::F, itr; kw...) where {F} = foldxt(
return_nothing,
Map(f),
itr;
Expand All @@ -124,7 +124,7 @@ ThreadsX.foreach(f::F, itr; kw...) where {F} = reduce(
kw...,
)

ThreadsX.foreach(f::F, itr, itrs...; kw...) where {F} = reduce(
ThreadsX.foreach(f::F, itr, itrs...; kw...) where {F} = foldxt(
return_nothing,
MapSplat(f),
zip(itr, itrs...);
Expand Down
18 changes: 9 additions & 9 deletions src/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ without_basesize(; basesize = nothing, kw...) = kw

function ThreadsX.reduce(op, itr; kw...)
xf, reducible = extract_transducer(itr)
result = reduce(
result = foldxt(
op,
xf,
reducible;
Expand All @@ -16,7 +16,7 @@ end

function ThreadsX.mapreduce(f, op, itr; kw...)
xf, reducible = extract_transducer(itr)
result = reduce(
result = foldxt(
op,
opcompose(xf, Map(f)),
reducible;
Expand All @@ -33,7 +33,7 @@ function ThreadsX.mapreduce(f, op, itr, itrs...; kw...)
# `Base` just does `reduce(op, map(f, ...))`:
return mapreduce(f, op, itr, itrs...; without_basesize(; kw...)...)
end
return reduce(
return foldxt(
op,
MapSplat(f),
zip(itr, itrs...);
Expand Down Expand Up @@ -64,7 +64,7 @@ asbool(f) = x -> f(x)::Bool

# TODO: `any` and `all` should be done with "unordered" version
ThreadsX.any(itr; kw...) = ThreadsX.any(identity, itr; kw...)
ThreadsX.any(f, itr; kw...) = reduce(
ThreadsX.any(f, itr; kw...) = foldxt(
right, # no need to use `|`
opcompose(Map(asbool(f)), ReduceIf(identity)),
simd = Val(true),
Expand All @@ -75,7 +75,7 @@ ThreadsX.any(f, itr; kw...) = reduce(
)

ThreadsX.all(itr; kw...) = ThreadsX.all(identity, itr; kw...)
ThreadsX.all(f, itr; kw...) = reduce(
ThreadsX.all(f, itr; kw...) = foldxt(
right, # no need to use `&`
opcompose(Map(asbool(f)), ReduceIf(!)),
itr;
Expand All @@ -86,7 +86,7 @@ ThreadsX.all(f, itr; kw...) = reduce(
)

ThreadsX.findfirst(itr; kw...) = ThreadsX.findfirst(identity, itr; kw...)
ThreadsX.findfirst(f, array::AbstractArray; kw...) = reduce(
ThreadsX.findfirst(f, array::AbstractArray; kw...) = foldxt(
right,
ReduceIf(i -> f(@inbounds array[i])),
keys(array);
Expand All @@ -99,7 +99,7 @@ ThreadsX.findfirst(f, array::AbstractArray; kw...) = reduce(
ThreadsX.findlast(itr; kw...) = ThreadsX.findlast(identity, itr; kw...)
function ThreadsX.findlast(f, array::AbstractArray; kw...)
idx = keys(array)
return reduce(
return foldxt(
right,
opcompose(Map(i -> (@inbounds idx[i])), ReduceIf(i -> f(@inbounds array[i]))),
lastindex(idx):-1:firstindex(idx);
Expand All @@ -125,7 +125,7 @@ end
_minmax((min0, max0), (min1, max1)) = (min(min0, min1), max(max0, max1))

ThreadsX.extrema(itr; kw...) = ThreadsX.extrema(identity, itr; kw...)
ThreadsX.extrema(f, itr; kw...) = reduce(
ThreadsX.extrema(f, itr; kw...) = foldxt(
asmonoid(_minmax),
Map(x -> (y = f(x); (y, y))),
itr;
Expand Down Expand Up @@ -189,7 +189,7 @@ function ThreadsX.unique(f::F, itr::AbstractVector{X}; kw...) where {F,X}
# Using inference as an optimization. The result of this inference
# does not affect the result:
Y = Core.Compiler.return_type(f, Tuple{X})
ys, = reduce(
ys, = foldxt(
PushUnique(f),
Map(identity),
itr;
Expand Down
4 changes: 2 additions & 2 deletions test/environments/main/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ version = "0.1.3-DEV"

[[Transducers]]
deps = ["ArgCheck", "BangBang", "CompositionsBase", "DefineSingletons", "Distributed", "InitialValues", "Logging", "Markdown", "Requires", "Setfield", "SplittablesBase", "Tables"]
git-tree-sha1 = "d9bfa17064d3ea0da8213aa315d55cb8c84b60db"
git-tree-sha1 = "2e635a1e840281ed5bbc1661963beb2fff1739a6"
repo-rev = "master"
repo-url = "https://github.com/JuliaFolds/Transducers.jl.git"
uuid = "28d57a85-8fef-5791-bfe6-a80928e7c999"
version = "0.4.41-DEV"
version = "0.4.44-DEV"

[[UUIDs]]
deps = ["Random", "SHA"]
Expand Down