-
-
Notifications
You must be signed in to change notification settings - Fork 517
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
k-Combinations with negative k #39411
Comments
@MarcusAichmayr For this we can insert a condition to check for negative values and return an empty list if this condition is true. I will add a PR with the required changes. |
@MarcusAichmayr I would like to work on this assign me |
A user who passes a negative number for |
Works can I document the same
…On Fri, 31 Jan, 2025, 06:55 DaveWitteMorris, ***@***.***> wrote:
A user who passes a negative number for r has probably made a mistake, so
I think the ValueError is reasonable. (I think the error comes from
itertools.combinations, and I think staying consistent with that has
value.) If this is going to be changed, I think there will need to be a
deprecation period first. But I personally am not at all convinced that it
should be changed, and I think just documenting the behaviour might be best.
—
Reply to this email directly, view it on GitHub
<#39411 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOY55UMAFZQQXXXM2UBJH632NLGH5AVCNFSM6AAAAABWFCQV22VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMRWGA4DCMRXGU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
@DaveWitteMorris shouldn't the error be also returned in the case of list(Combinations(-1,3))? This is just an example. Though the output I'm getting is an empty list. |
Yes, I think an error would be better. However, this is a change in behaviour that is not fixing a clear bug, so there would need to be a deprecation. For the first year, the function needs to behave as it always did, but print a warning message that the default behaviour will change in the future. This could be handled by adding a keyword argument
See Deprecation and sage.misc.superseded.deprecation for more information about deprecation. |
Okay I will work on this. |
@pawani27: Didn't abhishekdubey369 reply before you did that they were going to work on this issue? Please coordinate with them so there isn't wasted effort. |
I actually did start working on this as you can see from my very first comment on this issue but no problem if @abhishekdubey369 has already made progress on this. @abhishekdubey369 Please let me know as to your preference. |
@pawani I have started working on it . If you want we can coordinate and
work together on this. Thanks
…On Mon, 3 Feb, 2025, 05:49 Pawani, ***@***.***> wrote:
I actually did start working on this as you can see from my very first
comment on this issue but no problem if @abhishekdubey369
<https://github.com/abhishekdubey369> has already made progress on this.
@abhishekdubey369 <https://github.com/abhishekdubey369> Please let me
know as to your preference.
—
Reply to this email directly, view it on GitHub
<#39411 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOY55UMNHW2I44DXWTQ3JBL2N2Y2BAVCNFSM6AAAAABWFCQV22VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMRZGY2DKMBTGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@abhishekdubey369 Yeah sure. |
Steps To Reproduce
Call
Expected Behavior
Actual Behavior
Instead, we obtain a
ValueError
:Additional Information
How many
k
-combinations of{1, ..., n}
exist fork = -1
? According to Wikipedia, this number is equal to the binomial coefficient(n, k)
. Fork = -1
, we have(n, -1) = 0
. Hence, there are no-1
-combinations and we should obtain the empty list.Environment
Checklist
The text was updated successfully, but these errors were encountered: