posit-dev / positron

Positron, a next-generation data science IDE
Other
2.51k stars 78 forks source link

unable to expand ~ 100 element fast.ai list (`L`) in environment pane #1071

Closed jjallaire closed 1 year ago

jjallaire commented 1 year ago

Does this issue occur when all extensions are disabled?: Yes/No

For the following code:

from fastai.text.all import untar_data, URLs, get_text_files, coll_repr, WordTokenizer, first

path = untar_data(URLs.IMDB)
files = get_text_files(path, folders = [
    'train',
    'test',
    'unsup'
])

txt = files[0].open().read(); txt[:75]

spacy = WordTokenizer()
toks = first(spacy([txt]))

The toks variable is not expandable in the Environment pane:

Screen Shot 2023-08-13 at 6 18 05 PM
petetronic commented 1 year ago

It looks like toks is of a custom type fastcore.foundation.L which doesn't derive from Python's typical collections (list, tuple). We cannot assume all iterable types have "children" from an environment inspector perspective, but widening the logic to consider the presence of an __iter__ implementation - but not one of the unwanted types like string, bytearray, etc - would allow expansion.

petetronic commented 1 year ago

Confirmed this is now fixed in main after https://github.com/rstudio/positron/pull/1083