From 09e468d674b4eee2f99b6e3616340b0ceca92f0b Mon Sep 17 00:00:00 2001 From: mozhonglin Date: Fri, 10 Apr 2020 18:38:36 +0800 Subject: [PATCH] fix issue #79 --- 100_Numpy_exercises.ipynb | 4 ++-- 100_Numpy_exercises.md | 2 +- 100_Numpy_exercises_with_hints.md | 4 ++-- 100_Numpy_exercises_with_hints_with_solutions.md | 8 ++++---- 100_Numpy_exercises_with_solutions.md | 8 ++++---- 100_Numpy_random.ipynb | 2 +- source/exercises100.ktx | 3 ++- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/100_Numpy_exercises.ipynb b/100_Numpy_exercises.ipynb index 2e4a30ee..a0587e98 100644 --- a/100_Numpy_exercises.ipynb +++ b/100_Numpy_exercises.ipynb @@ -564,7 +564,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "#### 36. Extract the integer part of a random array using 5 different methods (★★☆)" + "#### 36. Extract the integer part of a random array of positive numbers using 4 different methods (★★☆)" ] }, { @@ -1478,5 +1478,5 @@ ], "metadata": {}, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/100_Numpy_exercises.md b/100_Numpy_exercises.md index 1e7ce709..85c1eac4 100644 --- a/100_Numpy_exercises.md +++ b/100_Numpy_exercises.md @@ -113,7 +113,7 @@ np.sqrt(-1) == np.emath.sqrt(-1) #### 35. How to compute ((A+B)*(-A/2)) in place (without copy)? (★★☆) -#### 36. Extract the integer part of a random array using 5 different methods (★★☆) +#### 36. Extract the integer part of a random array of positive numbers using 4 different methods (★★☆) #### 37. Create a 5x5 matrix with row values ranging from 0 to 4 (★★☆) diff --git a/100_Numpy_exercises_with_hints.md b/100_Numpy_exercises_with_hints.md index 96fa44af..b9921540 100644 --- a/100_Numpy_exercises_with_hints.md +++ b/100_Numpy_exercises_with_hints.md @@ -113,8 +113,8 @@ np.sqrt(-1) == np.emath.sqrt(-1) `hint: np.arange(dtype=datetime64['D'])` #### 35. How to compute ((A+B)*(-A/2)) in place (without copy)? (★★☆) `hint: np.add(out=), np.negative(out=), np.multiply(out=), np.divide(out=)` -#### 36. Extract the integer part of a random array using 5 different methods (★★☆) -`hint: %, np.floor, np.ceil, astype, np.trunc` +#### 36. Extract the integer part of a random array of positive numbers using 4 different methods (★★☆) +`hint: %, np.floor, astype, np.trunc` #### 37. Create a 5x5 matrix with row values ranging from 0 to 4 (★★☆) `hint: np.arange` #### 38. Consider a generator function that generates 10 integers and use it to build an array (★☆☆) diff --git a/100_Numpy_exercises_with_hints_with_solutions.md b/100_Numpy_exercises_with_hints_with_solutions.md index 8319fdbf..3840ca6c 100644 --- a/100_Numpy_exercises_with_hints_with_solutions.md +++ b/100_Numpy_exercises_with_hints_with_solutions.md @@ -331,15 +331,14 @@ np.divide(A,2,out=A) np.negative(A,out=A) np.multiply(A,B,out=A) ``` -#### 36. Extract the integer part of a random array using 5 different methods (★★☆) -`hint: %, np.floor, np.ceil, astype, np.trunc` +#### 36. Extract the integer part of a random array of positive numbers using 4 different methods (★★☆) +`hint: %, np.floor, astype, np.trunc` ```python Z = np.random.uniform(0,10,10) print (Z - Z%1) print (np.floor(Z)) -print (np.ceil(Z)-1) print (Z.astype(int)) print (np.trunc(Z)) ``` @@ -463,7 +462,8 @@ for dtype in [np.float32, np.float64]: `hint: np.set_printoptions` ```python -np.set_printoptions(threshold=np.nan) +import sys +np.set_printoptions(threshold=sys.maxsize) Z = np.zeros((16,16)) print(Z) ``` diff --git a/100_Numpy_exercises_with_solutions.md b/100_Numpy_exercises_with_solutions.md index aaafa807..33e5389b 100644 --- a/100_Numpy_exercises_with_solutions.md +++ b/100_Numpy_exercises_with_solutions.md @@ -211,7 +211,7 @@ print(Z) # Author: Evgeni Burovski Z = np.arange(11) -Z[(3 < Z) & (Z < 8)] *= -1 +Z[(3 < Z) & (Z <= 8)] *= -1 print(Z) ``` #### 26. What is the output of the following script? (★☆☆) @@ -331,7 +331,7 @@ np.divide(A,2,out=A) np.negative(A,out=A) np.multiply(A,B,out=A) ``` -#### 36. Extract the integer part of a random array using 5 different methods (★★☆) +#### 36. Extract the integer part of a random array of positive numbers using 4 different methods (★★☆) ```python @@ -339,7 +339,6 @@ Z = np.random.uniform(0,10,10) print (Z - Z%1) print (np.floor(Z)) -print (np.ceil(Z)-1) print (Z.astype(int)) print (np.trunc(Z)) ``` @@ -463,7 +462,8 @@ for dtype in [np.float32, np.float64]: ```python -np.set_printoptions(threshold=np.nan) +import sys +np.set_printoptions(threshold=sys.maxsize) Z = np.zeros((16,16)) print(Z) ``` diff --git a/100_Numpy_random.ipynb b/100_Numpy_random.ipynb index 3abd9829..37dd57da 100644 --- a/100_Numpy_random.ipynb +++ b/100_Numpy_random.ipynb @@ -51,5 +51,5 @@ ], "metadata": {}, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/source/exercises100.ktx b/source/exercises100.ktx index 1840c420..9051fe77 100644 --- a/source/exercises100.ktx +++ b/source/exercises100.ktx @@ -595,7 +595,8 @@ How to print all the values of an array? (★★☆) hint: np.set_printoptions < a49 -np.set_printoptions(threshold=np.nan) +import sys +np.set_printoptions(threshold=sys.maxsize) Z = np.zeros((16,16)) print(Z)