Error loading Krusell Smith function

Thank you for those who have put the Krusell Smith material for Julia. Very helpful!

I am encountering the following error when running
using NBInclude
@nbinclude(“KSfunctions.ipynb”)

LoadError: LoadError: cannot assign variable QuantEcon.VFI from module Main
in expression starting at ~/Julia/krusell_smith_code/KSfunctions.ipynb:In[+5]:1
in expression starting at ~/Julia/krusell_smith_code/KrusellSmith.jl:2
top-level scope at Parameters.jl:553

I have installed the QuantEcon package as per instructions.
I am relatively new to Julia / gitHub so I would appreciate any help you can give.

Thanks

@lorenzo.garlappi Thank you for reporting.

It looks like a name conflict, but I wasn’t able to reproduce the error.

Would you let me know your environment (version of Julia, packages, etc) and the procedure to get the error?

On the other hand, since VFI is already defined in QuantEcon.jl, maybe I should have avoided the same name. If you replace VFI in the two notebooks with another name, like VFI_KS, I guess you won’t get the error.

Thank you for your quick reply.

I am running Julia, version v"1.0.1" on a Mac, OS Sierra 10.12.6

I have added the two notebooks

KrusellSmith.ipynb
KSfunctions.ipynb

to my working directory and created in the same directory a Julia file called KrusellSmith.jl which contains just the following 2 lines:

using NBInclude
@nbinclude(“KSfunctions.ipynb”)

Upon running the second line I get the error:

LoadError: LoadError: cannot assign variable QuantEcon.VFI from module Main
in expression starting at /Users/garlappi/aa/Julia/krusell_smith_code/KSfunctions.ipynb:In[+5]:1
in expression starting at /Users/garlappi/aa/Julia/krusell_smith_code/KrusellSmith.jl:2
top-level scope at Parameters.jl:553

Here is a list of my installed packages

julia> Pkg.status()
Project QuantEconLecturePackages v0.9.6
Status ~/aa/Julia/.projects/QuantEconLecturePackages-v0.9.7/Project.toml

[6e4b80f9] BenchmarkTools v0.4.2

[3da002f7] ColorTypes v0.7.5

[34da2185] Compat v2.0.0

[a93c6f00] DataFrames v0.17.1

[1313f7d8] DataFramesMeta v0.4.1

[39dd38d3] Dierckx v0.4.1

[31c24e10] Distributions v0.16.4

[2fe49d83] Expectations v1.0.2

[f6369f11] ForwardDiff v0.10.3

[38e38edf] GLM v1.1.1

[28b8d3ca] GR v0.38.1

[a98d9a8b] Interpolations v0.11.2

[033835bb] JLD2 v0.1.2

[5ab0869b] KernelDensity v0.5.1

[b964fa9f] LaTeXStrings v1.0.3

[0db19996] NBInclude v2.1.0

[76087f3c] NLopt v0.5.1

[2774e3e8] NLsolve v3.0.1

[429524aa] Optim v0.17.2

[d96e819e] Parameters v0.10.3

[91a5bcdd] Plots v0.23.1

[f27b6e38] Polynomials v0.5.2

[92933f4c] ProgressMeter v0.9.0

[1fd47b50] QuadGK v2.0.3

[fcd29c91] QuantEcon v0.15.0

[295af30f] Revise v1.1.0

[f2b01f46] Roots v0.7.4

[90137ffa] StaticArrays v0.10.3

[f3b207a7] StatsPlots v0.10.2

[37e2e46d] LinearAlgebra

[9a3f8284] Random

[2f01184e] SparseArrays

[10745b16] Statistics

[8dfed614] Test

Thanks!

@lorenzo.garlappi Could you try it with v1.1.0? It’s a little hard for me to try 1.0.1. (And unfortunately I cannot use mac.) If this fixes the issue, there was probably some changes in variable scope between 1.0.1 and 1.1.0, although I don’t think that’s the case.

Having said that, it would be better to avoid name conflicts in general. You can also try the fix I mentioned above or python like import style; import QuantEcon and QuantEcon.gridmake.

Thank you! Updating to v1.1.0 fixed the problem.