teext.constraints¶
Types that express a constraint.
Data:
|
|
|
|
|
|
|
|
|
Functions:
|
Assert that the given number is a fraction. |
|
Assert that the given number is a natural number. |
|
Assert that the given number is a percentage. |
|
Assert that the given number is a positive integer. |
|
Assert that the given number is a probability. |
|
Check whether the given number is a fraction. |
|
Check whether the given number is a natural number. |
|
Check whether the given number is a percentage. |
|
Check whether the given number is a positive integer. |
|
Check whether the given number is a probability. |
- Fraction¶
A type for fractions (i.e., floats between 0 and 1, inclusive).
alias of
float
- NaturalNum¶
A type for natural numbers (i.e., integers without the negative numbers).
alias of
int
- Percentage¶
A type for percentages (i.e., floats between 0 and 1, inclusive).
alias of
float
- PositiveInt¶
A type for positive integers.
alias of
int
- Probability¶
A type for probabilities (i.e., floats between 0 and 1, inclusive).
alias of
float
- assert_fraction(num)¶
Assert that the given number is a fraction.
- Parameters
num (float) –
- Return type
Fraction
- assert_natural_num(num)¶
Assert that the given number is a natural number.
- Parameters
num (int) –
- Return type
NaturalNum
- assert_percentage(num)¶
Assert that the given number is a percentage.
- Parameters
num (float) –
- Return type
Percentage
- assert_positive_int(num)¶
Assert that the given number is a positive integer.
- Parameters
num (int) –
- Return type
PositiveInt
- assert_prob(num)¶
Assert that the given number is a probability.
- Parameters
num (float) –
- Return type
Probability
- is_fraction(num)¶
Check whether the given number is a fraction.
- Parameters
num (float) –
- Return type
typing_extensions.TypeGuard[Fraction]
- is_natural_num(num)¶
Check whether the given number is a natural number.
- Parameters
num (int) –
- Return type
typing_extensions.TypeGuard[NaturalNum]
- is_percentage(num)¶
Check whether the given number is a percentage.
- Parameters
num (float) –
- Return type
typing_extensions.TypeGuard[Percentage]
- is_positive_int(num)¶
Check whether the given number is a positive integer.
- Parameters
num (int) –
- Return type
typing_extensions.TypeGuard[PositiveInt]
- is_prob(num)¶
Check whether the given number is a probability.
- Parameters
num (float) –
- Return type
typing_extensions.TypeGuard[Probability]