package_name_to_import_with package#

Subpackages#

Submodules#

Module contents#

Expose selected package contents.

class BinaryArithmeticOperator(value)[source]#

Bases: CustomStrEnum

Define supported arithmetic operators.

ADDITION = '+'#
SUBTRACTION = '-'#
MULTIPLICATION = '*'#
DIVISION = '/'#
class CustomFloatEnum(value)[source]#

Bases: float, Enum

Inherit enum.Enum and modify behaviour of __str__.

pydantic model CustomPydanticBaseModel[source]#

Bases: BaseModel

Inherit pydantic.BaseModel and change behaviour to handle undefined attributes.

Show JSON schema
{
   "title": "CustomPydanticBaseModel",
   "description": "Inherit `pydantic.BaseModel` and change behaviour to handle undefined attributes.",
   "type": "object",
   "properties": {},
   "additionalProperties": false
}

Config:
  • extra: str = forbid

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

class CustomStrEnum(value)[source]#

Bases: str, Enum

Inherit enum.Enum and modify behaviour of __str__.

calculate_results(first_input: float, operator: BinaryArithmeticOperator, second_input: float) float[source]#

Perform basic binary arithmetic expressions.

Parameters:
  • first_input (float) -- left operand of binary arithmetic expression

  • operator (BinaryArithmeticOperator) -- kind of binary arithmetic expression

  • second_input (float) -- right operand of binary arithmetic expression

Returns:

result of binary arithmetic expression

Return type:

float

Examples

>>> from package_name_to_import_with import calculate_results
>>> calculate_results(1, "+", 2)
3.0
>>> calculate_results(1, "-", 2)
-1.0
>>> calculate_results(1, "*", 2)
2.0
>>> calculate_results(1, "/", 2)
0.5
define_garbage_collection_decorator(function_to_be_decorated: Callable[[...], Any]) Callable[[...], Any][source]#

Perform forcefully garbage collection after execution of provided function.

Parameters:

function_to_be_decorated (FunctionType) -- function whose execution may require forceful garbage collection

Returns:

decorated function

Return type:

FunctionType

solve_simplification(expression: str) float[source]#

Evaluate arithmetic expression.

Parameters:

expression (str) -- standard arithmetic expression

Returns:

result of arithmetic expression

Return type:

float

Examples

>>> from package_name_to_import_with import solve_simplification
>>> solve_simplification("0 + 1 - 2 * 3 / 4")
-0.5
>>> solve_simplification("5 * 6 / (7 + 8) - 9")
-7.0