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

Deprecate negative k in Combinations #39868

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

EigenVector22
Copy link

Fixes #39411
Implemented deprecation for handling negative k values passed to Combinations(mset, k),

Added an allow_negative keyword argument:

  • None (default): Returns empty list, gives DeprecationWarning (once per instance).
  • True: Returns empty list, no warning.
  • False: Raises ValueError.

Updated the implementation to use a helper method _handle_negative_k in the base class Combinations_msetk to avoid code duplication( especially while giving warnings, had issues with this while testing). Ensuring the same, added a flag
_issued_negative_k_warning to ensure the deprecation warning is only shown once per object.

Added doctests for this new behaviour.

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

Fixes sagemath#39411
Implemented deprecation for handling negative k values
passed to Combinations(mset, k),

Added an `allow_negative` keyword argument:
- None (default): Returns empty list, gives DeprecationWarning (once per instance).
- True: Returns empty list, no warning.
- False: Raises ValueError.

Updated the implementation to use a helper method
`_handle_negative_k` in the base class Combinations_msetk
to avoid code duplication( especially while giving warnings, had issues with this while testing). Ensuring the same added  a flag
`_issued_negative_k_warning` to ensure the deprecation
warning is only shown once per object.

Added Doctests for this new behaviour.
@EigenVector22
Copy link
Author

@DaveWitteMorris hello, can you please review this and give feedback for the same,

@DaveWitteMorris
Copy link
Member

@EigenVector22 There were already people working on this issue. Please choose an issue that has not already been claimed, unless you get permission from the people who have claimed it (or the issue has been abandoned for a long time, which is not the case here).

@EigenVector22
Copy link
Author

my bad, sure, i'll communicate with people working on this and accordingly close the PR if they are ready,
Thanks,

@EigenVector22
Copy link
Author

@DaveWitteMorris again apologies, I've communicated with both the people on the issue thread, the issue has been resolved, can refer the issue thread for confirmation. Any feedback to improve the above implementation.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

k-Combinations with negative k
2 participants