Skip to content

bug: WindowDataset.crop_spect_vectors_keep_classes method can crop twice #213

Description

@NickleDave

as spotted by @yardencsGitHub
in line 312, the variable lbl_tb_cropped should be just lbl_tb -- not the vector that's been cropped already. As currently written, this would have the effect of "cropping" the dataset twice
https://github.com/NickleDave/vak/blob/68bba5865436ec7d705fdca82b4ee021dc86bf81/src/vak/datasets/window_dataset.py#L312

    # try cropping off the end first
    lbl_tb_cropped = lbl_tb[:cropped_length]

    if np.array_equal(np.unique(lbl_tb_cropped), classes):
            x_inds[cropped_length:] = WindowDataset.INVALID_WINDOW_VAL
            return spect_id_vector[:cropped_length], spect_inds_vector[:cropped_length], x_inds
        else:
            # try truncating from the back instead
            lbl_tb_cropped = lbl_tb_cropped[-cropped_length:]  # <-- SHOULD BE `lbl_tb` !!!
            if np.array_equal(np.unique(lbl_tb_cropped), classes):
                x_inds[:-cropped_length] = WindowDataset.INVALID_WINDOW_VAL
                return spect_id_vector[-cropped_length:], spect_inds_vector[-cropped_length:], x_inds

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions