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

Make accessor namespace opt-in #25

Open
kmnhan opened this issue Apr 24, 2024 · 1 comment
Open

Make accessor namespace opt-in #25

kmnhan opened this issue Apr 24, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@kmnhan
Copy link
Owner

kmnhan commented Apr 24, 2024

Description

It is recommended to provide a single accessor under the package namespace. (See pydata/xarray#1080)

Currently, we have multiple callable accessors in the top level namespace of xarray.DataArray, but this is not good practice!

Possible solutions

The best way is to move all these accessors to a single accessor namespace:

Current New
da.qplot da.er.qplot
da.qshow da.er.qshow
da.qsel da.er.qsel
da.kspace da.er.kspace
da.modelfit da.er.modelfit
da.parallel_fit da.er.parallel_fit
ds.modelfit ds.er.modelfit

However, we lose the convenience of calling these functions directly. As a workaround, we should add an opt-in environment variable to enable the top-level accessors. This way, users can choose to use the old syntax if they prefer!

@kmnhan kmnhan added the enhancement New feature or request label Apr 24, 2024
@kmnhan kmnhan self-assigned this Apr 24, 2024
@kmnhan kmnhan mentioned this issue Apr 27, 2024
3 tasks
@kmnhan kmnhan added this to the 3.0 Release milestone Apr 28, 2024
@kmnhan
Copy link
Owner Author

kmnhan commented Jul 8, 2024

Recently, I'm leaning towards making this an opt-out feature, or to not implementing it altogether. Although the pythonic way is obviously to make it an opt-in feature, I don't think better syntax uniformity is worth the extra code complexity. Besides, if we're not going to add any more accessors, the current number of accessors are modest, and I don't think they will cause any confusion if we just document them properly.

Maybe we should try to reduce the number of accessors instead by merging some of them. For instance, we could merge modelfit and parallel_fit into a single qfit accessor to keep consistency.

@kmnhan kmnhan removed this from the 3.0 Release milestone Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant