Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 1, 2023
1 parent 83f7081 commit 69caa66
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 29 deletions.
11 changes: 11 additions & 0 deletions _autosummary/one.api.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,17 @@
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">One</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cache_dir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'auto'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">wildcards</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tables_dir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/one/api.html#One"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#one.api.One" title="Link to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="one.converters.html#one.converters.ConversionMixin" title="one.converters.ConversionMixin"><code class="xref py py-class docutils literal notranslate"><span class="pre">ConversionMixin</span></code></a></p>
<p>An API for searching and loading data on a local filesystem</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="one.api.One.uuid_filenames">
<span class="sig-name descname"><span class="pre">uuid_filenames</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">None</span></em><a class="headerlink" href="#one.api.One.uuid_filenames" title="Link to this definition"></a></dt>
<dd><p>whether datasets on disk have a UUID in their filename</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="one.api.One.offline">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">offline</span></span><a class="headerlink" href="#one.api.One.offline" title="Link to this definition"></a></dt>
Expand Down
80 changes: 59 additions & 21 deletions _modules/one/api.html

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions _modules/one/converters.html
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,9 @@ <h1>Source code for one.converters</h1><div class="highlight"><pre>
<span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dataset</span><span class="p">,</span> <span class="n">pd</span><span class="o">.</span><span class="n">Series</span><span class="p">)</span> <span class="ow">or</span> <span class="nb">len</span><span class="p">(</span><span class="n">dataset</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span>
<span class="n">session_path</span><span class="p">,</span> <span class="n">rel_path</span> <span class="o">=</span> <span class="n">dataset</span><span class="p">[[</span><span class="s1">&#39;session_path&#39;</span><span class="p">,</span> <span class="s1">&#39;rel_path&#39;</span><span class="p">]]</span><span class="o">.</span><span class="n">to_numpy</span><span class="p">()</span><span class="o">.</span><span class="n">flatten</span><span class="p">()</span>
<span class="n">file</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">cache_dir</span><span class="p">,</span> <span class="n">session_path</span><span class="p">,</span> <span class="n">rel_path</span><span class="p">)</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">uuid_filenames</span><span class="p">:</span>
<span class="n">i</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">name</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dataset</span><span class="p">,</span> <span class="n">pd</span><span class="o">.</span><span class="n">Series</span><span class="p">)</span> <span class="k">else</span> <span class="n">dataset</span><span class="o">.</span><span class="n">index</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">file</span> <span class="o">=</span> <span class="n">add_uuid_string</span><span class="p">(</span><span class="n">file</span><span class="p">,</span> <span class="n">i</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">)</span> <span class="k">else</span> <span class="n">i</span><span class="p">)</span>
<span class="k">return</span> <span class="n">file</span> <span class="c1"># files[0] if len(datasets) == 1 else files</span></div>


Expand Down
14 changes: 12 additions & 2 deletions _modules/one/tests/test_converters.html
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,23 @@ <h1>Source code for one.tests.test_converters</h1><div class="highlight"><pre>
<span class="n">alf_path</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;hoferlab/Subjects/SWC_043/2020-09-21/001/&#39;</span>
<span class="s1">&#39;alf/probe00/_phy_spikes_subset.channels.npy&#39;</span><span class="p">)</span>
<span class="n">expected</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">one</span><span class="o">.</span><span class="n">alyx</span><span class="o">.</span><span class="n">cache_dir</span><span class="p">)</span><span class="o">.</span><span class="n">joinpath</span><span class="p">(</span><span class="o">*</span><span class="n">alf_path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">))</span>
<span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">one</span><span class="o">.</span><span class="n">record2path</span><span class="p">(</span><span class="n">rec</span><span class="o">.</span><span class="n">loc</span><span class="p">[(</span><span class="bp">self</span><span class="o">.</span><span class="n">eid</span><span class="p">,</span> <span class="s1">&#39;00c234a3-a4ff-4f97-a522-939d15528a45&#39;</span><span class="p">)])</span>
<span class="n">data_id</span> <span class="o">=</span> <span class="s1">&#39;00c234a3-a4ff-4f97-a522-939d15528a45&#39;</span>
<span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">one</span><span class="o">.</span><span class="n">record2path</span><span class="p">(</span><span class="n">rec</span><span class="o">.</span><span class="n">loc</span><span class="p">[(</span><span class="bp">self</span><span class="o">.</span><span class="n">eid</span><span class="p">,</span> <span class="n">data_id</span><span class="p">)])</span>
<span class="bp">self</span><span class="o">.</span><span class="n">assertIsInstance</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">Path</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">assertEqual</span><span class="p">(</span><span class="n">expected</span><span class="p">,</span> <span class="n">path</span><span class="p">)</span>
<span class="c1"># As pd.DataFrame</span>
<span class="n">idx</span> <span class="o">=</span> <span class="n">rec</span><span class="o">.</span><span class="n">rel_path</span> <span class="o">==</span> <span class="s1">&#39;alf/probe00/_phy_spikes_subset.channels.npy&#39;</span>
<span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">one</span><span class="o">.</span><span class="n">record2path</span><span class="p">(</span><span class="n">rec</span><span class="p">[</span><span class="n">idx</span><span class="p">])</span>
<span class="bp">self</span><span class="o">.</span><span class="n">assertEqual</span><span class="p">(</span><span class="n">expected</span><span class="p">,</span> <span class="n">path</span><span class="p">)</span></div>
<span class="bp">self</span><span class="o">.</span><span class="n">assertEqual</span><span class="p">(</span><span class="n">expected</span><span class="p">,</span> <span class="n">path</span><span class="p">)</span>
<span class="c1"># With UUID in file name</span>
<span class="k">try</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">one</span><span class="o">.</span><span class="n">uuid_filenames</span> <span class="o">=</span> <span class="kc">True</span>
<span class="n">expected</span> <span class="o">=</span> <span class="n">expected</span><span class="o">.</span><span class="n">with_suffix</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39;.</span><span class="si">{</span><span class="n">data_id</span><span class="si">}</span><span class="s1">.npy&#39;</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">assertEqual</span><span class="p">(</span><span class="n">expected</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">one</span><span class="o">.</span><span class="n">record2path</span><span class="p">(</span><span class="n">rec</span><span class="p">[</span><span class="n">idx</span><span class="p">]))</span> <span class="c1"># as pd.DataFrame</span>
<span class="bp">self</span><span class="o">.</span><span class="n">assertEqual</span><span class="p">(</span><span class="n">expected</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">one</span><span class="o">.</span><span class="n">record2path</span><span class="p">(</span><span class="n">rec</span><span class="p">[</span><span class="n">idx</span><span class="p">]</span><span class="o">.</span><span class="n">squeeze</span><span class="p">()))</span> <span class="c1"># as pd.Series</span>
<span class="bp">self</span><span class="o">.</span><span class="n">assertEqual</span><span class="p">(</span><span class="n">expected</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">one</span><span class="o">.</span><span class="n">record2path</span><span class="p">(</span><span class="n">rec</span><span class="p">[</span><span class="n">idx</span><span class="p">]</span><span class="o">.</span><span class="n">droplevel</span><span class="p">(</span><span class="mi">0</span><span class="p">)))</span> <span class="c1"># no eid</span>
<span class="k">finally</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">one</span><span class="o">.</span><span class="n">uuid_filenames</span> <span class="o">=</span> <span class="kc">False</span></div>


<div class="viewcode-block" id="TestOnlineConverters.test_eid2path">
Expand Down
Loading

0 comments on commit 69caa66

Please sign in to comment.