From b38b0c2889dab78408bd3d288527d5f2819c3195 Mon Sep 17 00:00:00 2001 From: artfintl <35037140+artfintl@users.noreply.github.com> Date: Wed, 10 Feb 2021 14:24:03 +0800 Subject: [PATCH 1/2] Update 100_Numpy_exercises_with_solutions.md --- 100_Numpy_exercises_with_solutions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/100_Numpy_exercises_with_solutions.md b/100_Numpy_exercises_with_solutions.md index 5f40a6a..95a4cdc 100644 --- a/100_Numpy_exercises_with_solutions.md +++ b/100_Numpy_exercises_with_solutions.md @@ -682,7 +682,7 @@ print(F) w,h = 16,16 I = np.random.randint(0,2,(h,w,3)).astype(np.ubyte) -F = I[...,0]*256*256 + I[...,1]*256 +I[...,2] +F = I[...,0]*(256*256) + I[...,1]*256 +I[...,2] n = len(np.unique(F)) print(np.unique(I)) ``` @@ -1179,4 +1179,4 @@ idx = np.random.randint(0, X.size, (N, X.size)) means = X[idx].mean(axis=1) confint = np.percentile(means, [2.5, 97.5]) print(confint) -``` \ No newline at end of file +``` From fb03972f0dc6752580707a5c1897f3501721aa2b Mon Sep 17 00:00:00 2001 From: artfintl <35037140+artfintl@users.noreply.github.com> Date: Thu, 18 Feb 2021 16:09:04 +0800 Subject: [PATCH 2/2] Update 100_Numpy_exercises_with_solutions.md --- 100_Numpy_exercises_with_solutions.md | 1 + 1 file changed, 1 insertion(+) diff --git a/100_Numpy_exercises_with_solutions.md b/100_Numpy_exercises_with_solutions.md index 95a4cdc..12c658a 100644 --- a/100_Numpy_exercises_with_solutions.md +++ b/100_Numpy_exercises_with_solutions.md @@ -682,6 +682,7 @@ print(F) w,h = 16,16 I = np.random.randint(0,2,(h,w,3)).astype(np.ubyte) +# The parenthesis around 256*256 ensure the dtpye promoted to uint32 properly.Otherwise the first term will overflow. F = I[...,0]*(256*256) + I[...,1]*256 +I[...,2] n = len(np.unique(F)) print(np.unique(I))