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
[ENH] Testing for erroneous use of reserved attributes #2772
Comments
I can implement this! Here is an idea - we have a class attribute which is a set of protected names in Then we add a test for every concrete implementation of an estimator we make sure none of its class specific attributes are in the set of banned names? (ie we could exclude any We can get the set of child-specific names for testing by subtracting the set of parent attributes from the set of child-attributes? Just an idea, lmk what you think and I take take a stab at implementing it. |
Hm, that would take care of these not being in the constructor. It would not cover the "accident" cases, or would it? Where a non-hyper-parameter attribute is being written to in one of the methods. How would we detect this? |
They are already excluded, since the collections is done via |
@ltsaprounis, can your mock estimator perhaps notice which attributes are being written to? |
Alternative/potentially hacky solution...... In Base Classes/Heterogenous Meta Estimator we could overwrite the setattr() call. In it we could see where setattr() is being called from by doing the following:
And put is some checks that calls to |
(and to be fair, I thought we were trying to cover cases where it is in the constructor? that at least seemed to be the error case that we were running into) |
I did not know you could do that!
In the error case, it was set by the constructor, but not an arg to the constructor. Would that not be missed by your first proposed solution? |
Hmm, yes, revisiting my original solution I do think it wouldn't work! |
All base classes have some reserved attributes, see PR #2769, and we have already run into the problem twice, of concrete estimators using attributes that have the same name as reserved attributes.
We should test for this, but ... how?
Any good ideas, @miraep8? Given that you are the other person who ran into this...
The text was updated successfully, but these errors were encountered: