Skip to content

Commit

Permalink
build based on e3d4a69
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed Sep 27, 2023
1 parent f4ee5f2 commit 87748e9
Show file tree
Hide file tree
Showing 4 changed files with 195 additions and 195 deletions.
124 changes: 62 additions & 62 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.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
0.224804 0.117058 0.44345 0.568328 0.0235011
0.717238 0.0302223 0.945995 0.115954 0.857946
0.0854091 0.214175 0.827286 0.0381257 0.945226
0.775363 0.0781562 0.952343 0.628572 0.796343
0.119159 0.233274 0.827165 0.917192 0.540049
</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.10735547260217504
<div class="highlight"><pre><span></span><code>0.7172380520852902
</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.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
0.697371 0.330722 0.354536 0.0474699 0.295169
0.584075 0.0945093 0.978462 0.318677 0.28179
0.691732 0.0959486 0.214853 0.780836 0.911502
0.628111 0.932264 0.766494 0.771844 0.589091
0.087503 0.456247 0.463265 0.453528 0.731271
</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.48627338290447597
<div class="highlight"><pre><span></span><code>0.9115024405815143
</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.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
10 0.268285 0.063876
20 0.135592 0.710228
30 0.896544 0.0778282
40 0.262642 0.180784
50 0.939728 … 0.923708
60 0.926714 0.217524
70 0.671016 0.76913
80 0.0371024 0.462047
90 0.633063 0.629707
100 0.828244 … 0.718469
</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.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
2001-01-01T00:00:00 0.559245 0.458656 0.924954
2001-02-01T00:00:00 0.948169 0.67631 0.884507
2001-03-01T00:00:00 0.386628 0.282949 0.859587
2001-04-01T00:00:00 0.925091 0.980403 0.267938
2001-05-01T00:00:00 … 0.0668847 0.528337 0.507813
2001-06-01T00:00:00 0.969911 0.54733 0.386702
2001-07-01T00:00:00 0.561792 0.1696 0.527495
2001-08-01T00:00:00 0.567188 0.0738264 0.376395
2001-09-01T00:00:00 0.44949 0.98366 0.752974
2001-10-01T00:00:00 … 0.927745 0.636661 0.147688
2001-11-01T00:00:00 0.298851 0.368344 0.266593
2001-12-01T00:00:00 0.0612054 0.981123 0.513454
</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.707503 0.856036
40 0.704763 0.218042
70 0.334315 0.925995
100 0.0722643 0.975471
10 0.268285 0.331898
40 0.262642 0.373491
70 0.671016 0.837362
100 0.828244 0.420671
</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.707503 0.76825
40 0.704763 0.948691
70 0.334315 0.174939
100 0.0722643 0.847381
10 0.268285 0.063876
40 0.262642 0.180784
70 0.671016 0.76913
100 0.828244 0.718469
</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> 40.625 ns (0 allocations: 0 bytes)
<div class="highlight"><pre><span></span><code> 37.818 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.000 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.59996 1.92902 2.98214 2.96037
2.40896 1.953 1.29279 2.04543
1.30904 2.98038 2.34355 1.43971
2.69323 2.44441 2.29509 1.6286
2.98415 3.19152 2.56511 3.18605
1.33774 3.23467 3.08125 3.00202
</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.519991 0.385804 0.596428 0.592074
0.481792 0.3906 0.258557 0.409086
0.261809 0.596077 0.468709 0.287942
0.538645 0.488883 0.459018 0.325719
0.596829 0.638305 0.513022 0.63721
0.267548 0.646934 0.616249 0.600404
</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.585552 0.626904
30 0.113518 0.833073
20 0.974271 0.0439778
30 0.0137022 0.361386
</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.48292894388602203
<div class="highlight"><pre><span></span><code>0.9502053067373577
</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.0464393
21 m 0.115483
31 m 0.591312
41 m 0.738719
11 m 0.0465835
21 m 0.646732
31 m 0.641901
41 m 0.341585
</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.052960839404580407
0.35304726407543974
0.7907012692027247
0.03667616290196363
0.8181641114727453
0.8510169747088009
0.6606244757373735
0.5290433885038783
0.3392758852716278
0.8745209683096743
</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 87748e9

Please sign in to comment.