pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/TheAlgorithms/Python/pull/14991

requests-be6017ec12798e73.css" /> fix: reject non-integer bucket counts by tomatotomata · Pull Request #14991 · TheAlgorithms/Python · GitHub
Skip to content

fix: reject non-integer bucket counts - #14991

Open
tomatotomata wants to merge 1 commit into
TheAlgorithms:masterfrom
tomatotomata:codex/bucket-sort-type-error-14970
Open

fix: reject non-integer bucket counts#14991
tomatotomata wants to merge 1 commit into
TheAlgorithms:masterfrom
tomatotomata:codex/bucket-sort-type-error-14970

Conversation

@tomatotomata

Copy link
Copy Markdown

Description

Add dedicated validation for bucket_sort's bucket_count argument. Non-integer values now raise a clear TypeError before arithmetic or bucket allocation, including on empty inputs; booleans are rejected explicitly despite inheriting from int in Python. The existing behavior for positive integer counts is unchanged.

Issue reference

Closes #14970

Validation

  • python -m doctest sorts/bucket_sort.py
  • python -m ruff check sorts/bucket_sort.py
  • git diff --check
  • Direct checks for float, bool, string, empty-input, and valid integer inputs.

I used coding assistance to prepare this focused fix and reviewed the rendered diff and test output manually. The patch is limited to sorts/bucket_sort.py.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bucket_sort has no dedicated error handling when the number of buckets in inputted as a float instead of an integer.

2 participants

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy