Skip to content

Commit 1c849ec

Browse files
committed
Fix fn_w_counter caller logic and remove unused import - Feyza
1 parent 6d3db0e commit 1c849ec

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎Week04/functions_feyza_ozdemir.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import inspect
2-
31
custom_power = lambda x=0, /, e=1: x ** e
42

53

@@ -28,6 +26,9 @@ def custom_equation(
2826
:return: The result of (x**a + y**b) / c as a float.
2927
:rtype: float
3028
"""
29+
if not (type(x) is int and type(y) is int and type(a) is int and type(b) is int and type(c) is int):
30+
raise TypeError("All parameters must be integers.")
31+
3132
return float((x ** a + y ** b) / c)
3233

3334

@@ -38,11 +39,10 @@ def fn_w_counter() -> (int, dict[str, int]):
3839
:return: The total call count and a dictionary of caller counts.
3940
:rtype: (int, dict[str, int])
4041
"""
41-
caller_frame = inspect.currentframe().f_back
42-
caller_name = caller_frame.f_globals.get("__name__", "__main__") if caller_frame else "__main__"
42+
caller = __name__
4343

4444
fn_w_counter.total_calls += 1
45-
fn_w_counter.caller_counts[caller_name] = fn_w_counter.caller_counts.get(caller_name, 0) + 1
45+
fn_w_counter.caller_counts[caller] = fn_w_counter.caller_counts.get(caller, 0) + 1
4646

4747
return fn_w_counter.total_calls, dict(fn_w_counter.caller_counts)
4848

0 commit comments

Comments
 (0)