Skip to content

Commit

Permalink
Factor out transpose!.
Browse files Browse the repository at this point in the history
  • Loading branch information
orenbenkiki committed Jun 1, 2024
1 parent f508663 commit 86ad201
Show file tree
Hide file tree
Showing 13 changed files with 267 additions and 185 deletions.
2 changes: 1 addition & 1 deletion docs/v0.1.0/.documenter-siteinfo.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2024-06-01T14:35:03","documenter_version":"1.4.1"}}
{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2024-06-01T18:28:22","documenter_version":"1.4.1"}}
18 changes: 12 additions & 6 deletions docs/v0.1.0/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1712,6 +1712,12 @@ <h1 id="Index">
</a>
</li>
<li>
<a href="matrix_layouts.html#Daf.MatrixLayouts.copy_array">
<code>Daf.MatrixLayouts.copy_array
</code>
</a>
</li>
<li>
<a href="messages.html#Daf.MatrixLayouts.depict">
<code>Daf.MatrixLayouts.depict
</code>
Expand Down Expand Up @@ -1868,12 +1874,6 @@ <h1 id="Index">
</a>
</li>
<li>
<a href="read_only.html#Daf.ReadOnly.copy_array">
<code>Daf.ReadOnly.copy_array
</code>
</a>
</li>
<li>
<a href="read_only.html#Daf.ReadOnly.is_read_only_array">
<code>Daf.ReadOnly.is_read_only_array
</code>
Expand Down Expand Up @@ -2162,6 +2162,12 @@ <h1 id="Index">
</a>
</li>
<li>
<a href="matrix_layouts.html#LinearAlgebra.transpose!">
<code>LinearAlgebra.transpose!
</code>
</a>
</li>
<li>
<a href="computations.html#Daf.Computations.@computation">
<code>Daf.Computations.@computation
</code>
Expand Down
99 changes: 98 additions & 1 deletion docs/v0.1.0/matrix_layouts.html
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,10 @@ <h2 id="Changing-layout">
</strong>, summing the UMIs of a gene is fast, and summing the UMIs of a cell is slow.
</p>
<p>In contrast,
<a href="matrix_layouts.html#LinearAlgebra.transpose!">
<code>transpose!
</code> (with a
</code>
</a> (with a
<code>!
</code>) is slow; it creates a rearranged copy of the data, also returning a matrix whose rows are genes and columns are cells, but this time, in column-major layout. Therefore, in this case summing the UMIs of a gene will be slow, and summing the UMIs of a cell will be fast.
</p>
Expand Down Expand Up @@ -650,6 +652,89 @@ <h2 id="Changing-layout">
</div>
</section>
</article>
<article class="docstring">
<header>
<a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring">
</a>
<a class="docstring-binding" id="LinearAlgebra.transpose!" href="#LinearAlgebra.transpose!">
<code>LinearAlgebra.transpose!
</code>
</a>
<span class="docstring-category">Function
</span>
</header>
<section>
<div>
<pre>
<code class="language-julia hljs">transpose!(matrix::AbstractMatrix)::AbstractMatrix
transpose!(matrix::NamedMatrix)::NamedMatrix
</code>
</pre>
<p>This is a shorthand for
<code>LinearAlgebra.transpose!(similar(transpose(m)), m)
</code>. That is, this will return a transpose of a matrix, but instead of simply using a zero-copy wrapper, it actually rearranges the data. See
<a href="matrix_layouts.html#Daf.MatrixLayouts.relayout!">
<code>relayout!
</code>
</a>.
</p>
</div>
</section>
</article>
<article class="docstring">
<header>
<a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring">
</a>
<a class="docstring-binding" id="Daf.MatrixLayouts.copy_array" href="#Daf.MatrixLayouts.copy_array">
<code>Daf.MatrixLayouts.copy_array
</code>
</a>
<span class="docstring-category">Function
</span>
</header>
<section>
<div>
<pre>
<code class="language-julia hljs">copy_array(array::AbstractArray)::AbstractArray
</code>
</pre>
<p>Create a mutable copy of an array. This differs from
<code>Base.copy
</code> in the following:
</p>
<ul>
<li>Copying a read-only array is a mutable array. In contrast, both
<code>Base.copy
</code> and
<code>Base.deepcopy
</code> of a read-only array will return a read-only array, which is technically correct, but is rather pointless for
<code>Base.copy
</code>.
</li>
<li>Copying will preserve the layout of the data; for example, copying a
<code>Transpose
</code> array is still a
<code>Transpose
</code> array. In contrast, while
<code>Base.deepcopy
</code> will preserve the layout,
<code>Base.copy
</code> will silently
<a href="matrix_layouts.html#Daf.MatrixLayouts.relayout!">
<code>relayout!
</code>
</a> the matrix, which is both expensive and confusing.
</li>
<li>Copying a sparse vector or matrix gives the same type of sparse array or matrix. Copying anything else gives a simple dense array regardless of the original type. This is done because a
<code>deepcopy
</code> of
<code>PyArray
</code> will still share the underlying buffer. Sigh.
</li>
</ul>
</div>
</section>
</article>
<h2 id="Ensuring-code-efficiency">
<a class="docs-heading-anchor" href="#Ensuring-code-efficiency">Ensuring code efficiency
</a>
Expand Down Expand Up @@ -789,6 +874,12 @@ <h2 id="Index">
</a>
</li>
<li>
<a href="matrix_layouts.html#Daf.MatrixLayouts.copy_array">
<code>Daf.MatrixLayouts.copy_array
</code>
</a>
</li>
<li>
<a href="matrix_layouts.html#Daf.MatrixLayouts.inefficient_action_handler">
<code>Daf.MatrixLayouts.inefficient_action_handler
</code>
Expand Down Expand Up @@ -830,6 +921,12 @@ <h2 id="Index">
</code>
</a>
</li>
<li>
<a href="matrix_layouts.html#LinearAlgebra.transpose!">
<code>LinearAlgebra.transpose!
</code>
</a>
</li>
</ul>
</article>
<nav class="docs-footer">
Expand Down
Binary file modified docs/v0.1.0/objects.inv
Binary file not shown.
64 changes: 0 additions & 64 deletions docs/v0.1.0/read_only.html
Original file line number Diff line number Diff line change
Expand Up @@ -353,64 +353,6 @@ <h2 id="Arrays">
</div>
</section>
</article>
<article class="docstring">
<header>
<a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring">
</a>
<a class="docstring-binding" id="Daf.ReadOnly.copy_array" href="#Daf.ReadOnly.copy_array">
<code>Daf.ReadOnly.copy_array
</code>
</a>
<span class="docstring-category">Function
</span>
</header>
<section>
<div>
<pre>
<code class="language-julia hljs">copy_array(array::AbstractArray)::AbstractArray
</code>
</pre>
<p>Create a mutable copy of an array. This differs from
<code>Base.copy
</code> in the following:
</p>
<ul>
<li>Copying a
<a href="read_only.html#Daf.ReadOnly.read_only_array">
<code>read_only_array
</code>
</a> is a mutable array. In contrast, both
<code>Base.copy
</code> and
<code>Base.deepcopy
</code> of a read-only array will return a read-only array, which is technically correct, but is rather pointless for
<code>Base.copy
</code>.
</li>
<li>Copying will preserve the layout of the data; for example, copying a
<code>Transpose
</code> array is still a
<code>Transpose
</code> array. In contrast, while
<code>Base.deepcopy
</code> will preserve the layout,
<code>Base.copy
</code> will silently
<a href="matrix_layouts.html#Daf.MatrixLayouts.relayout!">
<code>relayout!
</code>
</a> the matrix, which is both expensive and confusing.
</li>
<li>Copying a sparse vector or matrix gives the same type of sparse array or matrix. Copying anything else gives a simple dense array regardless of the original type. This is done because a
<code>deepcopy
</code> of
<code>PyArray
</code> will still share the underlying buffer. Sigh.
</li>
</ul>
</div>
</section>
</article>
<h2 id="Data">
<a class="docs-heading-anchor" href="#Data">Data
</a>
Expand Down Expand Up @@ -539,12 +481,6 @@ <h2 id="Index">
</a>
</li>
<li>
<a href="read_only.html#Daf.ReadOnly.copy_array">
<code>Daf.ReadOnly.copy_array
</code>
</a>
</li>
<li>
<a href="read_only.html#Daf.ReadOnly.is_read_only_array">
<code>Daf.ReadOnly.is_read_only_array
</code>
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/search_index.js

Large diffs are not rendered by default.

Loading

0 comments on commit 86ad201

Please sign in to comment.