{"id":1037,"date":"2021-02-18T15:50:15","date_gmt":"2021-02-18T15:50:15","guid":{"rendered":"https:\/\/helpdesk.reden.nl\/revesdse\/?page_id=1037"},"modified":"2025-03-11T14:32:18","modified_gmt":"2025-03-11T14:32:18","slug":"python","status":"publish","type":"page","link":"https:\/\/docs.reden.nl\/reves\/python\/","title":{"rendered":"Python"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"Python-settings\"><span class=\"ez-toc-section\" id=\"python-settings\"><\/span>Python settings<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can configure your python settings in Reves DSE by following these steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to <strong>File, Python settings\u2026<\/strong> in the menu bar.<\/li>\n\n\n\n<li>The <em>Python settings<\/em> window appears.<\/li>\n\n\n\n<li><strong>Select<\/strong> a Python version from the dropdown list of supported versions: <strong>3.7 &#8211; 3.12 .<\/strong>\n<ul class=\"wp-block-list\">\n<li>The Python version in the settings is used to determine which \u201c<em>Python.Runtime<\/em>\u201d library must be used to communication with the specified Python version.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Add the path to your <em>python.exe<\/em> by <strong>clicking the Open button<\/strong><img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" border=\"0\" src=\"\/wp-content\/uploads\/sites\/4\/Image3.png\" alt=\"\"> to open the dialog window where you can select your python.exe.\n<ul class=\"wp-block-list\">\n<li>The <em>python.exe<\/em> path is used to determine if the system environment variables do contain the path to the <em>python.exe<\/em> directory which is needed for the python functionality work at all. Furthermore, the directory of the <em>python.exe<\/em> is used to add additional paths of the Python engine which are needed for finding Python modules.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Test your settings by clicking the <strong>Try init button<\/strong> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" border=\"0\" src=\"\/wp-content\/uploads\/sites\/4\/Image60.png\" alt=\"\"> in the toolbar<\/li>\n\n\n\n<li>When the try is finished the textbox displays the information concerning the made checks and the result of the initialization attempt.<\/li>\n\n\n\n<li>You can also set the following optional setting:\n<ul class=\"wp-block-list\">\n<li><em>Reinitialize python with each call<\/em>: Start each Python call with a new interpreter. The initialization of the PythonEngine is usually only done once for each calculation session. As a result, the Python interpreter is kept alive during the whole calculation session and only shutdown when the calculation is finished. <strong>Starting each Python call with a new interpreter has the advantage of each call not being affected by the caching of a previous python call (e.g.&nbsp;python modules are reloaded etc&#8230;)<\/strong>. Enabling this option can impacts the calculation time significantly since each solution will likely initialize and shutdown the PythonEngine at least once.<\/li>\n\n\n\n<li><em>Redirect python script messages to the progress output<\/em>: With this option enabled the Python stdout\/stderr will be redirected to a stream in Python be read by Reves DSE after the Python function call has ended. This option can impact the calculation time slightly since each calculation will execute the additional code to redirect the stdout\/stderr.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-columns is-not-stacked-on-mobile has-border-color has-custom-color-1-border-color has-custom-color-3-background-color has-background is-layout-flex wp-container-core-columns-is-layout-44468703 wp-block-columns-is-layout-flex\" style=\"border-width:1px;padding-top:var(--wp--preset--spacing--10);padding-right:var(--wp--preset--spacing--10);padding-bottom:var(--wp--preset--spacing--10);padding-left:var(--wp--preset--spacing--10)\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:5%\">\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/sites\/2\/tip.png\" alt=\"\" class=\"wp-image-156\"\/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:95%\">\n<figure class=\"wp-block-table tipTable\"><table class=\"has-fixed-layout\" style=\"border-style:none;border-width:0px\"><tbody><tr><td>You could also consider using the <em><a href=\"https:\/\/docs.python.org\/3\/library\/importlib.html#importlib.reload\">reload<\/a> <\/em>function in your python code to reload a previously imported&nbsp;<em>module.<\/em><\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Adding-a-Python-function-to-the-model\"><span class=\"ez-toc-section\" id=\"adding-a-python-function-to-the-model\"><\/span>Adding a Python function to the model<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can add a Python function to the canvas by following these steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Drag<\/strong> the <em>Python functio<\/em>n <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" border=\"0\" src=\"\/wp-content\/uploads\/sites\/4\/Image34.png\" alt=\"\"> item from the toolbox to the canvas or <strong>double click<\/strong> it.<\/li>\n\n\n\n<li>The Python function editor popup appears.<\/li>\n\n\n\n<li>Click the <strong>Open button<\/strong> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" border=\"0\" src=\"\/wp-content\/uploads\/sites\/4\/Image3.png\" alt=\"\"> to open the dialog window where you can browse to the Python file<\/li>\n\n\n\n<li><strong>Click<\/strong> Open in the dialog window to load the Python code.\n<ul class=\"wp-block-list\">\n<li>The file should have the format shown below. All functional code must be contained inside a&nbsp;<strong>function definition<\/strong>. Additionally, the function requires a&nbsp;<strong>return statement<\/strong>&nbsp;at the end for Reves DSE to use the result.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\"><pre><span style=\"color: blue;\">import<\/span> sys<br><span style=\"color: blue;\">import<\/span> math<br><br><span style=\"color: blue;\">def<\/span> <span style=\"color: #009769;\">test1<\/span>(F,E,r):<br>  <span style=\"color: blue;\">return<\/span> F\/(E*r*(0.025-r))<br><br><span style=\"color: blue;\">def<\/span> <span style=\"color: #009769;\">test2<\/span>():<br>  x = (5 * 6 * 7 + 8)\/2.56<br>  result = x + 2.5<br>  <span style=\"color: blue;\">return<\/span> result<\/pre><\/pre>\n\n\n\n<ol start=\"5\" class=\"wp-block-list\">\n<li><strong>Select a function<\/strong> from the <strong>drop-down list<\/strong> which contains the recognized functions from the Python code lines.<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-columns is-not-stacked-on-mobile has-border-color has-custom-color-1-border-color has-custom-color-2-background-color has-background is-layout-flex wp-container-core-columns-is-layout-44468703 wp-block-columns-is-layout-flex\" style=\"border-width:1px;padding-top:var(--wp--preset--spacing--10);padding-right:var(--wp--preset--spacing--10);padding-bottom:var(--wp--preset--spacing--10);padding-left:var(--wp--preset--spacing--10)\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:5%\">\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/sites\/2\/note.png\" alt=\"\" class=\"wp-image-154\"\/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:95%\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\" style=\"border-style:none;border-width:0px\"><tbody><tr><td>Check the formatting (white lines and indents) in your Python code if the&nbsp; function seem to be missing from the list and reselect your Python file in the file browse dialog to reload the code.<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n<\/div>\n\n\n\n<ol start=\"6\" class=\"wp-block-list\">\n<li>Enable the buffering of the results by checking the &#8220;Buffer the results&#8221; checkbox. This way the combination of input and output values will be remembered during the calculation session and prevent Reves DSE from executed the Python script unnecessarily.<\/li>\n\n\n\n<li>You can also set <em>Script execution location<\/em> to explicitly set an execution location for the python scripts in the model. This folder is then also added to the Python paths, so any other Python scripts in this folder will be available to the Python interpreter.<\/li>\n\n\n\n<li><strong>Link input and output<\/strong> parameters of the selected Python function to parameters in the model by <strong>selecting<\/strong> the corresponding parameter <strong>from the drop-down list<\/strong>.<\/li>\n\n\n\n<li>You can add multiple parameters to the single Python output parameter since Reves DSE cannot determine if this Python parameter contains a single value or multiple values.<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-columns is-not-stacked-on-mobile has-border-color has-custom-color-1-border-color has-custom-color-2-background-color has-background is-layout-flex wp-container-core-columns-is-layout-44468703 wp-block-columns-is-layout-flex\" style=\"border-width:1px;padding-top:var(--wp--preset--spacing--10);padding-right:var(--wp--preset--spacing--10);padding-bottom:var(--wp--preset--spacing--10);padding-left:var(--wp--preset--spacing--10)\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:5%\">\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/sites\/2\/note.png\" alt=\"\" class=\"wp-image-154\"\/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:95%\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\" style=\"border-style:none;border-width:0px\"><tbody><tr><td>Reves DSE supports the use of scalar and array parameters and is able to link those to either the input or output of a Python script. Length checks are not performed so it is important to make sure that the array length in the script matches the array length of the DSE parameter.<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n<\/div>\n\n\n\n<ol start=\"9\" class=\"wp-block-list\">\n<li><strong>Click<\/strong> the <strong>OK button<\/strong> to add the Python function to the canvas.<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-columns is-not-stacked-on-mobile has-border-color has-custom-color-1-border-color has-custom-color-3-background-color has-background is-layout-flex wp-container-core-columns-is-layout-44468703 wp-block-columns-is-layout-flex\" style=\"border-width:1px;padding-top:var(--wp--preset--spacing--10);padding-right:var(--wp--preset--spacing--10);padding-bottom:var(--wp--preset--spacing--10);padding-left:var(--wp--preset--spacing--10)\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:5%\">\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/sites\/2\/tip.png\" alt=\"\" class=\"wp-image-156\"\/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:95%\">\n<p class=\"tipTable\" style=\"border-style:none;border-width:0px\">You can also test your Python function settings in the \u2018<em>Test<\/em>\u2019 tab page. See the <a href=\"#python-function-test\">Python<\/a> section for more detailed information about this.<\/p>\n<\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Adding-a-Python-function-to-the-view\"><span class=\"ez-toc-section\" id=\"adding-a-python-function-to-the-view\"><\/span>Adding a Python function to the view<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can add a Python function to the design view canvas by following these steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Drag<\/strong> the<em> Python function<\/em> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" border=\"0\" src=\"\/wp-content\/uploads\/sites\/4\/Image34.png\" alt=\"\"> item from the toolbox to the canvas or <strong>double click<\/strong> it.<\/li>\n\n\n\n<li>The Python function editor popup appears.<\/li>\n\n\n\n<li>Click the <strong>Open button<\/strong> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" border=\"0\" src=\"\/wp-content\/uploads\/sites\/4\/Image3.png\" alt=\"\"> to open the dialog window where you can browse to the Python file.<\/li>\n\n\n\n<li><strong>Click<\/strong> Open in the dialog window to load the Python code.<\/li>\n\n\n\n<li><strong>Select<\/strong> a function from the drop-down list which contains the recognized functions from the Python code lines.<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-columns is-not-stacked-on-mobile has-border-color has-custom-color-1-border-color has-custom-color-2-background-color has-background is-layout-flex wp-container-core-columns-is-layout-44468703 wp-block-columns-is-layout-flex\" style=\"border-width:1px;padding-top:var(--wp--preset--spacing--10);padding-right:var(--wp--preset--spacing--10);padding-bottom:var(--wp--preset--spacing--10);padding-left:var(--wp--preset--spacing--10)\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:5%\">\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/sites\/2\/note.png\" alt=\"\" class=\"wp-image-154\"\/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:95%\">\n<p>Check the formatting (white lines and indents) in your Python code if function seem to be missing from the list and reselect your Python file in the file browse dialog to reload the code.<\/p>\n<\/div>\n<\/div>\n\n\n\n<ol start=\"6\" class=\"wp-block-list\">\n<li><strong>Link<\/strong> input parameters of the selected Python function to parameters in the model by <strong>selecting<\/strong> the corresponding parameter from the drop-down list.<\/li>\n\n\n\n<li><strong>Click<\/strong> the <strong>OK button<\/strong> to add the Python function to the canvas.<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-columns is-not-stacked-on-mobile has-border-color has-custom-color-1-border-color has-custom-color-3-background-color has-background is-layout-flex wp-container-core-columns-is-layout-44468703 wp-block-columns-is-layout-flex\" style=\"border-width:1px;padding-top:var(--wp--preset--spacing--10);padding-right:var(--wp--preset--spacing--10);padding-bottom:var(--wp--preset--spacing--10);padding-left:var(--wp--preset--spacing--10)\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:5%\">\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/sites\/2\/tip.png\" alt=\"\" class=\"wp-image-156\"\/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:95%\">\n<p class=\"tipTable\" style=\"border-style:none;border-width:0px\">You can also test your Python function settings in the \u2018<em>Test<\/em>\u2019 tab page. See the <a href=\"#python-function-test\">Python<\/a> section for more detailed information about this.<\/p>\n<\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Progress-output-in-the-calculation-environment\"><span class=\"ez-toc-section\" id=\"progress-output-in-the-calculation-environment\"><\/span>Progress output in the calculation environment<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>During calculations and after calculations you will find a <em>Python progress<\/em> panel and a <em>Progress<\/em> panel on the right side of the calculations environment. The first panel will show a log containing information related to the python calls. This information has been reduced compared to the information provided by the \u2018<em>Test<\/em>\u2019 tab page in the Python function editor to prevent information clutter. The log will provide:<\/p>\n\n\n\n<ul class=\"wp-block-list is-style-default\">\n<li>A time stamp with certain messages.<\/li>\n\n\n\n<li>The notification that a Python function call will be started.<\/li>\n\n\n\n<li>The current counter for a Python function call during the calculation session.<\/li>\n\n\n\n<li>Any redirected Python stdout\/stderr output, if enabled in the settings.<\/li>\n\n\n\n<li>Whether a Python function call has been skipped due to the results buffer.<\/li>\n\n\n\n<li>Any caught error messages.<\/li>\n<\/ul>\n\n\n\n<p>The <em>Progress<\/em> panel will display the current debug settings if these are enabled and provide progress metrics like run time, solutions generated, solve iterations and the random seed used at each solve thread.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Using-the-Python-function-in-the-calculation-environment\"><span class=\"ez-toc-section\" id=\"using-the-python-function-in-the-calculation-environment\"><\/span>Using the Python function in the calculation environment<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can perform post analysis on a solution with any of the Python canvas items added to the view canvas. You can select solutions in the solution explorer and then press the <strong>Start button<\/strong> <img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/sites\/4\/Image60.png\" alt=\"\" width=\"16\" height=\"16\" border=\"0\"> on the right side of your Python canvas item. The input values for the Python function will be gathered from the selected solutions. If multiple solutions are selected then the Python function call will be performed for each individual solution in the selection. The progress and the results of each Python function call will be posted to the <em>Python progress<\/em> panel.<\/p>\n\n\n\n<div class=\"wp-block-columns is-not-stacked-on-mobile has-border-color has-custom-color-1-border-color has-custom-color-2-background-color has-background is-layout-flex wp-container-core-columns-is-layout-44468703 wp-block-columns-is-layout-flex\" style=\"border-width:1px;padding-top:var(--wp--preset--spacing--10);padding-right:var(--wp--preset--spacing--10);padding-bottom:var(--wp--preset--spacing--10);padding-left:var(--wp--preset--spacing--10)\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:5%\">\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/sites\/2\/note.png\" alt=\"\" class=\"wp-image-154\"\/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:95%\">\n<p>Be careful if multiple solutions are selected and the output of the python script is a file. If the python script does not handle the cases where the&nbsp; output file already exists it will be likely be overwritten with every Python function call.<\/p>\n<\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Python-function-test\"><span class=\"ez-toc-section\" id=\"python-function-test\"><\/span>Python function test<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can test your Python function setting in the second tab page called <em>Test<\/em> in the Python function editor. It is recommended to test these settings to at least ensure the Python function call works and to check if your output parameter linkage is correct.<\/p>\n\n\n\n<p>You can test your Python function settings in by following these steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Complete your function<\/strong> settings in the <em>Python function<\/em> tab page.<\/li>\n\n\n\n<li><strong>Enter your input values<\/strong> in the input column in the table on the left. These test values are entered as is and not converted.<\/li>\n\n\n\n<li><strong>Press the Start button<\/strong> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" border=\"0\" src=\"\/wp-content\/uploads\/sites\/4\/Image60.png\" alt=\"\"> to test the Python functions with these input values.<\/li>\n\n\n\n<li>After completion the textbox below will display information regarding the Python function execution and the elapsed time. The <em>output<\/em> column in the table on the right will display the return values from the Python function.<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-columns is-not-stacked-on-mobile has-border-color has-custom-color-1-border-color has-custom-color-2-background-color has-background is-layout-flex wp-container-core-columns-is-layout-44468703 wp-block-columns-is-layout-flex\" style=\"border-width:1px;padding-top:var(--wp--preset--spacing--10);padding-right:var(--wp--preset--spacing--10);padding-bottom:var(--wp--preset--spacing--10);padding-left:var(--wp--preset--spacing--10)\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:5%\">\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/sites\/2\/note.png\" alt=\"\" class=\"wp-image-154\"\/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:95%\">\n<p>Additional rows are added to the table on the right if the Python function returns more values than output rows available. Do not forget to adjust the output parameters in your settings if the amount of output parameters did not match in your test.<\/p>\n<\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Limitations-and-remarks\"><span class=\"ez-toc-section\" id=\"limitations-and-remarks\"><\/span>Limitations and remarks<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The python functionality in DSE works by using an external Python application to execute the Python script. The coupling and calling are enabled by using a third-party library called &#8216;Python for .NET&#8217; (Python.Engine.dll \/ Python Engine). DSE has limited control over the issues that might occur on the Python side due to the external nature of this approach. Errors or crashes on the Python side which are not reported back to DSE through the Python Engine cannot be handled by DSE and might crash the application. The following section contains any limitations of this Python integration approach and remarks concerning how to use it.<\/p>\n\n\n\n<p>Please report any recurring (reproducible) crashes to us by e-mail: <a href=\"mailto:revesdse@reden.nl\">revesdse@reden.nl<\/a>. (Providing an example python script or a DSE model to reproduce the error with would be appreciated.)<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The Python functionality only works with a <strong>64-bit Python<\/strong> installation.<\/li>\n\n\n\n<li>The only supported <strong>Python versions are 3.7 up to 3.12<\/strong>.<\/li>\n\n\n\n<li>Scripts containing <strong>Matplotlib<\/strong> or importing modules containing <strong>Matplotlib<\/strong> are not supported and will crash DSE.<\/li>\n\n\n\n<li>This library \u201cis an integration of the CPython engine\u201d and therefore only compatible with <strong>CPython<\/strong> compatible modules\/libraries.<\/li>\n\n\n\n<li>The <strong>system environment variables PATH <\/strong>for python and any other python folder locations (like Scripts) is based the provided paths in the <em>Python settings window<\/em>.<\/li>\n\n\n\n<li><strong>Reves DSE is limited to a single calculation thread when it contains a Python script<\/strong>. This is due to recurring instability issues with multithreaded calculations which result in sudden crashes and freezing of the application.<\/li>\n\n\n\n<li>The <strong>function input values<\/strong> are assumed to be <strong>real values<\/strong> when they are entered. Python functions that require an <strong>input value to be an integer<\/strong> (ex. an input value to determine the number of iterations)<strong> do not work<\/strong>.<\/li>\n\n\n\n<li>Reves DSE supports the use of scalar and array parameters and can link those to either the input or output of a Python script. The use of dictionaries is currently not supported.<\/li>\n\n\n\n<li>The <strong>Python function is required<\/strong> to have a <strong>\u201creturn\u201d command<\/strong> so Reves DSE can receive the output values.<\/li>\n\n\n\n<li>If the Python function settings has <strong>multiple output values<\/strong> specified, then it can only <strong>solve in one direction<\/strong> (only the output parameters) instead of solving both ways like a Reves DSE expression can. Due to this it is likely that your model will not generate solutions if you manually set a value for a model parameter that is linked to a Python function output.<\/li>\n\n\n\n<li>For Python items in the model, it is crucial for the number of linked output parameters to match the output amount of the Python function. If the number does not match the solution generation could fail or the found solution is invalid\/incorrect.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Python settings You can configure your python settings in Reves DSE by following these steps: You could also consider using the reload function in your python code to reload a previously imported&nbsp;module. Adding a Python function to the model You can add a Python function to the canvas by following these steps: import sysimport mathdef [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1037","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/docs.reden.nl\/reves\/wp-json\/wp\/v2\/pages\/1037","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/docs.reden.nl\/reves\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/docs.reden.nl\/reves\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/docs.reden.nl\/reves\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.reden.nl\/reves\/wp-json\/wp\/v2\/comments?post=1037"}],"version-history":[{"count":7,"href":"https:\/\/docs.reden.nl\/reves\/wp-json\/wp\/v2\/pages\/1037\/revisions"}],"predecessor-version":[{"id":1453,"href":"https:\/\/docs.reden.nl\/reves\/wp-json\/wp\/v2\/pages\/1037\/revisions\/1453"}],"wp:attachment":[{"href":"https:\/\/docs.reden.nl\/reves\/wp-json\/wp\/v2\/media?parent=1037"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}