From 8da712b51ef56b156d30f831e2c3ec72bdef9ffb Mon Sep 17 00:00:00 2001 From: David Hendriks <davidhendriks93@gmail.com> Date: Tue, 5 Jan 2021 13:25:27 +0000 Subject: [PATCH] Updated all the (self)documentation and put the individual pieces in one by one. Now it doesn't break and the output is nice --- docs/source/_static/coverage.svg | 21 --- docs/source/binary_c_parameters.rst | 8 +- docs/source/conf.py | 42 ++++-- docs/source/coverage.svg | 21 --- docs/source/custom_logging_functions.rst | 2 +- docs/source/distribution_functions.rst | 2 +- docs/source/functions.rst | 2 +- docs/source/grid.rst | 2 +- docs/source/grid_options_defaults.rst | 6 +- docs/source/grid_options_descriptions.rst | 161 +++++++++++++++++++++- docs/source/hpc_functions.rst | 2 +- docs/source/index.rst | 3 +- docs/source/modules.rst | 1 - docs/source/plot_functions.rst | 2 +- docs/source/run_system_wrapper.rst | 2 +- docs/source/spacing_functions.rst | 2 +- docs/source/stellar_types.rst | 2 +- docs/source/tutorials.rst | 3 - docs/source/useful_funcs.rst | 2 +- 19 files changed, 204 insertions(+), 82 deletions(-) delete mode 100644 docs/source/_static/coverage.svg delete mode 100644 docs/source/coverage.svg delete mode 100644 docs/source/tutorials.rst diff --git a/docs/source/_static/coverage.svg b/docs/source/_static/coverage.svg deleted file mode 100644 index e3a194825..000000000 --- a/docs/source/_static/coverage.svg +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<svg xmlns="http://www.w3.org/2000/svg" width="99" height="20"> - <linearGradient id="b" x2="0" y2="100%"> - <stop offset="0" stop-color="#bbb" stop-opacity=".1"/> - <stop offset="1" stop-opacity=".1"/> - </linearGradient> - <mask id="a"> - <rect width="99" height="20" rx="3" fill="#fff"/> - </mask> - <g mask="url(#a)"> - <path fill="#555" d="M0 0h63v20H0z"/> - <path fill="#e05d44" d="M63 0h36v20H63z"/> - <path fill="url(#b)" d="M0 0h99v20H0z"/> - </g> - <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> - <text x="31.5" y="15" fill="#010101" fill-opacity=".3">coverage</text> - <text x="31.5" y="14">coverage</text> - <text x="80" y="15" fill="#010101" fill-opacity=".3">5%</text> - <text x="80" y="14">5%</text> - </g> -</svg> diff --git a/docs/source/binary_c_parameters.rst b/docs/source/binary_c_parameters.rst index b24fad112..31481dd7b 100644 --- a/docs/source/binary_c_parameters.rst +++ b/docs/source/binary_c_parameters.rst @@ -1,5 +1,10 @@ Binary\_c parameters ==================== +The following chapter contains all the parameters that the current version of binary\_c can handle, along with their descriptions and other properties. + + +This information was obtained by the following binary_c build: + **binary_c git branch**: branch_david **binary_c git revision**: 5473:20210104:97f766764 **Built on**: Jan 4 2021 18:40:36 Section: stars @@ -2330,4 +2335,5 @@ Section: misc | **Description**: Display list of arguments with their default values. Useful for batchmode. | **Parameter input type**: * | **Default value**: NULL -| **Extra**: Ignore \ No newline at end of file +| **Extra**: Ignore + diff --git a/docs/source/conf.py b/docs/source/conf.py index ccf1ef45f..118f1a9be 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -3,7 +3,7 @@ # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html - +# https://brendanhasz.github.io/2019/01/05/sphinx.html # -- Path setup -------------------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, @@ -13,14 +13,16 @@ import os import sys +import sphinx_rtd_theme + # https://www.sphinx-doc.org/en/1.5/ext/example_google.html # Include paths for python code sys.path.insert(0, os.path.abspath(".")) -sys.path.insert(0, os.path.abspath("../../binarycpython")) -# sys.path.insert(0, os.path.abspath('../../examples')) -sys.path.insert(0, os.path.abspath("../../")) -sys.path.insert(0, os.path.abspath("../../binarycpython/utils")) +# sys.path.insert(0, os.path.abspath("../../binarycpython")) +# # sys.path.insert(0, os.path.abspath('../../examples')) +# sys.path.insert(0, os.path.abspath("../../")) +# sys.path.insert(0, os.path.abspath("../../binarycpython/utils")) sys.path.insert(0, os.path.join(os.getenv("BINARY_C"), "src/API/")) # include paths for c code @@ -33,9 +35,6 @@ copyright = "2020, David Hendriks, Robert Izzard" author = "David Hendriks, Robert Izzard" - - - # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be @@ -50,12 +49,14 @@ extensions = [ "sphinx.ext.napoleon", "hawkmoth", "m2r2", + "sphinx_rtd_theme", + "sphinx_autodoc_typehints", # https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html ] # Napoleon settings -napoleon_google_docstring = True -napoleon_numpy_docstring = False +napoleon_google_docstring = True # https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html +napoleon_numpy_docstring = False napoleon_include_init_with_doc = False napoleon_include_private_with_doc = False napoleon_include_special_with_doc = True @@ -66,7 +67,6 @@ napoleon_use_ivar = False napoleon_use_param = True napoleon_use_rtype = True - source_suffix = [".rst", ".md"] # Add any paths that contain templates here, relative to this directory. @@ -82,8 +82,9 @@ exclude_patterns = [] # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -# -html_theme = "alabaster" + +# html_theme = "alabaster" +html_theme = "sphinx_rtd_theme" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, @@ -91,7 +92,6 @@ html_theme = "alabaster" html_static_path = ["_static"] - """Patching m2r2""" import m2r2 @@ -107,4 +107,16 @@ def patched_m2r2_setup(app): version=m2r2.__version__, parallel_read_safe=True, parallel_write_safe=True, ) -m2r2.setup = patched_m2r2_setup \ No newline at end of file +m2r2.setup = patched_m2r2_setup + +# Generate some custom documentations for this version of binarycpython and binary_c +from binarycpython.utils.functions import write_binary_c_parameter_descriptions_to_rst_file +from binarycpython.utils.grid_options_defaults import write_grid_options_to_rst_file + +print("Generating binary_c_parameters.rst") +write_binary_c_parameter_descriptions_to_rst_file("binary_c_parameters.rst") +print("Done") + +print("Generating grid_options_descriptions.rst") +write_grid_options_to_rst_file("grid_options_descriptions.rst") +print("Done") diff --git a/docs/source/coverage.svg b/docs/source/coverage.svg deleted file mode 100644 index e3a194825..000000000 --- a/docs/source/coverage.svg +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<svg xmlns="http://www.w3.org/2000/svg" width="99" height="20"> - <linearGradient id="b" x2="0" y2="100%"> - <stop offset="0" stop-color="#bbb" stop-opacity=".1"/> - <stop offset="1" stop-opacity=".1"/> - </linearGradient> - <mask id="a"> - <rect width="99" height="20" rx="3" fill="#fff"/> - </mask> - <g mask="url(#a)"> - <path fill="#555" d="M0 0h63v20H0z"/> - <path fill="#e05d44" d="M63 0h36v20H63z"/> - <path fill="url(#b)" d="M0 0h99v20H0z"/> - </g> - <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> - <text x="31.5" y="15" fill="#010101" fill-opacity=".3">coverage</text> - <text x="31.5" y="14">coverage</text> - <text x="80" y="15" fill="#010101" fill-opacity=".3">5%</text> - <text x="80" y="14">5%</text> - </g> -</svg> diff --git a/docs/source/custom_logging_functions.rst b/docs/source/custom_logging_functions.rst index 84f5bcf99..e382d4320 100644 --- a/docs/source/custom_logging_functions.rst +++ b/docs/source/custom_logging_functions.rst @@ -1,7 +1,7 @@ custom\_logging\_functions module ================================= -.. automodule:: custom_logging_functions +.. automodule:: binarycpython.utils.custom_logging_functions :members: :undoc-members: :show-inheritance: diff --git a/docs/source/distribution_functions.rst b/docs/source/distribution_functions.rst index 0e6da4a9e..5881ee382 100644 --- a/docs/source/distribution_functions.rst +++ b/docs/source/distribution_functions.rst @@ -1,7 +1,7 @@ distribution_functions module ================================= -.. automodule:: distribution_functions +.. automodule:: binarycpython.utils.distribution_functions :members: :undoc-members: :show-inheritance: \ No newline at end of file diff --git a/docs/source/functions.rst b/docs/source/functions.rst index 087d090c0..e675cc878 100644 --- a/docs/source/functions.rst +++ b/docs/source/functions.rst @@ -1,7 +1,7 @@ functions module ================ -.. automodule:: functions +.. automodule:: binarycpython.utils.functions :members: :undoc-members: :show-inheritance: diff --git a/docs/source/grid.rst b/docs/source/grid.rst index ea842b975..5f3347e6f 100644 --- a/docs/source/grid.rst +++ b/docs/source/grid.rst @@ -1,7 +1,7 @@ grid\_class module ================================= -.. automodule:: grid +.. automodule:: binarycpython.utils.grid :members: :undoc-members: :show-inheritance: \ No newline at end of file diff --git a/docs/source/grid_options_defaults.rst b/docs/source/grid_options_defaults.rst index 185893b36..c66555ac9 100644 --- a/docs/source/grid_options_defaults.rst +++ b/docs/source/grid_options_defaults.rst @@ -1,7 +1,7 @@ -grid\_options\_defaults module -================================= +Grid options and descriptions +============================= -.. automodule:: grid_options_defaults +.. automodule:: binarycpython.utils.grid_options_defaults :members: :undoc-members: :show-inheritance: \ No newline at end of file diff --git a/docs/source/grid_options_descriptions.rst b/docs/source/grid_options_descriptions.rst index db86452ce..5cef43570 100644 --- a/docs/source/grid_options_descriptions.rst +++ b/docs/source/grid_options_descriptions.rst @@ -1,7 +1,156 @@ -grid\_options\_descriptions module -================================== +Population grid code options +============================ +The following chapter contains all grid code options, along with their descriptions +There are 27 options that are not described yet. + + +Public options +-------------- +The following options are meant to be changed by the user. + + +| **C_auto_logging**: Dictionary containing parameters to be logged by binary_c. The structure of this dictionary is as follows: the key is used as the headline which the user can then catch. The value at that key is a list of binary_c system parameters (like star[0].mass) + +| **C_logging_code**: Variable to store the exact code that is used for the custom_logging. In this way the user can do more complex logging, as well as putting these logging strings in files. + +| **amt_cores**: The amount of cores that the population grid will use. The multiprocessing is useful but make sure to figure out how many logical cores the machine has. The core is multiprocessed, not multithreaded, and will gain no extra speed when amt_cores exceeds the amount of logical cores. Input: int + +| **binary**: Set this to 1 if the population contains binaries. Input: int + +| **condor**: Int flag whether to use a condor type population evolution. + +| **condor_command**: No description available yet + +| **condor_dir**: No description available yet + +| **condor_extra_settings**: No description available yet + +| **condor_jobid**: No description available yet + +| **condor_join_pwd**: No description available yet + +| **condor_memory**: No description available yet + +| **condor_njobs**: No description available yet + +| **condor_postpone_join**: No description available yet + +| **condor_universe**: No description available yet + +| **custom_logging_func_memaddr**: Memory adress where the custom_logging_function is stored. Input: int + +| **evolution_type**: Variable containing the type of evolution used of the grid. Multiprocessing or linear processing + +| **failed_systems_threshold**: Variable storing the maximum amount of systems that are allowed to fail before logging their commandline arguments to failed_systems log files + +| **gridcode_filename**: Filename for the grid code. Set and used by the population object. TODO: allow the user to provide their own function, rather than only a generated function. + +| **log_args**: Boolean to log the arguments. Unused + +| **log_args_dir**: Directory to log the arguments to. Unused + +| **log_file**: Log file for the population object. Unused + +| **modulo**: No description available yet + +| **parse_function**: Function that the user can provide to handle the output the binary_c. This function has to take the arguments (self, output). Its best not to return anything in this function, and just store stuff in the grid_options['results'] dictionary, or just output results to a file + +| **population_type**: variable storing what kind of population type should be evolved. See population_type_options for the options. + +| **results**: Dictionary in which the user can place their results. This dictionary gets merged at the end of a mulitprocessing simulation. + +| **slurm**: Int flag whether to use a slurm type population evolution. + +| **slurm_array**: No description available yet + +| **slurm_command**: No description available yet + +| **slurm_control_CPUs**: No description available yet + +| **slurm_dir**: No description available yet + +| **slurm_extra_settings**: No description available yet + +| **slurm_jobarrayindex**: No description available yet + +| **slurm_jobid**: No description available yet + +| **slurm_jobname**: No description available yet + +| **slurm_memory**: No description available yet + +| **slurm_njobs**: No description available yet + +| **slurm_ntasks**: No description available yet + +| **slurm_partition**: No description available yet + +| **slurm_postpone_join**: No description available yet + +| **slurm_postpone_sbatch**: No description available yet + +| **slurm_time**: No description available yet + +| **slurm_use_all_node_CPUs**: No description available yet + +| **slurm_warn_max_memory**: No description available yet + +| **source_file_filename**: Variable containing the source file containing lines of binary_c commandline calls. These all have to start with binary_c. + +| **tmp_dir**: Directory where certain types of output are stored. The grid code is stored in that directory, as well as the custom logging libraries. Log files and other diagnostics will usually be written to this location, unless specified otherwise + +| **verbosity**: Verbosity of the population code. Default is 0, by which only errors will be printed. Higher values will show more output, which is good for debugging. + +Private options +--------------- +The following options are not meant to be changed by the user, as these options are used and set internally by the object itself. The description still is provided, but just for documentation purposes. +| **_binary_c_config_executable**: Full path of the binary_c-config executable. This options is not used in the population object. + +| **_binary_c_dir**: Director where binary_c is stored. This options are not really used + +| **_binary_c_executable**: Full path to the binary_c executable. This options is not used in the population object. + +| **_binary_c_shared_library**: Full path to the libbinary_c file. This options is not used in the population object + +| **_commandline_input**: String containing the arguments passed to the population object via the command line. Set and used by the population object. + +| **_count**: Counter tracking which system the generator is on. + +| **_custom_logging_shared_library_file**: filename for the custom_logging shared library. Used and set by the population object + +| **_end_time_evolution**: Variable storing the end timestamp of the population evolution. Set by the object itself + +| **_errors_exceeded**: Variable storing a boolean flag whether the amount of errors was higher than the set threshold (failed_systems_threshold). If True, then the commandline arguments of the failing systems will not be stored in the failed_system_log files. + +| **_errors_found**: Variable storing a boolean flag whether errors by binary_c are encountered. + +| **_evolution_type_options**: List containing the evolution type options. + +| **_failed_count**: Variable storing the amount of failed systems. + +| **_failed_prob**: Variable storing the total probability of all the failed systems + +| **_failed_systems_error_codes**: List storing the unique error codes raised by binary_c of the failed systems + +| **_grid_variables**: Dictionary storing the grid_variables. These contain properties which are accessed by the _generate_grid_code function + +| **_main_pid**: Main process ID of the master process. Used and set by the population object. + +| **_population_id**: Variable storing a unique 32-char hex string. + +| **_population_type_options**: List storing the population_type options. + +| **_probtot**: Total probability of the population. + +| **_repeat**: Factor of how many times a system should be repeated. Consider the evolution splitting binary_c argument for supernovae kick repeating. + +| **_start_time_evolution**: Variable storing the start timestamp of the population evolution. Set by the object itself. + +| **_store_memaddr**: Memory adress of the store object for binary_c. + +| **_system_generator**: Function object that contains the system generator function. This can be from a grid, or a source file, or a montecarlo grid. + +| **_total_starcount**: Variable storing the total amount of systems in the generator. Used and set by the population object. + +| **_weight**: Weight factor for each system. The calculated probability is mulitplied by this. If the user wants each system to be repeated several times, then this variable should not be changed, rather change the _repeat variable instead, as that handles the reduction in probability per system. This is useful for systems that have a process with some random element in it. -.. automodule:: grid_options_descriptions - :members: - :undoc-members: - :show-inheritance: \ No newline at end of file diff --git a/docs/source/hpc_functions.rst b/docs/source/hpc_functions.rst index bb7f5b350..d336a0be0 100644 --- a/docs/source/hpc_functions.rst +++ b/docs/source/hpc_functions.rst @@ -1,7 +1,7 @@ hpc\_functions module ================================= -.. automodule:: hpc_functions +.. automodule:: binarycpython.utils.hpc_functions :members: :undoc-members: :show-inheritance: \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst index 2cc0b56d9..bf0ccf76e 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -13,8 +13,9 @@ Welcome to binary_c-python's documentation! readme_link modules examples - tutorials binary_c_parameters + grid_options_descriptions + Indices and tables ================== diff --git a/docs/source/modules.rst b/docs/source/modules.rst index c3304001b..d4aaac502 100644 --- a/docs/source/modules.rst +++ b/docs/source/modules.rst @@ -10,7 +10,6 @@ This chapter contains the (auto)documentation for all the functions and modules functions grid grid_options_defaults - grid_options_descriptions hpc_functions plot_functions run_system_wrapper diff --git a/docs/source/plot_functions.rst b/docs/source/plot_functions.rst index 9eef3f7f8..6af374e53 100644 --- a/docs/source/plot_functions.rst +++ b/docs/source/plot_functions.rst @@ -1,7 +1,7 @@ plot\_functions module ================================= -.. automodule:: plot_functions +.. automodule:: binarycpython.utils.plot_functions :members: :undoc-members: :show-inheritance: \ No newline at end of file diff --git a/docs/source/run_system_wrapper.rst b/docs/source/run_system_wrapper.rst index 44020176e..388b6878c 100644 --- a/docs/source/run_system_wrapper.rst +++ b/docs/source/run_system_wrapper.rst @@ -1,7 +1,7 @@ run\_system\_wrapper module ================================= -.. automodule:: run_system_wrapper +.. automodule:: binarycpython.utils.run_system_wrapper :members: :undoc-members: :show-inheritance: \ No newline at end of file diff --git a/docs/source/spacing_functions.rst b/docs/source/spacing_functions.rst index 22af7e645..be0cf254d 100644 --- a/docs/source/spacing_functions.rst +++ b/docs/source/spacing_functions.rst @@ -1,7 +1,7 @@ spacing\_functions module ================================= -.. automodule:: spacing_functions +.. automodule:: binarycpython.utils.spacing_functions :members: :undoc-members: :show-inheritance: \ No newline at end of file diff --git a/docs/source/stellar_types.rst b/docs/source/stellar_types.rst index 4fbcab371..1254b3d55 100644 --- a/docs/source/stellar_types.rst +++ b/docs/source/stellar_types.rst @@ -1,7 +1,7 @@ stellar\_types module ===================== -.. automodule:: stellar_types +.. automodule:: binarycpython.utils.stellar_types :members: :undoc-members: :show-inheritance: diff --git a/docs/source/tutorials.rst b/docs/source/tutorials.rst deleted file mode 100644 index ec639385c..000000000 --- a/docs/source/tutorials.rst +++ /dev/null @@ -1,3 +0,0 @@ -Tutorials -========= -This chapter contains some tutorials for some problems \ No newline at end of file diff --git a/docs/source/useful_funcs.rst b/docs/source/useful_funcs.rst index 0c0e9d99a..2b8b9d26a 100644 --- a/docs/source/useful_funcs.rst +++ b/docs/source/useful_funcs.rst @@ -1,7 +1,7 @@ useful\_funcs module ================================= -.. automodule:: useful_funcs +.. automodule:: binarycpython.utils.useful_funcs :members: :undoc-members: :show-inheritance: \ No newline at end of file -- GitLab