|
1 | | -custom_power = lambda x=0, /, e=1: x ** e |
| 1 | +custom_power = lambda x = 0, /, e = 1: x**e |
2 | 2 |
|
3 | | -def custom_equation(x: int = 0, /, y: int = 0, a: int = 1, b: int = 1, *, c: int = 1) -> float: |
| 3 | +def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int = 1) -> float: |
4 | 4 | """ |
5 | | - Calculate the result of the equation: (x**a + y**b) / c. |
| 5 | + Calculate a custom equation based on the provided parameters. |
6 | 6 |
|
7 | | - :param x: positional-only integer, default is 0 |
8 | | - :param y: positional-only integer, default is 0 |
9 | | - :param a: positional-or-keyword integer, default is 1 |
10 | | - :param b: positional-or-keyword integer, default is 1 |
11 | | - :param c: keyword-only integer, default is 1 |
12 | | - :return: float result of the equation |
| 7 | + The function computes the result of the equation: |
| 8 | + (x**a + y**b) / c |
| 9 | +
|
| 10 | + :param x: The first integer value (positional-only, default is 0). |
| 11 | + :param y: The second integer value (positional-only, default is 0). |
| 12 | + :param a: The exponent for x (positional or keyword, default is 1). |
| 13 | + :param b: The exponent for y (positional or keyword, default is 1). |
| 14 | + :param c: The divisor (keyword-only, default is 1). |
| 15 | + :return: The result of the equation as a float. |
13 | 16 | """ |
14 | 17 | return (x**a + y**b) / c |
15 | 18 |
|
16 | | -def fn_w_counter(): |
17 | | - """ |
18 | | - A function that tracks and counts the number of calls, |
19 | | - and records the caller's information. |
20 | | - |
21 | | - :return: Tuple containing total number of calls and a dictionary |
22 | | - with the caller's __name__ as key and the count of calls as value. |
23 | | - """ |
24 | | - if not hasattr(fn_w_counter, "call_count"): |
25 | | - fn_w_counter.call_count = 0 |
26 | | - fn_w_counter.callers = {} |
27 | | - |
28 | | - fn_w_counter.call_count += 1 |
29 | | - caller_name = __name__ |
30 | | - |
31 | | - if caller_name in fn_w_counter.callers: |
32 | | - fn_w_counter.callers[caller_name] += 1 |
| 19 | +def fn_w_counter() -> (int, dict[str, int]): |
| 20 | + if not hasattr(fn_w_counter, "call_counter"): |
| 21 | + fn_w_counter.call_counter = 0 |
| 22 | + fn_w_counter.caller_count_dict = {} |
| 23 | + |
| 24 | + caller = __name__ |
| 25 | + fn_w_counter.call_counter += 1 |
| 26 | + |
| 27 | + if caller not in fn_w_counter.caller_count_dict: |
| 28 | + fn_w_counter.caller_count_dict[caller] = 1 |
33 | 29 | else: |
34 | | - fn_w_counter.callers[caller_name] = 1 |
35 | | - |
36 | | - return fn_w_counter.call_count, fn_w_counter.callers |
| 30 | + fn_w_counter.caller_count_dict[caller] += 1 |
| 31 | + |
| 32 | + return fn_w_counter.call_counter, fn_w_counter.caller_count_dict |
0 commit comments