Skip to content

zip(..., strict=False) wreaks havoc #3

Description

@finlayiainmaclean

Thanks for the great repo!

https://github.com/pauling-ai/Protonify/blob/e3a3b3650b63252931cd8652c391d536e63ce9b8/protonify/FreeEnergyPredictor.py#L36C1-L52C20

   def predict(self, smiles_list):
        unimol_input = self.preprocess_data(smiles_list)
        dataset = MolDataset(unimol_input)
        dataloader = DataLoader(dataset, 
                                batch_size=self.batch_size, 
                                shuffle=False,
                                collate_fn=self.model.batch_collate_fn,
                                )

        results = {}
        for batch in dataloader:
            net_input, _ = self.decorate_torch_batch(batch)
            with torch.no_grad():
                predictions = self.model(**net_input)
                for smiles, energy in zip(smiles_list, predictions):
                    results[smiles] = energy.item()
        return results

zip(smiles_list, predictions, strict=False) means that if smiles_list > batch_size, zip silently truncates to len(predictions) and reuses the first batch_size SMILES for every batch.

See original issue in the official unipka repo.

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