-
Notifications
You must be signed in to change notification settings - Fork 13
Constants inheritance proposal #1 #104
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #104 +/- ##
==========================================
- Coverage 88.68% 88.65% -0.03%
==========================================
Files 101 101
Lines 10008 10050 +42
==========================================
+ Hits 8875 8909 +34
- Misses 1133 1141 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
|
Hi @davidhassell, I think that is an excellent solution: minimal code required to implement the inheritance, as per your example snippet, and it can keep the logic loosely coupled:
Good thinking. I was trying to work out whether the |
|
Thanks. Good point on doc string rewriting. Currently it is not in place for these new classes, but I reckon if we add simply the metaclass to |
Oh, I didn't consider this, so I guess a simple option is just to not apply it to those classes, if it does end up causing issue! On the topic the All good. If you would like review once this is ready just ping me. Thanks. |
|
Will do. I've just remembered, after a bit of tinkering, that the docstring rewriting only happens on methods of the class, rather than the class itself. It may/may not be trivial to extend it to the Can we somehow copy the class itself in the same way. I have no idea, but it'll fun(?) finding out. If this is not easy to fix, I suggest that we implement it as it stands and dwell on the more elegant solution at our leisure. |
|
(I should say that adding the metaclass absolutely did the trick for method docstring rewriting on the |
I think that should be do-able via an approach not dissimilar to one used for copying the methods. But I could be wrong. Would not some investigation, Good luck, if you want to try it.
Sounds like a good plan to me. I think the class copying for class docstring re-writing, as above, constitutes another issue entirely, so perhaps we can throw an issue up for it to tackle at a good time. |
|
Class docstring rewriting is a reality . I think it's all there, now, for now. |
sadielbartholomew
left a comment
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 have a small number of minor comments, but overall this is great and it works perfectly (as far as I can reasonably determine) to retain the behaviour and documentation of the cfdm constants and functions for getting & setting them, while changing the underlying implementation so maintenance is easier and inheritance by cf-python is more robust. 🎉
|
HI Sadie - I think it's OK to merge now? |
I found a hash symbol lurking, as in my above comment, but otherwise the minor feedback is all addressed and everything is shipshape, so please merge! I'll start reviewing the cf-python follow-on PR this afternoon. |
Co-authored-by: Sadie L. Bartholomew <sadie.bartholomew@ncas.ac.uk>
|
Great - thanks |
Hi @sadielbartholomew here are some thoughts for refactoring the constants access situation so that we can most effortlessly use it in cf-python. The user-facing API is unchanged. What do you think?
The on-line docs are unchanged. There is a small change to the
help(cfdm.rtol)docs, but tolerable, I think.cf-python would use it as follows:
So cf-python need not know anything about the functionality nor API nor docs from cfdm.
This is just one idea of many, I'm sure.