Skip to content

Commit

Permalink
Line too long (alchemistry#424)
Browse files Browse the repository at this point in the history
* 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 f017972.

* Revert "Add default value for mnb in get_determine_orientation"

This reverts commit a1ea9d9.

* Revert "src\alchemlyb\visualisation\ti_dhdl.py  too-many-statements"

This reverts commit d2ed7fa.

* Revert "src\alchemlyb\parsing\namd.py  too-many-branches"

This reverts commit 7ece0f8.

* Revert "src\alchemlyb\workflows\abfe.py  too-many-branches"

This reverts commit ea1ecca.

* Revert "src\alchemlyb\visualisation\dF_state.py  too-many-branches"

This reverts commit 3a311d4.

---------

Co-authored-by: Zhiyi Wu <zwu@exscientia.ai>
  • Loading branch information
2 people authored and jaclark5 committed Nov 15, 2024
1 parent 337aac5 commit 0c52fd9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
# General information about the project.
now = datetime.datetime.now()
project = "alchemlyb"
author = 'The alchemlyb development team (see <a href="https://raw.githubusercontent.com/alchemistry/alchemlyb/master/AUTHORS">AUTHORS</a>)'
author = 'The alchemlyb development team ' \
+ '(see <a href="https://raw.githubusercontent.com/alchemistry/alchemlyb/master/AUTHORS">AUTHORS</a>)'
copyright = f"2017-{now.year}, " + author


Expand Down
6 changes: 4 additions & 2 deletions src/alchemlyb/parsing/amber.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,17 @@ 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
old_nstep = nstep
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
Expand Down
3 changes: 2 additions & 1 deletion src/alchemlyb/parsing/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0c52fd9

Please sign in to comment.