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

Implement Widget.from_values #7033

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Implement Widget.from_values #7033

wants to merge 4 commits into from

Conversation

philippjfr
Copy link
Member

@philippjfr philippjfr commented Jul 28, 2024

Implements #6071

  • Add docs
  • Update examples
  • Add tests

Copy link

codecov bot commented Jul 28, 2024

Codecov Report

Attention: Patch coverage is 31.81818% with 15 lines in your changes missing coverage. Please review.

Project coverage is 81.77%. Comparing base (78982fb) to head (7387b62).
Report is 1 commits behind head on main.

Files Patch % Lines
panel/widgets/base.py 37.50% 10 Missing ⚠️
panel/util/__init__.py 16.66% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7033      +/-   ##
==========================================
- Coverage   82.22%   81.77%   -0.46%     
==========================================
  Files         326      326              
  Lines       48271    48293      +22     
==========================================
- Hits        39691    39491     -200     
- Misses       8580     8802     +222     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jbednar
Copy link
Member

jbednar commented Aug 14, 2024

This is a good start towards #7003; thanks! A few questions:

  1. What starting value is used by default? Seems like you'd want a midpoint value by default, not just the start value?
  2. For a Pandas Series, it should be cheap to calculate the min, avg, and max in a single pass (e.g. df['column_name'].agg(['min', 'average', 'max'])) to get the start, value, and end; is that a useful special case for a Series?
  3. Range widgets seem like they'd need different behavior, since a range should normally default to the start and end of the range. Will that already happen automatically?

@philippjfr
Copy link
Member Author

What starting value is used by default? Seems like you'd want a midpoint value by default, not just the start value?

Honestly, while that's the logic for something like interact I'm not convinced that this is actually a better default.

For a Pandas Series, it should be cheap to calculate the min, avg, and max in a single pass (e.g. df['column_name'].agg(['min', 'average', 'max'])) to get the start, value, and end; is that a useful special case for a Series?

Afaik, that isn't the case. It's no cheaper than doing the individual queries.

Range widgets seem like they'd need different behavior, since a range should normally default to the start and end of the range. Will that already happen automatically?

Will take a look.

@jbednar
Copy link
Member

jbednar commented Jan 21, 2025

What starting value is used by default? Seems like you'd want a midpoint value by default, not just the start value?
Honestly, while that's the logic for something like interact I'm not convinced that this is actually a better default.

Hmm. I think I'd typically rather have a middle value mainly because choosing the lower or the upper seems arbitrary, and is also by definition an extreme value. Still, I guess it's not worth a lot of extra work. Plus using a midpoint could be problematic in some cases, e.g. when only a finite enumerable list of values is allowed, without values in between.

For a Pandas Series, it should be cheap to calculate the min, avg, and max in a single pass (e.g. df['column_name'].agg(['min', 'average', 'max'])) to get the start, value, and end; is that a useful special case for a Series?
Afaik, that isn't the case. It's no cheaper than doing the individual queries.

Drat. I saw some docs that implied they were performed together, but it didn't actually state that explicitly, and briefly clicking around in the source code suggests that it's decomposed into a separate call per agg function. Alas! You do need to run min and max to get the range bounds, but I guess running average would be an additional cost.

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.

2 participants