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

still some errors #3

Closed
Datseris opened this issue Jan 11, 2022 · 9 comments
Closed

still some errors #3

Datseris opened this issue Jan 11, 2022 · 9 comments

Comments

@Datseris
Copy link
Contributor

Hi, it doesn't work yet, once again, here is the code I use to test:

using Agents

model, zombie_step!, model_step! = Models.zombies()

using OSMMakie
using GLMakie
ac(agent) = agent.infected ? :green : :black
as(agent) = agent.infected ? 6 : 5
fig = Figure(); display(fig)
ax = Axis(fig[1,1])
osmplot!(ax, model.space.map)
ids = model.scheduler(model)
colors = Observable([ac(model[i]) for i in ids])
sizes = Observable([as(model[i]) for i in ids])
pos = Observable(Point2f[OSM.latlon(model[i].pos, model) for i in ids])
scatter!(ax, pos; color = colors, markersize = sizes)

with Agents master. This code is useful because now the default graph is different. It already highlighted one problem.
In line 41 in recipe.jl you need to write zip(1:Graphs.ne(osm.graph), instead of 1:osm.gra.ne. Not all graphs have a .ne field, but the ne function always returns the number of edges. I was going to do a PR but even after this fix there is another problem:

ERROR: LoadError: KeyError: key :osm_edge_colors not found
Stacktrace:
  [1] getindex(h::Dict{Symbol, Observable}, key::Symbol)
    @ Base .\dict.jl:481
  [2] getindex
    @ C:\Users\datse\.julia\packages\MakieCore\S8PkO\src\attributes.jl:96 [inlined] 
  [3] getindex
    @ C:\Users\datse\.julia\packages\MakieCore\S8PkO\src\attributes.jl:192 [inlined]
  [4] getproperty
    @ C:\Users\datse\.julia\packages\MakieCore\S8PkO\src\attributes.jl:83 [inlined] 
  [5] set_edge_defaults(osmplot::Combined{OSMMakie.osmplot, Tuple{LightOSM.OSMGraph{Int32, Int64, Float64}}})
    @ OSMMakie C:\Users\datse\.julia\dev\OSMMakie\src\defaults.jl:45
  [6] plot!(osmplot::Combined{OSMMakie.osmplot, Tuple{LightOSM.OSMGraph{Int32, Int64, Float64}}})   
    @ OSMMakie C:\Users\datse\.julia\dev\OSMMakie\src\recipe.jl:55
  [7] plot!(scene::Scene, P::Type{Combined{OSMMakie.osmplot, Tuple{LightOSM.OSMGraph{Int32, Int64, Float64}}}}, attributes::Attributes, input::Tuple{Observable{LightOSM.OSMGraph{Int32, Int64, Float64}}}, args::Observable{Tuple{LightOSM.OSMGraph{Int32, Int64, Float64}}})

Indeed, looking at the definition of Attributes at lline 23, there isn't any attribute with that name. I'm not sure how to fix this part as I've never learned the Makie recipe system yet.

@fbanning
Copy link
Member

Indeed, looking at the definition of Attributes at lline 23, there isn't any attribute with that name.

Sorry, accidentally left that osm_edge_colors attribute in there even though it's currently unused. Just fixed that on master.

In line 41 in recipe.jl you need to write zip(1:Graphs.ne(osm.graph), instead of 1:osm.gra.ne. Not all graphs have a .ne field, but the ne function always returns the number of edges.

That should be fixed now as well. Thanks for the heads up.

I wanted to test your MWE but it threw an error that I don't have permissions to load the Artifacts.toml:

ERROR: LoadError: SystemError: opening file "/home/fbanning/.julia/packages/Agents/vmoBx/src/spaces/../../Artifacts.toml": Keine Berechtigung
Stacktrace:
  [1] systemerror(p::String, errno::Int32; extrainfo::Nothing)
    @ Base ./error.jl:168
  [2] #systemerror#62
    @ ./error.jl:167 [inlined]
  [3] systemerror
    @ ./error.jl:167 [inlined]
  [4] open(fname::String; lock::Bool, read::Nothing, write::Nothing, create::Nothing, truncate::Bool, append::Nothing)
    @ Base ./iostream.jl:293
  [5] open(fname::String, mode::String; lock::Bool)
    @ Base ./iostream.jl:355
  [6] open(fname::String, mode::String)
    @ Base ./iostream.jl:355
  [7] open(::Pkg.Artifacts.var"#9#13"{Dict{String, Any}}, ::String, ::Vararg{String, N} where N; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base ./io.jl:328
  [8] open
    @ ./io.jl:328 [inlined]
  [9] bind_artifact!(artifacts_toml::String, name::String, hash::Base.SHA1; platform::Nothing, download_info::Nothing, lazy::Bool, force::Bool)
    @ Pkg.Artifacts /home/abuild/rpmbuild/BUILD/julia-1.6.3/usr/share/julia/stdlib/v1.6/Pkg/src/Artifacts.jl:245
 [10] test_map()
    @ Agents.OSM ~/.julia/packages/Agents/vmoBx/src/spaces/openstreetmap.jl:136
 [11] zombies(; seed::Int64)
    @ Agents.Models ~/.julia/packages/Agents/vmoBx/src/models/zombies.jl:12
 [12] zombies()
    @ Agents.Models ~/.julia/packages/Agents/vmoBx/src/models/zombies.jl:12
 [13] top-level scope
    @ ~/Code/test-OSMMakie/agents-test.jl:3

I've never worked with artifacts before as far as I know. Do I have to set up anything in a specific way?

@Datseris
Copy link
Contributor Author

@AayushSabharwal ooooooo oooooo problem! You know anything of this artifacts??? @fbanning thanks for the fixes, I'll get back to it as soon as I can, probably in a couple of days.

@fbanning
Copy link
Member

Worked now after I've cloned the master branch and created a symlink to its directory from ~/.julia/dev/. Don't ask me why it works like this but not when I do ]add Agents#master. Maybe something to keep in mind if it continues to happen.

@AayushSabharwal
Copy link

This is weird. I'll take a look.

@fbanning
Copy link
Member

This is what the plot looks like now:
Screenshot_20220112_133806

Take care that you need to use lonlat instead of latlon for proper north-oriented plotting. Here's a quick fix for it:

pos = Observable(Point2f[reverse(OSM.latlon(model[i].pos, model)) for i in ids])

Also it's currently impossible to see the uninfected agents, so I suggest to use ac(agent) = agent.infected ? :red : :green instead.

@AayushSabharwal
Copy link

That looks awesome!

@fbanning
Copy link
Member

Since the errors raised in this issue seem to be fixed now, I would close it. Feel free to play around with OSMMakie a bit more and see how you can break and/or extend it. :)

@Datseris
Copy link
Contributor Author

@fbanning just double checking: all of these stuff are fixed in the interaction branch, right? Nothing is on master as far as I can tell:

image

@fbanning
Copy link
Member

I've created the above plot on the master branch. The fixes discussed above were merged in v0.0.2. There should be no need to use the interaction branch to be able to use osmplot/osmplot!.

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

No branches or pull requests

3 participants