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

Issue a warning when overwriting attributes with accessors instead of erroring #1082

Closed
shoyer opened this issue Nov 6, 2016 · 1 comment

Comments

@shoyer
Copy link
Member

shoyer commented Nov 6, 2016

On the mailing list, @rabernat wrote:

Also, how can I interactively develop an accessor? If I try to
re-register under the same name, I get the error
AccessorRegistrationError: cannot register accessor <class
'main.ExchAccessor'> under name 'exch' for type <class
'xarray.core.dataset.Dataset'> because an attribute with that name
already exists.

In #1080, @smartass101 suggests:

Btw, perhaps it might be better to (perhaps optionally) issue a warning when overriding an existing class attribute during registering instead of completely refusing to do so.

I think this is a good idea, and would nicely solve @rabernat's problem (which might be your problem, too). We could add a new keyword argument (e.g., allow_override=True or warn=True to register_*_accessor) which switches to this new mode.

Should it be the default behavior? It is also possible that warnings instead of errors are enough in general.

@smartass101
Copy link

I vote for warning by default. Raising an error brings more inconvenience than it's worth.
Remember to warneach time, not just on first code run.

On November 6, 2016 2:11:54 PM GMT+01:00, Stephan Hoyer notifications@github.com wrote:

On the mailing list, @rabernat wrote:

Also, how can I interactively develop an accessor? If I try to
re-register under the same name, I get the error
AccessorRegistrationError: cannot register accessor <class
'main.ExchAccessor'> under name 'exch' for type <class
'xarray.core.dataset.Dataset'> because an attribute with that name
already exists.

In #1080, @smartass101 suggests:

Btw, perhaps it might be better to (perhaps optionally) issue a
warning when overriding an existing class attribute during registering
instead of completely refusing to do so.

I think this is a good idea, and would nicely solve @rabernat's problem
(which might be your problem, too). We could add a new keyword argument
(e.g., allow_override=True or warn=True to register_*_accessor)
which switches to this new mode.

Should it be the default behavior? It is also possible that warnings
instead of errors are enough in general.

You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#1082

Sent from my Android device with K-9 Mail. Please excuse my brevity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants