-
Notifications
You must be signed in to change notification settings - Fork 22
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
feat: Adding addition of 0 #370
Conversation
@HDembinski, thoughts? Is this fine? |
It is weird that adding None and False also works. Adding 0 makes sense, but why allow the others? |
Partially because it is natural in construction (you can just check truthiness, and don't have to require a specific type check; any false-like does not affect the histogram when added - you can have False will always work, as it's a subclass of integer with value 0 (It was just an integer before Python 2.2 or 2.3, IIRC). |
Ok, I understand better now. If the argument to The question then again is what should happen with the flow bins. The consistent thing is to include them, since the other operators also work on the flow bins. |
Okay, will place on hold until we have more support for operators on views. We need at least addition then for all views. Is it legal to add a double/int to each of the 3 accumulators? |
That should work for WeightedSum out of the box, but not for Mean or WeightedMean. |
So Mean and WeightedMean should not support |
They should, but they cannot support addition of constants in general, unless we find a reasonable interpretation of adding a number to a mean. So far, we should only allow the addition of 0, which we define to do nothing. |
You probably already know this:
We should also raise an error in case someone adds |
Okay, we should just check for int/float 0 and only allow that, then. |
7d7b967
to
ceda8f3
Compare
Adding with a false-like, such as 0 or None, is now supported. This allows syntax like
sum(histogram_list)
without answering the hard question of what it means to add a constant to a histogram with flow bins and unevenly sized bins. That can be done much more clearly using the view or[...] =
syntax.Closes #261.