Skip to content
This repository has been archived by the owner on Nov 29, 2019. It is now read-only.

Defined label_formatter parameter on Widgets #48

Merged
merged 7 commits into from
May 16, 2018
Merged

Conversation

jlstevens
Copy link
Member

@jlstevens jlstevens commented May 16, 2018

This simple PR is long overdue imho: the widget labels can now be formatted nicely with a custom formatter.

Before:

After:

This is makes parambokeh widgets look a lot more polished!

Copy link
Member

@jbednar jbednar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks! Maybe should provide a dummy no-op formatter, or support None, to allow this behavior to be disabled easily for people who want to see a direct mapping to their parameter names?

@@ -29,6 +29,23 @@
__version__ = '0.2.1-unknown'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why we need this conditional anymore. @ceball ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite sure how this is in a pr about label format (I'm on my phone so can't easily see whole context), but isn't this just a case of parambokeh not having been updated to use autover yet?

@jlstevens
Copy link
Member Author

Maybe should provide a dummy no-op formatter, or support None, to allow this behavior to be disabled easily for people who want to see a direct mapping to their parameter names?

Addressed in 8dc2816 - just supply None to disable the formatter.

@jlstevens
Copy link
Member Author

I might add an option for label overrides...

@jlstevens
Copy link
Member Author

jlstevens commented May 16, 2018

Now you can set specific labels e.g if there is one specific label where the underscore is appropriate but you want the rest to become spaces:

override = {'unbounded_int': 'THIS INTEGER KNOWS NO BOUNDS'}
widgets = parambokeh.Widgets(BaseClass, label_formatter=parambokeh.default_label_formatter.instance(overrides=override))

@jbednar
Copy link
Member

jbednar commented May 16, 2018

The recent changes look good to me, thanks! Happy to see it merged when the tests pass.

@jlstevens
Copy link
Member Author

Looks to me like the tests have been broken a while, independent of this PR (e.g tests fail on master too). I can have a quick look to see if there is any easy fix but if there isn't I'm not sure how much effort to spend on that...

@jlstevens
Copy link
Member Author

In 8241d52 I fix a notebook using holoviews __call__. It still use opts unless we want parambokeh to require holoviews 1.10 with .options.

@jlstevens
Copy link
Member Author

jlstevens commented May 16, 2018

@ceball @philippjfr I pinned sphinx to 1.6 and install from nbsite master which fixed the doc build issue (at least on travis). This should be a temporary fix though as nbsite should be made to work with sphinx 1.7.

@jlstevens
Copy link
Member Author

@jbednar Ready to review again assuming the appveyor tests will pass. You may want to weigh in one some of the issues raised since you last looked.

@philippjfr In particular, 2e10365 seems to work but this just seemed the quickest fix to me and I haven't thought too deeply about it. What is clear is that using the user facing label as a key is a bad idea, such a key should always be the actual parameter name.

@jlstevens
Copy link
Member Author

@jbednar @philippjfr All tests have now gone green.


def HTMLWidget(*args, **kw):
return Div(name=kw['title'])
return Div(name=kw['name'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely sure this is the only two cases where this change is needed?

@philippjfr
Copy link
Member

As long as you confirm that the two places you switched to kw['name'] are the only occurrences where it's needed I'm happy to merge.

@philippjfr
Copy link
Member

Had a look, seems fine. I'll merge.

@philippjfr philippjfr merged commit 8d94548 into master May 16, 2018
@jlstevens
Copy link
Member Author

jlstevens commented May 16, 2018

As long as you confirm that the two places you switched to kw['name'] are the only occurrences where it's needed I'm happy to merge.

I rgrepped for name=, 'name' and .name but I suppose there is a chance it got into the kwargs. I'll check again to be sure.

@jlstevens
Copy link
Member Author

Had a look, seems fine. I'll merge.

Yeah, I don't see any other way name could be set.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants