-
-
Notifications
You must be signed in to change notification settings - Fork 404
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
Deprecation, consistency and docstrings for core methods #3128
Conversation
0ce6923
to
7ee1f52
Compare
So since |
8f5f0ac
to
d6ff0ff
Compare
@jlstevens Ready to review. |
All the suggested deprecations you describe seem very reasonable though (as I mention in #2322) I am not very enthusiastic about these giant docstrings. Are there any tools to validate this format? Check the actual signature matches what is declared in the docstring at least? |
Ok, I've found myself an emacs code folding solution I can use which makes me happier with these docstrings (at least from a developer perspective). I'll just fold away these docstrings in the files that have them if they stop me seeing the code. As for Google versus NumPy style, here are my thoughts:
I personally doubt anyone would find the google style confusing even if they haven't seen it before. This means that on balance, I vote for the google style. |
I'd be happy to switch to Google style, it's what bokeh uses and it is indeed a bit more compact. That said it's an even larger job to convert to that style because the first line with the quotes is expected to provide a summary, something we have never done, e.g.:
|
I think the fact that bokeh uses it makes it more compelling and the short summary line is a good idea anyway imho. |
I'm also going to tackle element docstrings and class hierarchies in this PR, they are all hopelessly outdated. |
b6349aa
to
5cb4c1c
Compare
5cb4c1c
to
b0af7a3
Compare
I am happy with these future deprecations and I do prefer the google style docstrings. I think it will be appreciated by users! I made one comment/suggestion, otherwise I am happy to merge. |
Co-Authored-By: philippjfr <philippjfr@continuum.io>
The last commit is a tiny change to a docstring and the previous build passed. Merging. |
@jbednar @philippjfr One thing to consider about the google style docstrings is what happens when we want to enable tab completion in IPython. Unfortunately, IPython only scans the first non-empty line which means you need to insert the signature on the initial line with the short description. At least IPython does seem to scan the whole line so we could append the signature after the short description. I'm not sure whether tools that use docstrings (e.g sphinx) will pick up on dynamically mutated docstrings (one option is to try to only update docstrings in an ipython context, e.g see the suggestion in holoviz/param#305). One thing that we cannot really fix is the mess a user would see calling |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This PR is an attempt to make the core API more consistent by ensuring that method signatures are consistent, deprecating methods which are not useful or duplicative and add consistent docstrings throughout.
As a first step I added a
config
variable calledfuture_deprecations
which guards all forward going deprecation warnings. A user could enable this flag to see if they are affected by any of the deprecationsNewly deprecated methods
These will go through a whole deprecation cycle, i.e. we will announce them as deprecated in the release notes, then disable the
future_deprecations
conditional in the next release so the warnings are raised and finally remove these methods. In all likelihood these methods will start raising warnings in 1.12 and be fully removed in 1.0..table
: This method exists on all elements and NdMapping types, despite the fact that a tabular representation makes little sense for many types of data, if we decide to replace this method we should instead add adataset
method which concatenates all types of data appropriately instead of "tabularizing" it. HoweverHoloMap.collapse
already offers this capability and in the simple case you can simple cast the Element to a Table so there is not much gained by adding a new method. However this method is used a fair bit throughout the docs so I think it has to go through a longer deprecation cycle. We may also have to consider moving collapse ontoUniformNdMapping
to allow collapsing types other than a HoloMap..mapping
: This exists on all elements and returns the horrible NdElement based dictionary format which we have removed a long time ago.ItemTable.values
: This existed for consistency with our oldNdColumns
class which has been replaced withDataset
long ago. It's not useful and should be removed. It also means that we might consider renamingdimension_values
tovalues
so removing clashes like this now will help us in the long run.HoloMap
/DynamicMap
.split_overlay
: This method is really not very useful to a user so I've decided to make it privateOverlay.collapse
: We should makecollapse
an operation that can be applied to all kinds of objects, the Overlay.collapse implementation was hugely outdated and will not work for the majority of typesElement.collapse_data
: This was a classmethod to perform collapse operations which has slowly been getting replaced with an Interface based implementationDimension.__call__
: Was replaced with Dimension.clone but we never added a warning.ViewableTree.from_values
: Old method which was required to construct tree from list of items, this is now supported by the standard constructorViewableTree.regroup
: Recomputes groups for items in ViewableTree which is highly inefficient and very rarely useful, also equivalent functionality achievable withhv.Layout(layout.relabel(group='New Group').values())
.Methods made more consistent
There are still a number of data conversion methods that have some usefulness and are used throughout the code and therefore probably require a longer deprecation cycle if we were to decide to remove them:
Element.columns
: Returns an OrderedDict of values along each dimensions. The main issue here is that this will flatten gridded and geometry data into a flat column, which is of limited utility. It may be nice to replace this with a method that returns the native dictionary format for each different type of data, columnar, geometry and gridded but we would have to find a different name.Element.array
: Returns an ndarray of values along each dimension again in a columnar format. This method is used a fair bit throughout the code and we probably shouldn't remove it.Element.dframe
: Returns a pandas dataframe of the values along each dimension, once again in a columnar format. Again this is frequently used so I've given it a good docstring, gave it a consistent signature throughout and allowed key dimensions to become dataframe indexes.Element.sample
: Element.sample and HoloMap.sample now accept the same signature (fixes Sample method signature is inconsistent #298).hist
: The .hist implementation had 4 completely different signatures which are now consistent (fixes The .hist method signature can be made more consistent #1728)Methods we should consider introducing as replacements
UniformNdMapping.dataset
: As a replacement for.table
we could provide a way method to collapse UniformNdMapping types down to a single Dataset.Old deprecations
A number of items have been deprecated for a long time but were never removed
.to
mdims
argument no longer supportedLayout.display
used to control display modes for Layout but removed a long time agoElement hierarchies
Addressing #143
This PR adjusts the inheritance hierarchies, introducing a new category of elements with
Geometry
as its baseclass.There are now the following general classes of elements:
Docstrings
Classes that have had docstrings added:
core/dimension.py
LabelledData
Dimensioned
core/element.py
Element
core/data/__init__.py
Dataset
core/layout.py
core/ndmapping.py
MultiDimensionalMapping
NdMapping
UniformNdMapping
core/overlay.py
Overlay
core/spaces.py
HoloMap
DynamicMap