change data, mathematics, function, geometry and geometry_plot_pylab. add data_step, data_step_std and helper. add an example and more documentation.

inside the data module rename read to read_columns add add new read function to read the whole file as string. add print_list function to print one element per line. add unique_list and unique_list_hashable to reduce the list into a unique list with same order. add find_last, str_between, str_to_list functions.

inside the mathematics module for vector add normalized creating a new object (normalize will change the object), isclose and iscloseto, change ang to round internal number. for matrix improve slicing and add transposed creating a new object (transpose will change object).

inside the function module add b_spline_basis, b_spline_curve_with_knots and b_spline_knots functions. add sample_hal_open and sample_half_open_seq. add circle and ellipse.

inside the geometry module change CS init from using lists to Directions and add new constructor CS.init_xzy using lists. rename Wireframe to Polyline. add classes B_spline_curve_with_knots, Ellipse, ArcCircle, ArcEllipse, ArcBSplineCurveWithKnots. add function sample_half_open to create a list of Points.

inside the geometry_plot_pylab module change the help text.

add step_and data data_step_std module to read a step file to list and draw the content.

add helper module with context manager and decorator timeit to meassure the time for a section or function.

add example for b_spline function.
This commit is contained in:
2020-01-08 21:59:53 +01:00
parent 4b42d7b508
commit 4fc4903dc2
56 changed files with 8756 additions and 947 deletions

View File

@@ -16,7 +16,7 @@
<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="next" title="pylib.data_step module" href="pylib.data_step.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" />
@@ -36,13 +36,34 @@
<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>
<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 class="field-odd"><p>2019-12-28</p>
</dd>
</dl>
<span class="target" id="module-data"></span><dl class="function">
<dt id="pylib.data.find_last">
<code class="sig-name descname">find_last</code><span class="sig-paren">(</span><em class="sig-param">sequence</em>, <em class="sig-param">pattern</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/data.html#find_last"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.data.find_last" title="Permalink to this definition"></a></dt>
<dd><p>Find last last occurance in sequence (text)</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>sequence</strong> (<em>str</em>) text to search in</p></li>
<li><p><strong>pattern</strong> (<em>str</em>) search pattern</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>index (-1 if pattern not in sequence)</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>int</p>
</dd>
</dl>
</dd></dl>
<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
@@ -137,14 +158,42 @@ False for int, dict, set</p>
</dl>
</dd></dl>
<dl class="function">
<dt id="pylib.data.print_list">
<code class="sig-name descname">print_list</code><span class="sig-paren">(</span><em class="sig-param">lst</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/data.html#print_list"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.data.print_list" title="Permalink to this definition"></a></dt>
<dd><p>Print list, one list element per line.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>lst</strong> (<em>list</em>) list to print</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>
<code class="sig-name descname">read</code><span class="sig-paren">(</span><em class="sig-param">file_name</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"><p><strong>filename</strong> (<em>str</em>) file to read</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>file content</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>str</p>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pylib.data.read_columns">
<code class="sig-name descname">read_columns</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_columns"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.data.read_columns" 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>file_name</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>
@@ -203,6 +252,72 @@ between consecutive terms).</p></li>
</dl>
</dd></dl>
<dl class="function">
<dt id="pylib.data.str_between">
<code class="sig-name descname">str_between</code><span class="sig-paren">(</span><em class="sig-param">text</em>, <em class="sig-param">left</em>, <em class="sig-param">right</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/data.html#str_between"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.data.str_between" title="Permalink to this definition"></a></dt>
<dd><p>Get text between two pattern.</p>
<p>Text can be multi-line.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>text</strong> (<em>str</em>) text to search in</p></li>
<li><p><strong>left</strong> (<em>str</em>) left pattern</p></li>
<li><p><strong>right</strong> (<em>str</em>) right pattern</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>text between the left and right pattern</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>str</p>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pylib.data.str_to_list">
<code class="sig-name descname">str_to_list</code><span class="sig-paren">(</span><em class="sig-param">string</em>, <em class="sig-param">delimiter=';\n'</em>, <em class="sig-param">newline_replacement=''</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/data.html#str_to_list"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.data.str_to_list" title="Permalink to this definition"></a></dt>
<dd><p>Converts a string with block information into a list.</p>
<p>This function un-wraps multi-line block information into one line.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>string</strong> (<em>str</em>) string with block information</p></li>
<li><p><strong>delimiter</strong> (<em>str</em>) block delimiter (default = ;n). This will be
removed from the resulting list.</p></li>
<li><p><strong>newline_replacement</strong> (<em>str</em>) block lines replacement (default = )</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>list of block information</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>list</p>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Every line is left striped. Empty line are ignored.</p>
</div>
<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="n">before</span> <span class="p">(</span><span class="n">string</span><span class="p">):</span>
<span class="n">FILE_DESCRIPTION</span><span class="p">((</span><span class="s1">&#39;Open CASCADE Model&#39;</span><span class="p">),</span><span class="s1">&#39;2;1&#39;</span><span class="p">);</span>
<span class="n">FILE_NAME</span><span class="p">(</span><span class="s1">&#39;Open CASCADE Shape Model&#39;</span><span class="p">,</span><span class="s1">&#39;2019-10-14T14:32:20&#39;</span><span class="p">,(</span><span class="s1">&#39;Author&#39;</span><span class="p">),(</span>
<span class="s1">&#39;Open CASCADE&#39;</span><span class="p">),</span><span class="s1">&#39;Open CASCADE STEP processor 7.1&#39;</span><span class="p">,</span><span class="s1">&#39;Open CASCADE 7.1&#39;</span>
<span class="p">,</span><span class="s1">&#39;Unknown&#39;</span><span class="p">);</span>
<span class="n">FILE_SCHEMA</span><span class="p">((</span><span class="s1">&#39;AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }&#39;</span><span class="p">));</span>
<span class="n">after</span> <span class="p">(</span><span class="nb">list</span> <span class="n">elements</span> <span class="n">one</span> <span class="n">per</span> <span class="n">line</span><span class="p">):</span>
<span class="n">FILE_DESCRIPTION</span><span class="p">((</span><span class="s1">&#39;Open CASCADE Model&#39;</span><span class="p">),</span><span class="s1">&#39;2;1&#39;</span><span class="p">)</span>
<span class="n">FILE_NAME</span><span class="p">(</span><span class="s1">&#39;Open CASCADE Shape Model&#39;</span><span class="p">,</span><span class="s1">&#39;2019-10-14T14:32:20&#39;</span><span class="p">,(</span><span class="s1">&#39;Author&#39;</span><span class="p">),(</span><span class="s1">&#39;Open CASCADE&#39;</span><span class="p">),</span><span class="s1">&#39;Open CASCADE STEP processor 7.1&#39;</span><span class="p">,</span><span class="s1">&#39;Open CASCADE 7.1&#39;</span><span class="p">,</span><span class="s1">&#39;Unknown&#39;</span><span class="p">)</span>
<span class="n">FILE_SCHEMA</span><span class="p">((</span><span class="s1">&#39;AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }&#39;</span><span class="p">))</span>
</pre></div>
</div>
</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>
@@ -223,6 +338,18 @@ between consecutive terms).</p></li>
</dl>
</dd></dl>
<dl class="function">
<dt id="pylib.data.unique_list">
<code class="sig-name descname">unique_list</code><span class="sig-paren">(</span><em class="sig-param">sequence</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/data.html#unique_list"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.data.unique_list" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="function">
<dt id="pylib.data.unique_list_hashable">
<code class="sig-name descname">unique_list_hashable</code><span class="sig-paren">(</span><em class="sig-param">sequence</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pylib/data.html#unique_list_hashable"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pylib.data.unique_list_hashable" title="Permalink to this definition"></a></dt>
<dd><p>faster using set() but elements of the sequence must be hashable.
unhashable types: list</p>
</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>
@@ -271,7 +398,7 @@ between consecutive terms).</p></li>
<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>
<li>Next: <a href="pylib.data_step.html" title="next chapter">pylib.data_step module</a></li>
</ul></li>
</ul></li>
</ul></li>