-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploying to gh-pages from @ 8ce88b6 🚀
- Loading branch information
Showing
27 changed files
with
605 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: e4c81ac4b1b7ab93fb71781061fff3ca | ||
config: eacb5f95efd53f0af1e04d727ffd7fac | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
<!DOCTYPE html> | ||
|
||
<html lang="en" data-content_root="../../"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>biocutils.print_truncated_list — biocutils 0.0.6 documentation</title> | ||
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" /> | ||
<link rel="stylesheet" type="text/css" href="../../_static/alabaster.css?v=233b9934" /> | ||
<script src="../../_static/documentation_options.js?v=1fd71caa"></script> | ||
<script src="../../_static/doctools.js?v=888ff710"></script> | ||
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script> | ||
<link rel="index" title="Index" href="../../genindex.html" /> | ||
<link rel="search" title="Search" href="../../search.html" /> | ||
|
||
<link rel="stylesheet" href="../../_static/custom.css" type="text/css" /> | ||
|
||
|
||
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" /> | ||
|
||
</head><body> | ||
|
||
|
||
<div class="document"> | ||
<div class="documentwrapper"> | ||
<div class="bodywrapper"> | ||
|
||
|
||
<div class="body" role="main"> | ||
|
||
<h1>Source code for biocutils.print_truncated_list</h1><div class="highlight"><pre> | ||
<span></span><span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Optional</span><span class="p">,</span> <span class="n">Sequence</span><span class="p">,</span> <span class="n">Callable</span> | ||
|
||
|
||
<div class="viewcode-block" id="print_truncated_list"> | ||
<a class="viewcode-back" href="../../api/biocutils.html#biocutils.print_truncated_list.print_truncated_list">[docs]</a> | ||
<span class="k">def</span> <span class="nf">print_truncated_list</span><span class="p">(</span><span class="n">x</span><span class="p">:</span> <span class="n">Sequence</span><span class="p">,</span> <span class="n">truncated_to</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span> <span class="n">full_threshold</span> <span class="o">=</span> <span class="mi">10</span><span class="p">,</span> <span class="n">transform</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">Callable</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">,</span> <span class="n">include_brackets</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> | ||
<span class="w"> </span><span class="sd">"""</span> | ||
<span class="sd"> Pretty-print a truncated list, replacing the middle elements with an</span> | ||
<span class="sd"> ellipsis if there are too many. This provides a useful preview of an</span> | ||
<span class="sd"> object without spewing out all of its contents on the screen.</span> | ||
|
||
<span class="sd"> Args:</span> | ||
<span class="sd"> x: List or some other sequence to be printed.</span> | ||
|
||
<span class="sd"> truncated_to:</span> | ||
<span class="sd"> Number of elements to truncate to, at the start and end of the</span> | ||
<span class="sd"> sequence. This should be less than half of ``full_threshold``.</span> | ||
|
||
<span class="sd"> full_threshold:</span> | ||
<span class="sd"> Threshold on the number of elements, below which the list is</span> | ||
<span class="sd"> shown in its entirety.</span> | ||
|
||
<span class="sd"> transform:</span> | ||
<span class="sd"> Optional transformation to apply to the elements of ``x``</span> | ||
<span class="sd"> after truncation but before printing.</span> | ||
|
||
<span class="sd"> sep:</span> | ||
<span class="sd"> Separator between elements in the printed list.</span> | ||
|
||
<span class="sd"> include_brackets:</span> | ||
<span class="sd"> Whether to include the start/end brackets.</span> | ||
|
||
<span class="sd"> Returns:</span> | ||
<span class="sd"> String containing the pretty-printed truncated list. </span> | ||
<span class="sd"> """</span> | ||
<span class="n">collected</span> <span class="o">=</span> <span class="p">[]</span> | ||
<span class="k">if</span> <span class="n">transform</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> | ||
<span class="n">transform</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">y</span> <span class="p">:</span> <span class="n">y</span> | ||
|
||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">></span> <span class="n">full_threshold</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">></span> <span class="n">truncated_to</span> <span class="o">*</span> <span class="mi">2</span><span class="p">:</span> | ||
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">truncated_to</span><span class="p">):</span> | ||
<span class="n">collected</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">repr</span><span class="p">(</span><span class="n">transform</span><span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="n">i</span><span class="p">])))</span> | ||
<span class="n">collected</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"..."</span><span class="p">)</span> | ||
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">truncated_to</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">):</span> | ||
<span class="n">collected</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">repr</span><span class="p">(</span><span class="n">transform</span><span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">-</span> <span class="n">i</span><span class="p">])))</span> | ||
<span class="k">else</span><span class="p">:</span> | ||
<span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="n">x</span><span class="p">:</span> | ||
<span class="n">collected</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">repr</span><span class="p">(</span><span class="n">transform</span><span class="p">(</span><span class="n">c</span><span class="p">)))</span> | ||
|
||
<span class="n">output</span> <span class="o">=</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">collected</span><span class="p">)</span> | ||
<span class="k">if</span> <span class="n">include_brackets</span><span class="p">:</span> | ||
<span class="n">output</span> <span class="o">=</span> <span class="s2">"["</span> <span class="o">+</span> <span class="n">output</span> <span class="o">+</span> <span class="s2">"]"</span> | ||
<span class="k">return</span> <span class="n">output</span></div> | ||
|
||
</pre></div> | ||
|
||
</div> | ||
|
||
</div> | ||
</div> | ||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation"> | ||
<div class="sphinxsidebarwrapper"> | ||
<h1 class="logo"><a href="../../index.html">biocutils</a></h1> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<h3>Navigation</h3> | ||
<ul> | ||
<li class="toctree-l1"><a class="reference internal" href="../../readme.html">Overview</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../../contributing.html">Contributions & Help</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../../license.html">License</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../../authors.html">Authors</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../../changelog.html">Changelog</a></li> | ||
<li class="toctree-l1"><a class="reference internal" href="../../api/modules.html">Module Reference</a></li> | ||
</ul> | ||
|
||
<div class="relations"> | ||
<h3>Related Topics</h3> | ||
<ul> | ||
<li><a href="../../index.html">Documentation overview</a><ul> | ||
<li><a href="../index.html">Module code</a><ul> | ||
</ul></li> | ||
</ul></li> | ||
</ul> | ||
</div> | ||
<div id="searchbox" style="display: none" role="search"> | ||
<h3 id="searchlabel">Quick search</h3> | ||
<div class="searchformwrapper"> | ||
<form class="search" action="../../search.html" method="get"> | ||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/> | ||
<input type="submit" value="Go" /> | ||
</form> | ||
</div> | ||
</div> | ||
<script>document.getElementById('searchbox').style.display = "block"</script> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
</div> | ||
</div> | ||
<div class="clearer"></div> | ||
</div> | ||
<div class="footer"> | ||
©2023, Aaron Lun. | ||
|
||
| | ||
Powered by <a href="http://sphinx-doc.org/">Sphinx 7.2.6</a> | ||
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.13</a> | ||
|
||
</div> | ||
|
||
|
||
|
||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.