-
Notifications
You must be signed in to change notification settings - Fork 45
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
Abstract provides defaults #1528
base: master
Are you sure you want to change the base?
Conversation
while hasattr(init, "_method"): | ||
init = getattr(init, "_method") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this terminate? How does the attribute get removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume it does terminate as it is the same code as before... sometimes my own code confuses me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see now, it is essentially recusing the init until it finds the real init
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me if it works!
I would probably say deprecate as otherwise people might have things broken at the last minute by accidentally updating... |
In master there are two ways that the decorators @default_parameters and @default_initial_values are converted to a mapping of the values in the init. Making these properties
@defaults
This calculated the mappings when the class is imported (even if not used)
The resulting mapping replace the calculate functions so the calculation is only done once!
This style also did not have properties for mypy to find
AbstractPyNNModel
This calculated the mapping every time the property was called
Only worked for classes that extended AbstractPyNNModel
This PR merges the best of both solutions into AbstractProvidesDefaults
AbstractPyNNModel and any class which used to be decorated by @defaults now extends AbstractPyNNModel
The calculation of the mappings is delayed until either property is used.
Then BOTH properties are filled in (as the calculation uses a lot of sharable work)
Tested by:
SpiNNakerManchester/IntegrationTests#307
question.
Which should we do: