typo in 59 and changed solution of 66

This commit is contained in:
silver
2017-04-01 12:01:36 +08:00
parent 62bf042b6c
commit 45b87e81d3
2 changed files with 6 additions and 4 deletions

View File

@@ -1015,7 +1015,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"#### 59. How to I sort an array by the nth column? (★★☆)" "#### 59. How to sort an array by the nth column? (★★☆)"
] ]
}, },
{ {

View File

@@ -1243,7 +1243,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"#### 59. How to I sort an array by the nth column? (★★☆)" "#### 59. How to sort an array by the nth column? (★★☆)"
] ]
}, },
{ {
@@ -1423,9 +1423,11 @@
"\n", "\n",
"w,h = 16,16\n", "w,h = 16,16\n",
"I = np.random.randint(0,2,(h,w,3)).astype(np.ubyte)\n", "I = np.random.randint(0,2,(h,w,3)).astype(np.ubyte)\n",
"F = I[...,0]*256*256 + I[...,1]*256 +I[...,2]\n", "#Note that we should compute 256*256 first. \n",
"#Otherwise numpy will only promote F.dtype to 'uint16' and overfolw will occur\n",
"F = I[...,0]*(256*256) + I[...,1]*256 +I[...,2]\n",
"n = len(np.unique(F))\n", "n = len(np.unique(F))\n",
"print(np.unique(I))" "print(n)"
] ]
}, },
{ {