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

Add compositional reprs #129

Merged
merged 6 commits into from
Oct 28, 2018
Merged

Add compositional reprs #129

merged 6 commits into from
Oct 28, 2018

Conversation

philippjfr
Copy link
Member

An initial implementation of compositional reprs, which can be improved later.

Some sample outputs for moderately complex dashboards include:

Row(
    HTML(str, width=200),
    Spacer(width=30),
    ParamMethod(method),
    Spacer(width=50),
    Column(
        Param(ParameterSets, name='Attractors', width=220),
        Param(Attractors, expand=True, name='Options', width=220)
    )
)
Column(
    Row(
        Markdown(str, width=170),
        Spacer(width=50),
        Column(
            Markdown(str, height=25, width=400),
            Spacer(height=-15),
            Markdown(str, width=500)
        ),
        Spacer(width=180),
        Column(
            HoloViews(DynamicMap),
            Button(name='Clear selection'),
            Spacer(height=-15)
        ),
        Markdown(str, width=80)
    ),
    Spacer(height=-50),
    Row(
        HoloViews(DynamicMap),
        HoloViews(DynamicMap)
    ),
    Row(
        HoloViews(DynamicMap),
        HoloViews(DynamicMap)
    )
)

@codecov-io
Copy link

codecov-io commented Oct 26, 2018

Codecov Report

Merging #129 into master will increase coverage by 0.3%.
The diff coverage is 94.62%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #129     +/-   ##
=========================================
+ Coverage   89.63%   89.94%   +0.3%     
=========================================
  Files          27       27             
  Lines        4034     4196    +162     
=========================================
+ Hits         3616     3774    +158     
- Misses        418      422      +4
Impacted Files Coverage Δ
panel/tests/test_widgets.py 100% <100%> (ø) ⬆️
panel/tests/test_util.py 100% <100%> (ø) ⬆️
panel/tests/test_panes.py 94.93% <100%> (+0.09%) ⬆️
panel/util.py 74.4% <100%> (+3.45%) ⬆️
panel/param.py 90.54% <100%> (+0.26%) ⬆️
panel/pane.py 81.84% <100%> (+0.3%) ⬆️
panel/tests/test_param.py 99.62% <100%> (ø) ⬆️
panel/tests/test_layout.py 100% <100%> (ø) ⬆️
panel/viewable.py 69.41% <77.77%> (+0.22%) ⬆️
panel/layout.py 97.28% <82.35%> (+0.21%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update afabc17...187841e. Read the comment docs.

@jbednar
Copy link
Member

jbednar commented Oct 26, 2018

That's a good start, thanks! I'd rather avoid the parentheses after Column and Row; this is not an eval-able expression, and I think it's better to make that clear (and avoid the extra whitespace).

The representation also doesn't yet achieve indicating how to index into this object, which is a feature of HoloViews reprs that I really find helpful. For that it would need to have numbers on the Row and Column entries to indicate which how to index the whole structure to reach that part. But of course implementing that can be postponed...

@philippjfr
Copy link
Member Author

How's this:

Column
    [0] Row
        [0] Markdown(str, width=170)
        [1] Spacer(width=50)
        [2] Column
            [0] Markdown(str, height=25, width=400)
            [1] Spacer(height=-15)
            [2] Markdown(str, width=500)
        [3] Spacer(width=180)
        [4] Column
            [0] HoloViews(DynamicMap)
            [1] Button(name='Clear selection')
            [2] Spacer(height=-15)
        [5] Markdown(str, width=80)
    [1] Spacer(height=-50)
    [2] Row
        [0] HoloViews(DynamicMap)
        [1] HoloViews(DynamicMap)
    [3] Row
        [0] HoloViews(DynamicMap)
        [1] HoloViews(DynamicMap)

@jbednar
Copy link
Member

jbednar commented Oct 26, 2018

Looks fabulous to me! I can super easily now pull out [0][5] and work with it!

@jbednar
Copy link
Member

jbednar commented Oct 26, 2018

I can't wait to update my interact() example to demonstrate how and why interact() is now a clear starting point, not a dead end!

@jbednar
Copy link
Member

jbednar commented Oct 28, 2018

I think we need to limit the reprs:

Column
    [0] WidgetBox
        [0] FloatSlider(end=2, name='a', start=-2, value=1.7)
        [1] FloatSlider(end=2, name='b', start=-2, value=1.7)
        [2] FloatSlider(end=2, name='c', start=-2, value=0.6)
        [3] FloatSlider(end=2, name='d', start=-2, value=1.2)
        [4] IntSlider(end=20000000, name='n', start=1, value=2000000)
        [5] Select(name='colormap', options={'bgy': ['#fff123', '#fff122', '#fff122', '#fff022',
'#fff021', '#fcf021', '#f9f021', '#f5f021', '#f2f020', '#eef020', '#eaef20', '#e7ef20', '#e3ef1f',
'#dfef1f', '#dcee1f', '#d8ee1f', '#d4ee1e', '#d1ee1e', '#cded1e', '#c9ed1e', '#c6ed1e', '#c2ec1d',
'#beec1d', '#bbec1d', '#b7eb1d', '#b3eb1d', '#b0ea1c', '#acea1c', '#a8ea1c', '#a4e91c', '#a1e91c',
'#9de81c', '#99e81c', '#95e71b', '#91e71b', '#8ee61b', '#8ae61b', '#86e51b', '#82e51b', '#7ee41b',
'#7ae31b', '#76e31a', '#72e21a', '#6ee21a', '#6ae11a', '#66e01a', '#62e01a', '#5edf1a', '#5ade1a',
... 5 pages of output ...
'#0b017e', '#0a017c', '#09017a', '#090178', '#080276', '#070274', '#060272', '#060270', '#05026e', 
'#04026c', '#030269', '#030267', '#020265', '#010263', '#010261', '#00025f', '#00025d', '#00025b', 
'#000259', '#000257', '#000255', '#000154', '#000152', '#000150', '#00004e'])
    [1] interactive(function, manual_name=Run Interact)

@philippjfr
Copy link
Member Author

I think we need to limit the reprs:

Yes, I'll add a function to generate shortened reprs for parameter values.

@philippjfr
Copy link
Member Author

@jbednar Mind playing around a bit?

@jbednar
Copy link
Member

jbednar commented Oct 28, 2018

Looks great to me:

Column
    [0] WidgetBox
        [0] FloatSlider(end=2, name='a', start=-2, value=1.7)
        [1] FloatSlider(end=2, name='b', start=-2, value=1.7)
        [2] FloatSlider(end=2, name='c', start=-2, value=0.6)
        [3] FloatSlider(end=2, name='d', start=-2, value=1.2)
        [4] IntSlider(end=20000000, name='n', start=1, value=2000000)
        [5] Select(name='colormap', options={'bgy': ['#fff123', ...}, value=['#b3fef5', '#b0fef5', ...])
    [1] interactive(function, manual_name='Run Interact')

@philippjfr philippjfr merged commit 82e3f43 into master Oct 28, 2018
@philippjfr philippjfr deleted the reprs branch March 6, 2019 14:46
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

3 participants