carpentries-incubator / julia-novice

A lesson exploring the Julia language
https://carpentries-incubator.github.io/julia-novice
Other
15 stars 20 forks source link

Trebuchet.jl version selection #30

Closed tkphd closed 2 years ago

tkphd commented 2 years ago

I'm working through ep. 4, and did the following as instructed:

julia> ]
(1.7) pkg> activate projects/trebuchet
(trebuchet) pkg> add Trebuchet
(trebuchet) pkg> status
      Status `projects/trebuchet/Project.toml`
  [98b73d46] Trebuchet v0.2.1

Then, in ep. 5,

julia> names(Trebuchets)
5-element Vector{Symbol}:
 :Trebuchet
 :TrebuchetState
 :run
 :simulate
 :visualise

Note: shoot is not listed!

julia> import Trebuchet as Trebuchets
julia> ?
help?> Trebuchets.shoot
  No documentation found.

  Trebuchet.shoot is a Function.

  # 2 methods for generic function "shoot":
  [1] shoot(::Any) in Trebuchet at ~/.julia/packages/Trebuchet/RdSqo/src/utils.jl:3
  [2] shoot(x...) in Trebuchet at ~/.julia/packages/Trebuchet/RdSqo/src/utils.jl:13

Indeed, there are no docstrings in utils.jl.

The current Trebuchet.jl source tree annotation shows the docstrings, but they were added in 2021 (about a year after v0.2.1 was released). Indeed, the commit message is "export and document shoot," so this explains both errors here (no shoot in names() and no docstrings).

So... how do I add the current/GitHub version of Trebuchet? I would like to update the lesson to show how to get matching output, with the docstrings for shoot without which the learner would have no idea what function signature to use.

tkphd commented 2 years ago

Ah, asked & answered...

julia>
(trebuchet) pkg> remove Trebuchet
(trebuchet) pkg> add https://github.com/FluxML/Trebuchet.jl
  ✓ Trebuchet
  1 dependency successfully precompiled in 7 seconds (123 already precompiled)
  1 dependency precompiled but a different version is currently loaded. Restart julia to access the new version

restart Julia, then

julia> ]
(1.7) pkg> activate project/trebuchet
(trebuchet) pkg> add https://github.com/FluxML/Trebuchet.jl
(trebuchet) pkg> status
      Status `project/trebuchet/Project.toml`
  [98b73d46] Trebuchet v0.2.1 `https://github.com/FluxML/Trebuchet.jl#master`
julia> import Trebuchet as Trebuchets
julia> names(Trebuchets)
6-element Vector{Symbol}:
 :Trebuchet
 :TrebuchetState
 :run
 :shoot
 :simulate
 :visualise
julia> ?Trebuchets.shoot
  shoot(ws, angle, w)
  shoot((ws, angle, w))

  Shoots a Trebuchet with weight w in kg. Releases the weight at the release angle angle in
  radians. The current wind speed is ws in m/s. Returns (t, dist), with travel time t in s
  and travelled distance dist in m.

I'll update the docs to pull the GitHub version, and perhaps ping those folks to release :grinning:

BeastyBlacksmith commented 2 years ago

add Trebuchet#master would be also an option (maybe Main instead of master)

tkphd commented 2 years ago

I thought that should work, but for some reason it didn't, or I tried something similar but slightly wrong... Thanks!