From 24ff96e309b0674854f3c137075214b5b1ce61d9 Mon Sep 17 00:00:00 2001 From: David Hendriks <davidhendriks93@gmail.com> Date: Wed, 5 Oct 2022 23:59:58 +0100 Subject: [PATCH] fixing flake8 issues --- .pre-commit-config.yaml | 7 +- binarycpython/tests/main_with_notebooks.py | 23 ------ binarycpython/tests/test_c_bindings.py | 29 +++----- binarycpython/tests/test_custom_logging.py | 26 ++++--- binarycpython/tests/test_dicts.py | 56 +++++++-------- binarycpython/tests/test_functions.py | 51 +++++++------- binarycpython/tests/test_plot_functions.py | 13 ++-- binarycpython/tests/test_useful_funcs.py | 12 ++-- .../tests_population_extensions/test_HPC.py | 66 ++++++++--------- .../test_distribution_functions.py | 42 +++++------ .../test_grid_options_defaults.py | 8 +-- .../tests_population_extensions/test_slurm.py | 14 ++-- binarycpython/utils/population_class.py | 25 ++----- .../miscellaneous_functions.py | 5 +- .../example_plotting_distributions.py | 23 +++--- examples/example_plotting_distributions.py | 70 +++++++++++-------- pyproject.toml | 2 - 17 files changed, 226 insertions(+), 246 deletions(-) delete mode 100755 binarycpython/tests/main_with_notebooks.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8be6a05db..c4790ffd1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,4 +24,9 @@ repos: rev: 5.0.4 hooks: - id: flake8 - args: ['--ignore=E129,E2,E501'] + args: ['--ignore=E129,E2,E501,W503,E722,binarycpython/tests/main.py,docs/source/examples/'] + exclude: | + (?x)^( + binarycpython/tests/main.py| + docs/source/examples/example_plotting_distributions.py + )$ diff --git a/binarycpython/tests/main_with_notebooks.py b/binarycpython/tests/main_with_notebooks.py deleted file mode 100755 index 7337c6896..000000000 --- a/binarycpython/tests/main_with_notebooks.py +++ /dev/null @@ -1,23 +0,0 @@ -# /usr/bin/env python -""" -Main file for the tests. This file imports all the combined_test functions from all files. -""" - -import unittest - -from binarycpython.tests.test_c_bindings import * -from binarycpython.tests.test_custom_logging import * -from binarycpython.tests.test_distributions import * -from binarycpython.tests.test_functions import * -from binarycpython.tests.test_grid import * -from binarycpython.tests.test_hpc_functions import * -from binarycpython.tests.test_plot_functions import * -from binarycpython.tests.test_run_system_wrapper import * -from binarycpython.tests.test_spacing_functions import * -from binarycpython.tests.test_useful_funcs import * -from binarycpython.tests.test_grid_options_defaults import * -from binarycpython.tests.test_stellar_types import * -from test_notebooks import * - -if __name__ == "__main__": - unittest.main() diff --git a/binarycpython/tests/test_c_bindings.py b/binarycpython/tests/test_c_bindings.py index 65ddd3252..00e79191a 100644 --- a/binarycpython/tests/test_c_bindings.py +++ b/binarycpython/tests/test_c_bindings.py @@ -2,11 +2,6 @@ Unittests for the c-bindings """ -import os -import sys -import time -import json -import textwrap import unittest import numpy as np @@ -14,23 +9,19 @@ from binarycpython import _binary_c_bindings from binarycpython.utils.functions import ( temp_dir, - verbose_print, is_capsule, Capturing, ) from binarycpython.utils.ensemble import ( - BinarycDecoder, - handle_ensemble_string_to_json, extract_ensemble_json_from_string, ) from binarycpython.utils.dicts import ( - inspect_dict, merge_dicts, ) - TMP_DIR = temp_dir("tests", "test_c_bindings") + #### some useful functions def return_argstring( m1=15.0, @@ -80,7 +71,7 @@ class test_run_system(unittest.TestCase): """ def test_output(self): - with Capturing() as output: + with Capturing() as _: self._test_output() def _test_output(self): @@ -126,7 +117,7 @@ class test_return_store_memaddr(unittest.TestCase): """ def test_return_store_memaddr(self): - with Capturing() as output: + with Capturing() as _: self._test_return_store_memaddr() def _test_return_store_memaddr(self): @@ -166,7 +157,7 @@ class test_ensemble_functions(unittest.TestCase): super(test_ensemble_functions, self).__init__(*args, **kwargs) def test_return_persistent_data_memaddr(self): - with Capturing() as output: + with Capturing() as _: self._test_return_persistent_data_memaddr() def _test_return_persistent_data_memaddr(self): @@ -180,7 +171,7 @@ class test_ensemble_functions(unittest.TestCase): self.assertTrue(is_capsule(output), msg="Object must be a capsule") def test_minimal_ensemble_output(self): - with Capturing() as output: + with Capturing() as _: self._test_minimal_ensemble_output() def _test_minimal_ensemble_output(self): @@ -210,7 +201,7 @@ class test_ensemble_functions(unittest.TestCase): self.assertNotEqual(test_json["number_counts"], {}) def test_minimal_ensemble_output_defer(self): - with Capturing() as output: + with Capturing() as _: self._test_minimal_ensemble_output_defer() def _test_minimal_ensemble_output_defer(self): @@ -252,7 +243,7 @@ class test_ensemble_functions(unittest.TestCase): self.assertNotEqual(ensemble_json_output["number_counts"], {}) def test_add_ensembles_direct(self): - with Capturing() as output: + with Capturing() as _: self._test_add_ensembles_direct() def _test_add_ensembles_direct(self): @@ -317,7 +308,7 @@ class test_ensemble_functions(unittest.TestCase): ) def test_compare_added_systems_with_double_deferred_systems(self): - with Capturing() as output: + with Capturing() as _: self._test_compare_added_systems_with_double_deferred_systems() def _test_compare_added_systems_with_double_deferred_systems(self): @@ -408,7 +399,7 @@ class test_ensemble_functions(unittest.TestCase): ) def test_combine_with_empty_json(self): - with Capturing() as output: + with Capturing() as _: self._test_combine_with_empty_json() def _test_combine_with_empty_json(self): @@ -438,7 +429,7 @@ class test_ensemble_functions(unittest.TestCase): ############# def test_full_ensemble_output(self): - with Capturing() as output: + with Capturing() as _: self._test_full_ensemble_output() def _test_full_ensemble_output(self): diff --git a/binarycpython/tests/test_custom_logging.py b/binarycpython/tests/test_custom_logging.py index 4b30ae48d..329dd7da5 100644 --- a/binarycpython/tests/test_custom_logging.py +++ b/binarycpython/tests/test_custom_logging.py @@ -2,10 +2,18 @@ Unittests for the custom_logging module """ +import os import unittest -from binarycpython.utils.custom_logging_functions import * -from binarycpython.utils.functions import Capturing +from binarycpython.utils.custom_logging_functions import ( + autogen_C_logging_code, + binary_c_log_code, + return_compilation_dict, + create_and_load_logging_function, + binary_c_write_log_code, + from_binary_c_config, +) +from binarycpython.utils.functions import Capturing, temp_dir TMP_DIR = temp_dir("tests", "test_custom_logging") @@ -16,7 +24,7 @@ class test_autogen_C_logging_code(unittest.TestCase): """ def test_autogen_C_logging_code(self): - with Capturing() as output: + with Capturing() as _: self._test_autogen_C_logging_code() # print("\n".join(output)) @@ -55,7 +63,7 @@ class test_binary_c_log_code(unittest.TestCase): """ def test_binary_c_log_code(self): - with Capturing() as output: + with Capturing() as _: self._test_binary_c_log_code() # print("\n".join(output)) @@ -85,7 +93,7 @@ class test_binary_c_write_log_code(unittest.TestCase): """ def test_binary_c_write_log_code(self): - with Capturing() as output: + with Capturing() as _: self._test_binary_c_write_log_code() # print("\n".join(output)) @@ -117,7 +125,7 @@ class test_from_binary_c_config(unittest.TestCase): """ def test_from_binary_c_config(self): - with Capturing() as output: + with Capturing() as _: self._test_from_binary_c_config() # print("\n".join(output)) @@ -156,7 +164,7 @@ class test_return_compilation_dict(unittest.TestCase): """ def test_return_compilation_dict(self): - with Capturing() as output: + with Capturing() as _: self._test_return_compilation_dict() # print("\n".join(output)) @@ -179,11 +187,11 @@ class test_return_compilation_dict(unittest.TestCase): class test_create_and_load_logging_function(unittest.TestCase): """ - Unit test for return_compilation_dict + Unit test for create_and_load_logging_function """ def test_create_and_load_logging_function(self): - with Capturing() as output: + with Capturing() as _: self._test_create_and_load_logging_function() # print("\n".join(output)) diff --git a/binarycpython/tests/test_dicts.py b/binarycpython/tests/test_dicts.py index 8d12b7caa..d321fde12 100644 --- a/binarycpython/tests/test_dicts.py +++ b/binarycpython/tests/test_dicts.py @@ -61,7 +61,7 @@ class test_merge_dicts(unittest.TestCase): """ def test_empty(self): - with Capturing() as output: + with Capturing() as _: self._test_empty() def _test_empty(self): @@ -81,7 +81,7 @@ class test_merge_dicts(unittest.TestCase): self.assertTrue(output_dict == input_dict) def test_unequal_types(self): - with Capturing() as output: + with Capturing() as _: self._test_unequal_types() def _test_unequal_types(self): @@ -95,7 +95,7 @@ class test_merge_dicts(unittest.TestCase): self.assertRaises(ValueError, merge_dicts, dict_1, dict_2) def test_bools(self): - with Capturing() as output: + with Capturing() as _: self._test_bools() def _test_bools(self): @@ -127,7 +127,7 @@ class test_merge_dicts(unittest.TestCase): self.assertEqual(output_dict["int"], 3) def test_floats(self): - with Capturing() as output: + with Capturing() as _: self._test_floats() def _test_floats(self): @@ -143,7 +143,7 @@ class test_merge_dicts(unittest.TestCase): self.assertEqual(output_dict["float"], 9.1) def test_lists(self): - with Capturing() as output: + with Capturing() as _: self._test_lists() def _test_lists(self): @@ -177,7 +177,7 @@ class test_merge_dicts(unittest.TestCase): ) def test_unsupported(self): - with Capturing() as output: + with Capturing() as _: self._test_unsupported() def _test_unsupported(self): @@ -198,7 +198,7 @@ class test_setopts(unittest.TestCase): """ def test_setopts(self): - with Capturing() as output: + with Capturing() as _: self._test_setopts() def _test_setopts(self): @@ -243,7 +243,7 @@ class test_inspect_dict(unittest.TestCase): """ def test_compare_dict(self): - with Capturing() as output: + with Capturing() as _: self._test_compare_dict() def _test_compare_dict(self): @@ -269,7 +269,7 @@ class test_inspect_dict(unittest.TestCase): self.assertTrue(compare_dict == output_dict) def test_compare_dict_with_print(self): - with Capturing() as output: + with Capturing() as _: self._test_compare_dict_with_print() def _test_compare_dict_with_print(self): @@ -293,7 +293,7 @@ class test_custom_sort_dict(unittest.TestCase): """ def test_custom_sort_dict(self): - with Capturing() as output: + with Capturing() as _: self._test_custom_sort_dict() def _test_custom_sort_dict(self): @@ -320,7 +320,7 @@ class test_filter_dict(unittest.TestCase): """ def test_filter_dict(self): - with Capturing() as output: + with Capturing() as _: self._test_filter_dict() def _test_filter_dict(self): @@ -343,7 +343,7 @@ class test_filter_dict_through_values(unittest.TestCase): """ def test_filter_dict_through_values(self): - with Capturing() as output: + with Capturing() as _: self._test_filter_dict_through_values() def _test_filter_dict_through_values(self): @@ -366,7 +366,7 @@ class test_prepare_dict(unittest.TestCase): """ def test_prepare_dict(self): - with Capturing() as output: + with Capturing() as _: self._test_prepare_dict() def _test_prepare_dict(self): @@ -393,7 +393,7 @@ class test_normalize_dict(unittest.TestCase): """ def test_normalize_dict(self): - with Capturing() as output: + with Capturing() as _: self._test_normalize_dict() def _test_normalize_dict(self): @@ -414,7 +414,7 @@ class test_multiply_values_dict(unittest.TestCase): """ def test_multiply_values_dict(self): - with Capturing() as output: + with Capturing() as _: self._test_multiply_values_dict() def _test_multiply_values_dict(self): @@ -437,7 +437,7 @@ class test_count_keys_recursive(unittest.TestCase): """ def test_count_keys_recursive(self): - with Capturing() as output: + with Capturing() as _: self._test_count_keys_recursive() def _test_count_keys_recursive(self): @@ -459,7 +459,7 @@ class test_keys_to_floats(unittest.TestCase): """ def test_keys_to_floats(self): - with Capturing() as output: + with Capturing() as _: self._test_keys_to_floats() def _test_keys_to_floats(self): @@ -481,7 +481,7 @@ class test_recursive_change_key_to_float(unittest.TestCase): """ def test_recursive_change_key_to_float(self): - with Capturing() as output: + with Capturing() as _: self._test_recursive_change_key_to_float() def _test_recursive_change_key_to_float(self): @@ -505,7 +505,7 @@ class test_recursive_change_key_to_string(unittest.TestCase): """ def test_recursive_change_key_to_string(self): - with Capturing() as output: + with Capturing() as _: self._test_recursive_change_key_to_string() def _test_recursive_change_key_to_string(self): @@ -536,7 +536,7 @@ class test_multiply_float_values(unittest.TestCase): """ def test_multiply_float_values(self): - with Capturing() as output: + with Capturing() as _: self._test_multiply_float_values() def _test_multiply_float_values(self): @@ -563,7 +563,7 @@ class test_subtract_dicts(unittest.TestCase): """ def test_empty(self): - with Capturing() as output: + with Capturing() as _: self._test_empty() def _test_empty(self): @@ -581,7 +581,7 @@ class test_subtract_dicts(unittest.TestCase): self.assertTrue(output_dict == input_dict) def test_unequal_types(self): - with Capturing() as output: + with Capturing() as _: self._test_unequal_types() def _test_unequal_types(self): @@ -611,7 +611,7 @@ class test_subtract_dicts(unittest.TestCase): self.assertEqual(output_dict["int"], 1) def test_floats(self): - with Capturing() as output: + with Capturing() as _: self._test_floats() def _test_floats(self): @@ -627,7 +627,7 @@ class test_subtract_dicts(unittest.TestCase): self.assertAlmostEqual(output_dict["float"], -0.1, 2) def test_zero_result(self): - with Capturing() as output: + with Capturing() as _: self._test_zero_result() def _test_zero_result(self): @@ -643,7 +643,7 @@ class test_subtract_dicts(unittest.TestCase): self.assertFalse(output_dict) def test_unsupported(self): - with Capturing() as output: + with Capturing() as _: self._test_unsupported() def _test_unsupported(self): @@ -695,7 +695,7 @@ class test_update_dicts(unittest.TestCase): self.assertEqual(output_dict["dict"], {"a": 2, "b": 1, "c": 2}) def test_unsupported(self): - with Capturing() as output: + with Capturing() as _: self._test_unsupported() def _test_unsupported(self): @@ -715,7 +715,7 @@ class test__nested_get(unittest.TestCase): """ def test__nested_get(self): - with Capturing() as output: + with Capturing() as _: self._test__nested_get() def _test__nested_get(self): @@ -738,7 +738,7 @@ class test__nested_set(unittest.TestCase): """ def test__nested_set(self): - with Capturing() as output: + with Capturing() as _: self._test__nested_set() def _test__nested_set(self): diff --git a/binarycpython/tests/test_functions.py b/binarycpython/tests/test_functions.py index 364ce9b47..6d1f80f9d 100644 --- a/binarycpython/tests/test_functions.py +++ b/binarycpython/tests/test_functions.py @@ -61,7 +61,7 @@ class test_verbose_print(unittest.TestCase): """ def test_print(self): - with Capturing() as output: + with Capturing() as _: self._test_print() def _test_print(self): @@ -71,7 +71,7 @@ class test_verbose_print(unittest.TestCase): verbose_print("test1", 1, 0) def test_not_print(self): - with Capturing() as output: + with Capturing() as _: self._test_not_print() def _test_not_print(self): @@ -88,7 +88,7 @@ class test_temp_dir(unittest.TestCase): """ def test_create_temp_dir(self): - with Capturing() as output: + with Capturing() as _: self._test_create_temp_dir() def _test_create_temp_dir(self): @@ -103,7 +103,6 @@ class test_temp_dir(unittest.TestCase): # Get username username = get_username() - dirname = "binary_c_python-{}".format(username) # self.assertTrue( @@ -122,7 +121,7 @@ class test_remove_file(unittest.TestCase): """ def test_remove_file(self): - with Capturing() as output: + with Capturing() as _: self._test_remove_file() def _test_remove_file(self): @@ -136,7 +135,7 @@ class test_remove_file(unittest.TestCase): remove_file(os.path.join(TMP_DIR, "test_remove_file_file.txt")) def test_remove_nonexisting_file(self): - with Capturing() as output: + with Capturing() as _: self._test_remove_nonexisting_file() def _test_remove_nonexisting_file(self): @@ -155,7 +154,7 @@ class test_create_hdf5(unittest.TestCase): """ def test_1(self): - with Capturing() as output: + with Capturing() as _: self._test_1() def _test_1(self): @@ -192,7 +191,7 @@ class test_output_lines(unittest.TestCase): """ def test_1(self): - with Capturing() as output: + with Capturing() as _: self._test_1() def _test_1(self): @@ -215,7 +214,7 @@ class test_example_parse_output(unittest.TestCase): """ def test_normal_output(self): - with Capturing() as output: + with Capturing() as _: self._test_normal_output() def _test_normal_output(self): @@ -248,7 +247,7 @@ class test_example_parse_output(unittest.TestCase): self.assertTrue(len(parsed_output["time"]) > 0) def test_mismatch_output(self): - with Capturing() as output: + with Capturing() as _: self._test_mismatch_output() def _test_mismatch_output(self): @@ -283,7 +282,7 @@ class test_get_defaults(unittest.TestCase): """ def test_no_filter(self): - with Capturing() as output: + with Capturing() as _: self._test_no_filter() def _test_no_filter(self): @@ -300,10 +299,10 @@ class test_get_defaults(unittest.TestCase): self.assertIn("use_fixed_timestep_%d", output_1.keys()) def test_filter(self): - with Capturing() as output: + with Capturing() as _: self._test_filter() - def test_filter(self): + def _test_filter(self): """ Test checking filtering works correctly """ @@ -324,7 +323,7 @@ class test_get_arg_keys(unittest.TestCase): """ def test_1(self): - with Capturing() as output: + with Capturing() as _: self._test_1() def _test_1(self): @@ -347,7 +346,7 @@ class test_create_arg_string(unittest.TestCase): """ def test_default(self): - with Capturing() as output: + with Capturing() as _: self._test_default() def _test_default(self): @@ -360,7 +359,7 @@ class test_create_arg_string(unittest.TestCase): self.assertEqual(argstring, "separation 40000 M_1 10") def test_sort(self): - with Capturing() as output: + with Capturing() as _: self._test_sort() def _test_sort(self): @@ -373,7 +372,7 @@ class test_create_arg_string(unittest.TestCase): self.assertEqual(argstring, "M_1 10 separation 40000") def test_filtered(self): - with Capturing() as output: + with Capturing() as _: self._test_filtered() def _test_filtered(self): @@ -392,7 +391,7 @@ class test_get_help(unittest.TestCase): """ def test_input_normal(self): - with Capturing() as output: + with Capturing() as _: self._test_input_normal() def _test_input_normal(self): @@ -407,7 +406,7 @@ class test_get_help(unittest.TestCase): ) def test_no_input(self): - with Capturing() as output: + with Capturing() as _: self._test_no_input() def _test_no_input(self): @@ -419,7 +418,7 @@ class test_get_help(unittest.TestCase): self.assertIsNone(output) def test_wrong_input(self): - with Capturing() as output: + with Capturing() as _: self._test_wrong_input() def _test_wrong_input(self): @@ -437,7 +436,7 @@ class test_get_help_all(unittest.TestCase): """ def test_all_output(self): - with Capturing() as output: + with Capturing() as _: self._test_all_output() def _test_all_output(self): @@ -467,7 +466,7 @@ class test_get_help_super(unittest.TestCase): """ def test_all_output(self): - with Capturing() as output: + with Capturing() as _: self._test_all_output() def _test_all_output(self): @@ -497,7 +496,7 @@ class test_make_build_text(unittest.TestCase): """ def test_output(self): - with Capturing() as output: + with Capturing() as _: self._test_output() def _test_output(self): @@ -527,7 +526,7 @@ class test_write_binary_c_parameter_descriptions_to_rst_file(unittest.TestCase): """ def test_bad_outputname(self): - with Capturing() as output: + with Capturing() as _: self._test_bad_outputname() def _test_bad_outputname(self): @@ -544,7 +543,7 @@ class test_write_binary_c_parameter_descriptions_to_rst_file(unittest.TestCase): ) def test_checkfile(self): - with Capturing() as output: + with Capturing() as _: self._test_checkfile() def _test_checkfile(self): @@ -556,7 +555,7 @@ class test_write_binary_c_parameter_descriptions_to_rst_file(unittest.TestCase): TMP_DIR, "test_write_binary_c_parameter_descriptions_to_rst_file_test_1.rst", ) - output_1 = write_binary_c_parameter_descriptions_to_rst_file(output_name) + _ = write_binary_c_parameter_descriptions_to_rst_file(output_name) self.assertTrue(os.path.isfile(output_name)) diff --git a/binarycpython/tests/test_plot_functions.py b/binarycpython/tests/test_plot_functions.py index 34c730fe0..e2940174d 100644 --- a/binarycpython/tests/test_plot_functions.py +++ b/binarycpython/tests/test_plot_functions.py @@ -3,10 +3,9 @@ Unittests for plot_functions """ import unittest -import numpy as np import matplotlib.pyplot as plt -from binarycpython.utils.plot_functions import * +from binarycpython.utils.plot_functions import color_by_index, plot_system from binarycpython.utils.functions import Capturing @@ -16,7 +15,7 @@ class test_color_by_index(unittest.TestCase): """ def test_1(self): - with Capturing() as output: + with Capturing() as _: self._test_1() def _test_1(self): @@ -36,7 +35,7 @@ class test_plot_system(unittest.TestCase): """ def test_mass_evolution_plot(self): - with Capturing() as output: + with Capturing() as _: self._test_mass_evolution_plot() def _test_mass_evolution_plot(self): @@ -73,7 +72,7 @@ class test_plot_system(unittest.TestCase): # output_fig_2 = plot_system(plot_type, show_plot=show_plot, M_1=1, metallicity=0.002, M_2=0.1, separation=0, orbital_period=100000000000) def test_orbit_evolution_plot(self): - with Capturing() as output: + with Capturing() as _: self._test_orbit_evolution_plot() def _test_orbit_evolution_plot(self): @@ -110,7 +109,7 @@ class test_plot_system(unittest.TestCase): # output_fig_2 = plot_system(plot_type, show_plot=show_plot, M_1=1, metallicity=0.002, M_2=0.1, separation=0, orbital_period=100000000000) def test_hr_diagram_plot(self): - with Capturing() as output: + with Capturing() as _: self._test_hr_diagram_plot() def _test_hr_diagram_plot(self): @@ -147,7 +146,7 @@ class test_plot_system(unittest.TestCase): # output_fig_2 = plot_system(plot_type, show_plot=show_plot, M_1=1, metallicity=0.002, M_2=0.1, separation=0, orbital_period=100000000000) def test_unknown_plottype(self): - with Capturing() as output: + with Capturing() as _: self._test_unknown_plottype() def _test_unknown_plottype(self): diff --git a/binarycpython/tests/test_useful_funcs.py b/binarycpython/tests/test_useful_funcs.py index 1c1ed5709..c70357467 100644 --- a/binarycpython/tests/test_useful_funcs.py +++ b/binarycpython/tests/test_useful_funcs.py @@ -27,7 +27,7 @@ class test_calc_period_from_sep(unittest.TestCase): """ def test_1(self): - with Capturing() as output: + with Capturing() as _: self._test_1() def _test_1(self): @@ -47,7 +47,7 @@ class test_calc_sep_from_period(unittest.TestCase): """ def test_1(self): - with Capturing() as output: + with Capturing() as _: self._test_1() def _test_1(self): @@ -65,7 +65,7 @@ class test_roche_lobe(unittest.TestCase): """ def test_1(self): - with Capturing() as output: + with Capturing() as _: self._test_1() def _test_1(self): @@ -88,7 +88,7 @@ class test_ragb(unittest.TestCase): """ def test_1(self): - with Capturing() as output: + with Capturing() as _: self._test_1() def _test_1(self): @@ -108,7 +108,7 @@ class test_rzams(unittest.TestCase): """ def test_1(self): - with Capturing() as output: + with Capturing() as _: self._test_1() def _test_1(self): @@ -141,7 +141,7 @@ class test_zams_collission(unittest.TestCase): """ def test_1(self): - with Capturing() as output: + with Capturing() as _: self._test_1() def _test_1(self): diff --git a/binarycpython/tests/tests_population_extensions/test_HPC.py b/binarycpython/tests/tests_population_extensions/test_HPC.py index 95c9a000d..a5c657c5b 100644 --- a/binarycpython/tests/tests_population_extensions/test_HPC.py +++ b/binarycpython/tests/tests_population_extensions/test_HPC.py @@ -37,7 +37,7 @@ class test_HPC_njobs(unittest.TestCase): """ def test_condor(self): - with Capturing() as output: + with Capturing() as _: self._test_condor() def _test_condor(self): @@ -54,7 +54,7 @@ class test_HPC_njobs(unittest.TestCase): self.assertEqual(result_condor, 10) def test_slurm(self): - with Capturing() as output: + with Capturing() as _: self._test_slurm() def _test_slurm(self): @@ -71,7 +71,7 @@ class test_HPC_njobs(unittest.TestCase): self.assertEqual(result_slurm, 11) def test_none(self): - with Capturing() as output: + with Capturing() as _: self._test_none() def _test_none(self): @@ -89,7 +89,7 @@ class test_HPC_job(unittest.TestCase): """ def test_HPC_job(self): - with Capturing() as output: + with Capturing() as _: self._test_HPC_job() def _test_HPC_job(self): @@ -109,7 +109,7 @@ class test_HPC_job_type(unittest.TestCase): """ def test_condor(self): - with Capturing() as output: + with Capturing() as _: self._test_condor() def _test_condor(self): @@ -124,7 +124,7 @@ class test_HPC_job_type(unittest.TestCase): self.assertEqual(result_condor, "condor") def test_slurm(self): - with Capturing() as output: + with Capturing() as _: self._test_slurm() def _test_slurm(self): @@ -139,7 +139,7 @@ class test_HPC_job_type(unittest.TestCase): self.assertEqual(result_slurm, "slurm") def test_none(self): - with Capturing() as output: + with Capturing() as _: self._test_none() def _test_none(self): @@ -158,7 +158,7 @@ class test_HPC_jobID(unittest.TestCase): """ def test_condor(self): - with Capturing() as output: + with Capturing() as _: self._test_condor() def _test_condor(self): @@ -177,7 +177,7 @@ class test_HPC_jobID(unittest.TestCase): ) def test_slurm(self): - with Capturing() as output: + with Capturing() as _: self._test_slurm() def _test_slurm(self): @@ -196,7 +196,7 @@ class test_HPC_jobID(unittest.TestCase): ) def test_none(self): - with Capturing() as output: + with Capturing() as _: self._test_none() def _test_none(self): @@ -215,7 +215,7 @@ class test_HPC_jobID_tuple(unittest.TestCase): """ def test_condor(self): - with Capturing() as output: + with Capturing() as _: self._test_condor() def _test_condor(self): @@ -231,7 +231,7 @@ class test_HPC_jobID_tuple(unittest.TestCase): self.assertEqual(condor_pop.HPC_jobID_tuple(), ("2", "3")) def test_slurm(self): - with Capturing() as output: + with Capturing() as _: self._test_slurm() def _test_slurm(self): @@ -247,7 +247,7 @@ class test_HPC_jobID_tuple(unittest.TestCase): self.assertEqual(slurm_pop.HPC_jobID_tuple(), ("4", "5")) def test_none(self): - with Capturing() as output: + with Capturing() as _: self._test_none() def _test_none(self): @@ -265,7 +265,7 @@ class test_HPC_dirs(unittest.TestCase): """ def test_condor(self): - with Capturing() as output: + with Capturing() as _: self._test_condor() def _test_condor(self): @@ -278,7 +278,7 @@ class test_HPC_dirs(unittest.TestCase): self.assertEqual(condor_pop.HPC_dirs(), ["condor_dir"]) def test_slurm(self): - with Capturing() as output: + with Capturing() as _: self._test_slurm() def _test_slurm(self): @@ -291,7 +291,7 @@ class test_HPC_dirs(unittest.TestCase): self.assertEqual(slurm_pop.HPC_dirs(), ["slurm_dir"]) def test_none(self): - with Capturing() as output: + with Capturing() as _: self._test_none() def _test_none(self): @@ -309,7 +309,7 @@ class test_HPC_id_filename(unittest.TestCase): """ def test_condor(self): - with Capturing() as output: + with Capturing() as _: self._test_condor() def _test_condor(self): @@ -322,7 +322,7 @@ class test_HPC_id_filename(unittest.TestCase): self.assertEqual(condor_pop.HPC_id_filename(), "ClusterID") def test_slurm(self): - with Capturing() as output: + with Capturing() as _: self._test_slurm() def _test_slurm(self): @@ -335,7 +335,7 @@ class test_HPC_id_filename(unittest.TestCase): self.assertEqual(slurm_pop.HPC_id_filename(), "jobid") def test_none(self): - with Capturing() as output: + with Capturing() as _: self._test_none() def _test_none(self): @@ -353,7 +353,7 @@ class test_HPC_check_requirements(unittest.TestCase): """ def test_condor(self): - with Capturing() as output: + with Capturing() as _: self._test_condor() def _test_condor(self): @@ -380,7 +380,7 @@ class test_HPC_check_requirements(unittest.TestCase): self.assertTrue(len(result_2[1]) == 0) def test_slurm(self): - with Capturing() as output: + with Capturing() as _: self._test_slurm() def _test_slurm(self): @@ -403,7 +403,7 @@ class test_HPC_check_requirements(unittest.TestCase): self.assertTrue(len(result_2[1]) == 0) def test_none(self): - with Capturing() as output: + with Capturing() as _: self._test_none() def _test_none(self): @@ -423,7 +423,7 @@ class test_HPC_set_status(unittest.TestCase): """ def test_condor(self): - with Capturing() as output: + with Capturing() as _: self._test_condor() def _test_condor(self): @@ -474,7 +474,7 @@ class test_HPC_set_status(unittest.TestCase): self.assertTrue(content_file == "test_set_condor_status") def test_slurm(self): - with Capturing() as output: + with Capturing() as _: self._test_slurm() def _test_slurm(self): @@ -527,7 +527,7 @@ class test_HPC_get_status(unittest.TestCase): """ def test_condor(self): - with Capturing() as output: + with Capturing() as _: self._test_condor() def _test_condor(self): @@ -557,7 +557,7 @@ class test_HPC_get_status(unittest.TestCase): self.assertEqual(status, "test_get_condor_status") def test_slurm(self): - with Capturing() as output: + with Capturing() as _: self._test_slurm() def _test_slurm(self): @@ -592,7 +592,7 @@ class test_HPC_job_task(unittest.TestCase): """ def test_condor(self): - with Capturing() as output: + with Capturing() as _: self._test_condor() def _test_condor(self): @@ -611,7 +611,7 @@ class test_HPC_job_task(unittest.TestCase): self.assertEqual(job_task, 1) def test_slurm(self): - with Capturing() as output: + with Capturing() as _: self._test_slurm() def _test_slurm(self): @@ -636,7 +636,7 @@ class test_HPC_dir(unittest.TestCase): """ def test_condor(self): - with Capturing() as output: + with Capturing() as _: self._test_condor() def _test_condor(self): @@ -654,7 +654,7 @@ class test_HPC_dir(unittest.TestCase): self.assertEqual(condor_pop.HPC_dir(), os.path.join(TMP_DIR, "condor")) def test_slurm(self): - with Capturing() as output: + with Capturing() as _: self._test_slurm() def _test_slurm(self): @@ -672,7 +672,7 @@ class test_HPC_dir(unittest.TestCase): self.assertEqual(slurm_pop.HPC_dir(), os.path.join(TMP_DIR, "slurm")) def test_none(self): - with Capturing() as output: + with Capturing() as _: self._test_slurm() def _test_none(self): @@ -692,7 +692,7 @@ class test_HPC_id_from_dir(unittest.TestCase): """ def test_condor(self): - with Capturing() as output: + with Capturing() as _: self._test_condor() def _test_condor(self): @@ -712,7 +712,7 @@ class test_HPC_id_from_dir(unittest.TestCase): self.assertEqual(id_from_dir.strip(), str(2)) def test_slurm(self): - with Capturing() as output: + with Capturing() as _: self._test_slurm() def _test_slurm(self): diff --git a/binarycpython/tests/tests_population_extensions/test_distribution_functions.py b/binarycpython/tests/tests_population_extensions/test_distribution_functions.py index 602df5ef3..57c21a7f5 100644 --- a/binarycpython/tests/tests_population_extensions/test_distribution_functions.py +++ b/binarycpython/tests/tests_population_extensions/test_distribution_functions.py @@ -32,7 +32,7 @@ import numpy as np from binarycpython.utils.useful_funcs import calc_sep_from_period from binarycpython.utils.functions import Capturing, temp_dir -from binarycpython.utils.grid import Population +from binarycpython import Population TMP_DIR = temp_dir("tests", "test_distributions") @@ -49,7 +49,7 @@ class test_flat(unittest.TestCase): """ def test_flat(self): - with Capturing() as output: + with Capturing() as _: self._test_flat() def _test_flat(self): @@ -71,7 +71,7 @@ class test_number(unittest.TestCase): """ def test_number(self): - with Capturing() as output: + with Capturing() as _: self._test_number() def _test_number(self): @@ -93,7 +93,7 @@ class test_const_distribution(unittest.TestCase): """ def test_const_distribution(self): - with Capturing() as output: + with Capturing() as _: self._test_const_distribution() def _test_const_distribution(self): @@ -124,7 +124,7 @@ class test_powerlaw(unittest.TestCase): """ def test_powerlaw(self): - with Capturing() as output: + with Capturing() as _: self._test_powerlaw() def _test_powerlaw(self): @@ -156,7 +156,9 @@ class test_powerlaw(unittest.TestCase): msg = "Error: Value perl: {} Value python: {} for mass, per: {}".format( perl_results[i], python_results[i], str(input_lists[i]) ) - self.assertLess(np.abs(python_results[i] - perl_results[i]), TOLERANCE) + self.assertLess( + np.abs(python_results[i] - perl_results[i]), TOLERANCE, msg=msg + ) # extra test for k = -1 self.assertRaises( @@ -170,7 +172,7 @@ class test_three_part_power_law(unittest.TestCase): """ def test_three_part_power_law(self): - with Capturing() as output: + with Capturing() as _: self._test_three_part_power_law() def _test_three_part_power_law(self): @@ -225,7 +227,7 @@ class test_Kroupa2001(unittest.TestCase): """ def test_Kroupa2001(self): - with Capturing() as output: + with Capturing() as _: self._test_Kroupa2001() def _test_Kroupa2001(self): @@ -274,7 +276,7 @@ class test_ktg93(unittest.TestCase): """ def test_ktg93(self): - with Capturing() as output: + with Capturing() as _: self._test_ktg93() def _test_ktg93(self): @@ -323,7 +325,7 @@ class test_imf_tinsley1980(unittest.TestCase): """ def test_imf_tinsley1980(self): - with Capturing() as output: + with Capturing() as _: self._test_imf_tinsley1980() def _test_imf_tinsley1980(self): @@ -348,7 +350,7 @@ class test_imf_scalo1986(unittest.TestCase): """ def test_imf_scalo1986(self): - with Capturing() as output: + with Capturing() as _: self._test_imf_scalo1986() def _test_imf_scalo1986(self): @@ -373,7 +375,7 @@ class test_imf_scalo1998(unittest.TestCase): """ def test_imf_scalo1998(self): - with Capturing() as output: + with Capturing() as _: self._test_imf_scalo1998() def _test_imf_scalo1998(self): @@ -398,7 +400,7 @@ class test_imf_chabrier2003(unittest.TestCase): """ def test_imf_chabrier2003(self): - with Capturing() as output: + with Capturing() as _: self._test_imf_chabrier2003() def _test_imf_chabrier2003(self): @@ -444,7 +446,7 @@ class test_duquennoy1991(unittest.TestCase): """ def test_duquennoy1991(self): - with Capturing() as output: + with Capturing() as _: self._test_duquennoy1991() def _test_duquennoy1991(self): @@ -466,7 +468,7 @@ class test_gaussian(unittest.TestCase): """ def test_gaussian(self): - with Capturing() as output: + with Capturing() as _: self._test_gaussian() def _test_gaussian(self): @@ -515,7 +517,7 @@ class test_Arenou2010_binary_fraction(unittest.TestCase): """ def test_Arenou2010_binary_fraction(self): - with Capturing() as output: + with Capturing() as _: self._test_Arenou2010_binary_fraction() def _test_Arenou2010_binary_fraction(self): @@ -558,7 +560,7 @@ class test_raghavan2010_binary_fraction(unittest.TestCase): """ def test_raghavan2010_binary_fraction(self): - with Capturing() as output: + with Capturing() as _: self._test_raghavan2010_binary_fraction() def _test_raghavan2010_binary_fraction(self): @@ -594,7 +596,7 @@ class test_Izzard2012_period_distribution(unittest.TestCase): """ def test_Izzard2012_period_distribution(self): - with Capturing() as output: + with Capturing() as _: self._test_Izzard2012_period_distribution() def _test_Izzard2012_period_distribution(self): @@ -669,7 +671,7 @@ class test_flatsections(unittest.TestCase): """ def test_flatsections(self): - with Capturing() as output: + with Capturing() as _: self._test_flatsections() def _test_flatsections(self): @@ -714,7 +716,7 @@ class test_sana12(unittest.TestCase): """ def test_sana12(self): - with Capturing() as output: + with Capturing() as _: self._test_sana12() def _test_sana12(self): diff --git a/binarycpython/tests/tests_population_extensions/test_grid_options_defaults.py b/binarycpython/tests/tests_population_extensions/test_grid_options_defaults.py index 773958294..22ab71a4b 100644 --- a/binarycpython/tests/tests_population_extensions/test_grid_options_defaults.py +++ b/binarycpython/tests/tests_population_extensions/test_grid_options_defaults.py @@ -13,7 +13,7 @@ from binarycpython.utils.functions import ( temp_dir, Capturing, ) -from binarycpython.utils.grid import Population +from binarycpython import Population TMP_DIR = temp_dir("tests", "test_grid_options_defaults") @@ -24,7 +24,7 @@ class test_grid_options_help(unittest.TestCase): """ def test_grid_options_help(self): - with Capturing() as output: + with Capturing() as _: self._test_grid_options_help() def _test_grid_options_help(self): @@ -65,7 +65,7 @@ class test_grid_options_description_checker(unittest.TestCase): """ def test_grid_options_description_checker(self): - with Capturing() as output: + with Capturing() as _: self._test_grid_options_description_checker() def _test_grid_options_description_checker(self): @@ -89,7 +89,7 @@ class test_write_grid_options_to_rst_file(unittest.TestCase): """ def test_write_grid_options_to_rst_file(self): - with Capturing() as output: + with Capturing() as _: self._test_write_grid_options_to_rst_file() def _test_write_grid_options_to_rst_file(self): diff --git a/binarycpython/tests/tests_population_extensions/test_slurm.py b/binarycpython/tests/tests_population_extensions/test_slurm.py index 73e145476..8f11be1c9 100644 --- a/binarycpython/tests/tests_population_extensions/test_slurm.py +++ b/binarycpython/tests/tests_population_extensions/test_slurm.py @@ -24,7 +24,7 @@ class test_slurmID(unittest.TestCase): """ def test_slurmID(self): - with Capturing() as output: + with Capturing() as _: self._test_slurmID() def _test_slurmID(self): @@ -49,7 +49,7 @@ class test_slurm_dirs(unittest.TestCase): """ def test_slurm_dirs(self): - with Capturing() as output: + with Capturing() as _: self._test_slurm_dirs() def _test_slurm_dirs(self): @@ -68,7 +68,7 @@ class test_slurm_check_requirements(unittest.TestCase): """ def test_slurm_check_requirements(self): - with Capturing() as output: + with Capturing() as _: self._test_slurm_check_requirements() def _test_slurm_check_requirements(self): @@ -97,7 +97,7 @@ class test_set_slurm_status(unittest.TestCase): """ def test_set_slurm_status(self): - with Capturing() as output: + with Capturing() as _: self._test_set_slurm_status() def _test_set_slurm_status(self): @@ -154,7 +154,7 @@ class test_get_slurm_status(unittest.TestCase): """ def test_get_slurm_status(self): - with Capturing() as output: + with Capturing() as _: self._test_get_slurm_status() def _test_get_slurm_status(self): @@ -189,7 +189,7 @@ class test_slurm_outfile(unittest.TestCase): """ def test_slurm_outfile(self): - with Capturing() as output: + with Capturing() as _: self._test_slurm_outfile() def _test_slurm_outfile(self): @@ -223,7 +223,7 @@ class test_make_slurm_dirs(unittest.TestCase): """ def test_make_slurm_dirs(self): - with Capturing() as output: + with Capturing() as _: self._test_make_slurm_dirs() def _test_make_slurm_dirs(self): diff --git a/binarycpython/utils/population_class.py b/binarycpython/utils/population_class.py index 88409e039..ebfb08d19 100644 --- a/binarycpython/utils/population_class.py +++ b/binarycpython/utils/population_class.py @@ -14,13 +14,15 @@ Tasks: - TODO: Some of the methods that we have defined in the (mixin) class are designed to be used as a portal to information (return_binary_c_version_info for example.) The current design is that they are all instance methods, but that is not always necessary. We can decorate them with @staticmethod, or @classmethod to make it easier to use them (https://realpython.com/instance-class-and-static-methods-demystified/) """ +import os import sys import time import uuid import copy import json import multiprocessing -import os + +from colorama import init as colorama_init from binarycpython.utils.functions import ( check_if_in_shell, @@ -28,16 +30,9 @@ from binarycpython.utils.functions import ( get_ANSI_colours, get_defaults, mem_use, - now, hostnames, - calculate_total_mass_system, -) -from binarycpython.utils.ensemble import ( - binaryc_json_serializer, - extract_ensemble_json_from_string, - format_ensemble_results, ) -from binarycpython.utils.dicts import AutoVivificationDict, merge_dicts, keys_to_floats +from binarycpython.utils.dicts import AutoVivificationDict # Class extensions from binarycpython.utils.population_extensions.analytics import analytics @@ -98,14 +93,6 @@ from binarycpython.utils.population_extensions.failing_systems_functions import from binarycpython.utils.ensemble import new_grid_ensemble_results -from binarycpython import _binary_c_bindings -from collections import ( - OrderedDict, -) -from collections.abc import Iterable # drop `.abc` with Python 2.7 or lower -from colorama import init as colorama_init -from typing import Union, Any - # Initialise colorama colorama_init() @@ -409,8 +396,8 @@ class Population( os.makedirs(path, exist_ok=True) if self.dir_ok(path) is False: print( - "Failed to make directory at {log_args_dir} for output of system arguments. Please check that this directory is correct and you have write access.".format( - subdir=subdir, path=path + "Failed to make directory at {path} for output of system arguments. Please check that this directory is correct and you have write access.".format( + path=path ) ) self.exit(code=1) diff --git a/binarycpython/utils/population_extensions/miscellaneous_functions.py b/binarycpython/utils/population_extensions/miscellaneous_functions.py index b3b3138c7..a3b35e72d 100644 --- a/binarycpython/utils/population_extensions/miscellaneous_functions.py +++ b/binarycpython/utils/population_extensions/miscellaneous_functions.py @@ -3,6 +3,9 @@ Main script to provide some extra miscellaneous functions that are not part of a """ # pylint: disable=E1101 +import sys +import psutil +import binarycpython class miscellaneous_functions: @@ -36,7 +39,7 @@ class miscellaneous_functions: match the current hostname or "default", if so use the corresponding value for the current machine. """ - hostnameslist = self.my_hostnames() + new_cmdline_args = None # loop over list of cmdline args diff --git a/docs/source/examples/example_plotting_distributions.py b/docs/source/examples/example_plotting_distributions.py index 5f27961b6..d34c43736 100644 --- a/docs/source/examples/example_plotting_distributions.py +++ b/docs/source/examples/example_plotting_distributions.py @@ -60,6 +60,8 @@ def plot_mass_distributions(): def plot_binary_fraction_distributions(): + mass_values = np.arange(0.11, 80, 0.1) + arenou_binary_distibution = [ Arenou2010_binary_fraction(mass) for mass in mass_values ] @@ -220,19 +222,20 @@ def plot_period_distributions(): plt.show() -plot_period_distributions() ################################################ # Sampling part of distribution and calculating probability ratio ################################################ # TODO show the difference between sampling over the full range, or taking a smaller range initially and compensating for it. - -# val = Izzard2012_period_distribution(1000, 10) -# print(val) -# val2 = Izzard2012_period_distribution(100, 10) -# print(val2) - - -# from binarycpython.utils.distribution_functions import (interpolate_in_mass_izzard2012) -# # print(interpolate_in_mass_izzard2012(15, 0.3, -1)) +if __name__ == "__main__": + plot_mass_distributions() + plot_binary_fraction_distributions() + plot_mass_ratio_distributions() + plot_period_distributions() + plot_period_distributions() + + # val = Izzard2012_period_distribution(1000, 10) + # print(val) + # val2 = Izzard2012_period_distribution(100, 10) + # print(val2) diff --git a/examples/example_plotting_distributions.py b/examples/example_plotting_distributions.py index 5f27961b6..45c8b02b1 100644 --- a/examples/example_plotting_distributions.py +++ b/examples/example_plotting_distributions.py @@ -3,26 +3,30 @@ import math import numpy as np import matplotlib.pyplot as plt -from binarycpython.utils.distribution_functions import ( - three_part_powerlaw, - Kroupa2001, - Arenou2010_binary_fraction, - raghavan2010_binary_fraction, - imf_scalo1998, - imf_scalo1986, - imf_tinsley1980, - imf_scalo1998, - imf_chabrier2003, - flatsections, - duquennoy1991, - sana12, - Izzard2012_period_distribution, -) +from binarycpython import Population + +# from binarycpython.utils.distribution_functions import ( +# three_part_powerlaw, +# Kroupa2001, +# Arenou2010_binary_fraction, +# raghavan2010_binary_fraction, +# imf_scalo1998, +# imf_scalo1986, +# imf_tinsley1980, +# imf_scalo1998, +# imf_chabrier2003, +# flatsections, +# duquennoy1991, +# sana12, +# Izzard2012_period_distribution, +# ) from binarycpython.utils.useful_funcs import calc_sep_from_period ################################################ # Example script to plot the available probability distributions. -# TODO: + +distribution_pop = Population() + ################################################ # mass distribution plots @@ -32,11 +36,11 @@ from binarycpython.utils.useful_funcs import calc_sep_from_period def plot_mass_distributions(): mass_values = np.arange(0.11, 80, 0.1) - kroupa_probability = [Kroupa2001(mass) for mass in mass_values] - scalo1986 = [imf_scalo1986(mass) for mass in mass_values] - tinsley1980 = [imf_tinsley1980(mass) for mass in mass_values] - scalo1998 = [imf_scalo1998(mass) for mass in mass_values] - chabrier2003 = [imf_chabrier2003(mass) for mass in mass_values] + kroupa_probability = [distribution_pop.Kroupa2001(mass) for mass in mass_values] + scalo1986 = [distribution_pop.imf_scalo1986(mass) for mass in mass_values] + tinsley1980 = [distribution_pop.imf_tinsley1980(mass) for mass in mass_values] + scalo1998 = [distribution_pop.imf_scalo1998(mass) for mass in mass_values] + chabrier2003 = [distribution_pop.mf_chabrier2003(mass) for mass in mass_values] plt.plot(mass_values, kroupa_probability, label="Kroupa") plt.plot(mass_values, scalo1986, label="scalo1986") @@ -60,11 +64,13 @@ def plot_mass_distributions(): def plot_binary_fraction_distributions(): + mass_values = np.arange(0.11, 80, 0.1) + arenou_binary_distibution = [ - Arenou2010_binary_fraction(mass) for mass in mass_values + distribution_pop.Arenou2010_binary_fraction(mass) for mass in mass_values ] raghavan2010_binary_distribution = [ - raghavan2010_binary_fraction(mass) for mass in mass_values + distribution_pop.raghavan2010_binary_fraction(mass) for mass in mass_values ] plt.plot(mass_values, arenou_binary_distibution, label="arenou 2010") @@ -88,7 +94,7 @@ def plot_mass_ratio_distributions(): mass_ratios = np.arange(0, 1, 0.01) example_mass = 2 flat_dist = [ - flatsections( + distribution_pop.flatsections( q, opts=[ {"min": 0.1 / example_mass, "max": 0.8, "height": 1}, @@ -114,7 +120,9 @@ def plot_mass_ratio_distributions(): def plot_period_distributions(): logperiod_values = np.arange(-2, 12, 0.1) - duquennoy1991_distribution = [duquennoy1991(logper) for logper in logperiod_values] + duquennoy1991_distribution = [ + distribution_pop.duquennoy1991(logper) for logper in logperiod_values + ] # Sana12 distributions period_min = 10**0.15 @@ -123,7 +131,7 @@ def plot_period_distributions(): m1 = 20 m2 = 15 sana12_distribution_q05 = [ - sana12( + distribution_pop.sana12( m1, m2, calc_sep_from_period(m1, m2, 10**logper), @@ -140,7 +148,7 @@ def plot_period_distributions(): m1 = 30 m2 = 1 sana12_distribution_q0033 = [ - sana12( + distribution_pop.sana12( m1, m2, calc_sep_from_period(m1, m2, 10**logper), @@ -157,7 +165,7 @@ def plot_period_distributions(): m1 = 30 m2 = 3 sana12_distribution_q01 = [ - sana12( + distribution_pop.sana12( m1, m2, calc_sep_from_period(m1, m2, 10**logper), @@ -174,7 +182,7 @@ def plot_period_distributions(): m1 = 30 m2 = 30 sana12_distribution_q1 = [ - sana12( + distribution_pop.sana12( m1, m2, calc_sep_from_period(m1, m2, 10**logper), @@ -189,11 +197,11 @@ def plot_period_distributions(): ] Izzard2012_period_distribution_10 = [ - Izzard2012_period_distribution(10**logperiod, 10) + distribution_pop.Izzard2012_period_distribution(10**logperiod, 10) for logperiod in logperiod_values ] Izzard2012_period_distribution_20 = [ - Izzard2012_period_distribution(10**logperiod, 20) + distribution_pop.Izzard2012_period_distribution(10**logperiod, 20) for logperiod in logperiod_values ] diff --git a/pyproject.toml b/pyproject.toml index dbcec3275..44a941414 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,8 +19,6 @@ extend-exclude = ''' [tool.flake8] max-line-length = 89 max-complexity = 18 -select = B,C,E,F,W,T4,B9 - [tool.coverage] -- GitLab