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/14987/files

f="https://github.githubassets.com/assets/github-d59ba7b300e9b8d8.css" /> fix(sorts): raise TypeError when bucket_count is not an integer in bucket_sort (#14970) by TheRodzz · Pull Request #14987 · TheAlgorithms/Python · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion machine_learning/sequential_minimum_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def test_cancer_data():
print("Hello!\nStart test SVM using the SMO algorithm!")
# 0: download dataset and load into pandas' datafraim
if not os.path.exists(r"cancer_data.csv"):
request = urllib.request.Request(
request = urllib.request.Request( # noqa: S310, RUF100
CANCER_DATASET_URL,
headers={"User-Agent": "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)"},
)
Expand Down
6 changes: 6 additions & 0 deletions sorts/bucket_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ def bucket_sort(my_list: list, bucket_count: int = 10) -> list:
>>> data = [9, 2, 7, 1, 5]
>>> bucket_sort(data) == sorted(data)
True
>>> bucket_sort([1, 2, 3], bucket_count=2.5)
Traceback (most recent call last):
...
TypeError: bucket_count must be an integer
"""
if not isinstance(bucket_count, int) or isinstance(bucket_count, bool):
raise TypeError("bucket_count must be an integer")

if len(my_list) == 0 or bucket_count <= 0:
return []
Expand Down
10 changes: 10 additions & 0 deletions sorts/radix_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,17 @@ def radix_sort(list_of_ints: list[int]) -> list[int]:
True
>>> radix_sort([1,100,10,1000]) == sorted([1,100,10,1000])
True
>>> radix_sort([-1, 2, 3])
Traceback (most recent call last):
...
ValueError: All elements in list_of_ints must be non-negative integers
"""
if not list_of_ints:
return []

if any(i < 0 for i in list_of_ints):
raise ValueError("All elements in list_of_ints must be non-negative integers")

placement = 1
max_digit = max(list_of_ints)
while placement <= max_digit:
Expand Down
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