Skip to content

Commit 5c168cd

Browse files
committed
implement Matlab notations for row- column- vectors and matrices
1 parent 2d9a386 commit 5c168cd

24 files changed

Lines changed: 654 additions & 134 deletions

docs/class_examples.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ <h2>Welcome to Usage Class Examples</h2>
353353
<p>Select a module in the left menu to view usage examples. These examples are not for production and are automatically extracted from the main section of each module.</p>
354354
<p>Back to the <a href='index.html'>Python'Pizza3 documentation</a>.</p>
355355
<p>When no module is selected, you see this welcome page. They are used to test classes with typical codes. The main section often serves as a testing script, example usage block, or self-contained test block. It's a way to demonstrate how the module's functionality works or to run simple unit tests and examples inline.</p>
356-
<p>Generated on: 2025-01-22 00:44:24</p>
356+
<p>Generated on: 2025-01-23 00:06:34</p>
357357

358358
</div>
359359

@@ -1523,11 +1523,12 @@ <h2>Welcome to Usage Class Examples</h2>
15231523
<pre class="code"><span class="kn">from</span> <span class="nn">pizza.dscript</span> <span class="kn">import</span> <span class="n">dscript</span>
15241524
<span class="kn">from</span> <span class="nn">pizza.private.mstruct</span> <span class="kn">import</span> <span class="n">param</span>
15251525
<span class="n">D</span> <span class="o">=</span> <span class="n">dscript</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s2">&quot;math example&quot;</span><span class="p">)</span>
1526-
<span class="n">D</span><span class="o">.</span><span class="n">DEFINITIONS</span><span class="o">.</span><span class="n">l</span> <span class="o">=</span> <span class="p">[</span><span class="mf">1e-3</span><span class="p">,</span> <span class="mf">2e-3</span><span class="p">,</span> <span class="mf">3e-3</span><span class="p">]</span>
1527-
<span class="n">D</span><span class="o">.</span><span class="n">DEFINITIONS</span><span class="o">.</span><span class="n">scale</span> <span class="o">=</span> <span class="s2">&quot;@</span><span class="si">{l}</span><span class="s2">*2&quot;</span>
1528-
<span class="n">D</span><span class="o">.</span><span class="n">DEFINITIONS</span><span class="o">.</span><span class="n">x0</span> <span class="o">=</span> <span class="s2">&quot;$[[[-0.5, -0.5],[-0.5, -0.5]],[[ 0.5, 0.5],[ 0.5, 0.5]]]*$</span><span class="si">{scale[0,0]}</span><span class="s2">&quot;</span>
1529-
<span class="n">D</span><span class="o">.</span><span class="n">DEFINITIONS</span><span class="o">.</span><span class="n">y0</span> <span class="o">=</span> <span class="s2">&quot;$[[[-0.5, -0.5],[0.5, 0.5]],[[ -0.5, -0.5],[ 0.5, 0.5]]]*$</span><span class="si">{scale[0,1]}</span><span class="s2">&quot;</span>
1530-
<span class="n">D</span><span class="o">.</span><span class="n">DEFINITIONS</span><span class="o">.</span><span class="n">z0</span> <span class="o">=</span> <span class="s2">&quot;$[[[-0.5, 0.5],[-0.5, 0.5]],[[ -0.5, 0.5],[ -0.5, 0.5]]]*$</span><span class="si">{l[2]}</span><span class="s2">&quot;</span>
1526+
<span class="n">D</span><span class="o">.</span><span class="n">DEFINITIONS</span><span class="o">.</span><span class="n">l</span> <span class="o">=</span> <span class="p">[</span><span class="mf">1e-3</span><span class="p">,</span> <span class="mf">2e-3</span><span class="p">,</span> <span class="mf">3e-3</span><span class="p">]</span> <span class="c1"># l is defined as a list</span>
1527+
<span class="n">D</span><span class="o">.</span><span class="n">DEFINITIONS</span><span class="o">.</span><span class="n">a</span> <span class="o">=</span> <span class="s2">&quot;$[1 2 3]&quot;</span> <span class="c1"># a is defined with Matlab notations</span>
1528+
<span class="n">D</span><span class="o">.</span><span class="n">DEFINITIONS</span><span class="o">.</span><span class="n">scale</span> <span class="o">=</span> <span class="s2">&quot;@</span><span class="si">{l}</span><span class="s2">*2*@</span><span class="si">{a}</span><span class="s2">&quot;</span> <span class="c1"># l is rescaled</span>
1529+
<span class="n">D</span><span class="o">.</span><span class="n">DEFINITIONS</span><span class="o">.</span><span class="n">x0</span> <span class="o">=</span> <span class="s2">&quot;$[[[-0.5, -0.5],[-0.5, -0.5]],[[ 0.5, 0.5],[ 0.5, 0.5]]]*$</span><span class="si">{scale[0,0]}</span><span class="s2">*$</span><span class="si">{a[0,0]}</span><span class="s2">&quot;</span>
1530+
<span class="n">D</span><span class="o">.</span><span class="n">DEFINITIONS</span><span class="o">.</span><span class="n">y0</span> <span class="o">=</span> <span class="s2">&quot;$[[[-0.5, -0.5],[0.5, 0.5]],[[ -0.5, -0.5],[ 0.5, 0.5]]]*$</span><span class="si">{scale[0,1]}</span><span class="s2">*$</span><span class="si">{a[0,1]}</span><span class="s2">&quot;</span>
1531+
<span class="n">D</span><span class="o">.</span><span class="n">DEFINITIONS</span><span class="o">.</span><span class="n">z0</span> <span class="o">=</span> <span class="s2">&quot;$[[[-0.5, 0.5],[-0.5, 0.5]],[[ -0.5, 0.5],[ -0.5, 0.5]]]*$</span><span class="si">{l[2]}</span><span class="s2">*$</span><span class="si">{a[0,2]}</span><span class="s2">&quot;</span>
15311532
<span class="n">D</span><span class="o">.</span><span class="n">DEFINITIONS</span><span class="o">.</span><span class="n">X0</span> <span class="o">=</span> <span class="s2">&quot;@</span><span class="si">{x0}</span><span class="s2">.flatten()&quot;</span>
15321533
<span class="n">D</span><span class="o">.</span><span class="n">DEFINITIONS</span><span class="o">.</span><span class="n">Y0</span> <span class="o">=</span> <span class="s2">&quot;@</span><span class="si">{y0}</span><span class="s2">.flatten()&quot;</span>
15331534
<span class="n">D</span><span class="o">.</span><span class="n">DEFINITIONS</span><span class="o">.</span><span class="n">Z0</span> <span class="o">=</span> <span class="s2">&quot;@</span><span class="si">{z0}</span><span class="s2">.flatten()&quot;</span>

docs/datatemplate3.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<div style="border: 2px solid red; padding: 10px; margin-bottom: 20px;">
9797
<h3 style="color: red;">Notice</h3>
9898
<p>This is a raw view of the Python source code due to an error in generating the documentation.</p>
99-
<p><strong>Date of Conversion:</strong> 2025-01-22 00:44:26</p>
99+
<p><strong>Date of Conversion:</strong> 2025-01-23 00:06:37</p>
100100
</div>
101101

102102
<h2></h2>

docs/dump_case4.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<div style="border: 2px solid red; padding: 10px; margin-bottom: 20px;">
9797
<h3 style="color: red;">Notice</h3>
9898
<p>This is a raw view of the Python source code due to an error in generating the documentation.</p>
99-
<p><strong>Date of Conversion:</strong> 2025-01-22 00:44:27</p>
99+
<p><strong>Date of Conversion:</strong> 2025-01-23 00:06:38</p>
100100
</div>
101101

102102
<h2></h2>

docs/dumpreduce.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<div style="border: 2px solid red; padding: 10px; margin-bottom: 20px;">
9797
<h3 style="color: red;">Notice</h3>
9898
<p>This is a raw view of the Python source code due to an error in generating the documentation.</p>
99-
<p><strong>Date of Conversion:</strong> 2025-01-22 00:44:28</p>
99+
<p><strong>Date of Conversion:</strong> 2025-01-23 00:06:38</p>
100100
</div>
101101

102102
<h2></h2>

docs/dumptemplate.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<div style="border: 2px solid red; padding: 10px; margin-bottom: 20px;">
9797
<h3 style="color: red;">Notice</h3>
9898
<p>This is a raw view of the Python source code due to an error in generating the documentation.</p>
99-
<p><strong>Date of Conversion:</strong> 2025-01-22 00:44:29</p>
99+
<p><strong>Date of Conversion:</strong> 2025-01-23 00:06:40</p>
100100
</div>
101101

102102
<h2></h2>

docs/dumptemplate3.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<div style="border: 2px solid red; padding: 10px; margin-bottom: 20px;">
9797
<h3 style="color: red;">Notice</h3>
9898
<p>This is a raw view of the Python source code due to an error in generating the documentation.</p>
99-
<p><strong>Date of Conversion:</strong> 2025-01-22 00:44:28</p>
99+
<p><strong>Date of Conversion:</strong> 2025-01-23 00:06:39</p>
100100
</div>
101101

102102
<h2></h2>

docs/geometry.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<div style="border: 2px solid red; padding: 10px; margin-bottom: 20px;">
9797
<h3 style="color: red;">Notice</h3>
9898
<p>This is a raw view of the Python source code due to an error in generating the documentation.</p>
99-
<p><strong>Date of Conversion:</strong> 2025-01-22 00:44:39</p>
99+
<p><strong>Date of Conversion:</strong> 2025-01-23 00:06:47</p>
100100
</div>
101101

102102
<h2></h2>

docs/index.html

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,6 @@ <h1>Pizza3 Documentation Index</h1>
388388
<li class="folder">
389389
<div class="folder-title" onclick="toggleFolder(this)">pizza/private</div>
390390
<ul class="folder-content">
391-
<li class="file"><a href="pizza/private/dscript_math.html" target="_blankpy">dscript_math</a></li>
392391
<li class="file"><a href="pizza/private/mstruct.html" target="_blankpy">mstruct</a></li>
393392
<li class="file"><a href="pizza/private/utils.html" target="_blankpy">utils</a></li>
394393
</ul>
@@ -441,7 +440,7 @@ <h2>Welcome to Pizza3 Documentation</h2>
441440
const markdownContent = `
442441
# Pizza Modules Documentation
443442
444-
Generated on: **2025-01-22 00:44:24**
443+
Generated on: **2025-01-23 00:06:34**
445444
446445
<hr style="border: none; height: 1px; background-color: #e0e0e0;" />
447446
@@ -580,33 +579,28 @@ <h2>Welcome to Pizza3 Documentation</h2>
580579
</a>
581580
</div>
582581
<div style="flex: 1 1 calc(33.33% - 20px); min-width: 200px;">
583-
<a href="#pizza_private_dscript_math" style="text-decoration: none; font-weight: bold;">
584-
16. pizza.private.dscript_math
585-
</a>
586-
</div>
587-
<div style="flex: 1 1 calc(33.33% - 20px); min-width: 200px;">
588582
<a href="#pizza_private_mstruct" style="text-decoration: none; font-weight: bold;">
589-
17. pizza.private.mstruct
583+
16. pizza.private.mstruct
590584
</a>
591585
</div>
592586
<div style="flex: 1 1 calc(33.33% - 20px); min-width: 200px;">
593587
<a href="#pizza_private_utils" style="text-decoration: none; font-weight: bold;">
594-
18. pizza.private.utils
588+
17. pizza.private.utils
595589
</a>
596590
</div>
597591
<div style="flex: 1 1 calc(33.33% - 20px); min-width: 200px;">
598592
<a href="#pizza_raster" style="text-decoration: none; font-weight: bold;">
599-
19. pizza.raster
593+
18. pizza.raster
600594
</a>
601595
</div>
602596
<div style="flex: 1 1 calc(33.33% - 20px); min-width: 200px;">
603597
<a href="#pizza_region" style="text-decoration: none; font-weight: bold;">
604-
20. pizza.region
598+
19. pizza.region
605599
</a>
606600
</div>
607601
<div style="flex: 1 1 calc(33.33% - 20px); min-width: 200px;">
608602
<a href="#pizza_script" style="text-decoration: none; font-weight: bold;">
609-
21. pizza.script
603+
20. pizza.script
610604
</a>
611605
</div>
612606
</div>
@@ -1702,7 +1696,7 @@ <h2>Welcome to Pizza3 Documentation</h2>
17021696
<a id="pizza_group" name="pizza_group"></a>
17031697
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; font-size: 0.8em;"><a href="#pizza_generic" title="Go to Previous Module: pizza.generic" style="text-decoration: none;">⬅️ Previous</a>
17041698
<a href="#table_of_contents" title="Back to Table of Contents" style="text-decoration: none;">⬆️ TOC</a>
1705-
<a href="#pizza_private_dscript_math" title="Go to Next Module: pizza.private.dscript_math" style="text-decoration: none;">➡️ Next</a>
1699+
<a href="#pizza_private_mstruct" title="Go to Next Module: pizza.private.mstruct" style="text-decoration: none;">➡️ Next</a>
17061700
</div>
17071701
17081702
## Module \`pizza.group\`
@@ -1812,22 +1806,8 @@ <h2>Welcome to Pizza3 Documentation</h2>
18121806
| \`groupobject\` | \`__repr__\` | Returns an unambiguous string representation of the groupobject. | 8 | 0.9999 |
18131807
| \`groupobject\` | \`__str__\` | Returns a readable string representation of the groupobject. | 5 | 0.9999 |
18141808
1815-
<a id="pizza_private_dscript_math" name="pizza_private_dscript_math"></a>
1816-
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; font-size: 0.8em;"><a href="#pizza_group" title="Go to Previous Module: pizza.group" style="text-decoration: none;">⬅️ Previous</a>
1817-
<a href="#table_of_contents" title="Back to Table of Contents" style="text-decoration: none;">⬆️ TOC</a>
1818-
<a href="#pizza_private_mstruct" title="Go to Next Module: pizza.private.mstruct" style="text-decoration: none;">➡️ Next</a>
1819-
</div>
1820-
1821-
## Module \`pizza.private.dscript_math\`
1822-
1823-
*No classes found in this module.*
1824-
1825-
**Class Examples:** Not available.
1826-
1827-
*No methods found in this module.*
1828-
18291809
<a id="pizza_private_mstruct" name="pizza_private_mstruct"></a>
1830-
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; font-size: 0.8em;"><a href="#pizza_private_dscript_math" title="Go to Previous Module: pizza.private.dscript_math" style="text-decoration: none;">⬅️ Previous</a>
1810+
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; font-size: 0.8em;"><a href="#pizza_group" title="Go to Previous Module: pizza.group" style="text-decoration: none;">⬅️ Previous</a>
18311811
<a href="#table_of_contents" title="Back to Table of Contents" style="text-decoration: none;">⬆️ TOC</a>
18321812
<a href="#pizza_private_utils" title="Go to Next Module: pizza.private.utils" style="text-decoration: none;">➡️ Next</a>
18331813
</div>
@@ -1900,7 +1880,7 @@ <h2>Welcome to Pizza3 Documentation</h2>
19001880
| \`param\` | \`disp\` | display method | 3 | 1.005 |
19011881
| \`param\` | \`dispmax\` | optimize display | 8 | 1.005 |
19021882
| \`param\` | \`escape\` | escape \$\{\} as $\{\{\}\} --> keep variable names convert $\{\} as \{\} --> prepare Python replacement | 35 | 1.005 |
1903-
| \`param\` | \`eval\` | Eval method for structure such as MS.alias | 123 | 1.005 |
1883+
| \`param\` | \`eval\` | Eval method for structure such as MS.alias | 124 | 1.005 |
19041884
| \`param\` | \`format\` | Format a string with fields using \{field\} as placeholders. Handles expressions like $\{variable1\}. | 54 | 1.005 |
19051885
| \`param\` | \`format_array\` | Format NumPy array for display with distinctions for scalars, row/column vectors, and ND arrays. Recursively formats multi-dimensional arrays without introducing unwanted commas. | 105 | 1.005 |
19061886
| \`param\` | \`format_legacy\` | format a string with field (use \{field\} as placeholders) s.replace(string), s.replace(string,escape=True) where: s is a struct object string is a string with possibly $\{variable1\} escape is a flag to prevent $\{\} replaced by \{\} | 27 | 1.005 |
@@ -1916,10 +1896,11 @@ <h2>Welcome to Pizza3 Documentation</h2>
19161896
| \`param\` | \`items\` | return all elements as iterable key, value | 3 | 1.005 |
19171897
| \`param\` | \`keys\` | return the fields | 4 | 1.005 |
19181898
| \`param\` | \`keyssorted\` | sort keys by length() | 5 | 1.005 |
1899+
| \`param\` | \`matlab_to_numpy\` | Convert Matlab 1D and 2D array syntax to NumPy syntax. | 50 | 1.005 |
19191900
| \`param\` | \`np2str\` | Convert all np entries of s into their string representations | 43 | 1.005 |
19201901
| \`param\` | \`protect\` | protect $variable as $\{variable\} | 11 | 1.005 |
19211902
| \`param\` | \`read\` | read the equivalent structure read(filename) | 35 | 1.005 |
1922-
| \`param\` | \`replace_matrix_shorthand\` | Transforms custom shorthand notations for NumPy arrays within a string into valid NumPy array constructors. Supports up to 4-dimensional arrays and handles variable references. | 146 | 1.005 |
1903+
| \`param\` | \`replace_matrix_shorthand\` | Transforms custom shorthand notations for NumPy arrays within a string into valid NumPy array constructors. Supports up to 4-dimensional arrays and handles variable references. | 149 | 1.005 |
19231904
| \`param\` | \`safe_fstring\` | Safely evaluate expressions in $\{\} using SafeEvaluator. | 61 | 1.005 |
19241905
| \`param\` | \`scan\` | scan(string) scan a string for variables | 11 | 1.005 |
19251906
| \`param\` | \`set\` | initialization | 3 | 1.005 |
@@ -1960,7 +1941,7 @@ <h2>Welcome to Pizza3 Documentation</h2>
19601941
| \`paramauto\` | \`disp\` | display method | 3 | 1.005 |
19611942
| \`paramauto\` | \`dispmax\` | optimize display | 8 | 1.005 |
19621943
| \`paramauto\` | \`escape\` | escape \$\{\} as $\{\{\}\} --> keep variable names convert $\{\} as \{\} --> prepare Python replacement | 35 | 1.005 |
1963-
| \`paramauto\` | \`eval\` | Eval method for structure such as MS.alias | 123 | 1.005 |
1944+
| \`paramauto\` | \`eval\` | Eval method for structure such as MS.alias | 124 | 1.005 |
19641945
| \`paramauto\` | \`format\` | Format a string with fields using \{field\} as placeholders. Handles expressions like $\{variable1\}. | 54 | 1.005 |
19651946
| \`paramauto\` | \`format_array\` | Format NumPy array for display with distinctions for scalars, row/column vectors, and ND arrays. Recursively formats multi-dimensional arrays without introducing unwanted commas. | 105 | 1.005 |
19661947
| \`paramauto\` | \`format_legacy\` | format a string with field (use \{field\} as placeholders) s.replace(string), s.replace(string,escape=True) where: s is a struct object string is a string with possibly $\{variable1\} escape is a flag to prevent $\{\} replaced by \{\} | 27 | 1.005 |
@@ -1976,10 +1957,11 @@ <h2>Welcome to Pizza3 Documentation</h2>
19761957
| \`paramauto\` | \`items\` | return all elements as iterable key, value | 3 | 1.005 |
19771958
| \`paramauto\` | \`keys\` | return the fields | 4 | 1.005 |
19781959
| \`paramauto\` | \`keyssorted\` | sort keys by length() | 5 | 1.005 |
1960+
| \`paramauto\` | \`matlab_to_numpy\` | Convert Matlab 1D and 2D array syntax to NumPy syntax. | 50 | 1.005 |
19791961
| \`paramauto\` | \`np2str\` | Convert all np entries of s into their string representations | 43 | 1.005 |
19801962
| \`paramauto\` | \`protect\` | protect $variable as $\{variable\} | 11 | 1.005 |
19811963
| \`paramauto\` | \`read\` | read the equivalent structure read(filename) | 35 | 1.005 |
1982-
| \`paramauto\` | \`replace_matrix_shorthand\` | Transforms custom shorthand notations for NumPy arrays within a string into valid NumPy array constructors. Supports up to 4-dimensional arrays and handles variable references. | 146 | 1.005 |
1964+
| \`paramauto\` | \`replace_matrix_shorthand\` | Transforms custom shorthand notations for NumPy arrays within a string into valid NumPy array constructors. Supports up to 4-dimensional arrays and handles variable references. | 149 | 1.005 |
19831965
| \`paramauto\` | \`safe_fstring\` | Safely evaluate expressions in $\{\} using SafeEvaluator. | 61 | 1.005 |
19841966
| \`paramauto\` | \`scan\` | scan(string) scan a string for variables | 11 | 1.005 |
19851967
| \`paramauto\` | \`set\` | initialization | 3 | 1.005 |

docs/index_matlab.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ <h2>Welcome to Pizza3 Matlab Documentation</h2>
328328
<p>Back to the <a href='index.html'>Python'Pizza3 documentation</a>.</p>
329329
<hr>
330330
<p><i>When no function is selected, you see this welcome page.</i></p>
331-
Generated on: 2025-01-22 00:45:04</div>
331+
Generated on: 2025-01-23 00:07:11</div>
332332
<div id='Hertz_forces' class='doc-content' style='display: none;'>
333333
<h1>Code to explain the displacement of SPH particles (amorphous) along a rigid wall made with beads of the same size (organized)</h1>
334334
<p>INRAE\Olivier Vitrac, Han Chen - 2023-02-23</p>

docs/modules_withexamples_list.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ pizza/forcefield.py
1313
pizza/generic.py
1414
pizza/group.py
1515
pizza/__init__.py
16-
pizza/private/dscript_math.py
1716
pizza/private/mstruct.py
1817
pizza/private/utils.py
1918
pizza/raster.py

0 commit comments

Comments
 (0)