318 lines
15 KiB
HTML
318 lines
15 KiB
HTML
|
||
<!DOCTYPE html>
|
||
|
||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<title>pylib.data module — pylib 2019.12.21 documentation</title>
|
||
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
|
||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
|
||
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></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>
|
||
<script type="text/javascript" src="_static/language_data.js"></script>
|
||
<script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||
<link rel="index" title="Index" href="genindex.html" />
|
||
<link rel="search" title="Search" href="search.html" />
|
||
<link rel="next" title="pylib.date module" href="pylib.date.html" />
|
||
<link rel="prev" title="pylib.numerical.ode_model module" href="pylib.numerical.ode_model.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">
|
||
|
||
<div class="section" id="module-pylib.data">
|
||
<span id="pylib-data-module"></span><h1>pylib.data module<a class="headerlink" href="#module-pylib.data" title="Permalink to this headline">¶</a></h1>
|
||
<p>Read and write data to or from file and manipulate data structures.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Date</dt>
|
||
<dd class="field-odd"><p>2019-10-11</p>
|
||
</dd>
|
||
</dl>
|
||
<span class="target" id="module-data"></span><dl class="function">
|
||
<dt id="pylib.data.fold_list">
|
||
<code class="sig-name descname">fold_list</code><span class="sig-paren">(</span><em class="sig-param">lst</em>, <em class="sig-param">n</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/data.html#fold_list"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.data.fold_list" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Convert one-dimensional kx1 array (list) to two-dimensional mxn
|
||
array. m = k / n</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>lst</strong> (<em>list</em>) – list to convert</p></li>
|
||
<li><p><strong>n</strong> (<em>int</em>) – length of the second dimenson</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p>two-dimensional array (list of lists)</p>
|
||
</dd>
|
||
<dt class="field-odd">Return type</dt>
|
||
<dd class="field-odd"><p>list</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="pylib.data.get_id">
|
||
<code class="sig-name descname">get_id</code><span class="sig-paren">(</span><em class="sig-param">ids</em>, <em class="sig-param">uide</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/data.html#get_id"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.data.get_id" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Get full id from unique id ending.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>ids</strong> (<em>list</em>) – ids</p></li>
|
||
<li><p><strong>uide</strong> (<em>str</em>) – unique id ending</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p>full id</p>
|
||
</dd>
|
||
<dt class="field-odd">Return type</dt>
|
||
<dd class="field-odd"><p>str or int</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="pylib.data.issequence">
|
||
<code class="sig-name descname">issequence</code><span class="sig-paren">(</span><em class="sig-param">obj</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/data.html#issequence"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.data.issequence" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>True for tuple, list, str
|
||
False for int, dict, set</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Example</dt>
|
||
<dd class="field-odd"><p></p></dd>
|
||
</dl>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">issequence</span><span class="p">(())</span>
|
||
<span class="go">True</span>
|
||
<span class="gp">>>> </span><span class="n">issequence</span><span class="p">((</span><span class="mi">3</span><span class="p">,</span> <span class="p">))</span>
|
||
<span class="go">True</span>
|
||
<span class="gp">>>> </span><span class="n">issequence</span><span class="p">([])</span>
|
||
<span class="go">True</span>
|
||
<span class="gp">>>> </span><span class="n">issequence</span><span class="p">([</span><span class="mi">1</span><span class="p">])</span>
|
||
<span class="go">True</span>
|
||
<span class="gp">>>> </span><span class="n">issequence</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">])</span>
|
||
<span class="go">True</span>
|
||
<span class="gp">>>> </span><span class="n">issequence</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span>
|
||
<span class="go">True</span>
|
||
</pre></div>
|
||
</div>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">issequence</span><span class="p">((</span><span class="mi">3</span><span class="p">))</span>
|
||
<span class="go">False</span>
|
||
<span class="gp">>>> </span><span class="n">issequence</span><span class="p">({})</span>
|
||
<span class="go">False</span>
|
||
<span class="gp">>>> </span><span class="n">issequence</span><span class="p">(</span><span class="nb">set</span><span class="p">())</span>
|
||
<span class="go">False</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="pylib.data.load">
|
||
<code class="sig-name descname">load</code><span class="sig-paren">(</span><em class="sig-param">file_name</em>, <em class="sig-param">default=None</em>, <em class="sig-param">verbose=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/data.html#load"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.data.load" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Load stored program objects from binary file.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>file_name</strong> (<em>str</em>) – file to load</p></li>
|
||
<li><p><strong>default</strong> (<em>object</em>) – return object if data loading fails</p></li>
|
||
<li><p><strong>verbose</strong> (<em>bool</em>) – verbose information (default = False)</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p>loaded data</p>
|
||
</dd>
|
||
<dt class="field-odd">Return type</dt>
|
||
<dd class="field-odd"><p>object</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="pylib.data.read">
|
||
<code class="sig-name descname">read</code><span class="sig-paren">(</span><em class="sig-param">file_name</em>, <em class="sig-param">x_column</em>, <em class="sig-param">y_column</em>, <em class="sig-param">default=None</em>, <em class="sig-param">verbose=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/data.html#read"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.data.read" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Read ascii data file.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>filename</strong> (<em>str</em>) – file to read</p></li>
|
||
<li><p><strong>x_column</strong> (<em>int</em>) – column index for the x data (first column is 0)</p></li>
|
||
<li><p><strong>y_column</strong> (<em>int</em>) – column index for the y data (first column is 0)</p></li>
|
||
<li><p><strong>default</strong> (<em>object</em>) – return object if data loading fails</p></li>
|
||
<li><p><strong>verbose</strong> (<em>bool</em>) – verbose information (default = False)</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p>x and y</p>
|
||
</dd>
|
||
<dt class="field-odd">Return type</dt>
|
||
<dd class="field-odd"><p>tuple(list, list)</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="pylib.data.seq">
|
||
<code class="sig-name descname">seq</code><span class="sig-paren">(</span><em class="sig-param">start</em>, <em class="sig-param">stop=None</em>, <em class="sig-param">step=1</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/data.html#seq"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.data.seq" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Create an arithmetic bounded sequence.</p>
|
||
<p>The sequence is one of the following;</p>
|
||
<ul class="simple">
|
||
<li><p>empty <span class="math notranslate nohighlight">\(\{\}=\emptyset\)</span>, if start and stop are the same</p></li>
|
||
<li><p>degenerate <span class="math notranslate nohighlight">\(\{a\}\)</span>, if the sequence has only one element.</p></li>
|
||
<li><p>left-close and right-open <span class="math notranslate nohighlight">\([a, b)\)</span></p></li>
|
||
</ul>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>start</strong> (<em>int</em><em> or </em><em>float</em>) – start of the sequence, the lower bound. If only start
|
||
is given than it is interpreted as stop and start will be 0.</p></li>
|
||
<li><p><strong>stop</strong> (<em>int</em><em> or </em><em>float</em>) – stop of sequence, the upper bound.</p></li>
|
||
<li><p><strong>step</strong> (<em>int</em><em> or </em><em>float</em>) – step size, the common difference (constant difference
|
||
between consecutive terms).</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p>arithmetic bounded sequence</p>
|
||
</dd>
|
||
<dt class="field-odd">Return type</dt>
|
||
<dd class="field-odd"><p>list</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="pylib.data.store">
|
||
<code class="sig-name descname">store</code><span class="sig-paren">(</span><em class="sig-param">file_name</em>, <em class="sig-param">object_data</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/data.html#store"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.data.store" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Store program objects to binary file.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>file_name</strong> (<em>str</em>) – file to store</p></li>
|
||
<li><p><strong>object_data</strong> (<em>object</em>) – data to store</p></li>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="pylib.data.unique_ending">
|
||
<code class="sig-name descname">unique_ending</code><span class="sig-paren">(</span><em class="sig-param">ids</em>, <em class="sig-param">n=1</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/data.html#unique_ending"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.data.unique_ending" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>From id list get list with unique ending.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>ids</strong> (<em>list</em>) – ids</p></li>
|
||
<li><p><strong>n</strong> (<em>int</em>) – minumum chars or ints</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p>unique ending of ids</p>
|
||
</dd>
|
||
<dt class="field-odd">Return type</dt>
|
||
<dd class="field-odd"><p>list</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="pylib.data.write">
|
||
<code class="sig-name descname">write</code><span class="sig-paren">(</span><em class="sig-param">file_name</em>, <em class="sig-param">data</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/data.html#write"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.data.write" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Write ascii file.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>file_name</strong> (<em>str</em>) – file to write</p></li>
|
||
<li><p><strong>data</strong> (<em>str</em>) – data to write</p></li>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
</div>
|
||
|
||
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||
<div class="sphinxsidebarwrapper">
|
||
<h1 class="logo"><a href="index.html">pylib</a></h1>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<h3>Navigation</h3>
|
||
<p class="caption"><span class="caption-text">Contents:</span></p>
|
||
<ul class="current">
|
||
<li class="toctree-l1 current"><a class="reference internal" href="modules.html">pylib</a><ul class="current">
|
||
<li class="toctree-l2 current"><a class="reference internal" href="pylib.html">pylib package</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
<div class="relations">
|
||
<h3>Related Topics</h3>
|
||
<ul>
|
||
<li><a href="index.html">Documentation overview</a><ul>
|
||
<li><a href="modules.html">pylib</a><ul>
|
||
<li><a href="pylib.html">pylib package</a><ul>
|
||
<li>Previous: <a href="pylib.numerical.ode_model.html" title="previous chapter">pylib.numerical.ode_model module</a></li>
|
||
<li>Next: <a href="pylib.date.html" title="next chapter">pylib.date module</a></li>
|
||
</ul></li>
|
||
</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" />
|
||
<input type="submit" value="Go" />
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<div class="clearer"></div>
|
||
</div>
|
||
<div class="footer">
|
||
©2019, Daniel Weschke.
|
||
|
||
|
|
||
Powered by <a href="http://sphinx-doc.org/">Sphinx 2.2.1</a>
|
||
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
||
|
||
|
|
||
<a href="_sources/pylib.data.rst.txt"
|
||
rel="nofollow">Page source</a>
|
||
</div>
|
||
|
||
|
||
|
||
|
||
</body>
|
||
</html> |