Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential bug of textattack.datasets.dataset.Dataset after calling filter_by_labels_ #745

Closed
wenh06 opened this issue Jul 17, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@wenh06
Copy link
Contributor

wenh06 commented Jul 17, 2023

Describe the bug
After calling filter_by_labels_, the _dataset attribute of a textattack.datasets.dataset.Dataset instance is no longer a list but a filter, which has no __len__ method, hence calling the __len__ method of textattack.datasets.dataset.Dataset would result in TypeError.

To Reproduce

import textattack
ds = textattack.datasets.dataset.Dataset(
    dataset=[
        ("Not good not bad.", 2),
        ("It is funny.", 1),
        ("Not interesting at all!", 0),
    ],
)
len(ds)  # 3
ds.filter_by_labels_(labels_to_keep=[0, 1])
len(ds)  # TypeError

Expected behavior

len method raises no error.

Screenshots or Traceback

image

System Information (please complete the following information):

  • OS: Linux
  • Textattack: master

Additional context
NA

@jxmorris12
Copy link
Collaborator

this was fixed in #746 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants