Skip to content

Commit

Permalink
1.9 Extensions (#5)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
longemen3000 and MasonProtter committed Jun 26, 2023
1 parent 2a51f8d commit 6540960
Show file tree
Hide file tree
Showing 23 changed files with 178 additions and 199 deletions.
65 changes: 0 additions & 65 deletions .github/workflows/check-xfail.yml

This file was deleted.

48 changes: 11 additions & 37 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,24 @@ on:
push:
branches:
- master
tags: '*'
pull_request:

jobs:
test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version:
- '1.7'
- '1.6'
envname: ["main"]
include:
- julia-version: '1.0'
envname: "jl10"
- julia-version: '1.8'
envname: "main_v2"
- julia-version: 'nightly'
envname: "main_v3"
fail-fast: false
name: Test Julia ${{ matrix.julia-version }}
julia-version: ['1.6', '1.7', '1.8', '1.9', 'nightly']
julia-arch: [x64, x86]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v2
- name: Setup julia
uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.julia-version }}
- run: julia -e 'using Pkg; pkg"add [email protected]"'
- run: julia -e 'using Run; Run.prepare("test/environments/${{ matrix.envname }}")'
- run: julia -e 'using Run; Run.test(project="test/environments/${{ matrix.envname }}")'
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: ./lcov.info
flags: Run.test
name: codecov-umbrella

# A job that succeeds if and only if all jobs in `test` succeed.
all-success:
if: always() && github.event.pull_request
needs: test
runs-on: ubuntu-latest
steps:
# https://github.com/tkf/merge-conclusions-action
- uses: tkf/merge-conclusions-action@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
arch: ${{ matrix.julia-arch }}
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
# with:
# annotate: true
26 changes: 0 additions & 26 deletions .github/workflows/vanilla-test.yml

This file was deleted.

21 changes: 18 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Transducers"
uuid = "28d57a85-8fef-5791-bfe6-a80928e7c999"
authors = ["Takafumi Arakaki <[email protected]>"]
version = "0.4.76"
version = "0.4.77"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down Expand Up @@ -33,7 +33,14 @@ Requires = "0.5, 1.0"
Setfield = "0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 1"
SplittablesBase = "0.1.2"
Tables = "0.2, 1.0"
julia = "1"
julia = "1.6"

[extensions]
TransducersBlockArraysExt = "BlockArrays"
TransducersDataFramesExt = "DataFrames"
TransducersLazyArraysExt = "LazyArrays"
TransducersOnlineStatsBaseExt = "OnlineStatsBase"
TransducersReferenceablesExt = "Referenceables"

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

[targets]
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"]
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"]

[weakdeps]
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
OnlineStatsBase = "925886fa-5bf2-5e8e-b522-a9147a512338"
Referenceables = "42d2dcc6-99eb-4e98-b66c-637b7d73030e"
12 changes: 6 additions & 6 deletions examples/tutorial_missings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,24 +247,24 @@ using DataTools: rightif

@test begin
foldxl(rightif(<, last), filtered_pairs)
end === Pair{Int64,Union{Missing, Int}}(2, 3)
end === Pair{Int,Union{Missing, Int}}(2, 3)

# ### Side note: why `Pair{Int64,Union{Missing,Int}}`?
# ### Side note: why `Pair{Int,Union{Missing,Int}}`?
#
# The result type just above using `rightif` is
# `Pair{Int64,Union{Missing,Int}}`:
# `Pair{Int,Union{Missing,Int}}`:

@test begin
typeof(foldxl(rightif(<, last), filtered_pairs))
end === Pair{Int64,Union{Missing,Int}}
end === Pair{Int,Union{Missing,Int}}

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

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

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

Expand Down Expand Up @@ -359,7 +359,7 @@ end
@test begin
[1, 3, missing, 0] |>
pairs |>
MapSplat(Pair) |> # avoid `Pair{Int64,Union{Missing, Int}}`
MapSplat(Pair) |> # avoid `Pair{Int,Union{Missing, Int}}`
foldxl(TeeRF(
Map(ismissing last)'(+), # count number of missings
Filter(!(ismissing last))'(TeeRF(
Expand Down
21 changes: 18 additions & 3 deletions src/interop/blockarrays.jl → ext/TransducersBlockArraysExt.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
module TransducersBlockArraysExt

if isdefined(Base, :get_extension)
using Transducers: Transducers, @return_if_reduced, @next, @simd_if, complete
using Transducers.Setfield: @set
using BlockArrays
else
using ..Transducers: Transducers, @return_if_reduced, @next, @simd_if, complete
using ..Transducers.Setfield: @set
using ..BlockArrays
end

"""
_foldl_blockarray(rf, acc, coll::BlockArrays.BlockArray)
"""
Expand Down Expand Up @@ -40,9 +52,7 @@ end
::Val{N₋₁},
) where {RF,N₋₁}

blockaxes = BlockArrays.blockaxes

@inbounds for b in blockaxes(coll, 1)
@inbounds for b in BlockArrays.blockaxes(coll, 1)
array = coll[b, block...]
@simd_if rf for k in axes(array, 1)
acc = @next(rf, acc, array[k, offset...])
Expand All @@ -51,4 +61,9 @@ end
return acc
end

Transducers.__foldl__(rf, acc, coll::BlockArrays.BlockArray) =
_foldl_blockarray(rf, acc, coll)

# TODO: write reduce for BlockArrays which can be done in the "natural" order

end
15 changes: 15 additions & 0 deletions ext/TransducersDataFramesExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module TransducersDataFramesExt

if isdefined(Base, :get_extension)
using Transducers
using DataFrames
else
using ..Transducers
using ..DataFrames
end

Transducers.asfoldable(df::DataFrames.AbstractDataFrame) = DataFrames.eachrow(df)
# We can't use `Compat.eachrow` here. See:
# https://github.com/JuliaData/DataFrames.jl/pull/2067

end #module
18 changes: 18 additions & 0 deletions src/interop/lazyarrays.jl → ext/TransducersLazyArraysExt.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
module TransducersLazyArraysExt

if isdefined(Base, :get_extension)
using Transducers: Transducers, @return_if_reduced, @next, @simd_if, complete, foldlargs, foldl_nocomplete
using Transducers.Setfield: @set
using LazyArrays
else
using ..Transducers: Transducers, @return_if_reduced, @next, @simd_if, complete, foldlargs, foldl_nocomplete
using ..Transducers.Setfield: @set
using ..LazyArrays
end

@inline function _foldl_lazy_cat_vectors(rf, acc, vectors)
isempty(vectors) && return complete(rf, acc)
result = @return_if_reduced foldlargs(acc, vectors...) do acc, arr
Expand Down Expand Up @@ -26,6 +38,12 @@ end
end
return complete(rf, acc)
end

Transducers.__foldl__(rf, acc, coll::LazyArrays.Hcat) = _foldl_lazy_hcat(rf, acc, coll)
Transducers.__foldl__(rf, acc, coll::LazyArrays.Vcat) = _foldl_lazy_vcat(rf, acc, coll)

# Vcat currently always is an `AbstractVector` or `AbstractMatrix`

# TODO: write reduce for Vcat/Hcat which can be done in the "natural" order

end
Loading

2 comments on commit 6540960

@MasonProtter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/86325

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.77 -m "<description of version>" 65409605186ab0b579b9f512a556bae41ce7e4c1
git push origin v0.4.77

Please sign in to comment.