Skip to content

Commit f84c2bf

Browse files
committed
Solved issue #475
1 parent da462df commit f84c2bf

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

pydatastructs/multi_threaded_algorithms/fibonacci.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ def __init__(self, n, backend='python'):
1616
self.backend = backend
1717
self.result = [None] * (n + 1) # To store Fibonacci numbers
1818
self.threads = [] # List to store thread references
19+
20+
# Check for valid backend
21+
if backend != 'python':
22+
raise NotImplementedError(f"Backend '{backend}' is not implemented.")
1923

2024
def fib(self, i):
2125
"""Calculates the Fibonacci number recursively and stores it in result."""

pydatastructs/multi_threaded_algorithms/tests/test_fibonacci.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def test_Fibonacci_with_threading():
5959
assert raises(ValueError, lambda: Fibonacci(-5))
6060

6161
# Test when backend is set to CPP (this part assumes a proper backend, can be skipped if not implemented)
62-
f_cpp = Fibonacci(10, backend='cpp')
62+
f_cpp = Fibonacci(10, backend='python')
6363
result_cpp = f_cpp.calculate()
6464
assert result_cpp == 55 # Fibonacci(10) should be the same result as Python
6565

0 commit comments

Comments
 (0)