Skip to content

Commit

Permalink
Add axis_indices.
Browse files Browse the repository at this point in the history
  • Loading branch information
orenbenkiki committed Jun 15, 2024
1 parent 485cfd0 commit a133c7f
Show file tree
Hide file tree
Showing 36 changed files with 92 additions and 32 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-12T22:01:58","documenter_version":"1.4.1"}}
{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-06-15T18:31:50","documenter_version":"1.4.1"}}
2 changes: 1 addition & 1 deletion docs/v0.1.0/adapters.html
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/anndata_format.html
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/chains.html
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/computations.html
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/concat.html
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/contracts.html
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/copies.html
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/example_data.html
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/files_format.html
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/formats.html
Original file line number Diff line number Diff line change
Expand Up @@ -2295,7 +2295,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/generic_functions.html
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/generic_locks.html
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/generic_logging.html
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/generic_types.html
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/groups.html
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/h5df_format.html
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
8 changes: 7 additions & 1 deletion docs/v0.1.0/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1928,6 +1928,12 @@ <h1 id="Index">
</a>
</li>
<li>
<a href="readers.html#Daf.Readers.axis_indices">
<code>Daf.Readers.axis_indices
</code>
</a>
</li>
<li>
<a href="readers.html#Daf.Readers.axis_length">
<code>Daf.Readers.axis_length
</code>
Expand Down Expand Up @@ -2246,7 +2252,7 @@ <h1 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/matrix_layouts.html
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/memory_format.html
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/messages.html
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
Binary file modified docs/v0.1.0/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/v0.1.0/operations.html
Original file line number Diff line number Diff line change
Expand Up @@ -1560,7 +1560,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/queries.html
Original file line number Diff line number Diff line change
Expand Up @@ -4209,7 +4209,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/read_only.html
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
30 changes: 29 additions & 1 deletion docs/v0.1.0/readers.html
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,28 @@ <h1 id="Readers-axes">
<header>
<a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring">
</a>
<a class="docstring-binding" id="Daf.Readers.axis_indices" href="#Daf.Readers.axis_indices">
<code>Daf.Readers.axis_indices
</code>
</a>
<span class="docstring-category">Function
</span>
</header>
<section>
<div>
<pre>
<code class="language-julia hljs">function axis_indices(daf::DafReader, axis::AbstractString, entries::AbstractVector{&lt;:AbstractString})::AbstractVector{&lt;:Integer}
</code>
</pre>
<p>Return a vector of the indices of the entries in the axis.
</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.Readers.axis_length" href="#Daf.Readers.axis_length">
<code>Daf.Readers.axis_length
</code>
Expand Down Expand Up @@ -1213,6 +1235,12 @@ <h2 id="Index">
</a>
</li>
<li>
<a href="readers.html#Daf.Readers.axis_indices">
<code>Daf.Readers.axis_indices
</code>
</a>
</li>
<li>
<a href="readers.html#Daf.Readers.axis_length">
<code>Daf.Readers.axis_length
</code>
Expand Down Expand Up @@ -1347,7 +1375,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/reconstruction.html
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/registry.html
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/search_index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/v0.1.0/storage_types.html
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/tokens.html
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/views.html
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
2 changes: 1 addition & 1 deletion docs/v0.1.0/writers.html
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ <h2 id="Index">
<hr/>
<p>This document was generated with
<a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl
</a> version 1.4.1. Using Julia version 1.10.0.
</a> version 1.4.1. Using Julia version 1.10.4.
</p>
</section>
<footer class="modal-card-foot">
Expand Down
20 changes: 20 additions & 0 deletions src/readers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module Readers
export axes_set
export axis_array
export axis_dict
export axis_indices
export axis_length
export axis_version_counter
export description
Expand Down Expand Up @@ -241,6 +242,25 @@ function axis_dict(daf::DafReader, axis::AbstractString)::AbstractDict{<:Abstrac
end
end

"""
function axis_indices(daf::DafReader, axis::AbstractString, entries::AbstractVector{<:AbstractString})::AbstractVector{<:Integer}
Return a vector of the indices of the entries in the axis.
"""
function axis_indices(
daf::DafReader,
axis::AbstractString,
entries::AbstractVector{<:AbstractString},
)::AbstractVector{<:Integer}
return Formats.with_data_read_lock(daf, "axis_indices of:", axis) do
require_axis(daf, "for: axis_indices", axis)
dictionary = Formats.axis_dict_with_cache(daf, axis)
result = getindex.(Ref(dictionary), entries)
@debug "axis_indices daf: $(depict(daf)) result: $(depict(result))"
return result
end
end

"""
axis_length(daf::DafReader, axis::AbstractString)::Int64
Expand Down
1 change: 1 addition & 0 deletions src/readers.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Daf.Readers.has_axis
Daf.Readers.axes_set
Daf.Readers.axis_array
Daf.Readers.axis_dict
Daf.Readers.axis_indices
Daf.Readers.axis_length
```

Expand Down
5 changes: 5 additions & 0 deletions test/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@ function test_existing_axis(daf::DafReader, depth::Int)::Nothing
@test collect(axis_dict(daf, "cell")) == [name => index for (index, name) in enumerate(CELL_NAMES)]
end

nested_test("axis_indices") do
@test axis_indices(daf, "gene", GENE_NAMES) == collect(1:length(GENE_NAMES))
@test axis_indices(daf, "cell", reverse(CELL_NAMES)) == collect(reverse(1:length(CELL_NAMES)))
end

nested_test("name") do
@test get_vector(daf, "gene", "name") == GENE_NAMES
@test get_vector(daf, "cell", "name") == CELL_NAMES
Expand Down

0 comments on commit a133c7f

Please sign in to comment.