diff --git a/binarycpython/tests/test_c_bindings.py b/binarycpython/tests/test_c_bindings.py index b231189ae81b36a5f233dcba1b7d88c4ddefc9a2..2fc163d8700d259e405cbe735ed3f1320ceb4759 100644 --- a/binarycpython/tests/test_c_bindings.py +++ b/binarycpython/tests/test_c_bindings.py @@ -29,7 +29,6 @@ from binarycpython.utils.dicts import ( ) - TMP_DIR = temp_dir("tests", "test_c_bindings") #### some useful functions diff --git a/binarycpython/tests/test_functions.py b/binarycpython/tests/test_functions.py index e75861045aafa53c03c4996c8d6c3f8205ca74c2..d4ad330ec5b5412989c52f1d9004b00c5fb5d3ca 100644 --- a/binarycpython/tests/test_functions.py +++ b/binarycpython/tests/test_functions.py @@ -9,12 +9,8 @@ import tempfile import json import h5py -from binarycpython.utils.custom_logging_functions import ( - binary_c_log_code -) -from binarycpython.utils.run_system_wrapper import ( - run_system -) +from binarycpython.utils.custom_logging_functions import binary_c_log_code +from binarycpython.utils.run_system_wrapper import run_system from binarycpython.utils.functions import ( temp_dir, Capturing, @@ -34,17 +30,12 @@ from binarycpython.utils.functions import ( get_help_all, get_help_super, write_binary_c_parameter_descriptions_to_rst_file, - make_build_text -) -from binarycpython.utils.dicts import ( - AutoVivificationDict, - inspect_dict, - merge_dicts + make_build_text, ) +from binarycpython.utils.dicts import AutoVivificationDict, inspect_dict, merge_dicts from binarycpython.utils.ensemble import ( binaryc_json_serializer, - handle_ensemble_string_to_json - + handle_ensemble_string_to_json, ) TMP_DIR = temp_dir("tests", "test_functions") @@ -161,6 +152,7 @@ class test_temp_dir(unittest.TestCase): os.path.join(general_temp_dir, "binary_c_python-{}".format(username)) ) == binary_c_temp_dir + class test_create_hdf5(unittest.TestCase): """ Unittests for create_hdf5 diff --git a/binarycpython/utils/ensemble.py b/binarycpython/utils/ensemble.py index 24e812ba3caa3c37359194b25d4abb80a872569c..72a0ced7d9879a9398135c70adb028e729b447d5 100644 --- a/binarycpython/utils/ensemble.py +++ b/binarycpython/utils/ensemble.py @@ -28,9 +28,8 @@ from binarycpython.utils.dicts import ( custom_sort_dict, recursive_change_key_to_string, ) -from binarycpython.utils.functions import ( - verbose_print -) +from binarycpython.utils.functions import verbose_print + def ensemble_setting(ensemble, parameter_name): """ diff --git a/binarycpython/utils/functions.py b/binarycpython/utils/functions.py index 906dd9f32c36565662dd241af5c2b206456165ea..1480a418e8e1aaf142b59a535621ba040bb015f2 100644 --- a/binarycpython/utils/functions.py +++ b/binarycpython/utils/functions.py @@ -9,7 +9,6 @@ Tasks: """ - import bz2 import collections from colorama import Fore, Back, Style @@ -45,11 +44,7 @@ import astropy.units as u import binarycpython.utils.moe_di_stefano_2017_data as moe_di_stefano_2017_data from binarycpython import _binary_c_bindings -from binarycpython.utils.dicts import ( - filter_dict, - filter_dict_through_values -) - +from binarycpython.utils.dicts import filter_dict, filter_dict_through_values ######################################################## diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py index 1891df1eb7d57c4b9ed59c5e05985d6ab95316e8..11aae04939b1ef7d9118f30dc82307fda444cf46 100644 --- a/binarycpython/utils/grid.py +++ b/binarycpython/utils/grid.py @@ -46,7 +46,7 @@ from typing import Union, Any from collections import ( OrderedDict, ) -from collections.abc import Iterable # drop `.abc` with Python 2.7 or lower +from collections.abc import Iterable # drop `.abc` with Python 2.7 or lower import setproctitle import py_rinterpolate @@ -1203,13 +1203,15 @@ class Population: # Setup of the generator # Check again if we use custom generator or not: if self.grid_options["evolution_type"] == "custom_generator": - generator = self.grid_options['custom_generator'] + generator = self.grid_options["custom_generator"] else: self._generate_grid_code(dry_run=False) self._load_grid_function() - generator = self.grid_options["_system_generator"](self, print_results=False) + generator = self.grid_options["_system_generator"]( + self, print_results=False + ) # TODO: build in method to handle with the HPC. # Continuously fill the queue @@ -1657,7 +1659,7 @@ class Population: # Check option to ignore 0 probability systems if not self.grid_options["run_zero_probability_system"]: - if full_system_dict.get('probability', 1) == 0: + if full_system_dict.get("probability", 1) == 0: run_system = False zero_prob_stars_skipped += 1 @@ -1775,7 +1777,7 @@ class Population: self.grid_options["verbosity"], 1, ) - + ensemble_output = extract_ensemble_json_from_string(ensemble_raw_output) ensemble_output = extract_ensemble_json_from_string(ensemble_raw_output) @@ -2110,8 +2112,12 @@ class Population: # user-provided custom generator if self.grid_options["evolution_type"] == "custom_generator": - if not isinstance(self.grid_options['custom_generator'], Iterable): - print("Error. provided no or wrong custom value for the system generator (custom_generator: {})".format(self.grid_options['custom_generator'])) + if not isinstance(self.grid_options["custom_generator"], Iterable): + print( + "Error. provided no or wrong custom value for the system generator (custom_generator: {})".format( + self.grid_options["custom_generator"] + ) + ) raise ValueError # NOTE: In the part above i apparently have moved the load grid function call to another part. Now i wonder if that was useful, because it would be best if that is handled in this function @@ -4723,7 +4729,7 @@ eccentricity3=0 Makes use of the self.bse_options['multiplicity'] value. If its not set, it will raise an error grid_options['multiplicity_fraction_function'] will be checked for the choice - + TODO: add option to put a manual binary fraction in here (solve via negative numbers being the functions) """ @@ -4822,7 +4828,9 @@ eccentricity3=0 raise ValueError(msg) # To make sure we normalize the dictionary - multiplicity_fraction_dict = normalize_dict(multiplicity_fraction_dict, verbosity=self.grid_options["verbosity"]) + multiplicity_fraction_dict = normalize_dict( + multiplicity_fraction_dict, verbosity=self.grid_options["verbosity"] + ) verbose_print( "Multiplicity: {} multiplicity_fraction: {}".format( diff --git a/binarycpython/utils/grid_options_defaults.py b/binarycpython/utils/grid_options_defaults.py index e8f7a51080ae87d01120e868af592c3b77199f57..bfe7a48b0ee789ed505ffaea73f6682dc86d199b 100644 --- a/binarycpython/utils/grid_options_defaults.py +++ b/binarycpython/utils/grid_options_defaults.py @@ -42,9 +42,9 @@ grid_options_defaults_dict = { "max_queue_size": 1000, # Maximum size of the system call queue. "run_zero_probability_system": True, # Whether to run the zero probability systems "_zero_prob_stars_skipped": 0, - "ensemble_factor_in_probability_weighted_mass": False, # Whether to multiply the ensemble results by 1/probability_weighted_mass - "do_dry_run": True, # Whether to do a dry run to calculate the total probability for this run - "custom_generator": None, # Place for the custom system generator + "ensemble_factor_in_probability_weighted_mass": False, # Whether to multiply the ensemble results by 1/probability_weighted_mass + "do_dry_run": True, # Whether to do a dry run to calculate the total probability for this run + "custom_generator": None, # Place for the custom system generator "exit_after_dry_run": False, # Exit after dry run? ########################## # Execution log: @@ -74,7 +74,7 @@ grid_options_defaults_dict = { "_loaded_Moe2017_data": False, # Holds flag whether the Moe and di Stefano (2017) data is loaded into memory "_set_Moe2017_grid": False, # Whether the Moe and di Stefano (2017) grid has been loaded "Moe2017_options": None, # Holds the Moe and di Stefano (2017) options. - "_Moe2017_JSON_data": None, # Stores the data + "_Moe2017_JSON_data": None, # Stores the data ########################## # Custom logging ########################## @@ -100,7 +100,7 @@ grid_options_defaults_dict = { ## General "evolution_type": "grid", # Flag for type of population evolution "_evolution_type_options": [ - "grid", + "grid", "custom_generator", ], # available choices for type of population evolution. # TODO: fill later with Monte Carlo, source file "_system_generator": None, # value that holds the function that generates the system @@ -504,7 +504,7 @@ grid_options_descriptions = { "m&s_options": "Internal variable that holds the Moe and di Stefano (2017) options. Don't write to this your self", "_loaded_Moe2017_data": "Internal variable storing whether the Moe and di Stefano (2017) data has been loaded into memory", "do_dry_run": "Whether to do a dry run to calculate the total probability for this run", - "_Moe2017_JSON_data": "Location to store the loaded Moe&diStefano2017 dataset", # Stores the data + "_Moe2017_JSON_data": "Location to store the loaded Moe&diStefano2017 dataset", # Stores the data } ### diff --git a/setup.py b/setup.py index 670225cc02f5d8f774c6d6f6508c95c418f7ddea..593b49d51373b27d6d5e456551fd89b30e162d60 100644 --- a/setup.py +++ b/setup.py @@ -13,6 +13,7 @@ import distutils.command.build # TODO: replace the tasks that call binary_c-config with a single function that handles the return status a bit better. + def version(): """ opens VERSION and returns version number @@ -21,6 +22,7 @@ def version(): with open("VERSION") as file: return file.read().strip() + VERSION_NUMBER = version() # Functions