Function check_sixtrack_output_data
has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
def check_sixtrack_output_data(jobname: str, basedir: Path):
"""Presence checks for SixDesk tracking output data.
This checks recursively all directories in `track`.
Will be busy for a while.
Function write_bash
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
def write_bash(
job_df: DataFrame,
output_dir: Path = None,
executable: str = "madx",
cmdline_arguments: dict = None,
Function convert_paths_in_dict_to_strings
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
def convert_paths_in_dict_to_strings(dict_: dict) -> dict:
"""Converts all Paths in the dict to strings, including those in iterables."""
dict_ = dict_.copy()
for key, value in dict_.items():
if isinstance(value, Path):
Function _create_stats_df
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
def _create_stats_df(df: pd.DataFrame, parameter: str, global_index: Any = None) -> TfsDataFrame:
""" Calculates the stats over a given parameter.
Note: Could be refactored to use `group_by`.
Args:
Function remove_twiss_fail_check
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
def remove_twiss_fail_check(jobname: str, basedir: Path):
""" Comments out the "Twiss fail" check from mad6t.sh """
LOG.info("Applying twiss-fail hack.")
for mad6t_path in (
get_mad6t_mask_path(jobname, basedir),
Avoid deeply nested control flow statements.
if not turn_dir.is_dir():
continue
Avoid deeply nested control flow statements.
if not len(angle_dirs):
raise OSError(f"No angle-dirs present in {str(turn_dir)}.")
Avoid deeply nested control flow statements.
for angle_dir in angle_dirs:
if not angle_dir.is_dir():
continue
htcondor_files = list(angle_dir.glob("htcondor.*"))
Function write_bash
has 5 arguments (exceeds 4 allowed). Consider refactoring.
def write_bash(
Function _plot_seeds
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def _plot_seeds(ax, df_da: TfsDataFrame, da_col: str, interpolated: bool) -> Tuple[list, list]:
"""Add the Seed lines to the polar plots, if df_da is given.
Args:
ax: Axes to plot in
Function fix_pythonfile_call
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def fix_pythonfile_call(jobname: str, basedir: Path):
""" Removes '<' in the `binary file` line in mad6t.sh so __file__ works. """
LOG.info("Applying python-file call fix.")
for mad6t_path in (
get_mad6t_mask_path(jobname, basedir),
Function map_kwargs
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def map_kwargs(add_dict: Dict[str, Any]) -> Dict[str, Any]:
"""
Maps the kwargs for the job-file.
Some arguments have pre-defined choices and defaults, the remaining ones are just passed on.
Function submit_sixtrack
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def submit_sixtrack(jobname: str, basedir: Path, python: Path = None,
sixdesk: Path = SIXDESK_UTILS, ssh: str = None, resubmit: bool = False):
""" Generate simulation files and check if runnable and submit. """
re_str = "Re-" if resubmit else ""
LOG.info(f"{re_str}Submitting to sixtrack.")