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

Utility for constructing Dimensions from Parameters? #1190

Closed
jbednar opened this issue Mar 10, 2017 · 6 comments
Closed

Utility for constructing Dimensions from Parameters? #1190

jbednar opened this issue Mar 10, 2017 · 6 comments
Assignees

Comments

@jbednar
Copy link
Member

jbednar commented Mar 10, 2017

An hv.Dimension is quite like a param.Parameter, in that both establish a named dimension with bounds, and they are often used for the same purpose, e.g. to determine the type of widget and the numerical range covered by that widget (such as a slider). In the code below, the declared kdims list is a copy of data already stored and declared on the underlying param.Parameterized object ig.DifferenceOfGaussians, and it would reduce redundancy and increase generality if those values could simply be looked up on the Parameterized object.

So, maybe we could have a utility that will accept a Parameterized object and then return a list of Dimensions for use as kdims, possibly with specified filtering (whitelist and blacklist) on the parameter names? Coupled with #1189, this approach could get rid of all the duplication between the DynamicMap and the DifferenceOfGaussians object, making it possible to use the same code with any such object to give widgets for whatever Parameters it found there.

import numpy as np
import holoviews as hv
import imagen as ig
import imagen.transferfn as tf
from imagen.image import FileImage
from imagen.transferfn.sheet_tf import Convolve
hv.notebook_extension()
%opts Image (cmap="gray") {+axiswise}

FileImage.filename = "/Users/jbednar/imagen/doc/images/ellen_arthur.pgm"

kdims = [hv.Dimension('size',                   range=(0.1, 2)),
         hv.Dimension('positive_size',          range=(0.1, 2)),
         hv.Dimension('negative_size',          range=(0.3, 4)),
         hv.Dimension('positive_aspect_ratio',  range=(1.0,10)),
         hv.Dimension('negative_aspect_ratio',  range=(1.0,10))]

def filtered_images(size,positive_size,negative_size,positive_aspect_ratio,negative_aspect_ratio):
    convolver = Convolve(kernel_pattern=ig.DifferenceOfGaussians(**locals()))
    return FileImage(output_fns=[convolver])[:]

FileImage()[:] + hv.DynamicMap(filtered_images, kdims=kdims)
@jlstevens jlstevens self-assigned this Mar 10, 2017
@jlstevens
Copy link
Contributor

Seems like a very plausible utility, either to just declare kdims from parameters or to declare the entire dynamic map...

@jbednar
Copy link
Member Author

jbednar commented Mar 10, 2017

Filtering by precedence would also be useful, so that by default hidden parameters aren't included, but the precedence value can be increased or decreased to get more or fewer widgets. That way there can be filtering that works across a set of Parameterized objects without knowing anything about their internals.

@philippjfr philippjfr modified the milestone: v2.0 Mar 15, 2017
@jlstevens jlstevens modified the milestones: v1.7.1, v2.0 Apr 27, 2017
@jlstevens
Copy link
Contributor

After some discussion we weren't convinced of the value of such a utility as it seems rather limited. Unless there are any new suggestions, I'm popping this issue off the 1.8 milestone. I suspect we might decide against the idea in future in which case the PR and this issue could then be closed.

@jlstevens jlstevens removed this from the v1.8 milestone Jun 18, 2017
@jlstevens jlstevens added this to the v1.9 milestone Jun 30, 2017
@philippjfr
Copy link
Member

Do we still want this? I really can't see an implementation that's actually going to be useful. In any case I don't think it will happen for 1.9.

@jlstevens
Copy link
Contributor

jlstevens commented Sep 26, 2017

@jbednar I'm happy to close this issue now but also happy to consider any updated proposals you might have in a new issue. Is that ok?

@jbednar jbednar closed this as completed Sep 27, 2017
@philippjfr philippjfr removed this from the v1.9 milestone Sep 27, 2017
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants