Is it a bug in comprehension?


#1

I got… hmmm… let’s call interesting behavior with the comprehension but only in function:

function foo(tmax, a, b, M, N)
    println("1: a=$a, b=$b, tmax = $tmax, M = $M, N = $N")
    tpts = [ tmax/M*i for i in 0:N ]
    println("2: a=$a, b=$b, tmax = $tmax, M = $M, N = $N")
    xpts = [ a+(b-a)/N*j for j in 0:M ]
    println("3: a=$a, b=$b, tmax = $tmax, M = $M, N = $N")
    return (tpts, xpts)
end

And then:

(t1, x1) = foo(1.0, -1.0, 2.0, 10, 10);

produces

1: a=-1.0, b=2.0, tmax = 1.0, M = 10, N = 10
2: a=-1.0, b=0.0, tmax = 1.0, M = 10, N = 10
3: a=-1.0, b=0.0, tmax = 1.0, M = 10, N = 10

Coefficient b got turned to zero after the first comprehension. (Julia 0.6.2 on Windows) Can anyone else confirm it?


#2

That is odd, and I can’t reproduce it on Linux (0.6.2 nor 0.7-dev). What do get as return for x1?
I get

julia> x1'                                                                                                                                                               
1×11 LinearAlgebra.Adjoint{Float64,Array{Float64,1}}:                                                                                                                    
 -1.0  -0.7  -0.4  -0.1  0.2  0.5  0.8  1.1  1.4  1.7  2.0                                                                                                               

Maybe someone else with a windows install can check too.


#3
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.2 (2017-12-13 18:08 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-w64-mingw32

julia> function foo(tmax, a, b, M, N)
           println("1: a=$a, b=$b, tmax = $tmax, M = $M, N = $N")
           tpts = [ tmax/M*i for i in 0:N ]
           println("2: a=$a, b=$b, tmax = $tmax, M = $M, N = $N")
           xpts = [ a+(b-a)/N*j for j in 0:M ]
           println("3: a=$a, b=$b, tmax = $tmax, M = $M, N = $N")
           return (tpts, xpts)
       end
foo (generic function with 1 method)

julia> (t1, x1) = foo(1.0, -1.0, 2.0, 10, 10);
1: a=-1.0, b=2.0, tmax = 1.0, M = 10, N = 10
2: a=-1.0, b=2.0, tmax = 1.0, M = 10, N = 10
3: a=-1.0, b=2.0, tmax = 1.0, M = 10, N = 10

#4

Interesting… I have exact same version of Julia.

However, I remember that about a month or two ago I was playing with PackageComiler.jl and I may have replaced original Julia image. Is there a way to check this?


#5

I get the range from -1.0 to 0.0. In fact, this is how I got onto this: I was generating the range like this only to see incorrect boundaries.


#6

Well if you have recompiled other stuff into julia then all bets are off. I suggest you download a new fresh version.


#7
Julia Version 0.6.0
Commit 903644385b* (2017-06-19 13:05 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
1: a=-1.0, b=2.0, tmax = 1.0, M = 10, N = 10
2: a=-1.0, b=2.0, tmax = 1.0, M = 10, N = 10
3: a=-1.0, b=2.0, tmax = 1.0, M = 10, N = 10

Also,

Julia Version 0.7.0-DEV.5012
Commit 4339f7416a* (2018-05-05 21:39 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
(t1, x1) = foo(1.0, -1.0, 2.0, 10, 10);
1: a=-1.0, b=2.0, tmax = 1.0, M = 10, N = 10
2: a=-1.0, b=0.0, tmax = 1.0, M = 10, N = 10
3: a=-1.0, b=0.0, tmax = 1.0, M = 10, N = 10

#8

Interesting that in 0.7 comprehension also destroys b.


#9

I can confirm the problem on

Julia Version 0.7.0-DEV.4690
Commit 78c7d87369* (2018-03-23 22:25 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, broadwell)
Environment:

but not on JuliaBox with

Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2673 v3 @ 2.40GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, haswell)

Re-installing clean Julia solved it on 0.6.2. It did look like I have replaced Julia’s image while playing with PackageCompiler.

EDIT: Submitted an issue


#10

Would it be Windows specific? All failures are in mingw environment.


#11

This seems to be the case. I don’t have other systems to test elsewhere.