Use type of first value as start argument for sum aggregator #1996
Closed
daviewales
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
Sure, that makes sense to me! I committed the change and it seems to work. (This probably should have been an issue instead.) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The
sum
aggregator uses Python's built-in sum function:visidata/visidata/aggregators.py
Line 128 in 4ffacbb
By default, the
sum
function has the argumentstart=0
.This means that it only works to sum types which are compatible with integers.
For example, if you try to sum
datedelta
values, you get:Would it make sense to automatically supply the type of the first value we are aggregating to
sum
to allow it to sum types which are not compatible withint
?Or is there something else we can add to the definition of
datedelta
to allow it to be summed with the defaultstart=0
?visidata/visidata/type_date.py
Line 96 in 4ffacbb
Beta Was this translation helpful? Give feedback.
All reactions