-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for broadcasted piping .|>. #16
Merged
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5be6d16
Added support for element-wise piping .|>.
racinmat c5e08ce
renamed elementwise to broadcast, bumped minor version
racinmat 130e774
working piping for .|>, but I don't know how shouldI write tests
racinmat b31fc6a
using comparisons without linenums
racinmat 07aea9d
tests are passing
racinmat 9e0152b
testing also for Julia 1.4
racinmat b7f93c2
better errors during tests
racinmat c148523
testing is independent on names of temporary variables
racinmat e9595b3
Updated badges
racinmat ca0aef0
fixed tests
racinmat f781005
Update test/runtests.jl
racinmat 1d8a318
split rewriting into separate functions based on broadcast
racinmat 5d14bc4
Merge remote-tracking branch 'origin/master'
racinmat a59c92a
calling correct functions
racinmat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,3 +47,10 @@ end | |
@test _macroexpand( :(@pipe a|>b|>c(_) ) ) == :(c(b(a))) | ||
@test _macroexpand( :(@pipe a|>b(x,_)|>c|>d(_,y) ) ) == :(d(c(b(x,a)),y)) | ||
@test _macroexpand( :(@pipe a|>b(xb,_)|>c|>d(_,xd)|>e(xe) |>f(xf,_,yf)|>_[i] ) ) == :(f(xf,(e(xe))(d(c(b(xb,a)),xd)),yf)[i]) #Very Complex | ||
|
||
# broadcasting | ||
fn(x) = x^2 | ||
@test _macroexpand( :(@pipe fn |> _.(1:2) ) ) == :(fn.(1:2)) | ||
@test _macroexpand( :(@pipe 1:10 .|> _*2 ) ) == :((1:10) .* 2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we also test
|
||
@test _macroexpand( :(@pipe 1:10 .|> fn ) ) == :(fn.(1:10)) | ||
@test _macroexpand( :(@pipe a .|> fn .|> _*2 ) ) == :(fn.(a) .* 2) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if we do:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it produces
:(var"._".(1:2))
and@pipe fn .|> _.(1:2)
crashes.I'm not entirely sure, what is desired behaviour, how the resulting code should look like.
In plain Julia
fn .|> x->x.(1:2) == fn |> x->x.(1:2)
, and sincefn
isa not iterable AFAIK, thenfn ,|>
produces same result asfn |>
, so I'm not sure where I want to go with this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we want to match the normal behavour.
Here is an interesting set of cases:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. If I understand it correctly, the embedding of input array is not able to cover cases 2 and 3, because the
.
notation is not expressive enough, so I should explicitly call broadcast function in the macro, right?Because I can write test for
but I'm kinda lost in decising what should
equal to.
What do you think? @oxinabox