← numpy-100

Small fix in Artisan #3

10adfebcc3541f9ca2f9bd644e9016528f8c5d05 · Nicolas Rougier · Jul 20, 2014 11:53

+4 −4 · 1 file changed

  • README.rst +4 −4
diff --git a/README.rst b/README.rst
index a4bfb55..e61e3f3 100644
--- a/README.rst
+++ b/README.rst
@@ -568,14 +568,14 @@ Artisan
       def distance(P0, P1, p):
         T = P1 - P0
         L = (T**2).sum(axis=1)
-        U = -((P0[:,0]-p[0])*T[:,0] + (P0[:,1]-p[1])*T[:,1]) / L
+        U = -((P0[:,0]-p[...,0])*T[:,0] + (P0[:,1]-p[...,1])*T[:,1]) / L
         U = U.reshape(len(U),1)
         D = P0 + U*T - p
         return np.sqrt((D**2).sum(axis=1))
 
-      P0 = np.random.uniform(-10,10,(100,2))
-      P1 = np.random.uniform(-10,10,(100,2))
-      p  = np.random.uniform(-10,10,(  1,2))
+      P0 = np.random.uniform(-10,10,(10,2))
+      P1 = np.random.uniform(-10,10,(10,2))
+      p  = np.random.uniform(-10,10,( 1,2))
       print distance(P0, P1, p)