Skip to content

Commit

Permalink
build based on 67c4259
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed Sep 30, 2023
1 parent b3a0396 commit 3cc04af
Show file tree
Hide file tree
Showing 4 changed files with 196 additions and 196 deletions.
126 changes: 63 additions & 63 deletions dev/crash/generated/course/course/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -551,32 +551,32 @@ <h2 id="dimensions-and-dimarrays">Dimensions and DimArrays<a class="headerlink"
<span class="n">A</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">rand</span><span class="p">(</span><span class="n">X</span><span class="p">(</span><span class="mi">5</span><span class="p">),</span><span class="w"> </span><span class="n">Y</span><span class="p">(</span><span class="mi">5</span><span class="p">))</span>
</code></pre></div>
<div class="highlight"><pre><span></span><code>5×5 DimArray{Float64,2} with dimensions: X, Y
0.284799 0.300196 0.7316 0.437931 0.493778
0.307533 0.509322 0.4605 0.741198 0.0253404
0.569357 0.00510929 0.366255 0.580418 0.473153
0.80285 0.426093 0.115463 0.972654 0.352493
0.617203 0.389015 0.518412 0.760126 0.954917
0.0191389 0.819933 0.764696 0.294098 0.237964
0.868251 0.229444 0.500254 0.660882 0.0807757
0.395765 0.193922 0.392154 0.829799 0.257758
0.678221 0.846071 0.519129 0.0515659 0.84316
0.660956 0.0355813 0.199046 0.931603 0.385837
</code></pre></div>
<p>get value</p>
<div class="highlight"><pre><span></span><code><span class="n">A</span><span class="p">[</span><span class="n">Y</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span><span class="w"> </span><span class="n">X</span><span class="p">(</span><span class="mi">2</span><span class="p">)]</span>
</code></pre></div>
<div class="highlight"><pre><span></span><code>0.30753286689676773
<div class="highlight"><pre><span></span><code>0.8682509612405509
</code></pre></div>
<p>As shown above, <code>Dimension</code>s can be used to construct arrays in <code>rand</code>, <code>ones</code>, <code>zeros</code> and <code>fill</code> with either a range for a lookup index or a number for the dimension length.</p>
<p>Or we can use the <code>Dim{X}</code> dims by using <code>Symbol</code>s, and indexing with keywords:</p>
<div class="highlight"><pre><span></span><code><span class="n">A</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">DimArray</span><span class="p">(</span><span class="n">rand</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="mi">5</span><span class="p">),</span><span class="w"> </span><span class="p">(</span><span class="ss">:a</span><span class="p">,</span><span class="w"> </span><span class="ss">:b</span><span class="p">))</span>
</code></pre></div>
<div class="highlight"><pre><span></span><code>5×5 DimArray{Float64,2} with dimensions: Dim{:a}, Dim{:b}
0.880591 0.97853 0.568949 0.714536 0.91811
0.611738 0.354618 0.646951 0.342044 0.745451
0.163752 0.081903 0.457454 0.667838 0.249053
0.640911 0.501742 0.92209 0.0400653 0.938277
0.0568913 0.36049 0.264699 0.933574 0.821843
0.764498 0.622001 0.00107922 0.464874 0.783775
0.310143 0.665714 0.55948 0.790729 0.98064
0.188671 0.796425 0.766516 0.348823 0.766108
0.381886 0.336574 0.955887 0.0410349 0.939628
0.500873 0.828451 0.775444 0.356713 0.553795
</code></pre></div>
<p>get value</p>
<div class="highlight"><pre><span></span><code><span class="n">A</span><span class="p">[</span><span class="n">a</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">b</span><span class="o">=</span><span class="mi">5</span><span class="p">]</span>
</code></pre></div>
<div class="highlight"><pre><span></span><code>0.24905284513288783
<div class="highlight"><pre><span></span><code>0.766108385053625
</code></pre></div>
<p>Often, we want to provide a lookup index for the dimension:</p>
<div class="highlight"><pre><span></span><code><span class="k">using</span><span class="w"> </span><span class="n">Dates</span>
Expand All @@ -588,16 +588,16 @@ <h2 id="dimensions-and-dimarrays">Dimensions and DimArrays<a class="headerlink"
X Sampled{Int64} 10:10:100 ForwardOrdered Regular Points,
Ti Sampled{DateTime} DateTime(&quot;2001-01-01T00:00:00&quot;):Month(1):DateTime(&quot;2001-12-01T00:00:00&quot;) ForwardOrdered Regular Points
2001-01-01T00:00:00 … 2001-12-01T00:00:00
10 0.859538 0.510701
20 0.626312 0.0728355
30 0.317968 0.384524
40 0.904192 0.306779
50 0.458359 … 0.440773
60 0.666228 0.450692
70 0.763109 0.318395
80 0.420933 0.879486
90 0.315691 0.84703
100 0.630614 … 0.693722
10 0.169857 0.472778
20 0.904785 0.959054
30 0.623205 0.523352
40 0.128775 0.24027
50 0.032771 … 0.652132
60 0.826151 0.472009
70 0.29575 0.268263
80 0.132968 0.899958
90 0.750803 0.732568
100 0.740371 … 0.57815
</code></pre></div>
<p>Here both <code>X</code> and <code>Ti</code> are dimensions from <code>DimensionalData</code>. The currently exported dimensions are <code>X, Y, Z, Ti</code> (<code>Ti</code> is shortening of <code>Time</code>).</p>
<p>The length of each dimension index has to match the size of the corresponding array axis.</p>
Expand All @@ -607,19 +607,19 @@ <h2 id="dimensions-and-dimarrays">Dimensions and DimArrays<a class="headerlink"
<div class="highlight"><pre><span></span><code>12×10 DimArray{Float64,2} with dimensions:
Dim{:time} Sampled{DateTime} DateTime(&quot;2001-01-01T00:00:00&quot;):Month(1):DateTime(&quot;2001-12-01T00:00:00&quot;) ForwardOrdered Regular Points,
Dim{:distance} Sampled{Int64} 10:10:100 ForwardOrdered Regular Points
… 80 90 100
2001-01-01T00:00:00 0.496481 0.548987 0.665327
2001-02-01T00:00:00 0.243256 0.515423 0.891191
2001-03-01T00:00:00 0.338874 0.212503 0.512338
2001-04-01T00:00:00 0.792727 0.956862 0.375485
2001-05-01T00:00:00 … 0.781406 0.0970052 0.832692
2001-06-01T00:00:00 0.169179 0.298254 0.00236707
2001-07-01T00:00:00 0.313127 0.191346 0.090902
2001-08-01T00:00:00 0.91972 0.356707 0.459371
2001-09-01T00:00:00 0.428351 0.719913 0.500616
2001-10-01T00:00:00 … 0.497982 0.654562 0.368425
2001-11-01T00:00:00 0.103765 0.825826 0.252257
2001-12-01T00:00:00 0.867363 0.10289 0.5484
… 80 90 100
2001-01-01T00:00:00 0.144225 0.522318 0.503864
2001-02-01T00:00:00 0.217531 0.190943 0.103221
2001-03-01T00:00:00 0.428647 0.279838 0.657452
2001-04-01T00:00:00 0.424215 0.112844 0.772144
2001-05-01T00:00:00 … 0.879794 0.466808 0.455066
2001-06-01T00:00:00 0.139114 0.699241 0.028569
2001-07-01T00:00:00 0.988428 0.413365 0.0556767
2001-08-01T00:00:00 0.638798 0.441855 0.83135
2001-09-01T00:00:00 0.273158 0.428962 0.326151
2001-10-01T00:00:00 … 0.89855 0.0988627 0.547158
2001-11-01T00:00:00 0.0392335 0.988484 0.617519
2001-12-01T00:00:00 0.200409 0.0643057 0.207228
</code></pre></div>
<p>Symbols can be more convenient to use than defining custom dims with <code>@dim</code>, but have some downsides. They don't inherit from a specific <code>Dimension</code> type, so plots will not know what axis to put them on. They also cannot use the basic constructor methods like <code>rand</code> or <code>zeros</code>, as we cannot dispatch on <code>Symbol</code> for Base methods without "type-piracy".</p>
<p><a id='Indexing-the-array-by-name-and-index'></a></p>
Expand All @@ -633,10 +633,10 @@ <h2 id="indexing-the-array-by-name-and-index">Indexing the array by name and ind
X Sampled{Int64} 10:30:100 ForwardOrdered Regular Points,
Ti Sampled{DateTime} DateTime(&quot;2001-01-01T00:00:00&quot;):Month(2):DateTime(&quot;2001-11-01T00:00:00&quot;) ForwardOrdered Regular Points
2001-01-01T00:00:00 … 2001-11-01T00:00:00
10 0.859538 0.65636
40 0.904192 0.0556786
70 0.763109 0.926217
100 0.630614 0.789308
10 0.169857 0.230855
40 0.128775 0.763189
70 0.29575 0.933188
100 0.740371 0.923614
</code></pre></div>
<p>When specifying only one dimension, all elements of the other dimensions are assumed to be included:</p>
<div class="highlight"><pre><span></span><code><span class="n">A</span><span class="p">[</span><span class="n">X</span><span class="p">(</span><span class="mi">1</span><span class="o">:</span><span class="mi">3</span><span class="o">:</span><span class="mi">10</span><span class="p">)]</span>
Expand All @@ -645,10 +645,10 @@ <h2 id="indexing-the-array-by-name-and-index">Indexing the array by name and ind
X Sampled{Int64} 10:30:100 ForwardOrdered Regular Points,
Ti Sampled{DateTime} DateTime(&quot;2001-01-01T00:00:00&quot;):Month(1):DateTime(&quot;2001-12-01T00:00:00&quot;) ForwardOrdered Regular Points
2001-01-01T00:00:00 … 2001-12-01T00:00:00
10 0.859538 0.510701
40 0.904192 0.306779
70 0.763109 0.318395
100 0.630614 0.693722
10 0.169857 0.472778
40 0.128775 0.24027
70 0.29575 0.268263
100 0.740371 0.57815
</code></pre></div>
<div class="admonition info">
<p class="admonition-title">Indexing</p>
Expand Down Expand Up @@ -708,13 +708,13 @@ <h2 id="indexing-performance">Indexing Performance<a class="headerlink" href="#i

<span class="n">println</span><span class="p">(</span><span class="nd">@btime</span><span class="w"> </span><span class="o">$</span><span class="n">A2</span><span class="p">[</span><span class="n">X</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span><span class="w"> </span><span class="n">Y</span><span class="p">(</span><span class="mi">2</span><span class="p">)])</span>
</code></pre></div>
<div class="highlight"><pre><span></span><code> 38.810 ns (0 allocations: 0 bytes)
<div class="highlight"><pre><span></span><code> 49.899 ns (0 allocations: 0 bytes)
1.0
</code></pre></div>
<p>and</p>
<div class="highlight"><pre><span></span><code><span class="n">println</span><span class="p">(</span><span class="nd">@btime</span><span class="w"> </span><span class="n">parent</span><span class="p">(</span><span class="o">$</span><span class="n">A2</span><span class="p">)[</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">])</span>
</code></pre></div>
<div class="highlight"><pre><span></span><code> 4.300 ns (0 allocations: 0 bytes)
<div class="highlight"><pre><span></span><code> 4.799 ns (0 allocations: 0 bytes)
1.0
</code></pre></div>
<p><a id='Specifying-dims-keyword-arguments-with-Dimension'></a></p>
Expand All @@ -726,19 +726,19 @@ <h2 id="specifying-dims-keyword-arguments-with-dimension">Specifying <code>dims<
</code></pre></div>
<div class="highlight"><pre><span></span><code>3×4×1 DimArray{Float64,3} with dimensions: X, Y, Ti
[:, :, 1]
3.32566 2.652 2.14852 2.96339
2.60884 2.25379 2.82214 2.50118
2.46994 2.87252 3.32822 3.29176
1.65591 1.52141 2.95111 3.11444
2.96544 2.98155 2.52007 2.68163
3.75834 2.53126 3.31173 2.61388
</code></pre></div>
<p>This also works in methods from <code>Statistics</code>:</p>
<div class="highlight"><pre><span></span><code><span class="k">using</span><span class="w"> </span><span class="n">Statistics</span>
<span class="n">mean</span><span class="p">(</span><span class="n">A3</span><span class="p">;</span><span class="w"> </span><span class="n">dims</span><span class="o">=</span><span class="n">Ti</span><span class="p">)</span>
</code></pre></div>
<div class="highlight"><pre><span></span><code>3×4×1 DimArray{Float64,3} with dimensions: X, Y, Ti
[:, :, 1]
0.665131 0.530399 0.429704 0.592678
0.521767 0.450759 0.564427 0.500236
0.493988 0.574504 0.665644 0.658353
0.331181 0.304282 0.590223 0.622888
0.593088 0.59631 0.504015 0.536325
0.751667 0.506252 0.662346 0.522776
</code></pre></div>
<p><a id='Methods-where-dims,-dim-types,-or-Symbols-can-be-used-to-indicate-the-array-dimension:'></a></p>
<p><a id='Methods-where-dims,-dim-types,-or-Symbols-can-be-used-to-indicate-the-array-dimension:-1'></a></p>
Expand Down Expand Up @@ -805,8 +805,8 @@ <h2 id="lookuparrays-and-selectors">LookupArrays and Selectors<a class="headerli
X Sampled{Int64} 20:10:30 ForwardOrdered Regular Points,
Ti Sampled{DateTime} DateTime(&quot;2001-05-01T00:00:00&quot;):Month(1):DateTime(&quot;2001-07-01T00:00:00&quot;) ForwardOrdered Regular Points
2001-05-01T00:00:00 … 2001-07-01T00:00:00
20 0.782962 0.190921
30 0.9909 0.810332
20 0.351814 0.498688
30 0.555669 0.169499
</code></pre></div>
<p>To select intervals in DimArrays (e.g. <code>A2</code>) you need to specify <code>dimname=a .. b</code>:</p>
<div class="highlight"><pre><span></span><code><span class="n">A2</span><span class="p">[</span><span class="n">distance</span><span class="o">=</span><span class="mi">12</span><span class="w"> </span><span class="o">..</span><span class="w"> </span><span class="mi">35</span><span class="p">,</span><span class="w"> </span><span class="n">time</span><span class="o">=</span><span class="n">Date</span><span class="p">(</span><span class="mi">2001</span><span class="p">,</span><span class="w"> </span><span class="mi">5</span><span class="p">)</span><span class="w"> </span><span class="o">..</span><span class="w"> </span><span class="n">Date</span><span class="p">(</span><span class="mi">2001</span><span class="p">,</span><span class="w"> </span><span class="mi">7</span><span class="p">)]</span>
Expand All @@ -823,7 +823,7 @@ <h2 id="lookuparrays-and-selectors">LookupArrays and Selectors<a class="headerli
<span class="n">A4</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">rand</span><span class="p">(</span><span class="n">Ti</span><span class="p">(</span><span class="n">timespan</span><span class="p">),</span><span class="w"> </span><span class="n">X</span><span class="p">(</span><span class="mi">10</span><span class="o">:</span><span class="mi">10</span><span class="o">:</span><span class="mi">100</span><span class="p">))</span>
<span class="n">A4</span><span class="p">[</span><span class="n">X</span><span class="p">(</span><span class="n">Near</span><span class="p">(</span><span class="mi">35</span><span class="p">)),</span><span class="w"> </span><span class="n">Ti</span><span class="p">(</span><span class="n">At</span><span class="p">(</span><span class="n">DateTime</span><span class="p">(</span><span class="mi">2001</span><span class="p">,</span><span class="mi">5</span><span class="p">)))]</span>
</code></pre></div>
<div class="highlight"><pre><span></span><code>0.28910712450878795
<div class="highlight"><pre><span></span><code>0.8027180826620864
</code></pre></div>
<p>Without dim wrappers selectors must be in the right order, and specify all axes:</p>
<div class="highlight"><pre><span></span><code><span class="k">using</span><span class="w"> </span><span class="n">Unitful</span>
Expand All @@ -834,20 +834,20 @@ <h2 id="lookuparrays-and-selectors">LookupArrays and Selectors<a class="headerli
Y Sampled{Quantity{Int64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}} (11:10:41) m ForwardOrdered Regular Points
and reference dimensions:
Ti Sampled{Quantity{Int64, 𝐓, Unitful.FreeUnits{(s,), 𝐓, nothing}}} (21:5:21) s ForwardOrdered Regular Points
11 m 0.615863
21 m 0.994817
31 m 0.471477
41 m 0.484082
11 m 0.512658
21 m 0.632215
31 m 0.390402
41 m 0.972882
</code></pre></div>
<p>We can also use Linear indices as in standard <code>Array</code>:</p>
<div class="highlight"><pre><span></span><code><span class="n">A5</span><span class="p">[</span><span class="mi">1</span><span class="o">:</span><span class="mi">5</span><span class="p">]</span>
</code></pre></div>
<div class="highlight"><pre><span></span><code>5-element Vector{Float64}:
0.12700124845474392
0.11599916233850782
0.42604872625496126
0.6590367016831751
0.043959238652969246
0.17921671516292537
0.787615971319035
0.9177146925932862
0.8565132683411395
0.7299733479749307
</code></pre></div>
<p>But unless the <code>DimArray</code> is one dimensional, this will return a regular <code>Array</code>. It is not possible to keep the <code>LookupArray</code> or even <code>Dimension</code>s after linear indexing is used.</p>
<p><a id='LookupArrays-and-traits'></a></p>
Expand Down
Loading

0 comments on commit 3cc04af

Please sign in to comment.