Skip to content

New script subvolume_charge.py#119

Merged
andthum merged 12 commits intomainfrom
feat/script/net-charge-of-volume
Nov 3, 2022
Merged

New script subvolume_charge.py#119
andthum merged 12 commits intomainfrom
feat/script/net-charge-of-volume

Conversation

@andthum
Copy link
Owner

@andthum andthum commented Nov 3, 2022

New script subvolume_charge.py

Type of change

  • Bug fix.
  • New feature.
  • Code refactoring.
  • Dependency update.
  • Documentation update.
  • Maintenance.
  • Other: Description.
  • Non-breaking (backward-compatible) change.
  • Breaking (non-backward-compatible) change.

Proposed changes

Create a new script subvolume_charge.py that calculates the net charge of cubic subvolumes of the simulation box.

PR checklist

  • I followed the guidelines in the Developer's guide.
  • New/changed code is properly tested.
  • New/changed code is properly documented.
  • New/changed features are tracked in CHANGELOG.rst.
  • The CI workflow is passing.

* Fix linter warnings/errors.
* Sort imports.
* Format code and docstrings.
* Update/Clarify docstrings.
* Refactor function `mdtools.select.atoms_around_point`: Remove the
  `warn_empty` and `verbose` arguments, because they can be parsed as
  keyword arguments.
Let `black` check the format of `mdtools.select` during the CI workflow.
Remove the `--line-length` option, because it is set in the config
file (`pyproject.toml`)

Add
*  `mdtools/scipy_helper_functions.py`
* `mdtools/statistics.py`
* `scripts/gmx/*.py`
* `scripts/*.py`
to the list of files whose format is checked by `black` during the CI
workflow.
The flake8 error code F821 ("undefined name name") was originally
ignored, because it caused false positives in docstrings, because flake8
does not recognize `doctest_global_setup` in the Sphiny config file
`conf.py`. However, when ignoring F821, developers don't get warned about
undefined variables in the source code.

Therefore, we don't exclude F821 generally, but exclude it during the
flake8 lining phase in the CI workflow and during the flake8 pre-commit
hook.
Set default output array if keyword arguments are given but the `out`
keyword is not defined.  This should speed up the calculation, because
no new memory must be allocated for the output array.
Refactor the function `mdtools.numpy_helper_functions.extend` to raise a
proper `numpy.AxisError` if the given axis is out of bounds for the
input array.

Additionally, add examples to the docstring.
Add a new function `mdtools.numpy_helper_functions.digitize_dd` that
extends the function `numpy.digitize` to multi-dimensional data.  The
new function takes a 2-dimensional array and multiple
bin arrays and returns the bin indices to which each value in the input
array belongs.
Fix function `mdtools.check.bins`.  Fixed issue: If `num` is `None` or
is not equal to `num != (stop - start) / step` it should be calculated
according to `int(np.around((stop - start) / step))`.  However, all
variables are of type `decimal.Decimal` which `np.around` cannot handle.
Therefore, `int(np.around((stop - start) / step))` was changed to
`round((stop - start) / step)`.

Additionally, fix the error that a message was shown (if `verbose` is
`True`) saying that `step` has been changed although it wasn't actually
changed.

Finally, sort the import statements of `mdtools.check`.
@github-actions github-actions bot added bugfix Pull requests that fix a bug enhancement New feature or request minor Change that results in a new minor version patch Change that results in a new patch version refactoring Code refactoring labels Nov 3, 2022
@andthum andthum force-pushed the feat/script/net-charge-of-volume branch from bfd910c to 144a5b3 Compare November 3, 2022 23:15
Add a new function `mdtools.structure.assign_atoms_to_grid` that takes
an MDAnalysis AtomGroup and assigns its atoms to the subvolumes that are
spanned by a given grid.
Create a new script `subvolume_charge.py` that calculate the net charge
of cubic subvolumes of the simulation box.
@andthum andthum force-pushed the feat/script/net-charge-of-volume branch from 144a5b3 to 5101274 Compare November 3, 2022 23:19
@andthum andthum merged commit 0a2dfc8 into main Nov 3, 2022
@andthum andthum deleted the feat/script/net-charge-of-volume branch November 3, 2022 23:26
andthum added a commit that referenced this pull request Jun 15, 2023
Fix a bug in the function `mdtools.check.bins` that was introduced in
commit f69d2fc (Pull Request 119
#119).  There an if condition was
changed such that although the variable `step` might be `None` it is
compared to an integer which raises a `TypeError`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull requests that fix a bug enhancement New feature or request minor Change that results in a new minor version patch Change that results in a new patch version refactoring Code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant