PAOFLOW.transport.parsers.parser_base#

Attributes#

Functions#

parse_index_array(index_string, max_value[, xval])

Parse a string representing a range or list of integer indices into a 0-based numpy array.

Module Contents#

PAOFLOW.transport.parsers.parser_base.comm[source]#
PAOFLOW.transport.parsers.parser_base.parse_index_array(index_string, max_value, xval=-1)[source]#

Parse a string representing a range or list of integer indices into a 0-based numpy array.

The string format allows specifying intervals using either comma-separated values or ranges. Each interval may be of the form:

  • i1 : a single index

  • i1-i2 : an inclusive range from i1 to i2

  • Nx : a placeholder that yields N entries of xval

Examples

"1-3,5,2x" would yield: [0, 1, 2, 4, -1, -1] assuming xval = -1 (default).

Parameters:
  • index_string (str) – A string representing a list of indices or ranges (1-based indexing).

  • max_value (int) – If an entry evaluates to a negative value or is unspecified (e.g. via x), then xval is substituted.

  • xval (int, optional) – The value to assign for Nx constructs (default is -1).

Returns:

`indices` – Parsed array of integer indices (0-based), ready for array slicing.

Return type:

ndarray of int

Raises:

ValueError – If the input format is invalid or inconsistent with expected size.