Skip to content

Commit

Permalink
init for redfun and & or
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Abbott committed Aug 17, 2020
1 parent 9d54a24 commit 396b3b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/macro.jl
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,8 @@ function action_functions(store)
init = store.redfun == :* ? :(one($TYP)) :
store.redfun == :max ? :(typemin($TYP)) :
store.redfun == :min ? :(typemax($TYP)) :
store.redfun == :& ? :(true) :
store.redfun == :| ? :(false) :
:(zero($TYP))

# Right now this would allow *= only with reduction * too. Could separate them:
Expand Down
4 changes: 4 additions & 0 deletions test/parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,10 @@ end
@test maximum(A) == @tullio (max) m := float(A[i])
@test minimum(A) == @tullio (min) m := float(A[i]) # fails with @avx

@test true == @tullio (&) p := A[i] > 0
@test_broken true === @tullio (&) p := A[i] > 0 # sum([true]) isa Int
@test true == @tullio (|) q := A[i] > 50

# in-place
C = copy(A)
@test cumprod(A) == @tullio (*) C[k] = ifelse(i<=k, A[i], 1)
Expand Down

2 comments on commit 396b3b6

@mcabbott
Copy link
Owner

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/19647

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.2.2 -m "<description of version>" 396b3b61a3d078b8321dfb75df86cada09446b32
git push origin v0.2.2

Please sign in to comment.