Improve coverage special_numbers (#12414)

* Improve coverage bell_numbers

* improve more function

* Update hamming_numbers.py

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
This commit is contained in:
Scarfinos 2024-12-27 23:22:36 +01:00 committed by GitHub
parent eb652cf3d4
commit 5bef6ac929
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 1 deletions

View File

@ -21,6 +21,10 @@ def bell_numbers(max_set_length: int) -> list[int]:
list: A list of Bell numbers for sets of lengths from 0 to max_set_length.
Examples:
>>> bell_numbers(-2)
Traceback (most recent call last):
...
ValueError: max_set_length must be non-negative
>>> bell_numbers(0)
[1]
>>> bell_numbers(1)

View File

@ -13,6 +13,10 @@ def hamming(n_element: int) -> list:
:param n_element: The number of elements on the list
:return: The nth element of the list
>>> hamming(-5)
Traceback (most recent call last):
...
ValueError: n_element should be a positive number
>>> hamming(5)
[1, 2, 3, 4, 5]
>>> hamming(10)
@ -22,7 +26,7 @@ def hamming(n_element: int) -> list:
"""
n_element = int(n_element)
if n_element < 1:
my_error = ValueError("a should be a positive number")
my_error = ValueError("n_element should be a positive number")
raise my_error
hamming_list = [1]

View File

@ -11,6 +11,8 @@ def int_to_base(number: int, base: int) -> str:
Where 'base' ranges from 2 to 36.
Examples:
>>> int_to_base(0, 21)
'0'
>>> int_to_base(23, 2)
'10111'
>>> int_to_base(58, 5)
@ -26,6 +28,10 @@ def int_to_base(number: int, base: int) -> str:
Traceback (most recent call last):
...
ValueError: 'base' must be between 2 and 36 inclusive
>>> int_to_base(-99, 16)
Traceback (most recent call last):
...
ValueError: number must be a positive integer
"""
if base < 2 or base > 36:
@ -101,6 +107,8 @@ def harshad_numbers_in_base(limit: int, base: int) -> list[str]:
Traceback (most recent call last):
...
ValueError: 'base' must be between 2 and 36 inclusive
>>> harshad_numbers_in_base(-12, 6)
[]
"""
if base < 2 or base > 36: