Skip to content
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

Added operation_kwargs Histogram property #3921

Merged
merged 4 commits into from
Sep 3, 2019

Conversation

jonmmease
Copy link
Collaborator

@jonmmease jonmmease commented Aug 22, 2019

Overview

For Histogram elements created using the holoviews.operation.histogram operation, this new property holds a dict of kwargs that can be used with the operation to recreate the Histogram from the same data set.

Or it will contain None, if the Histogram was created directly using the Histogram constructor.

Motivation

Having this information available makes it possible to create histograms with a subset of the original dataset that share the same properties as an original Histogram. For example:

import numpy as np
import holoviews as hv
from holoviews import opts
hv.extension('plotly')

np.random.seed(1)
points = hv.Points(np.random.randn(100,2))

hist1 = hv.operation.histogram(points, cumulative=True, num_bins=10, dynamic=False, normed=False)
hist1.operation_kwargs
{'cumulative': True,
 'dynamic': False,
 'normed': False,
 'bins': [-1.857981864446752,
  -1.419351107321437,
  -0.980720350196122,
  -0.542089593070807,
  -0.10345883594549199,
  0.335171921179823,
  0.7738026783051382,
  1.212433435430453,
  1.651064192555768,
  2.0896949496810833,
  2.528325706806398]}
hist1

newplot

hist2 = hv.operation.histogram(points.select(y=(0, None), x=(0, None)), **hist1.operation_kwargs)
hist1 * hist2

newplot-1

This will be especially convenient when combined with #3919, because the original dataset will be available as the hist1.dataset property.

TODO:

  • Presever operation_kwargs through clone.

For Histogram elements created using the histogram operation, this
holds a dict of operation kwargs that can be used to recreate the
histogram from the same dataset.  Or None, if the Histogram was created
directly using the Histogram constructor.
@jbednar
Copy link
Member

jbednar commented Aug 22, 2019

Sounds good!

@jonmmease
Copy link
Collaborator Author

I made operation_kwargs a private property of the Histogram element so that we're not committing to a particular API at this point. I opened #3941 to discuss what we might want to do with the API in the future.

Merging!

@jonmmease jonmmease merged commit 82acc56 into master Sep 3, 2019
@philippjfr philippjfr deleted the histogram_operation_kwargs branch September 20, 2019 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants