Feature description
Issue:
The bucket_sort function accepts an integer passed as an argument
def bucket_sort(my_list: list, bucket_count: int = 10)
When passing a float it causes an unhandled TypeError
Test used:
>>> data = [12, 7 , 22, 11, 4]
>>> bucket_sort(data, 2.5) == sorted(data)
True
TypeError: 'float' object cannot be interpreted as an integer
Proposed solution:
Either return an empty list for consistency to match when a bucket count of less than 0 is used
if len(my_list) == 0 or bucket_count <= 0 or not isinstance(bucket_count, int):
return [ ]
Or raise a clearer TypeError
if not isinstance(bucket_count, int):
raise TypeError("bucket_count must be an integer")
I would like to implement either solution.
Feature description
Issue:
The bucket_sort function accepts an integer passed as an argument
def bucket_sort(my_list: list, bucket_count: int = 10)
When passing a float it causes an unhandled TypeError
Test used:
TypeError: 'float' object cannot be interpreted as an integer
Proposed solution:
Either return an empty list for consistency to match when a bucket count of less than 0 is used
if len(my_list) == 0 or bucket_count <= 0 or not isinstance(bucket_count, int):
return [ ]
Or raise a clearer TypeError
if not isinstance(bucket_count, int):
raise TypeError("bucket_count must be an integer")
I would like to implement either solution.