Skip to content

Commit

Permalink
Merge pull request #27457 from non-Jedi/reducedim_custom_eltype
Browse files Browse the repository at this point in the history
Test dimensional reduce with non-bitstype
  • Loading branch information
mbauman authored Oct 8, 2019
2 parents 76d9b4b + f250511 commit 80dca30
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/reducedim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,21 @@ end
@test_throws DimensionMismatch maximum!(fill(0, 1, 1, 2, 1), B)
@test_throws DimensionMismatch minimum!(fill(0, 1, 1, 2, 1), B)
end

# issue #26709
@testset "dimensional reduce with custom non-bitstype types" begin
struct Variable
name::Symbol
end
struct AffExpr
vars::Vector{Variable}
end
Base.zero(::Union{Variable, Type{Variable}, AffExpr}) = AffExpr(Variable[])
Base.:+(v::Variable, w::Variable) = AffExpr([v, w])
Base.:+(aff::AffExpr, v::Variable) = AffExpr([aff.vars; v])
Base.:+(aff1::AffExpr, aff2::AffExpr) = AffExpr([aff1.vars; aff2.vars])
Base.:(==)(a::Variable, b::Variable) = a.name == b.name
Base.:(==)(a::AffExpr, b::AffExpr) = a.vars == b.vars

@test sum([Variable(:x), Variable(:y)], dims=1) == [AffExpr([Variable(:x), Variable(:y)])]
end

2 comments on commit 80dca30

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

Please sign in to comment.