Skip to content

Commit 43d810f

Browse files
committed
solve division by zero
1 parent 75dbb34 commit 43d810f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ def plot_function(self):
9999
"Min value must be non-negative for functions with log10 or sqrt."
100100
)
101101
return
102-
102+
# deal with the case of division by zero
103+
if "1/x" in function and 0 in [min_x, max_x]:
104+
self.show_error_message("Division by zero is not allowed.")
105+
return
103106
x = np.linspace(min_x, max_x, 400)
104107
if "log10" in function:
105108
x = np.where(

0 commit comments

Comments
 (0)