From 1848b87152702050772767a548627d02875a6428 Mon Sep 17 00:00:00 2001 From: Fernanda Gomes Date: Fri, 12 Oct 2018 20:57:01 +0200 Subject: [PATCH] Update plotting derivative and estimate Since Python 3 doesn't allow `map` to be iterable, a workaround is to turn the outcome to a list in order to plot. --- code-python3/gradient_descent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code-python3/gradient_descent.py b/code-python3/gradient_descent.py index 90239f5a..666e9003 100644 --- a/code-python3/gradient_descent.py +++ b/code-python3/gradient_descent.py @@ -23,8 +23,8 @@ def derivative(x): # plot to show they're basically the same import matplotlib.pyplot as plt x = range(-10,10) - plt.plot(x, map(derivative, x), 'rx') # red x - plt.plot(x, map(derivative_estimate, x), 'b+') # blue + + plt.plot(x, list(map(derivative, x)), 'rx') # red x + plt.plot(x, list(map(derivative_estimate, x)), 'b+') # blue + plt.show() # purple *, hopefully def partial_difference_quotient(f, v, i, h):