Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Abstract base class for Normalize#30178
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
After discussion on this weeks call I think we should go with the ABC flavor. Given:
If we are going to bring in a new language feature we should do that when it brings in a clear benefit so we should stick with ABC. |
The docs failure is real, The new class needs to be manually added to the rst. |
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.
modulo fixing the docs build.
If I'm not mistaken, once you put the base class into Sphinx, you can replace the duplicate docstrings in the no-longer-base class with |
The doc build failure looks a bit cryptic, but I think putting Norm here will solve it |
Thank you@tacaswell@timhoffm@QuLogic |
I want to point out that at the end of @functools.cachedef_make_norm_from_scale(scale_cls,scale_args,scale_kwargs_items,base_norm_cls,bound_init_signature,):""" Helper for `make_norm_from_scale`. This function is split out to enable caching (in particular so that different unpickles reuse the same class). In order to do so, - ``functools.partial`` *scale_cls* is expanded into ``func, args, kwargs`` to allow memoizing returned norms (partial instances always compare unequal, but we can check identity based on ``func, args, kwargs``; - *init* is replaced by *init_signature*, as signatures are picklable, unlike to arbitrary lambdas. """classNorm(base_norm_cls):def__reduce__(self):cls=type(self)# If the class is toplevel-accessible, it is possible to directly# pickle it "by name". This is required to support norm classes# defined at a module's toplevel, as the inner base_norm_cls is# otherwise unpicklable (as it gets shadowed by the generated norm# class). If either import or attribute access fails, fall back to# the general path. |
It doesn't create a class named |
Let's rename it to |
trygvrad commentedJun 25, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I changed it to I think this PR is ready to be merged now :) EDIT: I spoke before the tests had completed |
This PR is an alternative to#30149
It is created so that we can contrast full implementations of a protocol vs an abstract base class in light of the comment here#30149 (comment)
For context on why this is required, see the comment on the MultiNorm PR#29876 (comment)