From 9e8139ee3d67c11a6c3040de2f454a059a5bf267 Mon Sep 17 00:00:00 2001 From: evidencebp Date: Tue, 29 Oct 2024 20:38:49 +0200 Subject: [PATCH] Line too long (#424) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs\conf.py line-too-long Made line shorter, its end wasn't readable * src\alchemlyb\visualisation\dF_state.py too-many-branches Function plot_dF_state had 42 branches, while it is recommended not to have more than 12. The function is structured with clear blocks by logic and documentation. I extracted methods to encapsulate the logical blocks, reducing complexity. * src\alchemlyb\workflows\abfe.py too-many-branches Both methods generate_result and estimate had a bit too many branches. I extracted methods to reduce complexity and make code clearer. * src\alchemlyb\parsing\namd.py too-many-branches Two functions, extract_u_nk and _get_lambdas had too many branches. Smaller functions were extracted. * src\alchemlyb\parsing\amber.py line-too-long Made two readable lines shorter * src\alchemlyb\parsing\util.py line-too-long Made a readable line shorter * src\alchemlyb\visualisation\ti_dhdl.py too-many-statements The function plot_ti_dhdl had 81 statements, while it is recommended not to have more than 50. I extracted few smaller functions, reducing the length and increasing structure. * Add default value for mnb in get_determine_orientation The value of mnb is not set in the case of landscape orientation. It was like that even before extracting get_determine_orientation. However, now that this is a separated function, the test fails due to returning an unset variable. This might detect a bigger bug regarding not setting it unintentionally. * Fix _fit_estimators extraction _fit_estimators fails on E UnboundLocalError: cannot access local variable 'u_nk' where it is not associated with a value Since the goal is to reduce branches I revert that and extract the more isolated check_estimators_availability instead * Revert "Fix _fit_estimators extraction" This reverts commit f017972e44f97e9119c407d16db5d3122df02f3f. * Revert "Add default value for mnb in get_determine_orientation" This reverts commit a1ea9d90c38e7b9102dc3f60dfff00a5dd75d76b. * Revert "src\alchemlyb\visualisation\ti_dhdl.py too-many-statements" This reverts commit d2ed7faab7c2d1f5e80de51675f074a7533c37ec. * Revert "src\alchemlyb\parsing\namd.py too-many-branches" This reverts commit 7ece0f8adcbae6b23cb50ddac3d95a1a95b42ed5. * Revert "src\alchemlyb\workflows\abfe.py too-many-branches" This reverts commit ea1eccad5ad6795888c386e0ac429e924a669f59. * Revert "src\alchemlyb\visualisation\dF_state.py too-many-branches" This reverts commit 3a311d44ec9c08fd46585e3b5e184a3081112651. --------- Co-authored-by: Zhiyi Wu --- docs/conf.py | 3 ++- src/alchemlyb/parsing/amber.py | 6 ++++-- src/alchemlyb/parsing/util.py | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 8eb645fd..3c964189 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -54,7 +54,8 @@ # General information about the project. now = datetime.datetime.now() project = "alchemlyb" -author = 'The alchemlyb development team (see AUTHORS)' +author = 'The alchemlyb development team ' \ + + '(see AUTHORS)' copyright = f"2017-{now.year}, " + author diff --git a/src/alchemlyb/parsing/amber.py b/src/alchemlyb/parsing/amber.py index 6bb5441f..6e00481c 100644 --- a/src/alchemlyb/parsing/amber.py +++ b/src/alchemlyb/parsing/amber.py @@ -334,7 +334,8 @@ def extract(outfile, T): if nstep != old_nstep and dvdl is not None and nstep is not None: if finished: raise ValueError( - "TI Energy detected after the TIMINGS section. Did you concatenate the output file?" + "TI Energy detected after the TIMINGS section." + + " Did you concatenate the output file?" ) file_datum.gradients.append(dvdl) nensec += 1 @@ -342,7 +343,8 @@ def extract(outfile, T): elif line.startswith("MBAR Energy analysis") and file_datum.have_mbar: if finished: raise ValueError( - "MBAR Energy detected after the TIMINGS section. Did you concatenate the output file?" + "MBAR Energy detected after the TIMINGS section." + + " Did you concatenate the output file?" ) mbar = secp.extract_section( "^MBAR", "^ ---", file_datum.mbar_lambdas, extra=line diff --git a/src/alchemlyb/parsing/util.py b/src/alchemlyb/parsing/util.py index 9feddc9e..77217f52 100644 --- a/src/alchemlyb/parsing/util.py +++ b/src/alchemlyb/parsing/util.py @@ -78,7 +78,8 @@ def anyopen(datafile: Union[PathLike, IO], mode="r", compression=None): return compressor(datafile, mode=mode) else: raise ValueError( - "`datafile` is a stream, but specified `compression` '{compression}' is not supported" + "`datafile` is a stream" + + ", but specified `compression` '{compression}' is not supported" ) # otherwise, treat as a file