Skip to content

Create functions to find sequences of constant values in NumPy arrays#162

Merged
andthum merged 6 commits intomainfrom
feat/core/numpy-helper-functions/find-constant-regions
May 5, 2023
Merged

Create functions to find sequences of constant values in NumPy arrays#162
andthum merged 6 commits intomainfrom
feat/core/numpy-helper-functions/find-constant-regions

Conversation

@andthum
Copy link
Owner

@andthum andthum commented May 5, 2023

Create functions to find sequences of constant values in NumPy arrays

Type of change

  • Change of core package.
  • Change of scripts.
  • 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

  • Refactor the function mdtools.numpy_helper_functions.split_into_consecutive_subarrays:

    • Rename the function to mdtools.numpy_helper_functions.split_into_contig_seqs.
    • Remove the argument debug. Instead always check the input arguments.
    • Change the default of the argument sort from True to False.
    • Add the argument step_tol that allows to provide a tolerance value for the step size of the contiguous sequences.
    • Add the argument return_ix that allows to return the indices where the input array was split to create the subarrays.
  • Create a new function mdtools.numpy_helper_functions.get_const_seqs that extracts all sequences of constant values from an array.

  • Create a new function mdtools.numpy_helper_functions.find_const_seq_n that finds the first sequence of at least n constant values in an array.

  • Create a new function mdtools.numpy_helper_functions.find_const_seq_long that finds the longest sequence of constant values in an array.

PR checklist

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

andthum added 6 commits May 5, 2023 11:15
…e_subarrays`

Refactor the function
`mdtools.numpy_helper_functions.split_into_consecutive_subarrays`:

* Rename the function to
  `mdtools.numpy_helper_functions.split_into_contig_seqs`.

* Remove the argument `debug`.  Instead always check the input
  arguments.

* Change the default of the argument `sort` from `True` to `False`.

* Add the argument `step_tol` that allows to provide a tolerance value
  for the step size of the contiguous sequences.

* Add the argument `return_ix` that allows to return the indices where
  the input array was split to create the subarrays.

* Add examples to the docstring.
Create a new function `mdtools.numpy_helper_functions.get_const_seqs`
that extracts all sequences of constant values from an array.
Create a new function `mdtools.numpy_helper_functions.find_const_seq_n`
that finds the first sequence of at least n constant values in an array.
Create a new function
`mdtools.numpy_helper_functions.find_const_seq_long` that finds the
longest sequence of constant values in an array.
@github-actions github-actions bot added breaking Breaking changes enhancement New feature or request major-core Breaking change in the core package refactoring Code refactoring labels May 5, 2023
@andthum andthum merged commit 0b62442 into main May 5, 2023
@andthum andthum deleted the feat/core/numpy-helper-functions/find-constant-regions branch May 5, 2023 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Breaking changes enhancement New feature or request major-core Breaking change in the core package refactoring Code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant