/usr/share/doc/python-pebl/html/util.html is in python-pebl-doc 1.0.2-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><no title> — Pebl 1.0.1 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.0.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Pebl 1.0.1 documentation" href="index.html" />
<link rel="up" title="API Reference" href="apiref.html" />
<link rel="prev" title="taskcontroller.ec2 – Amazon EC2 task controller" href="taskcontroller/ec2.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="taskcontroller/ec2.html" title="taskcontroller.ec2 – Amazon EC2 task controller"
accesskey="P">previous</a> |</li>
<li><a href="index.html">Pebl 1.0.1 documentation</a> »</li>
<li><a href="apiref.html" accesskey="U">API Reference</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<span class="target" id="module-pebl.util"></span><p>Miscellaneous utility functions.</p>
<dl class="function">
<dt id="pebl.util.as_list">
<tt class="descclassname">pebl.util.</tt><tt class="descname">as_list</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#pebl.util.as_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Ensures that the result is a list.</p>
<p>If input is a list/tuple/set, return it.
If it’s None, return empty list.
Else, return a list with input as the only element.</p>
</dd></dl>
<dl class="function">
<dt id="pebl.util.autoassign">
<tt class="descclassname">pebl.util.</tt><tt class="descname">autoassign</tt><big>(</big><em>self</em>, <em>locals</em><big>)</big><a class="headerlink" href="#pebl.util.autoassign" title="Permalink to this definition">¶</a></dt>
<dd><p>Automatically assigns local variables to <cite>self</cite>.
Generally used in <cite>__init__</cite> methods, as in:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">foo</span><span class="p">,</span> <span class="n">bar</span><span class="p">,</span> <span class="n">baz</span><span class="o">=</span><span class="mi">1</span><span class="p">):</span>
<span class="n">autoassign</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="nb">locals</span><span class="p">())</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="pebl.util.cartesian_product">
<tt class="descclassname">pebl.util.</tt><tt class="descname">cartesian_product</tt><big>(</big><em>list_of_lists</em><big>)</big><a class="headerlink" href="#pebl.util.cartesian_product" title="Permalink to this definition">¶</a></dt>
<dd><p>Given n lists (or sets), generate all n-tuple combinations.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="nb">list</span><span class="p">(</span><span class="n">cartesian_product</span><span class="p">([[</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="s">"foo"</span><span class="p">]]))</span>
<span class="go">[(0, 0), (0, 1), (0, 'foo'), (1, 0), (1, 1), (1, 'foo')]</span>
</pre></div>
</div>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="nb">list</span><span class="p">(</span><span class="n">cartesian_product</span><span class="p">([[</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">]]))</span>
<span class="go">[(0, 0, 0), (0, 0, 1), (0, 1, 0), (0, 1, 1), (1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1)]</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="pebl.util.cond">
<tt class="descclassname">pebl.util.</tt><tt class="descname">cond</tt><big>(</big><em>condition</em>, <em>expr1</em>, <em>expr2</em><big>)</big><a class="headerlink" href="#pebl.util.cond" title="Permalink to this definition">¶</a></dt>
<dd><p>Marked for deletion.. Python2.5 provides this.</p>
</dd></dl>
<dl class="function">
<dt id="pebl.util.edit_distance">
<tt class="descclassname">pebl.util.</tt><tt class="descname">edit_distance</tt><big>(</big><em>network1</em>, <em>network2</em><big>)</big><a class="headerlink" href="#pebl.util.edit_distance" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the edit distance between two networks.</p>
<p>This is a good (but not the only one) metric for determining similarity
between two networks.</p>
</dd></dl>
<dl class="function">
<dt id="pebl.util.entropy_of_list">
<tt class="descclassname">pebl.util.</tt><tt class="descname">entropy_of_list</tt><big>(</big><em>lst</em><big>)</big><a class="headerlink" href="#pebl.util.entropy_of_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Given a list of values, generate histogram and calculate the entropy.</p>
</dd></dl>
<dl class="function">
<dt id="pebl.util.extended_property">
<tt class="descclassname">pebl.util.</tt><tt class="descname">extended_property</tt><big>(</big><em>func</em><big>)</big><a class="headerlink" href="#pebl.util.extended_property" title="Permalink to this definition">¶</a></dt>
<dd><p>Function decorator for defining property attributes</p>
<p>The decorated function is expected to return a dictionary
containing one or more of the following pairs:</p>
<blockquote>
<div><ul class="simple">
<li>fget - function for getting attribute value</li>
<li>fset - function for setting attribute value</li>
<li>fdel - function for deleting attribute</li>
</ul>
</div></blockquote>
</dd></dl>
<dl class="function">
<dt id="pebl.util.flatten">
<tt class="descclassname">pebl.util.</tt><tt class="descname">flatten</tt><big>(</big><em>seq</em><big>)</big><a class="headerlink" href="#pebl.util.flatten" title="Permalink to this definition">¶</a></dt>
<dd><p>Given a nested datastructure, flatten it.</p>
</dd></dl>
<dl class="function">
<dt id="pebl.util.levenshtein">
<tt class="descclassname">pebl.util.</tt><tt class="descname">levenshtein</tt><big>(</big><em>a</em>, <em>b</em><big>)</big><a class="headerlink" href="#pebl.util.levenshtein" title="Permalink to this definition">¶</a></dt>
<dd><p>Calculates the Levenshtein distance between <em>strings</em> a and b.</p>
<p>from <a class="reference external" href="http://hetland.org/coding/python/levenshtein.py">http://hetland.org/coding/python/levenshtein.py</a></p>
</dd></dl>
<dl class="function">
<dt id="pebl.util.logadd">
<tt class="descclassname">pebl.util.</tt><tt class="descname">logadd</tt><big>(</big><em>x</em>, <em>y</em><big>)</big><a class="headerlink" href="#pebl.util.logadd" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds two log values.</p>
<p>Ensures accuracy even when the difference between values is large.</p>
</dd></dl>
<dl class="function">
<dt id="pebl.util.logscale_probwheel">
<tt class="descclassname">pebl.util.</tt><tt class="descname">logscale_probwheel</tt><big>(</big><em>items</em>, <em>logweights</em><big>)</big><a class="headerlink" href="#pebl.util.logscale_probwheel" title="Permalink to this definition">¶</a></dt>
<dd><p>Randomly select an item from a [log] weighted list of items.</p>
<p>Fucntion just rescale logweights and exponentiates before calling
probwheel.</p>
</dd></dl>
<dl class="function">
<dt id="pebl.util.logsum">
<tt class="descclassname">pebl.util.</tt><tt class="descname">logsum</tt><big>(</big><em>lst</em><big>)</big><a class="headerlink" href="#pebl.util.logsum" title="Permalink to this definition">¶</a></dt>
<dd><p>Sums a list of log values, ensuring accuracy.</p>
</dd></dl>
<dl class="function">
<dt id="pebl.util.lru_cache">
<tt class="descclassname">pebl.util.</tt><tt class="descname">lru_cache</tt><big>(</big><em>maxsize</em><big>)</big><a class="headerlink" href="#pebl.util.lru_cache" title="Permalink to this definition">¶</a></dt>
<dd><p>Decorator applying a least-recently-used cache with the given maximum size.</p>
<p>Arguments to the cached function must be hashable.
Cache performance statistics stored in f.hits and f.misses.</p>
<p>from <a class="reference external" href="http://code.activestate.com/recipes/498245/">http://code.activestate.com/recipes/498245/</a></p>
</dd></dl>
<dl class="function">
<dt id="pebl.util.nestediter">
<tt class="descclassname">pebl.util.</tt><tt class="descname">nestediter</tt><big>(</big><em>lst1</em>, <em>lst2</em><big>)</big><a class="headerlink" href="#pebl.util.nestediter" title="Permalink to this definition">¶</a></dt>
<dd><p>A syntactic shortform for doing nested loops.</p>
</dd></dl>
<dl class="function">
<dt id="pebl.util.normalize">
<tt class="descclassname">pebl.util.</tt><tt class="descname">normalize</tt><big>(</big><em>lst</em><big>)</big><a class="headerlink" href="#pebl.util.normalize" title="Permalink to this definition">¶</a></dt>
<dd><p>Normalizes a list of numbers (sets sum to 1.0).</p>
</dd></dl>
<dl class="function">
<dt id="pebl.util.probwheel">
<tt class="descclassname">pebl.util.</tt><tt class="descname">probwheel</tt><big>(</big><em>items</em>, <em>weights</em><big>)</big><a class="headerlink" href="#pebl.util.probwheel" title="Permalink to this definition">¶</a></dt>
<dd><p>Randomly select an item from a weighted list of items.</p>
</dd></dl>
<dl class="function">
<dt id="pebl.util.rescale_logvalues">
<tt class="descclassname">pebl.util.</tt><tt class="descname">rescale_logvalues</tt><big>(</big><em>lst</em><big>)</big><a class="headerlink" href="#pebl.util.rescale_logvalues" title="Permalink to this definition">¶</a></dt>
<dd><p>Rescales a list of log values by setting max value to 0.0</p>
<p>This function is necessary when working with list of log values. Without
it, we could have overflows. This is a lot faster than using arbitrary
precision math libraries.</p>
</dd></dl>
<dl class="function">
<dt id="pebl.util.unzip">
<tt class="descclassname">pebl.util.</tt><tt class="descname">unzip</tt><big>(</big><em>l</em>, <em>*jj</em><big>)</big><a class="headerlink" href="#pebl.util.unzip" title="Permalink to this definition">¶</a></dt>
<dd><p>Opposite of zip().</p>
<p>jj is a tuple of list indexes (or keys) to extract or unzip. If not
specified, all items are unzipped.</p>
</dd></dl>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="taskcontroller/ec2.html"
title="previous chapter"><tt class="docutils literal"><span class="pre">taskcontroller.ec2</span></tt> – Amazon EC2 task controller</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/util.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="taskcontroller/ec2.html" title="taskcontroller.ec2 – Amazon EC2 task controller"
>previous</a> |</li>
<li><a href="index.html">Pebl 1.0.1 documentation</a> »</li>
<li><a href="apiref.html" >API Reference</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2008, Abhik Shah.
Last updated on Aug 18, 2015.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3.
</div>
</body>
</html>
|