Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
functions.html 66.91 KiB


<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>functions module &mdash; binary_c-python  documentation</title>
  

  
  <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="_static/pygments.css" type="text/css" />

  
  
  
  

  
  <!--[if lt IE 9]>
    <script src="_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
        <script src="_static/jquery.js"></script>
        <script src="_static/underscore.js"></script>
        <script src="_static/doctools.js"></script>
        <script src="_static/language_data.js"></script>
        <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
        <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
        <script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true, "ignoreClass": "document", "processClass": "math|output_area"}})</script>
    
    <script type="text/javascript" src="_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="grid_class module" href="grid.html" />
    <link rel="prev" title="distribution_functions module" href="distribution_functions.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="index.html" class="icon icon-home" alt="Documentation Home"> binary_c-python
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="readme_link.html">Python module for binary_c</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="modules.html">Binarycpython code</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="custom_logging_functions.html">custom_logging_functions module</a></li>
<li class="toctree-l2"><a class="reference internal" href="distribution_functions.html">distribution_functions module</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">functions module</a></li>
<li class="toctree-l2"><a class="reference internal" href="grid.html">grid_class module</a></li>
<li class="toctree-l2"><a class="reference internal" href="grid_options_defaults.html">Grid options and descriptions</a></li>
<li class="toctree-l2"><a class="reference internal" href="hpc_functions.html">hpc_functions module</a></li>
<li class="toctree-l2"><a class="reference internal" href="plot_functions.html">plot_functions module</a></li>
<li class="toctree-l2"><a class="reference internal" href="run_system_wrapper.html">run_system_wrapper module</a></li>
<li class="toctree-l2"><a class="reference internal" href="spacing_functions.html">spacing_functions module</a></li>
<li class="toctree-l2"><a class="reference internal" href="stellar_types.html">stellar_types module</a></li>
<li class="toctree-l2"><a class="reference internal" href="useful_funcs.html">useful_funcs module</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="example_notebooks.html">Example notebooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="binary_c_parameters.html">Binary_c parameters</a></li>
<li class="toctree-l1"><a class="reference internal" href="grid_options_descriptions.html">Population grid code options</a></li>
<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python">Visit the GitLab repo</a></li>
<li class="toctree-l1"><a class="reference external" href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/issues/new">Submit an issue</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">binary_c-python</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          














<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="index.html" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="modules.html">Binarycpython code</a> &raquo;</li>
        
      <li>functions module</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="_sources/functions.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  
<style>
/* CSS overrides for sphinx_rtd_theme */

/* 24px margin */
.nbinput.nblast.container,
.nboutput.nblast.container {
    margin-bottom: 19px;  /* padding has already 5px */
}

/* ... except between code cells! */
.nblast.container + .nbinput.container {
    margin-top: -19px;
}

.admonition > p:before {
    margin-right: 4px;  /* make room for the exclamation icon */
}

/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */
.math {
    text-align: unset;
}
</style>
<div class="section" id="module-binarycpython.utils.functions">
<span id="functions-module"></span><h1>functions module<a class="headerlink" href="#module-binarycpython.utils.functions" title="Permalink to this headline">¶</a></h1>
<p>Module containing most of the utility functions for the binarycpython package</p>
<p>Functions here are mostly functions used in other classes/functions, or
useful functions for the user</p>
<dl class="simple">
<dt>Tasks:</dt><dd><ul class="simple">
<li><p>TODO: change all prints to verbose_prints</p></li>
</ul>
</dd>
</dl>
<dl class="py class">
<dt id="binarycpython.utils.functions.BinaryCEncoder">
<em class="property">class </em><code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">BinaryCEncoder</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span></em>, <em class="sig-param"><span class="n">skipkeys</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">ensure_ascii</span><span class="o">=</span><span class="default_value">True</span></em>, <em class="sig-param"><span class="n">check_circular</span><span class="o">=</span><span class="default_value">True</span></em>, <em class="sig-param"><span class="n">allow_nan</span><span class="o">=</span><span class="default_value">True</span></em>, <em class="sig-param"><span class="n">sort_keys</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">indent</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">separators</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">default</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#BinaryCEncoder"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.BinaryCEncoder" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">json.encoder.JSONEncoder</span></code></p>
<p>Encoding class function to attempt to convert things to strings.</p>
<dl class="py method">
<dt id="binarycpython.utils.functions.BinaryCEncoder.default">
<code class="sig-name descname">default</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">o</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#BinaryCEncoder.default"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.BinaryCEncoder.default" title="Permalink to this definition">¶</a></dt>
<dd><p>Converting function. Well, could be more precise. look at the JSON module</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt id="binarycpython.utils.functions.Capturing">
<em class="property">class </em><code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">Capturing</code><a class="reference internal" href="_modules/binarycpython/utils/functions.html#Capturing"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.Capturing" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></p>
<p>Context manager to capture output and store it</p>
<dl class="py method">
<dt id="binarycpython.utils.functions.Capturing.__enter__">
<code class="sig-name descname">__enter__</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#Capturing.__enter__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.Capturing.__enter__" title="Permalink to this definition">¶</a></dt>
<dd><p>On entry we capture the stdout output</p>
</dd></dl>

<dl class="py method">
<dt id="binarycpython.utils.functions.Capturing.__exit__">
<code class="sig-name descname">__exit__</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span><span class="n">args</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#Capturing.__exit__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.Capturing.__exit__" title="Permalink to this definition">¶</a></dt>
<dd><p>On exit we release the capture again</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt id="binarycpython.utils.functions.binarycDecoder">
<em class="property">class </em><code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">binarycDecoder</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span></em>, <em class="sig-param"><span class="n">object_hook</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">parse_float</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">parse_int</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">parse_constant</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">strict</span><span class="o">=</span><span class="default_value">True</span></em>, <em class="sig-param"><span class="n">object_pairs_hook</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#binarycDecoder"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.binarycDecoder" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">json.decoder.JSONDecoder</span></code></p>
<p>Custom decoder to transform the numbers that are strings to actual floats</p>
<dl class="py method">
<dt id="binarycpython.utils.functions.binarycDecoder.decode">
<code class="sig-name descname">decode</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">s</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#binarycDecoder.decode"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.binarycDecoder.decode" title="Permalink to this definition">¶</a></dt>
<dd><p>Entry point function for decoding</p>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.binaryc_json_serializer">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">binaryc_json_serializer</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">obj</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#binaryc_json_serializer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.binaryc_json_serializer" title="Permalink to this definition">¶</a></dt>
<dd><p>Custom serialiser for binary_c to use when functions are present in the dictionary
that we want to export.</p>
<p>Function objects will be turned into str representations of themselves</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>obj</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Any</span></code>) – The object that might not be serialisable</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="xref py py-data docutils literal notranslate"><span class="pre">Any</span></code></p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>Either string representation of object if the object is a function, or the object itself</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.call_binary_c_config">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">call_binary_c_config</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">argument</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#call_binary_c_config"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.call_binary_c_config" title="Permalink to this definition">¶</a></dt>
<dd><p>Function to interface with the binary_c config file</p>
<dl class="simple">
<dt>input:</dt><dd><ul class="simple">
<li><p>argument: argument for the binary_c config</p></li>
</ul>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p><ul class="simple">
<li><p>raw output of binary_c-config</p></li>
</ul>
</p>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt id="binarycpython.utils.functions.catchtime">
<em class="property">class </em><code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">catchtime</code><a class="reference internal" href="_modules/binarycpython/utils/functions.html#catchtime"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.catchtime" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>Context manager to calculate time spent</p>
<dl class="py method">
<dt id="binarycpython.utils.functions.catchtime.__enter__">
<code class="sig-name descname">__enter__</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#catchtime.__enter__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.catchtime.__enter__" title="Permalink to this definition">¶</a></dt>
<dd><p>On entry we start the clock</p>
</dd></dl>

<dl class="py method">
<dt id="binarycpython.utils.functions.catchtime.__exit__">
<code class="sig-name descname">__exit__</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">type</span></em>, <em class="sig-param"><span class="n">value</span></em>, <em class="sig-param"><span class="n">traceback</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#catchtime.__exit__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.catchtime.__exit__" title="Permalink to this definition">¶</a></dt>
<dd><p>On exit we stop the clock and measure the time spent</p>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.convert_bytes">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">convert_bytes</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">size</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#convert_bytes"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.convert_bytes" title="Permalink to this definition">¶</a></dt>
<dd><p>Function to return the size + a magnitude string</p>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.count_keys_recursive">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">count_keys_recursive</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">input_dict</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#count_keys_recursive"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.count_keys_recursive" title="Permalink to this definition">¶</a></dt>
<dd><p>Function to count the total amount of keys in a dictionary</p>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.create_arg_string">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">create_arg_string</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">arg_dict</span></em>, <em class="sig-param"><span class="n">sort</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">filter_values</span><span class="o">=</span><span class="default_value">False</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#create_arg_string"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.create_arg_string" title="Permalink to this definition">¶</a></dt>
<dd><p>Function that creates the arg string for binary_c. Takes a dictionary containing the arguments
and writes them to a string
This string is missing the ‘binary_c ‘ at the start.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>arg_dict</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – dictionary</p></li>
<li><p><strong>sort</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>) – (optional, default = False) Boolean whether to sort the order of the keys.</p></li>
<li><p><strong>filter_values</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>) – (optional, default = False) filters the input dict on keys that have NULL or <cite>function</cite> as value.</p></li>
</ul>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>The string built up by combining all the key + value’s.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.create_hdf5">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">create_hdf5</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">data_dir</span></em>, <em class="sig-param"><span class="n">name</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#create_hdf5"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.create_hdf5" title="Permalink to this definition">¶</a></dt>
<dd><dl class="simple">
<dt>Function to create an hdf5 file from the contents of a directory:</dt><dd><ul class="simple">
<li><p>settings file is selected by checking on files ending on settings</p></li>
<li><p>data files are selected by checking on files ending with .dat</p></li>
</ul>
</dd>
</dl>
<p>TODO: fix missing settings files</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>data_dir</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – directory containing the data files and settings file</p></li>
<li><p><strong>name</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – name of hdf5file.</p></li>
</ul>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.custom_sort_dict">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">custom_sort_dict</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">input_dict</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#custom_sort_dict"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.custom_sort_dict" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a dictionary that is ordered, but can handle numbers better than normal OrderedDict</p>
<p>When the keys of the current dictionary are of mixed type, we first find all the unique types.
Sort that list of type names. Then find the values that fit that type.
Sort those and append them to the sorted keys list.
This is done until all the keys are sorted.</p>
<p>All objects other than dictionary types are directly return as they are</p>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.example_parse_output">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">example_parse_output</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">output</span></em>, <em class="sig-param"><span class="n">selected_header</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#example_parse_output"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.example_parse_output" title="Permalink to this definition">¶</a></dt>
<dd><p>Function that parses output of binary_c. This version serves as an example and is quite
detailed. Custom functions can be easier:</p>
<p>This function works in two cases:
if the caught line contains output like ‘example_header time=12.32 mass=0.94 ..’
or if the line contains output like ‘example_header 12.32 0.94’
Please don’t the two cases.</p>
<p>You can give a ‘selected_header’ to catch any line that starts with that.
Then the values will be put into a dictionary.</p>
<dl class="simple">
<dt>Tasks:</dt><dd><ul class="simple">
<li><p>TODO: Think about exporting to numpy array or pandas instead of a defaultdict</p></li>
<li><p>TODO: rethink whether this function is necessary at all</p></li>
<li><p>TODO: check this function again</p></li>
</ul>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>output</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – binary_c output string</p></li>
<li><p><strong>selected_header</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – string header of the output (the start of the line that you want to
process)</p></li>
</ul>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>dictionary containing parameters as keys and lists for the values</p>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="binarycpython.utils.functions.extract_ensemble_json_from_string">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">extract_ensemble_json_from_string</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">binary_c_output</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#extract_ensemble_json_from_string"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.extract_ensemble_json_from_string" title="Permalink to this definition">¶</a></dt>
<dd><p>Function to extract the ensemble_json information from a raw binary_c output string</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>binary_c_output</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – raw binary_c output string</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>JSON dictionary with the parsed ENSEMBLE_JSON data</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.filter_arg_dict">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">filter_arg_dict</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">arg_dict</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#filter_arg_dict"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.filter_arg_dict" title="Permalink to this definition">¶</a></dt>
<dd><p>Function to filter out keys that contain values included in [‘NULL’, ‘Function’, ‘’]</p>
<p>This function is called by get_defaults()</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>arg_dict</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – dictionary containing the argument + default key pairs of binary_c</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>filtered dictionary (pairs with NULL and Function values are removed)</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.get_arg_keys">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">get_arg_keys</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_arg_keys"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.get_arg_keys" title="Permalink to this definition">¶</a></dt>
<dd><p>Function that return the list of possible keys to give in the arg string.
This function calls get_defaults()</p>
<dl class="field-list simple">
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>list of all the parameters that binary_c accepts (and has default values for, since
we call get_defaults())</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.get_defaults">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">get_defaults</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">filter_values</span><span class="o">=</span><span class="default_value">False</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_defaults"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.get_defaults" title="Permalink to this definition">¶</a></dt>
<dd><p>Function that calls the binaryc get args function and cast it into a dictionary.</p>
<p>All the values are strings</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>filter_values</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>) – whether to filter out NULL and Function defaults.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>dictionary containing the parameter name as key and the parameter default as value</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.get_help">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">get_help</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">param_name</span><span class="o">=</span><span class="default_value">''</span></em>, <em class="sig-param"><span class="n">print_help</span><span class="o">=</span><span class="default_value">True</span></em>, <em class="sig-param"><span class="n">fail_silently</span><span class="o">=</span><span class="default_value">False</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_help"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.get_help" title="Permalink to this definition">¶</a></dt>
<dd><p>Function that returns the help info for a given parameter, by interfacing with binary_c</p>
<p>Will check whether it is a valid parameter.</p>
<p>Binary_c will output things in the following order;
- Did you mean?
- binary_c help for variable
- default
- available macros</p>
<p>This function reads out that structure and catches the different components of this output</p>
<dl class="simple">
<dt>Tasks:</dt><dd><ul class="simple">
<li><p>TODO: consider not returning None, but return empty dict</p></li>
</ul>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>param_name</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – name of the parameter that you want info from. Will get checked whether its a
valid parameter name</p></li>
<li><p><strong>print_help</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>) – (optional, default = True) whether to print out the help information</p></li>
<li><p><strong>fail_silently</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>) – (optional, default = False) Whether to print the errors raised if the</p></li>
<li><p><strong>isn't valid</strong> (<em>parameter</em>) – </p></li>
</ul>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>]</p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>Dictionary containing the help info. This dictionary contains ‘parameter_name’,
‘parameter_value_input_type’, ‘description’, optionally ‘macros’</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.get_help_all">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">get_help_all</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">print_help</span><span class="o">=</span><span class="default_value">True</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_help_all"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.get_help_all" title="Permalink to this definition">¶</a></dt>
<dd><p>Function that reads out the output of the return_help_all API call to binary_c. This return_help_all binary_c returns all the information for the parameters, their descriptions and other properties. The output is categorised in sections.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>print_help</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>) – (optional, default = True) prints all the parameters and their descriptions.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>returns a dictionary containing dictionaries per section. These dictionaries contain the parameters and descriptions etc for all the parameters in that section</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.get_help_super">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">get_help_super</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">print_help</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">fail_silently</span><span class="o">=</span><span class="default_value">True</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_help_super"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.get_help_super" title="Permalink to this definition">¶</a></dt>
<dd><p>Function that first runs get_help_all, and then per argument also run
the help function to get as much information as possible.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>print_help</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>) – (optional, default = False) Whether to print the information</p></li>
<li><p><strong>fail_silently</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>) – (optional, default = True) Whether to fail silently or to print the errors</p></li>
</ul>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>dictionary containing all dictionaries per section, which then contain as much info as possible per parameter.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.get_moe_di_stefano_dataset">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">get_moe_di_stefano_dataset</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">options</span></em>, <em class="sig-param"><span class="n">verbosity</span><span class="o">=</span><span class="default_value">0</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_moe_di_stefano_dataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.get_moe_di_stefano_dataset" title="Permalink to this definition">¶</a></dt>
<dd><p>Function to get the default moe and di Stefano dataset or accept a user input.</p>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.get_size">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">get_size</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">obj</span></em>, <em class="sig-param"><span class="n">seen</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#get_size"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.get_size" title="Permalink to this definition">¶</a></dt>
<dd><p>Recursively finds size of objects</p>
<p>From <a class="reference external" href="https://github.com/bosswissam/pysize">https://github.com/bosswissam/pysize</a></p>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.handle_ensemble_string_to_json">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">handle_ensemble_string_to_json</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">raw_output</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#handle_ensemble_string_to_json"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.handle_ensemble_string_to_json" title="Permalink to this definition">¶</a></dt>
<dd><p>Function that deals with the raw output of the ensemble and
creates a working JSON dictionary out of it.</p>
<p>Having this wrapper makes it easy to</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>raw_output</strong> – raw output of the ensemble dump by binary_c</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>json.loads(raw_output, cls=binarycDecoder)</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.imports">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">imports</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#imports"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.imports" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.inspect_dict">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">inspect_dict</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">input_dict</span></em>, <em class="sig-param"><span class="n">indent</span><span class="o">=</span><span class="default_value">0</span></em>, <em class="sig-param"><span class="n">print_structure</span><span class="o">=</span><span class="default_value">True</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#inspect_dict"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.inspect_dict" title="Permalink to this definition">¶</a></dt>
<dd><p>Function to (recursively) inspect a (nested) dictionary.
The object that is returned is a dictionary containing the key of the input_dict, but as value
it will return the type of what the value would be in the input_dict</p>
<p>In this way we inspect the structure of these dictionaries, rather than the exact contents.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>input_dict</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – dictionary you want to inspect</p></li>
<li><p><strong>print_structure</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>) – (optional, default = True)</p></li>
<li><p><strong>indent</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – (optional, default = 0) indent of the first output</p></li>
</ul>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p><dl class="simple">
<dt>Dictionary that has the same structure as the input_dict, but as values it has the</dt><dd><p>type(input_dict[key]) (except if the value is a dict)</p>
</dd>
</dl>
</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.is_capsule">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">is_capsule</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">o</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#is_capsule"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.is_capsule" title="Permalink to this definition">¶</a></dt>
<dd><p>Function to tell whether object is a capsule</p>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.load_logfile">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">load_logfile</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">logfile</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#load_logfile"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.load_logfile" title="Permalink to this definition">¶</a></dt>
<dd><p>Experimental function that parses the generated log file of binary_c.</p>
<p>This function is not finished and shouldn’t be used yet.</p>
<dl class="simple">
<dt>Tasks:</dt><dd><ul class="simple">
<li><p>TODO:</p></li>
</ul>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>logfile</strong> (<em>-</em>) – filename of the log file you want to parse</p>
</dd>
</dl>
<p>Returns:</p>
<dl class="field-list simple">
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.make_build_text">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">make_build_text</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#make_build_text"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.make_build_text" title="Permalink to this definition">¶</a></dt>
<dd><p>Function to make build text</p>
<dl class="field-list simple">
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>string containing information about the build and the git branch</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.merge_dicts">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">merge_dicts</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">dict_1</span></em>, <em class="sig-param"><span class="n">dict_2</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#merge_dicts"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.merge_dicts" title="Permalink to this definition">¶</a></dt>
<dd><p>Function to merge two dictionaries in a custom way.</p>
<p>Behaviour:</p>
<dl class="simple">
<dt>When dict keys are only present in one of either:</dt><dd><ul class="simple">
<li><p>we just add the content to the new dict</p></li>
</ul>
</dd>
<dt>When dict keys are present in both, we decide based on the value types how to combine them:</dt><dd><ul class="simple">
<li><p>dictionaries will be merged by calling recursively calling this function again</p></li>
<li><p>numbers will be added</p></li>
<li><p>(opt) lists will be appended</p></li>
<li><p>In the case that the instances do not match: for now I will raise an error</p></li>
</ul>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dict_1</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – first dictionary</p></li>
<li><p><strong>dict_2</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – second dictionary</p></li>
</ul>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>Merged dictionary</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.multiply_values_dict">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">multiply_values_dict</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">input_dict</span></em>, <em class="sig-param"><span class="n">factor</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#multiply_values_dict"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.multiply_values_dict" title="Permalink to this definition">¶</a></dt>
<dd><p>Function that goes over dictionary recursively and multiplies the value if possible by a factor</p>
<p>If the key equals “general_info”, the multiplication gets skipped</p>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.output_lines">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">output_lines</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">output</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#output_lines"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.output_lines" title="Permalink to this definition">¶</a></dt>
<dd><p>Function that outputs the lines that were received from the binary_c run, but now as an iterator.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>output</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – raw binary_c output</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>Iterator over the lines of the binary_c output</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.parse_binary_c_version_info">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">parse_binary_c_version_info</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">version_info_string</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#parse_binary_c_version_info"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.parse_binary_c_version_info" title="Permalink to this definition">¶</a></dt>
<dd><p>Function that parses the binary_c version info. Long function with a lot of branches</p>
<p>TODO: fix this function. stuff is missing: isotopes, macros, nucleosynthesis_sources</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>version_info_string</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – raw output of version_info call to binary_c</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>‘isotopes’ for isotope info, ‘argpairs’ for argument pair info (TODO: explain), ‘ensembles’ for ensemble settings/info, ‘macros’ for macros, ‘elements’ for atomic element info, ‘DTlimit’ for (TODO: explain), ‘nucleosynthesis_sources’ for nucleosynthesis sources, and ‘miscellaneous’ for all those that were not caught by the previous groups. ‘git_branch’, ‘git_build’, ‘revision’ and ‘email’ are also keys, but its clear what those contain.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>Parsed version of the version info, which is a dictionary containing the keys</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.recursive_change_key_to_float">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">recursive_change_key_to_float</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">input_dict</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#recursive_change_key_to_float"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.recursive_change_key_to_float" title="Permalink to this definition">¶</a></dt>
<dd><p>Function to recursively change the key to float</p>
<p>This only works if the dict contains just sub-dicts or numbers/strings.
Does not work with lists as values</p>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.recursive_change_key_to_string">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">recursive_change_key_to_string</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">input_dict</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#recursive_change_key_to_string"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.recursive_change_key_to_string" title="Permalink to this definition">¶</a></dt>
<dd><p>Function to recursively change the key back to a string but this time in a format that we decide</p>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.remove_file">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">remove_file</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">file</span></em>, <em class="sig-param"><span class="n">verbosity</span><span class="o">=</span><span class="default_value">0</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#remove_file"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.remove_file" title="Permalink to this definition">¶</a></dt>
<dd><p>Function to remove files but with verbosity</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>file</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – full file path to the file that will be removed.</p></li>
<li><p><strong>verbosity</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – current verbosity level (Optional)</p></li>
</ul>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>the path of a sub directory called binary_c_python in the TMP of the file system</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.return_binary_c_version_info">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">return_binary_c_version_info</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">parsed</span><span class="o">=</span><span class="default_value">False</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#return_binary_c_version_info"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.return_binary_c_version_info" title="Permalink to this definition">¶</a></dt>
<dd><p>Function that returns the version information of binary_c. This function calls the function
_binary_c_bindings.return_version_info()</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>parsed</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>) – Boolean flag whether to parse the version_info output of binary_c. default = False</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>]</p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>Either the raw string of binary_c or a parsed version of this in the form of a nested
dictionary</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.subtract_dicts">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">subtract_dicts</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">dict_1</span></em>, <em class="sig-param"><span class="n">dict_2</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#subtract_dicts"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.subtract_dicts" title="Permalink to this definition">¶</a></dt>
<dd><p>Function to subtract two dictionaries.</p>
<p>Only allows values to be either a dict or a numerical type</p>
<dl class="simple">
<dt>For the overlapping keys (key name present in both dicts):</dt><dd><dl class="simple">
<dt>When the keys are of the same type:</dt><dd><ul class="simple">
<li><p>If the types are of numerical type: subtract the value at dict 2 from dict 1.</p></li>
<li><p>If the types are both dictionaries: call this function with the subdicts</p></li>
</ul>
</dd>
<dt>When the keys are not of the same type:</dt><dd><ul class="simple">
<li><p>if the keys are all of numerical types</p></li>
</ul>
</dd>
</dl>
</dd>
<dt>For the unique keys:</dt><dd><ul class="simple">
<li><p>if the key is from dict 1: adds the value to the new dict (be it numerical value or dict)</p></li>
<li><dl class="simple">
<dt>If the key is from dict 2: Adds the negative of its value in case of numerical type.</dt><dd><p>if the type is a dict, the result of subtract_dicts({}, dict_2[key]) will be set</p>
</dd>
</dl>
</li>
</ul>
</dd>
</dl>
<p>If the result is 0, the key will be removed from the resulting dict.
If that results in an empty dict, the dict will be removed too.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dict_1</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – first dictionary</p></li>
<li><p><strong>dict_2</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – second dictionary</p></li>
</ul>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>Subtracted dictionary</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.temp_dir">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">temp_dir</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span><span class="n">args</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#temp_dir"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.temp_dir" title="Permalink to this definition">¶</a></dt>
<dd><p>Function to create directory within the TMP directory of the file system</p>
<p>Makes use of os.makedirs exist_ok which requires python 3.2+</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>arguments</strong> (<em>function</em>) – str input where each next input will be a child of the previous full_path. e.g. temp_dir(‘tests’, ‘grid’) will become ‘/tmp/binary_c_python/tests/grid’</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>the path of a sub directory called binary_c_python in the TMP of the file system</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.update_dicts">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">update_dicts</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">dict_1</span></em>, <em class="sig-param"><span class="n">dict_2</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#update_dicts"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.update_dicts" title="Permalink to this definition">¶</a></dt>
<dd><p>Function to update dict_1 with values of dict_2 in a recursive way.</p>
<p>Behaviour:</p>
<dl class="simple">
<dt>When dict keys are only present in one of either:</dt><dd><ul class="simple">
<li><p>we just add the content to the new dict</p></li>
</ul>
</dd>
<dt>When dict keys are present in both, we decide based on the value types how to combine them:</dt><dd><ul class="simple">
<li><p>value of dict2 will be taken</p></li>
</ul>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dict_1</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – first dictionary</p></li>
<li><p><strong>dict_2</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>) – second dictionary</p></li>
</ul>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>New dictionary with Updated values</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.verbose_print">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">verbose_print</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">message</span></em>, <em class="sig-param"><span class="n">verbosity</span></em>, <em class="sig-param"><span class="n">minimal_verbosity</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#verbose_print"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.verbose_print" title="Permalink to this definition">¶</a></dt>
<dd><p>Function that decides whether to print a message based on the current verbosity
and its minimum verbosity</p>
<p>if verbosity is equal or higher than the minimum, then we print</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>message</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – message to print</p></li>
<li><p><strong>verbosity</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – current verbosity level</p></li>
<li><p><strong>minimal_verbosity</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – threshold verbosity above which to print</p></li>
</ul>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="binarycpython.utils.functions.write_binary_c_parameter_descriptions_to_rst_file">
<code class="sig-prename descclassname">binarycpython.utils.functions.</code><code class="sig-name descname">write_binary_c_parameter_descriptions_to_rst_file</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">output_file</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/binarycpython/utils/functions.html#write_binary_c_parameter_descriptions_to_rst_file"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#binarycpython.utils.functions.write_binary_c_parameter_descriptions_to_rst_file" title="Permalink to this definition">¶</a></dt>
<dd><p>Function that calls the get_help_super() to get the help text/descriptions for all the
parameters available in that build.
Writes the results to a .rst file that can be included in the docs.</p>
<dl class="simple">
<dt>Tasks:</dt><dd><ul class="simple">
<li><dl class="simple">
<dt>TODO: add the specific version git branch, git build, git commit, and binary_c version to</dt><dd><p>this document</p>
</dd>
</dl>
</li>
</ul>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>output_file</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – name of the output .rst file containing the ReStructuredText formatted output
of all the binary_c parameters.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></p>
</dd>
</dl>
</dd></dl>

</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="grid.html" class="btn btn-neutral float-right" title="grid_class module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="distribution_functions.html" class="btn btn-neutral float-left" title="distribution_functions module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        
        &copy; Copyright 2021, David Hendriks, Robert Izzard

    </p>
  </div>
    
    
    
    Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a
    
    <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
    
    provided by <a href="https://readthedocs.org">Read the Docs</a>.
<br><br>
Generated on binarycpython git branch: development_version/2.1.7 git revision b3e29831acaa0f53ec69dc9f97f9d49b48d0c6c9 url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python/-/tree/development_version/2.1.7">git url</a>.
<br><br>
Using binary_c with bit branch branch_david: git revision: "6101:20210807:c5232be5c" url: <a href="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/tree/branch_david">git url</a>.



</footer>

        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>