UndefVarError: linspace not defined


#1

New to julia 1.0, I am running some examples and got the following errors, do you have any ideas how to solve this?
Thanks.

‘’’
julia> linspace(0,2*pi,10)
ERROR: UndefVarError: linspace not defined
Stacktrace:
[1] top-level scope at none:0
‘’’


Weave with PyPlot.jl
#2

Linspace was deprecated. You should be able to use

range(0,stop=2*pi,length=10)

#3

Worked!
Thank you very much.
BTW, where could I find the information about whether a specific function is deprecated or not?
For “linspace”, I googled a lot before posting here, however I was failed to find any information about this.


#4

If you run the code with Julia v0.7 it will print a deprecation warning.


#5

Even more readable with unicode :slight_smile:

range(0, stop=2π, length=10)

#6

Then, if linspace is deprecated, please update the documentation at

https://julialang.org/downloads/plotting.html

It is very frustrating when you are a new user, you pick an example from a tutorial and it doesn’t work! I would suggest to try not to break old code.


#7

Good catch! The code is here https://github.com/JuliaLang/www.julialang.org/blob/9f544a5476c74a74d7dfb1f15e939550e5dd851e/downloads/plotting.html, care to make a pull request?


#8

Not OP, but this should do the trick. Looks like it just slipped through the cracks.


#9

Seelengrab did it faster than myself!


#10

Just a question, is there any particular reason why stop became a named argument? It seems antisymmetric with the start argument.
Be able to use as range(start, stop) would be nice.


#11

In Julia v1.1 it will be the exactly the way you want. Until then, if you use Compat.jl with the current versions of Julia, you can use the new notation as soon as https://github.com/JuliaLang/Compat.jl/pull/633 is merged


#12

This is the correct answer.

But, being required to maintain a Julia v0.7 installation just to learn about a deprecated function is kind of a pain, even for people experienced with Julia. In practice, examples using linspace etc. will be around for some time, and will continue to cause confusion.

I’m just pointing it out. Not complaining about it. It has not bothered me enough to try to find a solution myself.


#13

In practice, examples using linspace etc. will be around for some time, and will continue to cause confusion.

Gotta catch them all? Here are a few examples to start your collection off…


#14

Maybe admit an error and get that function name back?


#15

All (or almost) of the decisions to make deprecations and replacements were discussed thoroughly over a long period and were made for good reasons.


#16

Sorry for digressing a bit from the OP, but I had this issue today as the convolution function from Julia 0.6 (conv) is not in Julia 1.0 and I could not find it in any of the release notes for 0.7/1.0.

In the end I went back to my 0.7 installation to try and get an informative warning message (it told me that conv had been moved to DSP.jl.

Is there somewhere with a more comprehensive list of deprecations than the release notes? Or if people find these should they submit a PR to change the 0.7 release note? Thanks