question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Better error message when using sum() with plots

See original GitHub issue

I think it’d be nice to make holoviews work with Python sum().

sum([holoviews.Area(data=(x[num], y[num])) for num in range(8)]).cols(2)

This is currently raising an exception, since sum([area1, area2, area3, ...]) is equivalent to 0 + area1 + area2 + area3 (the 0 is the start in sum(iterable, /, start=0)). And Area (or other elements) __radd__ is not implemented for 0.

Feels like using sum() would make cases like the above much more readable than alternatives using functools.reduce or loops. I think it’d be worth implementing it, even if Area() + 0 may not make so much sense per se.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
datapythonistacommented, Feb 10, 2021

You’ve got pretty amazing error messages suggesting the right thing to do for some mistakes (like a misspelled opt). Not sure how many users would think of sum, but maybe raising an error message suggesting to use Layout when _radd_ is called for 0 could be useful. Something like:

def __radd__(self, other):
    if isinstance(other, int) and other == 0:
        raise TypeError("unsupported operand type(s) for +: 'int' and 'Overlay'. "
                        "If you are using `sum(elements)` to combine a list of elements, "
                        "we recommend you to use `holoviews.Layout(elements)` instead.")
    ...
0reactions
jlstevenscommented, Apr 20, 2021

Addressed in the PR referenced above.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting an error while plotting sum and average in pandas
Calling the groupby() method of a DataFrame yields a groupby object upon which you then need to call an aggregation function, like sum...
Read more >
Plotting means and error bars (ggplot2) - Cookbook for R
First, it is necessary to summarize the data. This can be done in a number of ways, as described on this page. In...
Read more >
Refactor validation rule show error message if sum of number ...
It should show and error message if the sum of a number of fields must equal the value in another field when saving...
Read more >
Interpreting Residual Plots to Improve Your Regression
When you run a regression, Stats iQ automatically calculates and plots residuals to help you understand and improve your regression model.
Read more >
8 Excel Error Messages You're Sick of Seeing (And How to Fix ...
Best Practices That'll Help You Reduce Excel Errors ... #VALUE! Excel error message shown vertically down the Sum column of a spreadsheet ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found