diff --git a/binarycpython/utils/functions.py b/binarycpython/utils/functions.py index 27a32531207db9c075c33f92e4d8a3fdce7aaed4..4effffa2f7370e2fc7a5a47288f89b58691abc2c 100644 --- a/binarycpython/utils/functions.py +++ b/binarycpython/utils/functions.py @@ -163,7 +163,7 @@ def parse_binary_c_version_info(version_info_string): ########################## # Isotopes: # Split off - isotopes = set([el for el in cleaned if el.startswith('Isotope ')]) + isotopes = set([el for el in cleaned if el.startswith("Isotope ")]) cleaned = cleaned - isotopes isotope_dict = {} @@ -171,23 +171,36 @@ def parse_binary_c_version_info(version_info_string): split_info = el.split("Isotope ")[-1].strip().split(" is ") isotope_info = split_info[-1] - name = isotope_info.split(' ')[0].strip() + name = isotope_info.split(" ")[0].strip() # Get details - mass_g = float(isotope_info.split(",")[0].split('(')[1].split("=")[-1][:-2].strip()) - mass_amu = float(isotope_info.split(",")[0].split('(')[-1].split("=")[-1].strip()) - mass_mev = float(isotope_info.split(",")[-3].split("=")[-1].replace(")", "").strip()) + mass_g = float( + isotope_info.split(",")[0].split("(")[1].split("=")[-1][:-2].strip() + ) + mass_amu = float( + isotope_info.split(",")[0].split("(")[-1].split("=")[-1].strip() + ) + mass_mev = float( + isotope_info.split(",")[-3].split("=")[-1].replace(")", "").strip() + ) A = int(isotope_info.split(",")[-1].strip().split("=")[-1].replace(")", "")) Z = int(isotope_info.split(",")[-2].strip().split("=")[-1]) # - isotope_dict[int(split_info[0])] = {'name': name, 'Z': Z, 'A': A, 'mass_mev': mass_mev, 'mass_g': mass_g, 'mass_amu': mass_amu} - version_info_dict['isotopes'] = isotope_dict + isotope_dict[int(split_info[0])] = { + "name": name, + "Z": Z, + "A": A, + "mass_mev": mass_mev, + "mass_g": mass_g, + "mass_amu": mass_amu, + } + version_info_dict["isotopes"] = isotope_dict ########################## # Argpairs: # Split off - argpairs = set([el for el in cleaned if el.startswith('ArgPair')]) + argpairs = set([el for el in cleaned if el.startswith("ArgPair")]) cleaned = cleaned - argpairs argpair_dict = {} @@ -199,33 +212,33 @@ def parse_binary_c_version_info(version_info_string): else: argpair_dict[split_info[0]][split_info[1]] = split_info[2] - version_info_dict['argpairs'] = argpair_dict + version_info_dict["argpairs"] = argpair_dict ########################## # ensembles: # Split off - ensembles = set([el for el in cleaned if el.startswith('Ensemble')]) + ensembles = set([el for el in cleaned if el.startswith("Ensemble")]) cleaned = cleaned - ensembles ensemble_dict = {} for el in ensembles: split_info = el.split("Ensemble ")[-1].split(" is ") - if len(split_info)>1: + if len(split_info) > 1: ensemble_dict[int(split_info[0])] = split_info[-1] - version_info_dict['ensembles'] = ensemble_dict + version_info_dict["ensembles"] = ensemble_dict ########################## # macros: # Split off - macros = set([el for el in cleaned if el.startswith('macroxyz')]) + macros = set([el for el in cleaned if el.startswith("macroxyz")]) cleaned = cleaned - macros param_type_dict = { - 'STRING': str, - 'FLOAT': float, - 'MACRO': str, - 'INT': int, - 'LONG_INT': int, + "STRING": str, + "FLOAT": float, + "MACRO": str, + "INT": int, + "LONG_INT": int, } macros_dict = {} @@ -241,12 +254,12 @@ def parse_binary_c_version_info(version_info_string): macros_dict[param_name] = param_type_dict[param_type](param_value) except ValueError: macros_dict[param_name] = str(param_value) - version_info_dict['macros'] = macros_dict + version_info_dict["macros"] = macros_dict ########################## # Elements: # Split off: - elements = set([el for el in cleaned if el.startswith('Element')]) + elements = set([el for el in cleaned if el.startswith("Element")]) cleaned = cleaned - elements # Fill dict: @@ -257,31 +270,42 @@ def parse_binary_c_version_info(version_info_string): # get isotope info isotopes = {} - if not split_info[-1][0]=='0': + if not split_info[-1][0] == "0": isotope_string = split_info[-1].split(" = ")[-1] - isotopes = {int(split_isotope.split("=")[0]):split_isotope.split("=")[1] for split_isotope in isotope_string.split(" ")} + isotopes = { + int(split_isotope.split("=")[0]): split_isotope.split("=")[1] + for split_isotope in isotope_string.split(" ") + } - elements_dict[int(name_info[0])] = {'name': name_info[-1], 'atomic_number': int(name_info[0]), 'amt_isotopes': len(isotopes), 'isotopes': isotopes} - version_info_dict['elements'] = version_info_dict + elements_dict[int(name_info[0])] = { + "name": name_info[-1], + "atomic_number": int(name_info[0]), + "amt_isotopes": len(isotopes), + "isotopes": isotopes, + } + version_info_dict["elements"] = version_info_dict ########################## # dt_limits: # split off - dt_limits = set([el for el in cleaned if el.startswith('DTlimit')]) + dt_limits = set([el for el in cleaned if el.startswith("DTlimit")]) cleaned = cleaned - dt_limits # Fill dict dt_limits_dict = {} for el in dt_limits: split_info = el.split("DTlimit ")[-1].split(" : ") - dt_limits_dict[split_info[1].strip()] = {'index': int(split_info[0]), 'value': float(split_info[-1])} + dt_limits_dict[split_info[1].strip()] = { + "index": int(split_info[0]), + "value": float(split_info[-1]), + } - version_info_dict['dt_limits'] = dt_limits_dict + version_info_dict["dt_limits"] = dt_limits_dict ########################## # Nucleosynthesis sources: # Split off - nucsyn_sources = set([el for el in cleaned if el.startswith('Nucleosynthesis')]) + nucsyn_sources = set([el for el in cleaned if el.startswith("Nucleosynthesis")]) cleaned = cleaned - nucsyn_sources # Fill dict @@ -290,7 +314,7 @@ def parse_binary_c_version_info(version_info_string): split_info = el.split("Nucleosynthesis source")[-1].strip().split(" is ") nucsyn_sources_dict[int(split_info[0])] = split_info[-1] - version_info_dict['nucleosynthesis_sources'] = nucsyn_sources_dict + version_info_dict["nucleosynthesis_sources"] = nucsyn_sources_dict ########################## # miscellaneous: @@ -298,21 +322,23 @@ def parse_binary_c_version_info(version_info_string): # TODO: filter a bit more. misc_dict = {} - git_revision = [el for el in cleaned if el.startswith('git revision')] - misc_dict['git_revision'] = git_revision[0].split("git revision ")[-1].replace("\"", '') + git_revision = [el for el in cleaned if el.startswith("git revision")] + misc_dict["git_revision"] = ( + git_revision[0].split("git revision ")[-1].replace('"', "") + ) - git_branch = [el for el in cleaned if el.startswith('git branch')] - misc_dict['git_branch'] = git_branch[0].split("git branch ")[-1].replace("\"", '') + git_branch = [el for el in cleaned if el.startswith("git branch")] + misc_dict["git_branch"] = git_branch[0].split("git branch ")[-1].replace('"', "") - build = [el for el in cleaned if el.startswith('Build')] - misc_dict['build'] = build[0].split("Build: ")[-1].replace("\"", '') + build = [el for el in cleaned if el.startswith("Build")] + misc_dict["build"] = build[0].split("Build: ")[-1].replace('"', "") - email = [el for el in cleaned if el.startswith('Email')] - misc_dict['email'] = email[0].split("Email ")[-1].split(',') + email = [el for el in cleaned if el.startswith("Email")] + misc_dict["email"] = email[0].split("Email ")[-1].split(",") - misc_dict['uncaught'] = cleaned + misc_dict["uncaught"] = cleaned - version_info_dict['miscellaneous'] = misc_dict + version_info_dict["miscellaneous"] = misc_dict return version_info_dict @@ -643,7 +669,7 @@ def get_help_all(print_help=True): params_dict[param_name] = { "param_name": param_name, "description": param_description, - "rest": ''.join(rest) if rest else '', + "rest": "".join(rest) if rest else "", } # make section_dict @@ -943,6 +969,7 @@ def binaryc_json_serializer(obj): return str(obj) return obj + def handle_ensemble_string_to_json(raw_output): """ Function that deals with the raw output of the ensemble and diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py index ab4ad0c843f71ec1b08fbd888e2cea2e7ee4825f..df752eb9bfeddd6ee15f22d1f88ea2bf6351b181 100644 --- a/binarycpython/utils/grid.py +++ b/binarycpython/utils/grid.py @@ -350,7 +350,6 @@ class Population: Function that returns the version information of binary_c """ - version_info = _binary_c_bindings.return_version_info().strip() if parsed: