Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Totally weird parsing/unknown problem... #749

Closed
Datseris opened this issue Jun 21, 2018 · 8 comments · Fixed by #791
Closed

Totally weird parsing/unknown problem... #749

Datseris opened this issue Jun 21, 2018 · 8 comments · Fixed by #791
Milestone

Comments

@Datseris
Copy link
Contributor

I am facing some parsing problems when trying to use PyPlot to plot and save figures to use in my documentation...

I am sorry, I don't really know how to make a MWE because I got no clue where the problem is. The documentation example works fine for me.

```@example 8
using PyPlot, DynamicalBilliards
b = billiard_polygon(6, 1)
a = Antidot([0.0,0.0], 0.5)
bd = Billiard(b.obstacles..., a)

figure()
plot_obstacle!(bd[end])
plot_obstacle!(bd[1])
plot_obstacle!(bd[2]; linewidth = 3.0, linestyle = "dashed", color = (0.0, 0.5, 0.5))

PyPlot.xlim(-1, 1); PyPlot.ylim(-1, 1);

savefig("obstacles_example.svg"); nothing # hide

Gives error:

 !! failed to run code block.

UndefVarError(:igure) [src\visualizing.md]

please note that this error is not from my side; copy-pasting this block to the REPL is fine

On the other side, these:

```@example 8
plot_billiard(bd)
savefig("billiard_example.svg"); nothing # hide
```@example 8
p = randominside(bd)
plot_particle!(p)
# Plot one more particle with purple color,
# pentagon shape and bigger size (default is s=30):
p2 = randominside(bd)
plot_particle!(p2; color=(0.5, 0, 0.8), marker="p", s=60.0)
savefig("particles_example.svg"); nothing # hide

parse fine, they do their figures, do their plottings, they save their figures and all is cool. Not only that, but even though the initial block failed to run correctly, the using DynamicalBilliards, PyPlot statement took effect, since it is used in the later blocks.

Let me know if I can do more to help. If you want to run these code blocks you have to checkout the branch namefield of DynamicalBilliards. These examples are in the docs/visualizing.md file.

@Datseris
Copy link
Contributor Author

Forgot to mention: Julia 0.7 and latest stable documenter.

@fredrikekre
Copy link
Member

I can not reproduce this error.

@mortenpi
Copy link
Member

Me neither, although I am also running into type Array has no field obstacles with DynamicalBilliards v1.6.3. What I can think of:

  • I would try be-building and re-compiling the packages, especially PyPlot.
  • What Julia are you using exactly.. the 0.7.0-alpha binary or self-built from master? If the latter, maybe the build is broken somehow.
  • For replication, if you could put the complete example up somewhere together with Manifest.toml, perhaps we'll be able to replicate it then.

@Datseris
Copy link
Contributor Author

Hi @mortenpi I did what you said but it wasn't very fruitful. I am using 0.7.0-alpha.0, using the windows installer.

I want to stress that what I am reporting here cannot be an issue with neither PyPlot or DynamicalBilliards. The code I use is valid, and when pasted on the REPL runs fine. There is a parsing issue definitely.

The issue happens in both of my computers, which operate on Windows 10.

You can find the complete example along with the Manifest.toml by doing:

]
develop https://github.com/JuliaDynamics/DynamicalBilliards.jl#namefield

this will install for you the branch namefield of DynamicalBilliards. Then the only thing you have to do is

cd(Pkg.dir("DynamicalBilliards")*"/docs")
include("make.jl")

(of course doc deployment will fail)

When you do that, you will get a warning/error:

julia> include("make.jl")
Documenter: setting up build directory.
Documenter: expanding markdown templates.
 !! failed to run code block.

UndefVarError(:bd) [src\visualizing.md]

which is associated with the file visualizing.md, and specifically its first code block:

```@example obstacles
using DynamicalBilliards, PyPlot

bd = billiard_sinai()

plot_obstacle!(bd[2])
plot_obstacle!(bd[4], color = "blue", linestyle = "dotted", lw = 5.0)
plot_obstacle!(bd[1], facecolor = "yellow", edgecolor = "black")
savefig("rand_obstacles.svg"); nothing # hide

even though the code is valid and runs on the REPL.

@Datseris
Copy link
Contributor Author

One more parsing error to report:

```@example phasespace
using DynamicalBilliards

t = 1000000.0
l = 1.0; r = 1.0; w = 0.4

bd = billiard_mushroom(l, w, r)

p = MushroomTools.randomchaotic(l, w, r)

ratio, dic = boundarymap_portion(bd, t, p, 0.01)
trueratio = MushroomTools.g_c_2D(l,w,r)
println("2D numeric - theory: $(abs(ratio - trueratio))")

ratio = phasespace_portion(bd, t, p, 0.01)
trueratio = MushroomTools.g_c_3D(l,w,r)
println("3D numeric - theory: $(abs(ratio - trueratio))")

gives

 !! Warning in src\basic\phasespaces.md:

Failed to parse expression.

ERROR: Base.Meta.ParseError("unexpected \"=\"")

even though the code block is once again valid and if copy-pasted on the REPL runs fine and prints the results fine.

@fredrikekre
Copy link
Member

I'm thinking it might be related to line endings, since you are on Windows. Documenter should normalize all of them, but perhaps we have missed that somewhere?
Can you try running this function on all your files, and try again?

function replace_newlines(filename)
    str = read(filename, String)
    str = replace(str, "\r\n" => "\n")
    write(filename, str)
end

@Datseris
Copy link
Contributor Author

Did not work :( I'll try re-installing everything

@scls19fr
Copy link

I'm also facing a weird issue see #790

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants