Julia libraries tutorial


#1

Author: Cla B

Dear all,

while trying to run the code for a 3D plot using Julia 0.4.2 (http://quantecon.net/jl/julia_libraries.html#d-plots) I get the following error message:

"LoadError: MethodError: `meshgrid` has no method matching meshgrid(::LinSpace{Float64}, ::LinSpace{Float64})
while loading In[7], in expression starting on line 20

in getindex at C:\Users\Io.julia\v0.4\PyCall\src\PyCall.jl:239"

QuantEcon is installed. Any idea about the source of the problem?

Thank you for your tutorial, I find it great!

Best,

Claudio


#2

Thanks for the feedback Claudio. It’s appreciated. I’m at a conference today but one of us will get back to you soon.

Regards, John.


#3

Hi Claudio.

Thanks for noticing this. The problem is the following:

julia> xgrid, ygrid = meshgrid(x, y)
ERROR: MethodError: `meshgrid` has no method matching meshgrid(::LinSpace{Float64}, ::LinSpace{Float64})

At one point, I believe that the linspace command gave an array as its output, but since then Julia has created a LinSpace type. Note the type of x (or y),

julia> typeof(x)
LinSpace{Float64}

We will fix this in next day or so, but until then you can use the following command to get the correct meshgrid

julia> xgrid, ygrid = meshgrid(collect(x), collect(y))

Collect takes an iterable object (in this case a LinSpace) and puts it into an array.


#4

Notice that my suggestion may soon not be necessary.

We are considering a change in the way meshgrid is defined that would allow LinSpace types to be passed into the function. See this pull interest on our github repository.