Skip to content

Commit

Permalink
build based on b1d4189
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed Sep 27, 2023
1 parent dc3da31 commit f4ee5f2
Show file tree
Hide file tree
Showing 4 changed files with 196 additions and 196 deletions.
126 changes: 63 additions & 63 deletions previews/PR542/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.227049 0.996389 0.0524242 0.727933 0.620542
0.402302 0.461058 0.0786711 0.477911 0.458939
0.0960822 0.376477 0.982941 0.997075 0.334638
0.309413 0.239642 0.208052 0.502161 0.104704
0.256912 0.0603839 0.777921 0.033172 0.0721566
0.40314 0.926639 0.244585 0.343284 0.398188
0.107355 0.797301 0.81289 0.580513 0.938082
0.0534774 0.153303 0.399264 0.68874 0.325789
0.454216 0.920751 0.637882 0.765131 0.37306
0.425583 0.715209 0.18017 0.204701 0.565643
</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.402302389169122
<div class="highlight"><pre><span></span><code>0.10735547260217504
</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.914523 0.0714386 0.656859 0.644705 0.0882663
0.199871 0.605637 0.299683 0.116575 0.686303
0.0696973 0.390727 0.924696 0.462953 0.64712
0.239893 0.847146 0.407316 0.938753 0.413926
0.988969 0.183317 0.65267 0.177249 0.296906
0.482338 0.34949 0.146381 0.255552 0.219775
0.915978 0.652476 0.456089 0.268651 0.568028
0.368746 0.0249949 0.84809 0.511747 0.486273
0.71239 0.216985 0.634463 0.817175 0.204615
0.667027 0.0596753 0.0514026 0.909288 0.727042
</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.647120088012183
<div class="highlight"><pre><span></span><code>0.48627338290447597
</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.102097 0.658062
20 0.674996 0.114785
30 0.638572 0.458142
40 0.857048 0.989975
50 0.341971 … 0.320274
60 0.587276 0.0420102
70 0.375594 0.371984
80 0.618184 0.597631
90 0.744212 0.17168
100 0.242758 … 0.974841
10 0.707503 0.76825
20 0.167955 0.866952
30 0.359916 0.684745
40 0.704763 0.948691
50 0.504203 … 0.939797
60 0.766141 0.0532124
70 0.334315 0.174939
80 0.800847 0.835635
90 0.898545 0.0163581
100 0.0722643 … 0.847381
</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.853812 0.30883 0.766298
2001-02-01T00:00:00 0.712404 0.289242 0.250616
2001-03-01T00:00:00 0.937353 0.205867 0.758864
2001-04-01T00:00:00 0.625327 0.309296 0.560046
2001-05-01T00:00:00 … 0.964716 0.0158235 0.00563723
2001-06-01T00:00:00 0.744213 0.69638 0.779653
2001-07-01T00:00:00 0.998621 0.174617 0.0739157
2001-08-01T00:00:00 0.841774 0.0923788 0.925965
2001-09-01T00:00:00 0.360667 0.58683 0.256237
2001-10-01T00:00:00 … 0.619454 0.955172 0.342898
2001-11-01T00:00:00 0.485499 0.0181293 0.759003
2001-12-01T00:00:00 0.694465 0.627173 0.0603817
… 80 90 100
2001-01-01T00:00:00 0.729117 0.826835 0.515699
2001-02-01T00:00:00 0.741958 0.578919 0.511525
2001-03-01T00:00:00 0.318624 0.0319162 0.153849
2001-04-01T00:00:00 0.042836 0.621021 0.18357
2001-05-01T00:00:00 … 0.104172 0.610821 0.425051
2001-06-01T00:00:00 0.510674 0.989495 0.0598336
2001-07-01T00:00:00 0.384069 0.881949 0.905395
2001-08-01T00:00:00 0.505954 0.315908 0.849816
2001-09-01T00:00:00 0.201468 0.0729327 0.783553
2001-10-01T00:00:00 … 0.629445 0.644866 0.905105
2001-11-01T00:00:00 0.232548 0.918845 0.190193
2001-12-01T00:00:00 0.0135716 0.520319 0.121795
</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.102097 0.245062
40 0.857048 0.187552
70 0.375594 0.737626
100 0.242758 0.300589
10 0.707503 0.856036
40 0.704763 0.218042
70 0.334315 0.925995
100 0.0722643 0.975471
</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.102097 0.658062
40 0.857048 0.989975
70 0.375594 0.371984
100 0.242758 0.974841
10 0.707503 0.76825
40 0.704763 0.948691
70 0.334315 0.174939
100 0.0722643 0.847381
</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> 46.411 ns (0 allocations: 0 bytes)
<div class="highlight"><pre><span></span><code> 40.625 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.800 ns (0 allocations: 0 bytes)
<div class="highlight"><pre><span></span><code> 4.000 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.00226 3.52337 2.42209 2.13854
1.6466 2.91362 2.42247 3.1457
2.01045 1.57995 2.43009 3.77207
2.59996 1.92902 2.98214 2.96037
2.40896 1.953 1.29279 2.04543
1.30904 2.98038 2.34355 1.43971
</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.400451 0.704674 0.484418 0.427709
0.329319 0.582723 0.484495 0.62914
0.40209 0.31599 0.486019 0.754414
0.519991 0.385804 0.596428 0.592074
0.481792 0.3906 0.258557 0.409086
0.261809 0.596077 0.468709 0.287942
</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.477551 0.973581
30 0.019119 0.0423076
20 0.585552 0.626904
30 0.113518 0.833073
</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.8779667492952091
<div class="highlight"><pre><span></span><code>0.48292894388602203
</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.445569
21 m 0.3644
31 m 0.246284
41 m 0.780096
11 m 0.0464393
21 m 0.115483
31 m 0.591312
41 m 0.738719
</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.7731505284054422
0.7575173106507627
0.7326410685463511
0.5428780485800679
0.6195447254161375
0.052960839404580407
0.35304726407543974
0.7907012692027247
0.03667616290196363
0.8181641114727453
</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 f4ee5f2

Please sign in to comment.