mcabbott / mcabbott/Tullio.jl

When supplied range conflicts with un-shifted index...

Open
#89 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
668
Forks
30
PR merge metrics
No merged PRs in 30d

Description

Hey,

the following one:

julia> using Tullio

julia> y = ^C

julia> y = (1:10) .* (1:10)'
10×10 Matrix{Int64}:
  1   2   3   4   5   6   7   8   9   10
  2   4   6   8  10  12  14  16  18   20
  3   6   9  12  15  18  21  24  27   30
  4   8  12  16  20  24  28  32  36   40
  5  10  15  20  25  30  35  40  45   50
  6  12  18  24  30  36  42  48  54   60
  7  14  21  28  35  42  49  56  63   70
  8  16  24  32  40  48  56  64  72   80
  9  18  27  36  45  54  63  72  81   90
 10  20  30  40  50  60  70  80  90  100

julia> f(x) = (@tullio res[i, j] := x[i, j+1] (i in 1:5, j in 1:5))
f (generic function with 1 method)

julia> f(y)
ERROR: "range of index i must agree"
Stacktrace:
 [1] ℳ𝒶𝓀ℯ
   @ ~/.julia/packages/Tullio/bgqFi/src/macro.jl:968 [inlined]
 [2] (::Tullio.Eval{var"#ℳ𝒶𝓀ℯ#180"{var"#𝒜𝒸𝓉!#177"}, var"#735#∇ℳ𝒶𝓀ℯ#179"{var"#∇𝒜𝒸𝓉!#178"}})(args::Matrix{Int64})
   @ Tullio ~/.julia/packages/Tullio/bgqFi/src/eval.jl:20
 [3] f(x::Matrix{Int64})
   @ Main ./REPL[119]:1
 [4] top-level scope
   @ REPL[120]:1

julia> f(x) = (@tullio res[i, j] := x[i+0, j+1] (i in 1:5, j in 1:5))
f (generic function with 1 method)

julia> f(y)
5×5 Matrix{Int64}:
  2   3   4   5   6
  4   6   8  10  12
  6   9  12  15  18
  8  12  16  20  24
 10  15  20  25  30

What is the reason that we need the artificial +0? My goal was to calculate only a subset of the initial x

Thanks,

Felix

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the Julia examples in the issue, then inspect Tullio's macro.jl around line 968 and eval.jl around line 20, where the error is reported. Determine why an explicit +0 changes the supplied range handling; done means the 1:5 subset example works without that workaround and remains correct for the shifted index.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.