Skip to content
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

Error with piping left in multiline @tullio begin ... end #140

Open
Emmanuel-R8 opened this issue Mar 9, 2022 · 1 comment
Open

Error with piping left in multiline @tullio begin ... end #140

Emmanuel-R8 opened this issue Mar 9, 2022 · 1 comment

Comments

@Emmanuel-R8
Copy link

MWE:

A = rand(4, 4, 5, 5)
B = rand(4, 4)

@tullio C[k, l] := A[i, j, k, l] * B[i, j]               # OK
@tullio C[k, l] := A[i, j, k, l] * B[i, j] |> sqrt       # OK
@tullio C[k, l] := sqrt <| A[i, j, k, l] * B[i, j]       # OK

@tullio C[k, l] := begin
    A[i, j, k, l] * B[i, j]
end                                    # OK

@tullio C[k, l] := begin
    A[i, j, k, l] * B[i, j] |> sqrt
end                                   # OK

@tullio C[k, l] := begin
    sqrt <| A[i, j, k, l] * B[i, j]
end                                   # KO
@mcabbott
Copy link
Owner

Be warned that these do different things:

julia> @tullio C[k, l] := A[i, j, k, l] * B[i, j] |> sqrt; C[3,4]  # sqrt outside the sum
2.0930036101114573

julia> @tullio C[k, l] := begin
           A[i, j, k, l] * B[i, j] |> sqrt
       end; C[3,4]
6.945564259296232

julia> @tullio C[k, l] := sqrt(A[i, j, k, l] * B[i, j]); C[3,4]  # sqrt is inside the sum
6.945564259296232

julia> Base.:|>
|> (generic function with 1 method)

julia> <|
ERROR: UndefVarError: <| not defined

So the |> symbol within the begin end isn't being processed by the macro at all, it's just calling Base.:|>. And since there is no <|, that gives an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants