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
Feature Request: Some form of path auto-completion #189
Comments
I think that auto-completing strings like this is not possible in python at all. (I would be happy to be proven wrong though.) What we can do instead is provide attribute-like access to child nodes, and have them autocomplete, in the same way that xarray already lets you autocomplete variable names. Then your example would work like this dt.model.<click tab> --> dt.model.experiment_a We can't do filesystem-like syntax like "../" like this though. I already have a PR where I started doing this but it stalled because the implementation in Xarray I need to copy was a bit hard for me to understand. If anyone else wants to have a go before I get back to it then please do! |
Pandas seems to have figured it out: import pandas as pd
df = pd.DataFrame()
df['foo_bar'] = [0, 1, 2, 3]
df['foo_ <tab> # --> df['foo_bar Not 100% sure how they do this and its possible that Ipython is doing a lot of the heavy lifting. |
Oh wow that's cool! Will have to look at how they manage that wizardry |
IPython looks for Xarray already has some support: https://github.com/pydata/xarray/blob/6e77f5e8942206b3e0ab08c3621ade1499d8235b/xarray/core/coordinates.py#L342-L348 |
(This isn't going to work for |
to support Something like |
@keewis apologies if I misunderstood, but I think you're misunderstanding what already works and what is being proposed as a feature here.
What I'm talking about is So what I've done so far in #98 is include direct paths to subtree nodes in the |
Oh wow ipython's key completion code literally special-cases numpy and pandas explicitly 🤯 |
There is an issue on ipython that if solved would actually allow this feature fully. |
I've merged #98 but will keep this open to track the nice-to-have feature of auto-completing relative paths as strings. |
I think it would probably be reasonable to limit |
The more I play with datatree, the more I realize the huge potential of this package. Amazing work @TomNicholas.
I have been using dt for CMIP6 analysis and one of the things that is still fairly slow for me is to navigate into different specific leaves of the tree. Having some sort of incremental auto-complete of the path like this:
similar to what happens in the bash shell with tab completion would be an absolute killer feature. Most users already know how to navigate this (from their terminal). For massive trees this would speed up the workflow tremendously.
On the other hand I have no idea how complex this is to implement. Just wanted to suggest this feature.
The text was updated successfully, but these errors were encountered: