- 
                Notifications
    You must be signed in to change notification settings 
- Fork 297
Make Coord abstract #3514
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 Coord abstract #3514
Conversation
29f20d1    to
    24fbaf1      
    Compare
  
    | One thing to bear in mind about this approach is that the   | 
| It might also make sense to make  | 
| @stephenworsley I played with a couple of options for the  from functools import wraps
...
class AuxCoord(Coord):
    @wraps(Coord.__init__)
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)Works fine, but has a minor performance overhead: timeit('AuxCoord(1)', setup='from iris.coords import AuxCoord')
Out[10]: 11.958185139999841
timeit('AuxCoord(1)', setup='from iris.coords import AuxCoord')
Out[11]: 11.816572594994796
timeit('AuxCoord(1)', setup='from iris.coords import AuxCoord')
Out[12]: 11.72259231901262
timeit('AuxCoord(1)', setup='from iris.coords import AuxCoord')
Out[13]: 11.927083795992075This is compared with  timeit('AuxCoord(1)', setup='from iris.coords import AuxCoord')
Out[5]: 11.874402218993055
timeit('AuxCoord(1)', setup='from iris.coords import AuxCoord')
Out[6]: 11.801809267999488
timeit('AuxCoord(1)', setup='from iris.coords import AuxCoord')
Out[7]: 11.369123923010193
timeit('AuxCoord(1)', setup='from iris.coords import AuxCoord')
Out[8]: 11.455261625000276An alternative is: class AuxCoord(Coord):
    def __init__(self, *args, **kwargs):
        self.__doc__ = super().__init__.__doc__
        super().__init__(*args, **kwargs)which has the following behaviour: timeit('AuxCoord(1)', setup='from iris.coords import AuxCoord')
Out[7]: 12.073399219996645
timeit('AuxCoord(1)', setup='from iris.coords import AuxCoord')
Out[8]: 12.17960434599081
timeit('AuxCoord(1)', setup='from iris.coords import AuxCoord')
Out[9]: 12.184167061001062
timeit('AuxCoord(1)', setup='from iris.coords import AuxCoord')
Out[10]: 12.351267233985709Or indeed, there is this: class AuxCoord(Coord):
    def __init__(self, *args, **kwargs):
        self.__doc__ = Coord.__init__.__doc__
        super().__init__(*args, **kwargs)which has the following behaviour: timeit('AuxCoord(1)', setup='from iris.coords import AuxCoord')
Out[10]: 11.896369188994868
timeit('AuxCoord(1)', setup='from iris.coords import AuxCoord')
Out[11]: 12.091242638998665
timeit('AuxCoord(1)', setup='from iris.coords import AuxCoord')
Out[12]: 12.14877037498809
timeit('AuxCoord(1)', setup='from iris.coords import AuxCoord')
Out[13]: 12.003538096003467Note that  Given the above, I'd be happy to opt for the first option using  | 
| @stephenworsley Could you please make an issue to cover  | 
| It looks like using  | 
4ec600b    to
    dbce081      
    Compare
  
    dbce081    to
    9ed21fe      
    Compare
  
    | """ | ||
|  | ||
| @wraps(Coord.__init__, assigned=("__doc__",), updated=()) | 
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.
@stephenworsley Very nice indeed 😉
For reference, see https://docs.python.org/3.7/library/functools.html#functools.update_wrapper
This addresses #3410 by making
__init__inCoordanabstractmethod.