Skip to content

Commit

Permalink
build based on 63b6924
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed Sep 14, 2023
1 parent 84fae9d commit 5a05fce
Show file tree
Hide file tree
Showing 4 changed files with 190 additions and 190 deletions.
124 changes: 62 additions & 62 deletions previews/PR528/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.124874 0.566452 0.913496 0.503004 0.943575
0.65846 0.145551 0.680193 0.767833 0.274717
0.754621 0.972466 0.757034 0.549937 0.0993212
0.856564 0.355987 0.283302 0.654112 0.311087
0.903285 0.856681 0.129552 0.112247 0.551085
0.597804 0.918939 0.777856 0.00586034 0.699214
0.414462 0.77739 0.150842 0.422255 0.832226
0.935682 0.89355 0.637625 0.212111 0.229073
0.969635 0.175979 0.763681 0.326808 0.388884
0.79129 0.35433 0.473844 0.855945 0.0213033
</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.6584600731758927
<div class="highlight"><pre><span></span><code>0.4144622040428879
</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.699059 0.7846 0.668121 0.615491 0.777982
0.670299 0.894482 0.712696 0.742939 0.239314
0.499818 0.109764 0.0703531 0.495425 0.450842
0.302298 0.662751 0.0455818 0.506814 0.335471
0.370046 0.50841 0.350326 0.863748 0.295432
0.437755 0.170615 0.104893 0.679601 0.74709
0.274344 0.20215 0.713324 0.296537 0.864095
0.511695 0.655711 0.23675 0.885893 0.982287
0.602673 0.51226 0.778458 0.876964 0.584909
0.0711301 0.0928026 0.0648247 0.343291 0.446488
</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.4508424181357401
<div class="highlight"><pre><span></span><code>0.9822870947716844
</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.542112 0.826426
20 0.0792752 0.647033
30 0.529978 0.178508
40 0.257827 0.00017745
50 0.143285 … 0.869402
60 0.787206 0.0859712
70 0.125833 0.843983
80 0.00607514 0.792338
90 0.304529 0.29552
100 0.483298 … 0.580883
10 0.651256 0.244734
20 0.378312 0.713528
30 0.390155 0.590736
40 0.396588 0.121892
50 0.161289 … 0.373574
60 0.713147 0.218157
70 0.390631 0.792741
80 0.268588 0.0341997
90 0.080967 0.606762
100 0.0569555 … 0.131921
</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 @@ -608,18 +608,18 @@ <h2 id="dimensions-and-dimarrays">Dimensions and DimArrays<a class="headerlink"
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.546073 0.776708 0.475906
2001-02-01T00:00:00 0.666282 0.248009 0.923467
2001-03-01T00:00:00 0.349775 0.883104 0.039746
2001-04-01T00:00:00 0.471359 0.63521 0.246456
2001-05-01T00:00:00 … 0.770968 0.372262 0.548898
2001-06-01T00:00:00 0.340405 0.620083 0.562722
2001-07-01T00:00:00 0.468234 0.624977 0.351428
2001-08-01T00:00:00 0.865936 0.263336 0.482265
2001-09-01T00:00:00 0.483682 0.176646 0.978312
2001-10-01T00:00:00 … 0.680192 0.973174 0.276208
2001-11-01T00:00:00 0.141882 0.0246634 0.768738
2001-12-01T00:00:00 0.469621 0.749869 0.515705
2001-01-01T00:00:00 0.922781 0.930888 0.203666
2001-02-01T00:00:00 0.764316 0.676847 0.0445599
2001-03-01T00:00:00 0.253754 0.626935 0.666934
2001-04-01T00:00:00 0.760605 0.755329 0.79325
2001-05-01T00:00:00 … 0.175144 0.471452 0.540445
2001-06-01T00:00:00 0.815999 0.514723 0.670398
2001-07-01T00:00:00 0.850374 0.0383241 0.751366
2001-08-01T00:00:00 0.759525 0.140204 0.246097
2001-09-01T00:00:00 0.324669 0.466258 0.157547
2001-10-01T00:00:00 … 0.810663 0.875189 0.721374
2001-11-01T00:00:00 0.665745 0.130457 0.454023
2001-12-01T00:00:00 0.682555 0.979643 0.916652
</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.542112 0.707524
40 0.257827 0.482177
70 0.125833 0.189332
100 0.483298 0.445263
10 0.651256 0.0823241
40 0.396588 0.745527
70 0.390631 0.755036
100 0.0569555 0.859614
</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.542112 0.826426
40 0.257827 0.00017745
70 0.125833 0.843983
100 0.483298 0.580883
10 0.651256 0.244734
40 0.396588 0.121892
70 0.390631 0.792741
100 0.0569555 0.131921
</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.655 ns (0 allocations: 0 bytes)
<div class="highlight"><pre><span></span><code> 45.859 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.400 ns (0 allocations: 0 bytes)
<div class="highlight"><pre><span></span><code> 4.800 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]
2.5247 1.75441 2.19061 2.4184
0.868353 2.72675 3.0262 2.49353
2.18482 2.57632 1.92604 3.68636
2.38554 1.31858 2.50474 3.74967
3.80839 2.50415 2.61911 2.50342
1.81406 2.05073 2.46407 1.9665
</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.50494 0.350882 0.438123 0.483681
0.173671 0.54535 0.60524 0.498706
0.436964 0.515264 0.385208 0.737272
0.477108 0.263717 0.500947 0.749934
0.761678 0.500831 0.523823 0.500683
0.362812 0.410146 0.492814 0.393299
</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.494727 0.543278
30 0.00466102 0.955162
20 0.258765 0.323051
30 0.792075 0.723141
</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.8201236140901906
<div class="highlight"><pre><span></span><code>0.24446794818390738
</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.223668
21 m 0.737353
31 m 0.342295
41 m 0.550501
11 m 0.722451
21 m 0.577807
31 m 0.518526
41 m 0.390371
</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.8926603158925618
0.4029306517840252
0.22671898658265388
0.7936924607105116
0.008231268361020616
0.20422204917824582
0.8654647982397592
0.48475509864346866
0.24971920721371743
0.9293696371119912
</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 5a05fce

Please sign in to comment.