Problem with Listing 1.10 on Statistics With Julia Book

Hello folks.

I’m working with Hayden Klok and Yoni Nazarathy’s book “Statistics With Julia” and the Listing 1.10 dont work.
the error is:
Warning: ‘getindex(o::PyObject, s::Symbol)’ is deprecated in favor of dot overloading (‘getproperty’) so elements should now be accessed as e.g. ‘o.s’ instead of ‘o[:s]’.
• caller - top-level scope at none:0
Core none:0

I’ve tried several ways to solve, but I haven’t been successful. How do you solve this?

the code:

using PyPlot
function hailLength(x,Int64)
n=0
while x != 1
if x % 2 == 0
x = Int(x/2)
else
x = 3x +1
end
n += 1
end
return n
end
lengths = [hailLength(x0) for x0 in 2:10^7]
plt[:hist](lengths, 1000, density=“true”)
xlabel(“Length”)
ylabel(“Frequency”);

elements should now be accessed as e.g. ‘o.s’ instead of ‘o[:s]’.

so use

plt.hist(lengths, 1000, density="true")
1 Like

YEEEAAAH, thaks, I was looking at line 3 haha

Hi, hope you are enjoying - feel free to contact us with direct feedback. We are just converting the code (of the whole book draft) from PyPlot.jl to Plots.jl. The updated draft version with Plots.jl code will be out at the end of the month.

4 Likes