Skip to content

Commit

Permalink
build based on b9162e1
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed Oct 25, 2023
1 parent 269bab3 commit 3351c5f
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.836353 0.45135 0.575665 0.653012 0.299386
0.695025 0.108935 0.62009 0.0619384 0.929028
0.558102 0.272767 0.314651 0.284842 0.59494
0.755206 0.665397 0.612796 0.559803 0.884249
0.0150781 0.547789 0.148028 0.305899 0.430283
0.886825 0.663113 0.345006 0.708647 0.500141
0.62562 0.0808804 0.952396 0.460546 0.294199
0.337137 0.426358 0.810977 0.0109063 0.44375
0.352569 0.169553 0.0636564 0.203524 0.412396
0.531725 0.653873 0.226694 0.591185 0.852786
</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.6950248785011353
<div class="highlight"><pre><span></span><code>0.6256200563896996
</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.366278 0.756602 0.766427 0.0794801 0.637914
0.473748 0.999974 0.0870332 0.22284 0.133033
0.467166 0.0737367 0.121948 0.937767 0.408601
0.816214 0.142759 0.613191 0.29757 0.545202
0.933806 0.858118 0.42064 0.153298 0.251866
0.576886 0.030847 0.578748 0.392428 0.231838
0.53283 0.599682 0.816367 0.275449 0.617538
0.885813 0.734413 0.382544 0.909043 0.602641
0.484542 0.719778 0.853476 0.645042 0.424303
0.0423277 0.514944 0.713075 0.13486 0.993104
</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.408601101514511
<div class="highlight"><pre><span></span><code>0.6026408264540775
</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.0639753 0.351287
20 0.552182 0.572392
30 0.933442 0.236315
40 0.302845 0.859055
50 0.962743 … 0.882027
60 0.680194 0.712976
70 0.102639 0.365647
80 0.395256 0.233862
90 0.0278574 0.789416
100 0.237418 … 0.621981
10 0.303582 0.840724
20 0.19608 0.562445
30 0.477187 0.409426
40 0.463664 0.647866
50 0.62124 … 0.863681
60 0.321363 0.317091
70 0.674344 0.172593
80 0.357305 0.692362
90 0.109979 0.96843
100 0.851717 … 0.806106
</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
10 90 100
2001-01-01T00:00:00 0.579009 0.383041 0.864481
2001-02-01T00:00:00 0.48559 0.653672 0.91889
2001-03-01T00:00:00 0.148585 0.486856 0.141925
2001-04-01T00:00:00 0.907284 0.246276 0.986651
2001-05-01T00:00:00 0.0397221 … 0.767109 0.60886
2001-06-01T00:00:00 0.710367 0.461739 0.668262
2001-07-01T00:00:00 0.438094 0.30205 0.274517
2001-08-01T00:00:00 0.957233 0.727946 0.00474724
2001-09-01T00:00:00 0.676977 0.819632 0.414498
2001-10-01T00:00:00 0.674454 … 0.261293 0.0503105
2001-11-01T00:00:00 0.832186 0.323212 0.197363
2001-12-01T00:00:00 0.206737 0.450643 0.425329
… 80 90 100
2001-01-01T00:00:00 0.0371997 0.616577 0.949363
2001-02-01T00:00:00 0.0389439 0.0976109 0.763285
2001-03-01T00:00:00 0.218997 0.326986 0.338424
2001-04-01T00:00:00 0.736101 0.699496 0.759248
2001-05-01T00:00:00 … 0.108538 0.252382 0.0349931
2001-06-01T00:00:00 0.132771 0.955354 0.437894
2001-07-01T00:00:00 0.814785 0.365565 0.0805921
2001-08-01T00:00:00 0.869641 0.248431 0.259953
2001-09-01T00:00:00 0.108951 0.894475 0.390745
2001-10-01T00:00:00 … 0.28933 0.0624734 0.541197
2001-11-01T00:00:00 0.644343 0.882143 0.55846
2001-12-01T00:00:00 0.77787 0.434187 0.269151
</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.0639753 0.053148
40 0.302845 0.614343
70 0.102639 0.611319
100 0.237418 0.924576
10 0.303582 0.990464
40 0.463664 0.830925
70 0.674344 0.672033
100 0.851717 0.984175
</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.0639753 0.351287
40 0.302845 0.859055
70 0.102639 0.365647
100 0.237418 0.621981
10 0.303582 0.840724
40 0.463664 0.647866
70 0.674344 0.172593
100 0.851717 0.806106
</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> 47.367 ns (0 allocations: 0 bytes)
<div class="highlight"><pre><span></span><code> 41.717 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.799 ns (0 allocations: 0 bytes)
<div class="highlight"><pre><span></span><code> 3.700 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]
1.65227 3.67499 2.03102 3.56559
3.02424 2.47076 1.86329 2.54639
2.39264 3.38933 2.79734 1.52628
2.79639 1.75784 1.71082 2.92937
2.48068 3.55639 3.50524 2.04383
2.03497 2.67365 2.54217 1.89146
</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.330453 0.734998 0.406205 0.713118
0.604848 0.494151 0.372657 0.509277
0.478527 0.677866 0.559469 0.305256
0.559277 0.351569 0.342165 0.585875
0.496136 0.711278 0.701048 0.408767
0.406994 0.534731 0.508434 0.378292
</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.853382 0.275164
30 0.0538397 0.582997
20 0.720264 0.0711878
30 0.132233 0.205478
</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.38752630808950395
<div class="highlight"><pre><span></span><code>0.5142996467518247
</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.967576
21 m 0.585845
31 m 0.706401
41 m 0.856619
11 m 0.572813
21 m 0.117864
31 m 0.366785
41 m 0.667637
</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.1762924454405561
0.41334885753045114
0.3919686493325456
0.8640550872476634
0.5511582069554256
0.4166986159000604
0.1819228914569201
0.39517839401716015
0.20620579851920973
0.9430388464407778
</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 3351c5f

Please sign in to comment.