Skip to content

Commit

Permalink
build based on b43bc14
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed Oct 19, 2023
1 parent 23f1c8b commit f8e169c
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.143229 0.0192974 0.958135 0.78502 0.303305
0.612886 0.617126 0.416803 0.0114008 0.811446
0.755186 0.776247 0.126391 0.243607 0.938471
0.366481 0.880473 0.362914 0.588401 0.594311
0.499708 0.508036 0.993475 0.0391336 0.254341
0.503869 0.275736 0.926133 0.618131 0.16689
0.700115 0.784351 0.604868 0.743023 0.225315
0.437163 0.916276 0.532677 0.695216 0.783893
0.190303 0.0836825 0.54542 0.0453942 0.490944
0.398892 0.736444 0.91336 0.840066 0.0971989
</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.6128862336600797
<div class="highlight"><pre><span></span><code>0.700114952090408
</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.227386 0.576795 0.0869421 0.469209 0.390442
0.165903 0.522416 0.643993 0.181856 0.443165
0.466376 0.972485 0.13263 0.0381917 0.327946
0.812446 0.177049 0.13688 0.70596 0.906024
0.901373 0.532501 0.464158 0.643733 0.833171
0.802629 0.393003 0.154407 0.856437 0.138739
0.842846 0.642617 0.228715 0.427013 0.710523
0.314275 0.371998 0.978115 0.493682 0.039541
0.32383 0.699193 0.924833 0.43576 0.263315
0.0748082 0.998075 0.0146854 0.0686442 0.793861
</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.3279461486213625
<div class="highlight"><pre><span></span><code>0.03954097241973964
</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.236099 0.94024
20 0.615621 0.580401
30 0.0407551 0.149335
40 0.814908 0.129276
50 0.666271 … 0.576069
60 0.556364 0.818782
70 0.957944 0.433324
80 0.98186 0.21948
90 0.658177 0.845586
100 0.502958 … 0.76605
10 0.420687 0.385807
20 0.207853 0.721167
30 0.775152 0.257362
40 0.39978 0.578833
50 0.664924 … 0.634454
60 0.686958 0.462935
70 0.710826 0.188422
80 0.509493 0.584671
90 0.433858 0.615475
100 0.364838 … 0.756591
</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.897789 0.62166 0.792711
2001-02-01T00:00:00 0.628483 0.458674 0.169205
2001-03-01T00:00:00 0.375249 0.981737 0.613014
2001-04-01T00:00:00 0.996957 0.705659 0.51958
2001-05-01T00:00:00 … 0.689874 0.98796 0.735365
2001-06-01T00:00:00 0.0475967 0.387731 0.750493
2001-07-01T00:00:00 0.673785 0.360993 0.565112
2001-08-01T00:00:00 0.444112 0.518989 0.0368685
2001-09-01T00:00:00 0.656753 0.903347 0.86811
2001-10-01T00:00:00 … 0.940707 0.155812 0.855063
2001-11-01T00:00:00 0.881618 0.822486 0.386584
2001-12-01T00:00:00 0.0557417 0.867183 0.393709
… 80 90 100
2001-01-01T00:00:00 0.751224 0.23627 0.946337
2001-02-01T00:00:00 0.632935 0.867657 0.31781
2001-03-01T00:00:00 0.870634 0.837257 0.710945
2001-04-01T00:00:00 0.25736 0.175362 0.347015
2001-05-01T00:00:00 … 0.626109 0.00371113 0.702871
2001-06-01T00:00:00 0.138879 0.833094 0.544801
2001-07-01T00:00:00 0.707422 0.544657 0.885108
2001-08-01T00:00:00 0.322254 0.871084 0.45254
2001-09-01T00:00:00 0.604385 0.276956 0.877198
2001-10-01T00:00:00 … 0.197187 0.214327 0.836328
2001-11-01T00:00:00 0.824173 0.529697 0.707142
2001-12-01T00:00:00 0.400035 0.29578 0.679653
</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.236099 0.709812
40 0.814908 0.282944
70 0.957944 0.862705
100 0.502958 0.905936
10 0.420687 0.480238
40 0.39978 0.397884
70 0.710826 0.897129
100 0.364838 0.575667
</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.236099 0.94024
40 0.814908 0.129276
70 0.957944 0.433324
100 0.502958 0.76605
10 0.420687 0.385807
40 0.39978 0.578833
70 0.710826 0.188422
100 0.364838 0.756591
</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> 44.443 ns (0 allocations: 0 bytes)
<div class="highlight"><pre><span></span><code> 46.100 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.399 ns (0 allocations: 0 bytes)
<div class="highlight"><pre><span></span><code> 4.200 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.13068 2.14002 2.88237 1.81191
2.75808 2.12625 2.42797 1.82773
2.78925 2.94404 2.29208 2.56536
3.29745 3.00654 2.83611 2.45304
2.77578 1.75159 1.47938 3.28179
2.08213 4.08917 0.825031 2.27091
</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.426137 0.428005 0.576474 0.362382
0.551616 0.42525 0.485593 0.365547
0.55785 0.588808 0.458416 0.513073
0.659491 0.601307 0.567221 0.490607
0.555155 0.350318 0.295876 0.656358
0.416426 0.817834 0.165006 0.454182
</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.610293 0.899892
30 0.126644 0.365532
20 0.548025 0.301189
30 0.918324 0.00994857
</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.7787176150085567
<div class="highlight"><pre><span></span><code>0.37627351584970414
</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.0582388
21 m 0.801343
31 m 0.605246
41 m 0.857819
11 m 0.66928
21 m 0.728834
31 m 0.129924
41 m 0.340435
</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.4921948189641109
0.11134082963346059
0.27357175645708187
0.04667162057068752
0.8070256388468255
0.9553499879545774
0.6287715555755742
0.8265074231952406
0.3349074917411822
0.6311953753076488
</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 f8e169c

Please sign in to comment.