From ea5125892022d4b75619193546b5462398ba903b Mon Sep 17 00:00:00 2001
From: David Hendriks <davidhendriks93@gmail.com>
Date: Sun, 8 Aug 2021 19:48:37 +0100
Subject: [PATCH] updated population notebook

---
 examples/notebook_population.ipynb | 439 +++++++++++++++++++++++------
 1 file changed, 356 insertions(+), 83 deletions(-)

diff --git a/examples/notebook_population.ipynb b/examples/notebook_population.ipynb
index 47a43d442..46f5cef96 100644
--- a/examples/notebook_population.ipynb
+++ b/examples/notebook_population.ipynb
@@ -33,7 +33,6 @@
    "metadata": {},
    "source": [
     "- running ensemble\n",
-    "- using the output\n",
     "- using M&S grid"
    ]
   },
@@ -267,6 +266,28 @@
     "help(example_pop.add_grid_variable)"
    ]
   },
+  {
+   "cell_type": "markdown",
+   "id": "bd75cebe-2152-4025-b680-dc020b80889b",
+   "metadata": {},
+   "source": [
+    "All the distribution functions that we can use are stored in the `binarycpython.utils.distribution_functions` or `binarycpython/utils/distribution_functions.py` on git. If you uncomment the help statement below you can see which functions are available now:"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 5,
+   "id": "048db541-3e92-4c5d-a25c-9c5a34b9c857",
+   "metadata": {
+    "scrolled": true,
+    "tags": []
+   },
+   "outputs": [],
+   "source": [
+    "# import binarycpython.utils.distribution_functions\n",
+    "# help(binarycpython.utils.distribution_functions)"
+   ]
+  },
   {
    "cell_type": "markdown",
    "id": "1b3a007b-5c17-42a7-a981-7e268e6f545c",
@@ -277,7 +298,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 5,
+   "execution_count": 6,
    "id": "47979841-2c26-4b26-8945-603d013dc93a",
    "metadata": {},
    "outputs": [
@@ -370,7 +391,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 6,
+   "execution_count": 7,
    "id": "0c986215-93b1-4e30-ad79-f7c397e9ff7d",
    "metadata": {},
    "outputs": [
@@ -435,7 +456,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 7,
+   "execution_count": 8,
    "id": "fd197154-a8ce-4865-8929-008d3483101a",
    "metadata": {},
    "outputs": [
@@ -443,7 +464,7 @@
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "adding: parse_function=<function parse_function at 0x7f54b3a21a60> to grid_options\n"
+      "adding: parse_function=<function parse_function at 0x7ff3bdf79620> to grid_options\n"
      ]
     }
    ],
@@ -508,7 +529,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 8,
+   "execution_count": 9,
    "id": "8ea376c1-1e92-45af-8cab-9d7fdca564eb",
    "metadata": {
     "tags": []
@@ -524,11 +545,11 @@
       "Grid has handled 20 stars\n",
       "with a total probability of 0.05150046619238192\n",
       "Total starcount for this run will be: 20\n",
+      "EXAMPLE_COMPACT_OBJECT             2.867655467480e+01 1.33079 9.81391 0.00167028 13\n",
       "Generating grid code\n",
       "Constructing/adding: lnm1\n",
-      "EXAMPLE_COMPACT_OBJECT             2.867655467480e+01 1.33079 9.81391 0.00167028 13\n",
-      "EXAMPLE_COMPACT_OBJECT             4.439623364590e+01 1.38004 7.81906 0.00224431 13\n",
       "EXAMPLE_COMPACT_OBJECT             1.931266944719e+01 1.3933 12.3177 0.00124307 13\n",
+      "EXAMPLE_COMPACT_OBJECT             4.439623364590e+01 1.38004 7.81906 0.00224431 13\n",
       "EXAMPLE_COMPACT_OBJECT             1.364277535630e+01 1.47961 15.4603 0.000925128 13\n",
       "EXAMPLE_COMPACT_OBJECT             1.017435498578e+01 1.59052 19.4046 0.000688507 13\n",
       "EXAMPLE_COMPACT_OBJECT             8.294870923827e+00 1.7197 24.3552 0.000512406 13\n",
@@ -540,7 +561,7 @@
       "EXAMPLE_COMPACT_OBJECT             3.449960890183e+00 2.80457 95.2174 8.70668e-05 14\n",
       "EXAMPLE_COMPACT_OBJECT             3.172196856333e+00 3.05193 119.51 6.47976e-05 14\n",
       "EXAMPLE_COMPACT_OBJECT             3.069627290216e+00 3.27563 150 4.82242e-05 14\n",
-      "Population-c8a5c8285f6047bfa420a68ccc89a04f finished! The total probability was: 0.05150046619238191. It took a total of 0.8319869041442871s to run 20 systems on 2 cores\n",
+      "Population-2a7732d03e594ef4b5dfe9051b41d9c0 finished! The total probability was: 0.05150046619238191. It took a total of 0.7797017097473145s to run 20 systems on 2 cores\n",
       "There were no errors found in this run.\n"
      ]
     }
@@ -564,7 +585,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 9,
+   "execution_count": 10,
    "id": "e1f0464b-0424-4022-b34b-5b744bc2c59d",
    "metadata": {},
    "outputs": [
@@ -572,7 +593,7 @@
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "{'population_name': 'c8a5c8285f6047bfa420a68ccc89a04f', 'evolution_type': 'grid', 'failed_count': 0, 'failed_prob': 0, 'failed_systems_error_codes': [], 'errors_exceeded': False, 'errors_found': False, 'total_probability': 0.05150046619238191, 'total_count': 20, 'start_timestamp': 1628442540.4302576, 'end_timestamp': 1628442541.2622445, 'total_mass_run': 730.1048014407228, 'total_probability_weighted_mass_run': 0.2983275843337705, 'zero_prob_stars_skipped': 0}\n"
+      "{'population_name': '2a7732d03e594ef4b5dfe9051b41d9c0', 'evolution_type': 'grid', 'failed_count': 0, 'failed_prob': 0, 'failed_systems_error_codes': [], 'errors_exceeded': False, 'errors_found': False, 'total_probability': 0.05150046619238191, 'total_count': 20, 'start_timestamp': 1628444120.234709, 'end_timestamp': 1628444121.0144107, 'total_mass_run': 730.1048014407228, 'total_probability_weighted_mass_run': 0.2983275843337705, 'zero_prob_stars_skipped': 0}\n"
      ]
     }
    ],
@@ -592,7 +613,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 10,
+   "execution_count": 11,
    "id": "83f8e519-4f7c-474a-ad95-f175a34fae81",
    "metadata": {},
    "outputs": [
@@ -634,7 +655,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 16,
+   "execution_count": 12,
    "id": "dacfed75-dfe3-4afd-a0ff-a4be17746021",
    "metadata": {},
    "outputs": [
@@ -642,7 +663,13 @@
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "adding: verbosity=10 to grid_options\n",
+      "Generating grid code\n",
+      "Generating grid code\n",
+      "Constructing/adding: lnm1\n",
+      "Saving grid code to grid_options\n",
+      "Writing grid code to /tmp/binary_c_python/binary_c_grid_2a7732d03e594ef4b5dfe9051b41d9c0.py\n",
+      "Loading grid code function from /tmp/binary_c_python/binary_c_grid_2a7732d03e594ef4b5dfe9051b41d9c0.py\n",
+      "Grid code loaded\n",
       "Writing binary_c calls to /tmp/binary_c_python/example_python_population_result/binary_c_calls.txt\n",
       "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n",
       "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n",
@@ -665,12 +692,12 @@
       "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n",
       "_calculate_multiplicity_fraction: Chosen not to use any multiplicity fraction.\n",
       "Grid has handled 20 stars\n",
-      "with a total probability of 0.25750233096190955\n",
+      "with a total probability of 0.05150046619238192\n",
       "/tmp/binary_c_python/example_python_population_result/binary_c_calls.txt\n",
-      "binary_c M_1 2.0 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.013208238029791246 separation 0\n",
-      "binary_c M_1 2.5102526289471614 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.009829948023831718 separation 0\n",
-      "binary_c M_1 3.1506841305680684 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.0073157281034221516 separation 0\n",
-      "binary_c M_1 3.9545065608702976 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.005444573822104362 separation 0\n"
+      "binary_c M_1 2.0 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.013208238029791246\n",
+      "binary_c M_1 2.5102526289471614 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.009829948023831718\n",
+      "binary_c M_1 3.1506841305680684 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.0073157281034221516\n",
+      "binary_c M_1 3.9545065608702976 eccentricity 0.02 max_evolution_time 15000 orbital_period 45000000080 phasevol 0.22723621650191106 probability 0.005444573822104362\n"
      ]
     }
    ],
@@ -694,7 +721,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 12,
+   "execution_count": 13,
    "id": "7212b6be-9787-4122-a7f1-86538cf38179",
    "metadata": {},
    "outputs": [
@@ -706,66 +733,29 @@
       "Constructing/adding: lnm1\n",
       "Grid has handled 20 stars\n",
       "with a total probability of 0.05150046619238192\n",
-      "Total starcount for this run will be: 20\n"
-     ]
-    },
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "Process Process-5:\n",
-      "Traceback (most recent call last):\n",
-      "Process Process-6:\n",
-      "Traceback (most recent call last):\n",
-      "  File \"/home/david/.pyenv/versions/3.6.4/lib/python3.6/multiprocessing/process.py\", line 258, in _bootstrap\n",
-      "    self.run()\n",
-      "  File \"/home/david/.pyenv/versions/3.6.4/lib/python3.6/multiprocessing/process.py\", line 93, in run\n",
-      "    self._target(*self._args, **self._kwargs)\n",
-      "  File \"/home/david/.pyenv/versions/3.6.4/lib/python3.6/multiprocessing/process.py\", line 258, in _bootstrap\n",
-      "    self.run()\n",
-      "  File \"/home/david/.pyenv/versions/3.6.4/envs/dev-binarycpython3.6.4/lib/python3.6/site-packages/binarycpython/utils/grid.py\", line 1312, in _process_run_population_grid\n",
-      "    self._evolve_system_mp(full_system_dict)\n",
-      "  File \"/home/david/.pyenv/versions/3.6.4/lib/python3.6/multiprocessing/process.py\", line 93, in run\n",
-      "    self._target(*self._args, **self._kwargs)\n",
-      "  File \"/home/david/.pyenv/versions/3.6.4/envs/dev-binarycpython3.6.4/lib/python3.6/site-packages/binarycpython/utils/grid.py\", line 1312, in _process_run_population_grid\n",
-      "    self._evolve_system_mp(full_system_dict)\n",
-      "  File \"/home/david/.pyenv/versions/3.6.4/envs/dev-binarycpython3.6.4/lib/python3.6/site-packages/binarycpython/utils/grid.py\", line 1128, in _evolve_system_mp\n",
-      "    self.grid_options[\"parse_function\"](self, out)\n",
-      "  File \"<ipython-input-12-6a22064fcbfb>\", line 30, in parse_function\n",
-      "    for el in output_lines(output):\n",
-      "NameError: name 'output_lines' is not defined\n",
-      "  File \"/home/david/.pyenv/versions/3.6.4/envs/dev-binarycpython3.6.4/lib/python3.6/site-packages/binarycpython/utils/grid.py\", line 1128, in _evolve_system_mp\n",
-      "    self.grid_options[\"parse_function\"](self, out)\n",
-      "  File \"<ipython-input-12-6a22064fcbfb>\", line 30, in parse_function\n",
-      "    for el in output_lines(output):\n",
-      "NameError: name 'output_lines' is not defined\n"
-     ]
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
+      "Total starcount for this run will be: 20\n",
       "Generating grid code\n",
-      "Constructing/adding: lnm1\n"
-     ]
-    },
-    {
-     "ename": "KeyboardInterrupt",
-     "evalue": "",
-     "output_type": "error",
-     "traceback": [
-      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
-      "\u001b[0;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
-      "\u001b[0;32m<ipython-input-12-6a22064fcbfb>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m    127\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    128\u001b[0m \u001b[0;31m# Evolve the population\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 129\u001b[0;31m \u001b[0mexample_pop\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mevolve\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    130\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    131\u001b[0m \u001b[0;31m#\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
-      "\u001b[0;32m~/.pyenv/versions/3.6.4/envs/dev-binarycpython3.6.4/lib/python3.6/site-packages/binarycpython/utils/grid.py\u001b[0m in \u001b[0;36mevolve\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m    766\u001b[0m         \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    767\u001b[0m             \u001b[0;31m# Execute population evolution subroutines\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 768\u001b[0;31m             \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mevolve_population\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    769\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    770\u001b[0m         \u001b[0;31m# Put all interesting stuff in a variable and output that afterwards, as analytics of the run.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
-      "\u001b[0;32m~/.pyenv/versions/3.6.4/envs/dev-binarycpython3.6.4/lib/python3.6/site-packages/binarycpython/utils/grid.py\u001b[0m in \u001b[0;36mevolve_population\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m    826\u001b[0m         ):\n\u001b[1;32m    827\u001b[0m             \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgrid_options\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"evolution_type\"\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m\"grid\"\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 828\u001b[0;31m                 \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_evolve_population_grid\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    829\u001b[0m             \u001b[0;31m# elif self.grid_options[\"evolution_type\"] == \"mc\":\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    830\u001b[0m             \u001b[0;31m#     # TODO: add MC option\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
-      "\u001b[0;32m~/.pyenv/versions/3.6.4/envs/dev-binarycpython3.6.4/lib/python3.6/site-packages/binarycpython/utils/grid.py\u001b[0m in \u001b[0;36m_evolve_population_grid\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m   1037\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1038\u001b[0m         \u001b[0msentinel\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mobject\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1039\u001b[0;31m         \u001b[0;32mfor\u001b[0m \u001b[0moutput_dict\u001b[0m \u001b[0;32min\u001b[0m \u001b[0miter\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mresult_queue\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msentinel\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   1040\u001b[0m             \u001b[0mcombined_output_dict\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmerge_dicts\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcombined_output_dict\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0moutput_dict\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1041\u001b[0m             \u001b[0;32mif\u001b[0m \u001b[0mresult_queue\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mempty\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
-      "\u001b[0;32m<string>\u001b[0m in \u001b[0;36mget\u001b[0;34m(self, *args, **kwds)\u001b[0m\n",
-      "\u001b[0;32m~/.pyenv/versions/3.6.4/lib/python3.6/multiprocessing/managers.py\u001b[0m in \u001b[0;36m_callmethod\u001b[0;34m(self, methodname, args, kwds)\u001b[0m\n\u001b[1;32m    755\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    756\u001b[0m         \u001b[0mconn\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_id\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmethodname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 757\u001b[0;31m         \u001b[0mkind\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mconn\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrecv\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    758\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    759\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0mkind\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m'#RETURN'\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
-      "\u001b[0;32m~/.pyenv/versions/3.6.4/lib/python3.6/multiprocessing/connection.py\u001b[0m in \u001b[0;36mrecv\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m    248\u001b[0m         \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_check_closed\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    249\u001b[0m         \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_check_readable\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 250\u001b[0;31m         \u001b[0mbuf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_recv_bytes\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    251\u001b[0m         \u001b[0;32mreturn\u001b[0m \u001b[0m_ForkingPickler\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mloads\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbuf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgetbuffer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    252\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
-      "\u001b[0;32m~/.pyenv/versions/3.6.4/lib/python3.6/multiprocessing/connection.py\u001b[0m in \u001b[0;36m_recv_bytes\u001b[0;34m(self, maxsize)\u001b[0m\n\u001b[1;32m    405\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    406\u001b[0m     \u001b[0;32mdef\u001b[0m \u001b[0m_recv_bytes\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmaxsize\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 407\u001b[0;31m         \u001b[0mbuf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_recv\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m4\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    408\u001b[0m         \u001b[0msize\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mstruct\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0munpack\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"!i\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbuf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgetvalue\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    409\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0mmaxsize\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0msize\u001b[0m \u001b[0;34m>\u001b[0m \u001b[0mmaxsize\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
-      "\u001b[0;32m~/.pyenv/versions/3.6.4/lib/python3.6/multiprocessing/connection.py\u001b[0m in \u001b[0;36m_recv\u001b[0;34m(self, size, read)\u001b[0m\n\u001b[1;32m    377\u001b[0m         \u001b[0mremaining\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msize\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    378\u001b[0m         \u001b[0;32mwhile\u001b[0m \u001b[0mremaining\u001b[0m \u001b[0;34m>\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 379\u001b[0;31m             \u001b[0mchunk\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mread\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mhandle\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mremaining\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    380\u001b[0m             \u001b[0mn\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mchunk\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    381\u001b[0m             \u001b[0;32mif\u001b[0m \u001b[0mn\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
-      "\u001b[0;31mKeyboardInterrupt\u001b[0m: "
+      "Constructing/adding: lnm1\n",
+      "Population-3680f3882c0a449c944462abffea2447 finished! The total probability was: 0.05150046619238191. It took a total of 0.6246354579925537s to run 20 systems on 2 cores\n",
+      "There were no errors found in this run.\n",
+      "\n",
+      "\n",
+      "time mass zams_mass probability radius stellar_type\n",
+      "2.867655467480e+01 1.33079 9.81391 0.00167028 1.72498e-05 13\n",
+      "1.931266944719e+01 1.3933 12.3177 0.00124307 1.72498e-05 13\n",
+      "4.439623364590e+01 1.38004 7.81906 0.00224431 1.72498e-05 13\n",
+      "1.364277535630e+01 1.47961 15.4603 0.000925128 1.72498e-05 13\n",
+      "1.017435498578e+01 1.59052 19.4046 0.000688507 1.72498e-05 13\n",
+      "8.294870923827e+00 1.7197 24.3552 0.000512406 1.72498e-05 13\n",
+      "6.802132608769e+00 1.84162 30.5689 0.000381347 1.72498e-05 13\n",
+      "5.723570798020e+00 1.99471 38.3678 0.00028381 1.72498e-05 13\n",
+      "4.933751523833e+00 2.15875 48.1564 0.000211219 1.72498e-05 13\n",
+      "4.337250536639e+00 2.35209 60.4424 0.000157195 9.97286e-06 14\n",
+      "3.862081089332e+00 2.56776 75.8628 0.000116989 1.08873e-05 14\n",
+      "3.449960890183e+00 2.80457 95.2174 8.70668e-05 1.18914e-05 14\n",
+      "3.172196856333e+00 3.05193 119.51 6.47976e-05 1.29402e-05 14\n",
+      "3.069627290216e+00 3.27563 150 4.82242e-05 1.38887e-05 14\n",
+      "\n"
      ]
     }
    ],
@@ -907,13 +897,296 @@
     "print(output)"
    ]
   },
+  {
+   "cell_type": "markdown",
+   "id": "c2ab0979-6575-481d-9c1c-ca98517b2437",
+   "metadata": {},
+   "source": [
+    "We can also set up a population that samples biinary systems, by adding extra grid variables. Below is an example of a full script that runs a binary population and registers when a double compact object is formed. The logging is rather compact and should be expanded top be more useful"
+   ]
+  },
   {
    "cell_type": "code",
-   "execution_count": null,
-   "id": "1c8f4d66-536a-44a9-b044-d284784536ec",
+   "execution_count": 14,
+   "id": "79acdbb2-7dd6-45c4-9609-80994f03619a",
    "metadata": {},
-   "outputs": [],
-   "source": []
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Generating grid code\n",
+      "Constructing/adding: lnm1\n",
+      "Constructing/adding: q\n",
+      "Constructing/adding: log10per\n",
+      "Grid has handled 125 stars\n",
+      "with a total probability of 0.0862478164626921\n",
+      "Total starcount for this run will be: 125\n",
+      "Generating grid code\n",
+      "Constructing/adding: lnm1\n",
+      "Constructing/adding: q\n",
+      "Constructing/adding: log10per\n",
+      "Population-d20a4c74d20a43b881c0c9e5def5f76c finished! The total probability was: 0.08624781646269201. It took a total of 8.561265707015991s to run 125 systems on 2 cores\n",
+      "There were no errors found in this run.\n",
+      "\n",
+      "\n",
+      "time mass_1 zams_mass_1 mass_2 zams_mass_2 stellar_type_1 prev_stellar_type_1 stellar_type_2 prev_stellar_type_2 metallicity probability\n",
+      "8.863377990313e+01 1.29444 5.88566 0 2.99283 13 5 15 15 0.02 0.000627913\n",
+      "1.146421815741e+02 0 5.88566 1.33062 4.43925 15 15 13 5 0.02 0.000627913\n",
+      "7.222715508467e+01 1.34922 5.88566 0 5.88566 13 5 15 15 0.02 0.000627913\n",
+      "1.350021848285e+01 1.48488 17.3205 0 0.1 13 5 15 15 0.02 0.000154349\n",
+      "1.171108213270e+01 1.53113 17.3205 0 0.1 13 5 15 15 0.02 0.000154349\n",
+      "1.171086983243e+01 1.53177 17.3205 0 0.1 13 9 15 15 0.02 0.000154349\n",
+      "1.170770599495e+01 1.53176 17.3205 0 4.40513 13 5 15 15 0.02 0.000172877\n",
+      "1.230407246199e+01 1.59499 17.3205 0 4.40513 13 5 15 15 0.02 0.000610573\n",
+      "1.108751340926e+01 1.70319 17.3205 0 8.71025 13 4 15 15 0.02 0.000610573\n",
+      "1.941017702765e+01 1.34903 17.3205 1.65097 8.71025 13 13 13 5 0.02 0.000172877\n",
+      "1.980988739731e+01 1.36979 17.3205 1.60808 8.71025 13 13 13 5 0.02 0.000121486\n",
+      "3.571858031651e+01 1.53174 17.3205 1.30504 8.71025 13 13 13 5 0.02 8.42148e-05\n",
+      "3.459153942631e+01 1.53176 17.3205 1.31004 8.71025 13 13 13 5 0.02 9.8162e-05\n",
+      "1.687368550125e+01 1.34937 17.3205 1.73856 13.0154 13 13 13 8 0.02 0.000172877\n",
+      "1.194842917007e+01 1.78096 17.3205 0 13.0154 13 8 15 15 0.02 0.000610573\n",
+      "1.733614170983e+01 1.53184 17.3205 1.42375 13.0154 13 13 13 5 0.02 9.8162e-05\n",
+      "1.723547465714e+01 1.38403 17.3205 1.71288 13.0154 13 13 13 8 0.02 0.000121486\n",
+      "1.764340254985e+01 1.53174 17.3205 1.41264 13.0154 13 13 13 5 0.02 8.42148e-05\n",
+      "1.170425790780e+01 1.52963 17.3205 0 17.3205 13 5 15 15 0.02 0.000172877\n",
+      "8.922967341481e+00 1.85486 17.3205 0 17.3205 13 8 15 15 0.02 0.000610573\n",
+      "1.232906623449e+01 1.41074 17.3205 1.34281 17.3205 13 13 13 8 0.02 0.000121486\n",
+      "1.170775828562e+01 1.53183 17.3205 1.53183 17.3205 13 5 13 5 0.02 9.8162e-05\n",
+      "1.170770422321e+01 1.53175 17.3205 1.53175 17.3205 13 5 13 5 0.02 8.42148e-05\n",
+      "5.075844624794e+00 2.12303 50.9713 0 0.1 13 8 15 15 0.02 3.79411e-05\n",
+      "4.766606588165e+00 2.20484 50.9713 0 0.1 14 8 15 15 0.02 3.79411e-05\n",
+      "4.768305081494e+00 2.18838 50.9713 0 0.1 13 8 15 15 0.02 3.79411e-05\n",
+      "4.458869865939e+00 2.29864 50.9713 0 12.8178 14 8 15 15 0.02 0.000150087\n",
+      "1.806014211040e+01 2.10446 50.9713 1.40749 12.8178 13 13 13 5 0.02 2.9863e-05\n",
+      "4.797342083485e+00 2.10328 50.9713 0 12.8178 13 13 15 1 0.02 4.24954e-05\n",
+      "1.721374713429e+01 2.21673 50.9713 1.42212 12.8178 14 14 13 5 0.02 2.41295e-05\n",
+      "4.055645404546e+00 2.47276 50.9713 0 25.5357 14 7 15 15 0.02 0.000150087\n",
+      "1.806123543037e+01 2.21893 50.9713 1.40745 12.8178 14 14 13 5 0.02 2.07011e-05\n",
+      "8.117519147635e+00 2.10433 50.9713 2.21473 25.5357 13 13 14 8 0.02 4.24954e-05\n",
+      "8.315554923168e+00 2.15343 50.9713 2.08519 25.5357 13 13 13 8 0.02 2.9863e-05\n",
+      "7.917420996633e+00 2.21892 50.9713 1.7431 25.5357 14 14 13 8 0.02 2.07011e-05\n",
+      "7.693213405973e+00 2.21805 50.9713 1.78384 25.5357 14 14 13 8 0.02 2.41295e-05\n",
+      "3.753837732894e+00 2.62517 50.9713 0 38.2535 14 7 15 15 0.02 0.000150087\n",
+      "7.087296558990e+00 2.10417 50.9713 2.40935 38.2535 13 13 14 8 0.02 4.24954e-05\n",
+      "7.007109286263e+00 2.15854 50.9713 2.28672 38.2535 13 13 14 8 0.02 2.9863e-05\n",
+      "5.653200958306e+00 2.21878 50.9713 2.0587 38.2535 14 14 13 8 0.02 2.41295e-05\n",
+      "5.733794947644e+00 2.21892 50.9713 1.99255 38.2535 14 14 13 8 0.02 2.07011e-05\n",
+      "3.513216011269e+00 2.76647 50.9713 0 50.9713 14 7 15 15 0.02 0.000150087\n",
+      "4.750574783854e+00 2.27442 50.9713 0 50.9713 14 8 15 15 0.02 4.24954e-05\n",
+      "7.278384712062e+00 1.29678 50.9713 2.09216 50.9713 13 8 13 13 0.02 2.9863e-05\n",
+      "4.765996194699e+00 2.20787 50.9713 2.20787 50.9713 14 8 14 8 0.02 2.07011e-05\n",
+      "4.765535914728e+00 2.21331 50.9713 2.21331 50.9713 14 8 14 8 0.02 2.41295e-05\n",
+      "3.104706358826e+00 3.17639 150 0 0.1 14 7 15 15 0.02 9.32641e-06\n",
+      "3.069363482023e+00 3.27572 150 0 0.1 14 7 15 15 0.02 9.32641e-06\n",
+      "3.047074050271e+00 3.3836 150 0 37.575 14 7 15 15 0.02 3.68933e-05\n",
+      "5.974759306305e+00 3.23604 150 2.53922 37.575 14 14 14 7 0.02 1.04459e-05\n",
+      "6.074084349384e+00 3.30145 150 2.13876 37.575 14 14 13 8 0.02 7.34071e-06\n",
+      "5.733865371895e+00 3.29994 150 2.00498 37.575 14 14 13 8 0.02 5.93135e-06\n",
+      "3.027099358410e+00 3.53631 150 0 75.05 14 7 15 15 0.02 3.68933e-05\n",
+      "5.807147339697e+00 3.30197 150 1.9791 37.575 14 14 13 8 0.02 5.08861e-06\n",
+      "4.862942347290e+00 3.25294 150 2.97823 75.05 14 14 14 7 0.02 1.04459e-05\n",
+      "4.556479830908e+00 3.29942 150 2.73221 75.05 14 14 14 7 0.02 7.34071e-06\n",
+      "3.853070305680e+00 3.29977 150 2.62486 75.05 14 14 14 7 0.02 5.93135e-06\n",
+      "3.881529045940e+00 3.30149 150 2.55924 75.05 14 14 14 7 0.02 5.08861e-06\n",
+      "3.015033359333e+00 3.64419 150 0 112.525 14 7 15 15 0.02 3.68933e-05\n",
+      "4.126828648362e+00 3.32047 150 0 112.525 14 14 15 3 0.02 1.04459e-05\n",
+      "3.990017992944e+00 3.3032 150 2.94027 112.525 14 14 14 7 0.02 7.34071e-06\n",
+      "3.206771867883e+00 3.07671 150 3.11282 112.525 14 14 14 7 0.02 5.93135e-06\n",
+      "3.006827156705e+00 3.72638 150 0 150 14 7 15 15 0.02 3.68933e-05\n",
+      "3.218786094847e+00 3.30337 150 3.01344 112.525 14 14 14 7 0.02 5.08861e-06\n",
+      "4.527722847382e+00 1.42238 150 0 150 13 5 15 15 0.02 1.04459e-05\n",
+      "3.069567332611e+00 3.27804 150 3.27804 150 14 7 14 7 0.02 5.93135e-06\n",
+      "5.726405299909e+00 1.29746 150 3.22759 150 13 8 14 14 0.02 7.34071e-06\n",
+      "3.069626478211e+00 3.27565 150 3.27565 150 14 7 14 7 0.02 5.08861e-06\n",
+      "\n"
+     ]
+    }
+   ],
+   "source": [
+    "import os\n",
+    "\n",
+    "from binarycpython.utils.grid import Population\n",
+    "from binarycpython.utils.custom_logging_functions import temp_dir\n",
+    "\n",
+    "def parse_function(self, output):\n",
+    "    \"\"\"\n",
+    "    Example parsing function\n",
+    "    \"\"\"\n",
+    "    \n",
+    "    # extract info from the population instance\n",
+    "\n",
+    "    # Get some information from the\n",
+    "    data_dir = self.custom_options[\"data_dir\"]\n",
+    "    base_filename = self.custom_options[\"base_filename\"]\n",
+    "\n",
+    "    # Check directory, make if necessary\n",
+    "    os.makedirs(data_dir, exist_ok=True)\n",
+    "\n",
+    "    #\n",
+    "    seperator = \" \"\n",
+    "\n",
+    "    # Create filename\n",
+    "    outfilename = os.path.join(data_dir, base_filename)\n",
+    "\n",
+    "    # The header columns matching this \n",
+    "    parameters = [\n",
+    "        \"time\", \n",
+    "        \"mass_1\", \"zams_mass_1\", \"mass_2\", \"zams_mass_2\",\n",
+    "        \"stellar_type_1\", \"prev_stellar_type_1\", \"stellar_type_2\", \"prev_stellar_type_2\", \n",
+    "        \"metallicity\", \"probability\"\n",
+    "    ]\n",
+    "    \n",
+    "    # Go over the output.\n",
+    "    for el in output.splitlines():\n",
+    "        headerline = el.split()[0]\n",
+    "\n",
+    "        # CHeck the header and act accordingly\n",
+    "        if headerline == \"EXAMPLE_DCO\":\n",
+    "            values = el.split()[1:]\n",
+    "\n",
+    "            if not len(parameters) == len(values):\n",
+    "                print(\"Amount of column names isnt equal to amount of columns\")\n",
+    "                raise ValueError\n",
+    "\n",
+    "            if not os.path.exists(outfilename):\n",
+    "                with open(outfilename, \"w\") as f:\n",
+    "                    f.write(seperator.join(parameters) + \"\\n\")\n",
+    "\n",
+    "            with open(outfilename, \"a\") as f:\n",
+    "                f.write(seperator.join(values) + \"\\n\")\n",
+    "\n",
+    "\n",
+    "# Create population object\n",
+    "example_pop = Population()\n",
+    "\n",
+    "# If you want verbosity, set this before other things\n",
+    "example_pop.set(verbosity=0)\n",
+    "\n",
+    "# Setting values can be done via .set(<parameter_name>=<value>)\n",
+    "example_pop.set(\n",
+    "    # binary_c physics options\n",
+    "    M_1=10,  # bse_options\n",
+    "    separation=0,  # bse_options\n",
+    "    orbital_period=45000000080,  # bse_options\n",
+    "    max_evolution_time=15000,  # bse_options\n",
+    "    eccentricity=0.02,  # bse_options\n",
+    "    \n",
+    "    # grid_options\n",
+    "    amt_cores=2,  # grid_options\n",
+    "\n",
+    "    # Custom options: the data directory and the output filename\n",
+    "    data_dir=os.path.join(\n",
+    "        temp_dir(), \"example_python_population_result\"\n",
+    "    ),  # custom_options\n",
+    "    base_filename=\"example_pop.dat\",  # custom_options\n",
+    ")\n",
+    "\n",
+    "# Creating a parsing function\n",
+    "example_pop.set(\n",
+    "    parse_function=parse_function,  # Setting the parse function thats used in the evolve_population\n",
+    ")\n",
+    "\n",
+    "### Custom logging\n",
+    "# Log the moment when the star turns into neutron\n",
+    "example_pop.set(\n",
+    "    C_logging_code=\"\"\"\n",
+    "// logger to find gravitational wave progenitors\n",
+    "if(stardata->star[0].stellar_type>=NS && stardata->star[1].stellar_type>=NS)\n",
+    "{\n",
+    "    if (stardata->model.time < stardata->model.max_evolution_time)\n",
+    "    {\n",
+    "        Printf(\"EXAMPLE_DCO %30.12e \" // 1\n",
+    "            \"%g %g %g %g \" // 2-5\n",
+    "            \"%d %d %d %d \" // 6-9\n",
+    "            \"%g %g\\\\n\", // 10-11\n",
+    "\n",
+    "            stardata->model.time, // 1\n",
+    "\n",
+    "            stardata->star[0].mass, //2\n",
+    "            stardata->common.zero_age.mass[0], //3\n",
+    "            stardata->star[1].mass, //4\n",
+    "            stardata->common.zero_age.mass[1], //5\n",
+    "\n",
+    "            stardata->star[0].stellar_type, //6\n",
+    "            stardata->previous_stardata->star[0].stellar_type, //7\n",
+    "            stardata->star[1].stellar_type, //8\n",
+    "            stardata->previous_stardata->star[1].stellar_type, //9\n",
+    "\n",
+    "            // model stuff\n",
+    "            stardata->common.metallicity, //10\n",
+    "            stardata->model.probability //11\n",
+    "        );\n",
+    "    }\n",
+    "    /* Kill the simulation to safe time */\n",
+    "    stardata->model.max_evolution_time = stardata->model.time - stardata->model.dtm;\n",
+    "}\n",
+    "\"\"\"\n",
+    ")\n",
+    "\n",
+    "# Add grid variables\n",
+    "resolution = {\"M_1\": 5, \"q\": 5, \"per\": 5}\n",
+    "\n",
+    "# Mass\n",
+    "example_pop.add_grid_variable(\n",
+    "    name=\"lnm1\",\n",
+    "    longname=\"Primary mass\",\n",
+    "    valuerange=[2, 150],\n",
+    "    resolution=\"{}\".format(resolution[\"M_1\"]),\n",
+    "    spacingfunc=\"const(math.log(2), math.log(150), {})\".format(resolution[\"M_1\"]),\n",
+    "    precode=\"M_1=math.exp(lnm1)\",\n",
+    "    probdist=\"three_part_powerlaw(M_1, 0.1, 0.5, 1.0, 150, -1.3, -2.3, -2.3)*M_1\",\n",
+    "    dphasevol=\"dlnm1\",\n",
+    "    parameter_name=\"M_1\",\n",
+    "    condition=\"\",  # Impose a condition on this grid variable. Mostly for a check for yourself\n",
+    ")\n",
+    "\n",
+    "# Mass ratio\n",
+    "example_pop.add_grid_variable(\n",
+    "    name=\"q\",\n",
+    "    longname=\"Mass ratio\",\n",
+    "    valuerange=[\"0.1/M_1\", 1],\n",
+    "    resolution=\"{}\".format(resolution['q']),\n",
+    "    spacingfunc=\"const(0.1/M_1, 1, {})\".format(resolution['q']),\n",
+    "    probdist=\"flatsections(q, [{'min': 0.1/M_1, 'max': 1.0, 'height': 1}])\",\n",
+    "    dphasevol=\"dq\",\n",
+    "    precode=\"M_2 = q * M_1\",\n",
+    "    parameter_name=\"M_2\",\n",
+    "    condition=\"\",  # Impose a condition on this grid variable. Mostly for a check for yourself\n",
+    ")\n",
+    "\n",
+    "#\n",
+    "example_pop.add_grid_variable(\n",
+    "   name=\"log10per\", # in days\n",
+    "   longname=\"log10(Orbital_Period)\",\n",
+    "   valuerange=[0.15, 5.5],\n",
+    "   resolution=\"{}\".format(resolution[\"per\"]),\n",
+    "   spacingfunc=\"const(0.15, 5.5, {})\".format(resolution[\"per\"]),\n",
+    "   precode=\"\"\"orbital_period = 10** log10per\n",
+    "sep = calc_sep_from_period(M_1, M_2, orbital_period)\n",
+    "sep_min = calc_sep_from_period(M_1, M_2, 10**0.15)\n",
+    "sep_max = calc_sep_from_period(M_1, M_2, 10**5.5)\"\"\",\n",
+    "   probdist=\"sana12(M_1, M_2, sep, orbital_period, sep_min, sep_max, math.log10(10**0.15), math.log10(10**5.5), -0.55)\",\n",
+    "   parameter_name=\"orbital_period\",\n",
+    "   dphasevol=\"dlog10per\",\n",
+    ")\n",
+    "\n",
+    "# Exporting of all the settings can be done with .export_all_info()\n",
+    "example_pop.export_all_info()\n",
+    "\n",
+    "# remove the result file if it exists\n",
+    "if os.path.isfile(os.path.join(temp_dir(), \"example_python_population_result\", \"example_pop.dat\")):\n",
+    "    os.remove(os.path.join(temp_dir(), \"example_python_population_result\", \"example_pop.dat\"))\n",
+    "\n",
+    "# Evolve the population\n",
+    "example_pop.evolve()\n",
+    "\n",
+    "# \n",
+    "with open(os.path.join(temp_dir(), \"example_python_population_result\", \"example_pop.dat\"), 'r') as f:\n",
+    "    output = f.read()\n",
+    "print(\"\\n\")\n",
+    "print(output)"
+   ]
   }
  ],
  "metadata": {
-- 
GitLab