{ "cells": [ { "cell_type": "markdown", "id": "d5c04b77-f0be-4b33-8c03-c72eb846527c", "metadata": {}, "source": [ "# Tutorial: Extra features and functionality of binary_c-python\n", "In this notebook we'll go over some of the extra features and functionality that was not covered in the other notebooks.\n", "\n", "Within the module `binarycpython.utils.functions` there are many functions that can be useful when using binarycpython. We can see which functions are in there, again by using the `help()`" ] }, { "cell_type": "code", "execution_count": 33, "id": "de73a2c1-7acd-4b55-a4c4-ee6a7e0758d0", "metadata": {}, "outputs": [], "source": [ "from binarycpython.utils.functions import (\n", " get_help,\n", " get_help_all,\n", " get_help_super,\n", " return_binary_c_version_info,\n", " get_defaults\n", ")\n", "# help(binarycpython.utils.functions)" ] }, { "cell_type": "markdown", "id": "88b93969-b6aa-41b7-8f4d-2eee38d7a756", "metadata": {}, "source": [ "## getting extra information about binary_c parameters\n", "There are several functions that can be used to get information about the parameters in binary_c: \n", "- `get_help(parameter)`: Function to get information about the specific input parameter. Prints the output on default but returns a dictionary containing the information. \n", "- `get_help_all(print_help=True)`: Function to get information about all the parameters. Prints the output on default but returns a dictionary containing the information. \n", "- `get_help_super()`: Function to get even more information about all the parameters. Does not print the output on default but returns a dictionary containing the information. \n", "- `get_defaults()`: Function that will get all the default values for the parameters. Returns a dictionary" ] }, { "cell_type": "code", "execution_count": 23, "id": "7cfe1832-7fec-4817-b633-5b275c65667f", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "parameter_name:\n", "\tM_1\n", "parameter_value_input_type:\n", "\tFloat\n", "description:\n", "\tThe initial mass of star one (in solar units, internally this is star index 0).\n", "default:\n", "\t0\n" ] }, { "data": { "text/plain": [ "{'parameter_name': 'M_1',\n", " 'parameter_value_input_type': 'Float',\n", " 'description': 'The initial mass of star one (in solar units, internally this is star index 0).',\n", " 'default': '0'}" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "get_help('M_1')" ] }, { "cell_type": "code", "execution_count": 22, "id": "af62a066-ef70-4b59-877e-2b5a6bafcfc2", "metadata": {}, "outputs": [], "source": [ "# get_help_all()" ] }, { "cell_type": "code", "execution_count": 21, "id": "b85f1956-ee69-444a-a212-cd7473007bf1", "metadata": {}, "outputs": [], "source": [ "# get_help_super()" ] }, { "cell_type": "code", "execution_count": 36, "id": "e22b7a47-2748-406e-bba4-e92825ea9b47", "metadata": {}, "outputs": [], "source": [ "# get_defaults()" ] }, { "cell_type": "markdown", "id": "c89ef423-82b9-49ed-8cf9-94c9ce41a82a", "metadata": {}, "source": [ "## Build information of binary_c\n", "Sometimes we want to know with which settings binary_c has been built. We can use the function `return_binary_c_version_info` for this.\n", "This function will parse the version info of binary_c and return a dictionary with all the settings." ] }, { "cell_type": "code", "execution_count": 32, "id": "4dae05bd-6a66-4b1f-be4a-d092627dfe37", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "dict_keys(['networks', 'isotopes', 'argpairs', 'ensembles', 'macros', 'elements', 'dt_limits', 'nucleosynthesis_sources', 'miscellaneous'])\n" ] } ], "source": [ "version_info_dict = return_binary_c_version_info(parsed=True)\n", "print(version_info_dict.keys())" ] }, { "cell_type": "markdown", "id": "708c7253-9d9d-4705-969b-23f29695517d", "metadata": {}, "source": [ "## Example parse function\n", "TODO: In the functions module there is an example parse function that can be used in conjunction with run_system. " ] }, { "cell_type": "code", "execution_count": 34, "id": "8656614a-09da-486f-b299-61cc6092187c", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Help on function get_defaults in module binarycpython.utils.functions:\n", "\n", "get_defaults(filter_values:bool=False) -> dict\n", " Function that calls the binaryc get args function and cast it into a dictionary.\n", " \n", " All the values are strings\n", " \n", " Args:\n", " filter_values: whether to filter out NULL and Function defaults.\n", " \n", " Returns:\n", " dictionary containing the parameter name as key and the parameter default as value\n", "\n" ] } ], "source": [] }, { "cell_type": "markdown", "id": "6fac26d0-a0d2-40c7-915d-0883247cd24d", "metadata": {}, "source": [ "## Dictionary modification\n", "- merge_dicts \n", "- update_dicts\n", "- multiply_values_dict\n", "\n", "TODO:" ] }, { "cell_type": "markdown", "id": "b3c259ef-9f89-4b26-9ce3-45af625bc398", "metadata": {}, "source": [ "## Getting help\n", "There are sever" ] }, { "cell_type": "code", "execution_count": null, "id": "bf3c1e28-1662-47a7-abab-aa6fb0ef0882", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.4" } }, "nbformat": 4, "nbformat_minor": 5 }