Skip to content

Commit 6540960

Browse files
1.9 Extensions (#5)
* transducers: 1.9 extensions * add OnlineStatsBase as test dependency * add explicit loading of OnlineStatsBase * update main enviroments * typo * explicitly import Transducers into extensions * import GenericInitialValue in OnlineStatsBaseExt * move OSNonZeroNObsError into Tranducers * typo in TransducersDataFramesExt * another typo in TransducersDataFramesExt * patch test to see if it the rest of the pkg works on nightly * tests: import Referenceables into scope * test on v1.9 * switch to regular Test.jl infrastructure * Delete vanilla-test.yml * Delete check-xfail.yml * Support 1.6+ * Support 1.6+ * revert changes to test infra * comment out test * revert commented out test * use Int instead of Int64 (32 bit tests) * trying to make test_ir pass * missing change in test_ir * skip doctests on 32 bit * skip doctests on 1.6 * fix test * Int64 -> Int * another fix to tests * bump version --------- Co-authored-by: Mason Protter <mason.protter@icloud.com>
1 parent 2a51f8d commit 6540960

23 files changed

+178
-199
lines changed

.github/workflows/check-xfail.yml

-65
This file was deleted.

.github/workflows/test.yml

+11-37
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,24 @@ on:
44
push:
55
branches:
66
- master
7-
tags: '*'
87
pull_request:
98

109
jobs:
1110
test:
12-
runs-on: ubuntu-latest
11+
runs-on: ${{ matrix.os }}
1312
strategy:
1413
matrix:
15-
julia-version:
16-
- '1.7'
17-
- '1.6'
18-
envname: ["main"]
19-
include:
20-
- julia-version: '1.0'
21-
envname: "jl10"
22-
- julia-version: '1.8'
23-
envname: "main_v2"
24-
- julia-version: 'nightly'
25-
envname: "main_v3"
26-
fail-fast: false
27-
name: Test Julia ${{ matrix.julia-version }}
14+
julia-version: ['1.6', '1.7', '1.8', '1.9', 'nightly']
15+
julia-arch: [x64, x86]
16+
os: [ubuntu-latest]
17+
2818
steps:
2919
- uses: actions/checkout@v2
30-
- name: Setup julia
31-
uses: julia-actions/setup-julia@v1
20+
- uses: julia-actions/setup-julia@v1
3221
with:
3322
version: ${{ matrix.julia-version }}
34-
- run: julia -e 'using Pkg; pkg"add Run@0.1"'
35-
- run: julia -e 'using Run; Run.prepare("test/environments/${{ matrix.envname }}")'
36-
- run: julia -e 'using Run; Run.test(project="test/environments/${{ matrix.envname }}")'
37-
- uses: julia-actions/julia-processcoverage@v1
38-
- uses: codecov/codecov-action@v1
39-
with:
40-
file: ./lcov.info
41-
flags: Run.test
42-
name: codecov-umbrella
43-
44-
# A job that succeeds if and only if all jobs in `test` succeed.
45-
all-success:
46-
if: always() && github.event.pull_request
47-
needs: test
48-
runs-on: ubuntu-latest
49-
steps:
50-
# https://github.com/tkf/merge-conclusions-action
51-
- uses: tkf/merge-conclusions-action@v1
52-
with:
53-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
arch: ${{ matrix.julia-arch }}
24+
- uses: julia-actions/julia-buildpkg@v1
25+
- uses: julia-actions/julia-runtest@v1
26+
# with:
27+
# annotate: true

.github/workflows/vanilla-test.yml

-26
This file was deleted.

Project.toml

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Transducers"
22
uuid = "28d57a85-8fef-5791-bfe6-a80928e7c999"
33
authors = ["Takafumi Arakaki <aka.tkf@gmail.com>"]
4-
version = "0.4.76"
4+
version = "0.4.77"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
@@ -33,7 +33,14 @@ Requires = "0.5, 1.0"
3333
Setfield = "0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 1"
3434
SplittablesBase = "0.1.2"
3535
Tables = "0.2, 1.0"
36-
julia = "1"
36+
julia = "1.6"
37+
38+
[extensions]
39+
TransducersBlockArraysExt = "BlockArrays"
40+
TransducersDataFramesExt = "DataFrames"
41+
TransducersLazyArraysExt = "LazyArrays"
42+
TransducersOnlineStatsBaseExt = "OnlineStatsBase"
43+
TransducersReferenceablesExt = "Referenceables"
3744

3845
[extras]
3946
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
@@ -51,6 +58,7 @@ LiterateTest = "d77d25b0-90d3-4a16-b10a-412a9d48f625"
5158
LoadAllPackages = "b37bcd2d-1570-475d-a8c6-9b4fae6d0ba9"
5259
Maybe = "334f122f-1118-46cc-837f-bff747ee6f78"
5360
OnlineStats = "a15396b6-48d5-5d58-9928-6d29437db91e"
61+
OnlineStatsBase = "925886fa-5bf2-5e8e-b522-a9147a512338"
5462
PerformanceTestTools = "dc46b164-d16f-48ec-a853-60448fc869fe"
5563
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
5664
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
@@ -63,4 +71,11 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
6371
TypedTables = "9d95f2ec-7b3d-5a63-8d20-e2491e220bb9"
6472

6573
[targets]
66-
test = ["Aqua", "BlockArrays", "Compat", "DataFrames", "DataTools", "Dates", "Distributed", "Documenter", "Folds", "InteractiveUtils", "LazyArrays", "LiterateTest", "LoadAllPackages", "Maybe", "OnlineStats", "PerformanceTestTools", "Pkg", "Random", "Referenceables", "SparseArrays", "StaticArrays", "Statistics", "StructArrays", "Test", "TypedTables"]
74+
test = ["Aqua", "BlockArrays", "Compat", "DataFrames", "DataTools", "Dates", "Distributed", "Documenter", "Folds", "InteractiveUtils", "LazyArrays", "LiterateTest", "LoadAllPackages", "Maybe", "OnlineStats", "OnlineStatsBase", "PerformanceTestTools", "Pkg", "Random", "Referenceables", "SparseArrays", "StaticArrays", "Statistics", "StructArrays", "Test", "TypedTables"]
75+
76+
[weakdeps]
77+
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
78+
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
79+
LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
80+
OnlineStatsBase = "925886fa-5bf2-5e8e-b522-a9147a512338"
81+
Referenceables = "42d2dcc6-99eb-4e98-b66c-637b7d73030e"

examples/tutorial_missings.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -247,24 +247,24 @@ using DataTools: rightif
247247

248248
@test begin
249249
foldxl(rightif(<, last), filtered_pairs)
250-
end === Pair{Int64,Union{Missing, Int}}(2, 3)
250+
end === Pair{Int,Union{Missing, Int}}(2, 3)
251251

252-
# ### Side note: why `Pair{Int64,Union{Missing,Int}}`?
252+
# ### Side note: why `Pair{Int,Union{Missing,Int}}`?
253253
#
254254
# The result type just above using `rightif` is
255-
# `Pair{Int64,Union{Missing,Int}}`:
255+
# `Pair{Int,Union{Missing,Int}}`:
256256

257257
@test begin
258258
typeof(foldxl(rightif(<, last), filtered_pairs))
259-
end === Pair{Int64,Union{Missing,Int}}
259+
end === Pair{Int,Union{Missing,Int}}
260260

261261
# This is because that's the element type of `pairs([1, 3, missing,
262262
# 0])` and `rightif` does not re-construct the input `Pair` like
263263
# `findmax_step`:
264264

265265
@test begin
266266
[1, 3, missing, 0] |> pairs |> first |> typeof
267-
end === Pair{Int64,Union{Missing, Int}}
267+
end === Pair{Int,Union{Missing, Int}}
268268

269269
# We can avoid this by pre-processing the input with `MapSplat(Pair)`:
270270

@@ -359,7 +359,7 @@ end
359359
@test begin
360360
[1, 3, missing, 0] |>
361361
pairs |>
362-
MapSplat(Pair) |> # avoid `Pair{Int64,Union{Missing, Int}}`
362+
MapSplat(Pair) |> # avoid `Pair{Int,Union{Missing, Int}}`
363363
foldxl(TeeRF(
364364
Map(ismissing last)'(+), # count number of missings
365365
Filter(!(ismissing last))'(TeeRF(

src/interop/blockarrays.jl ext/TransducersBlockArraysExt.jl

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
module TransducersBlockArraysExt
2+
3+
if isdefined(Base, :get_extension)
4+
using Transducers: Transducers, @return_if_reduced, @next, @simd_if, complete
5+
using Transducers.Setfield: @set
6+
using BlockArrays
7+
else
8+
using ..Transducers: Transducers, @return_if_reduced, @next, @simd_if, complete
9+
using ..Transducers.Setfield: @set
10+
using ..BlockArrays
11+
end
12+
113
"""
214
_foldl_blockarray(rf, acc, coll::BlockArrays.BlockArray)
315
"""
@@ -40,9 +52,7 @@ end
4052
::Val{N₋₁},
4153
) where {RF,N₋₁}
4254

43-
blockaxes = BlockArrays.blockaxes
44-
45-
@inbounds for b in blockaxes(coll, 1)
55+
@inbounds for b in BlockArrays.blockaxes(coll, 1)
4656
array = coll[b, block...]
4757
@simd_if rf for k in axes(array, 1)
4858
acc = @next(rf, acc, array[k, offset...])
@@ -51,4 +61,9 @@ end
5161
return acc
5262
end
5363

64+
Transducers.__foldl__(rf, acc, coll::BlockArrays.BlockArray) =
65+
_foldl_blockarray(rf, acc, coll)
66+
5467
# TODO: write reduce for BlockArrays which can be done in the "natural" order
68+
69+
end

ext/TransducersDataFramesExt.jl

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module TransducersDataFramesExt
2+
3+
if isdefined(Base, :get_extension)
4+
using Transducers
5+
using DataFrames
6+
else
7+
using ..Transducers
8+
using ..DataFrames
9+
end
10+
11+
Transducers.asfoldable(df::DataFrames.AbstractDataFrame) = DataFrames.eachrow(df)
12+
# We can't use `Compat.eachrow` here. See:
13+
# https://github.com/JuliaData/DataFrames.jl/pull/2067
14+
15+
end #module

src/interop/lazyarrays.jl ext/TransducersLazyArraysExt.jl

+18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
module TransducersLazyArraysExt
2+
3+
if isdefined(Base, :get_extension)
4+
using Transducers: Transducers, @return_if_reduced, @next, @simd_if, complete, foldlargs, foldl_nocomplete
5+
using Transducers.Setfield: @set
6+
using LazyArrays
7+
else
8+
using ..Transducers: Transducers, @return_if_reduced, @next, @simd_if, complete, foldlargs, foldl_nocomplete
9+
using ..Transducers.Setfield: @set
10+
using ..LazyArrays
11+
end
12+
113
@inline function _foldl_lazy_cat_vectors(rf, acc, vectors)
214
isempty(vectors) && return complete(rf, acc)
315
result = @return_if_reduced foldlargs(acc, vectors...) do acc, arr
@@ -26,6 +38,12 @@ end
2638
end
2739
return complete(rf, acc)
2840
end
41+
42+
Transducers.__foldl__(rf, acc, coll::LazyArrays.Hcat) = _foldl_lazy_hcat(rf, acc, coll)
43+
Transducers.__foldl__(rf, acc, coll::LazyArrays.Vcat) = _foldl_lazy_vcat(rf, acc, coll)
44+
2945
# Vcat currently always is an `AbstractVector` or `AbstractMatrix`
3046

3147
# TODO: write reduce for Vcat/Hcat which can be done in the "natural" order
48+
49+
end

0 commit comments

Comments
 (0)