Skip to content

Separate grouping logic into reusable function #215

Description

@ank1m

Separate grouping logic for input arguments and corresponding batch indices into reusable python function for use in different Python modules, e.g. in harmony-autotester.
The grouping logic is repeated here:

batch_indices = get_batch_indices(input_filenames)
unique_category_indices: list[int] = sorted(set(batch_indices), key=batch_indices.index)
logging.info(f"batch_indices = {batch_indices}")
# --- Construct a STAC object based on the batch indices ---
grouped: dict[int, list[str]] = {}
for k, v in zip(batch_indices, input_filenames, strict=False):
grouped.setdefault(k, []).append(v)
and
grouped: dict[int, list[Item]] = {}
for k, v in zip(batch_indices, items, strict=False):
grouped.setdefault(k, []).append(v)

Replace the duplicated implementations in both locations with the reusable function and develop unit test for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions