From dabb8a90cc409c6d2e6836660f56b0a3fff8bd6b Mon Sep 17 00:00:00 2001 From: WEN Hao Date: Tue, 18 Jul 2023 01:39:47 +0800 Subject: [PATCH] fix potential bug in the filter_by_labels_ method of the Dataset class --- textattack/datasets/dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/textattack/datasets/dataset.py b/textattack/datasets/dataset.py index c56931adc..53c924733 100644 --- a/textattack/datasets/dataset.py +++ b/textattack/datasets/dataset.py @@ -125,7 +125,7 @@ def filter_by_labels_(self, labels_to_keep): """ if not isinstance(labels_to_keep, set): labels_to_keep = set(labels_to_keep) - self._dataset = filter(lambda x: x[1] in labels_to_keep, self._dataset) + self._dataset = list(filter(lambda x: x[1] in labels_to_keep, self._dataset)) def __getitem__(self, i): """Return i-th sample."""