Skip to content

Commit

Permalink
[create-pull-request] automated change (#87)
Browse files Browse the repository at this point in the history
Co-authored-by: Philipp Matthias Schäfer <[email protected]>
  • Loading branch information
github-actions[bot] and fiveop authored Nov 14, 2024
1 parent bd749af commit 5528645
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 39 deletions.
4 changes: 2 additions & 2 deletions episodes/04_Using_the_package_manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ environment.

````
Status `~/projects/trebuchet/Project.toml`
[f6369f11] ForwardDiff v0.10.36
[295af30f] Revise v3.5.9
[f6369f11] ForwardDiff v0.10.38
[295af30f] Revise v3.6.2
[98b73d46] Trebuchet v0.2.2
````
Expand Down
38 changes: 17 additions & 21 deletions episodes/05_Write_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,24 @@ help?> Trebuchets.shoot

:::::: callout

## Methods
## Generic functions and methods

Here we see that the `shoot` function has two different _methods_.
The first one takes three arguments, while the second takes a `Tuple` with
three elements.
In the output we see that `shoot` has two different argument signatures: one with
three arguments and one with a `Tuple` of three elements as its single
argument. These two signatures correspond to two different implementations.
In our case one is calling the other.

Functions of the same name with different argument signatures are called
*methods* of a *generic function* of that name. In our example we have
two methods of the `shoot` generic function.

Almost all function in Julia are generic functions and in particular all user defined functions. An example with
particularly many methods is `+`. You can list its methods by executing
`methods(+)`, for example.

Julia determines which method to apply to a tuple of arguments according
to set of rules, which are documented in the [Julia Manual’s Methods
section](https://docs.julialang.org/en/v1/manual/methods/).

::::::

Expand Down Expand Up @@ -425,19 +438,6 @@ She can also lookup the docstring using the `@doc` macro
Return a tuple with the size of the buffer.
size(s::Sampleable)
The size (i.e. shape) of each sample. Always returns () when s is
univariate, and (length(s),) when s is multivariate.
size(d::MultivariateDistribution)
Return the sample size of distribution d, i.e (length(d),).
size(d::MatrixDistribution)
Return the size of each sample from distribution d.
size(g, i)
Return the number of vertices in g if i=1 or i=2, or 1 otherwise.
Expand Down Expand Up @@ -568,10 +568,6 @@ She looks up the documentation for that function
Returns the current value of observable.
getindex(A::ArrayPartition, i::Int, j...)
Returns the entry at index j... of the ith partition of A.
getindex(A::ArrayPartition, i::Colon, j...)
Returns the entry at index j... of every partition of A.
Expand Down
30 changes: 15 additions & 15 deletions episodes/07_Loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ Trebuchet( rand() * 500, rand() * pi/2 )

````output
2-element Trebuchet:
19.92126761754809
1.1758129035479739
353.42697829091327
1.5481002998262625
````

will give her a Trebuchet with a weight between 0 and 500 and a release angle between 0 and pi/2 radians at random.
Expand All @@ -121,9 +121,9 @@ distances = [shoot_distance(Trebuchet(rand() * 500, rand() * pi / 2), env) for _

````output
3-element Vector{Float64}:
106.68417294212176
116.21335516132379
73.730294183957
118.13337827163429
82.95579691187152
117.13566809575129
````

This is called an _array comprehension_.
Expand All @@ -138,16 +138,16 @@ distances = [(w,a) => shoot_distance(Trebuchet(w, a), env) for (w, a) in zip(wei

````output
10-element Vector{Pair{Tuple{Float64, Float64}, Float64}}:
(181.72785884820692, 0.397146829944134) => 101.73108411880898
(63.630046905466806, 0.0007390075864837765) => 38.578677436450356
(381.07768051820875, 0.14798050038431537) => 87.06414198100867
(282.3416703597322, 1.1918686477537617) => 69.0089195197084
(368.30808129827875, 0.0067941316204262366) => 59.34525074762748
(344.7882424260206, 0.3851870910679704) => 111.70986370160507
(372.4460093501431, 0.06855206373789495) => 72.63633120284015
(360.2628661185558, 1.4172206158209621) => 32.342739435405775
(43.15599567794415, 0.631090875891836) => 59.136515031317124
(483.7790756755326, 0.8497073005978015) => 110.42731071869284
(324.2732442832362, 0.71302644795678) => 114.55947796494196
(335.37667874032854, 0.6341110514590834) => 116.68767139752573
(103.60031609976255, 0.03878975933920561) => 51.650885425681984
(482.63166698166805, 0.11246399230891459) => 81.89097177495029
(300.6724895776015, 0.25573753399679877) => 97.56213345772589
(471.0242182881435, 1.1388331155474132) => 82.73493540156431
(253.00933394709475, 0.36203702332969495) => 102.38374906456522
(156.7643321929057, 0.5764919513105045) => 103.44235911682252
(32.41843752500701, 1.3341566788703363) => 15.176619860993625
(53.610542563477026, 1.4033289299752423) => 19.162338180404383
````

### Gradient descent
Expand Down
2 changes: 1 addition & 1 deletion episodes/10_Adding_tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ end
````

````output
Test.DefaultTestSet("Test arithmetic equalities", Any[], 1, false, false, true, 1.700042192846853e9, 1.70004219287704e9, false)
Test.DefaultTestSet("Test arithmetic equalities", Any[], 1, false, false, true, 1.731578522519902e9, 1.731578522550699e9, false)
````

With this Melissa can run her test using the pkg mode of the REPL:
Expand Down

0 comments on commit 5528645

Please sign in to comment.