Merge pull request #90 from sam1902/master

Fix bug in solution 53 .ipynb & .md files
This commit is contained in:
Nicolas P. Rougier
2020-01-18 08:18:53 +01:00
committed by GitHub
4 changed files with 16 additions and 10 deletions

View File

@@ -1017,9 +1017,12 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"Z = np.arange(10, dtype=np.float32)\n", "# Thanks Vikas (https://stackoverflow.com/a/10622758/5989906) \n",
"Z = Z.astype(np.int32, copy=False)\n", "# & unutbu (https://stackoverflow.com/a/4396247/5989906)\n",
"print(Z)" "Z = (np.random.rand(10)*100).astype(np.float32)\n",
"Y = Z.view(np.int32)\n",
"Y[:] = Z\n",
"print(Y)"
] ]
}, },
{ {
@@ -2165,7 +2168,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.4" "version": "3.7.6"
} }
}, },
"nbformat": 4, "nbformat": 4,

View File

@@ -527,9 +527,12 @@ print(D)
```python ```python
Z = np.arange(10, dtype=np.float32) # Thanks Vikas (https://stackoverflow.com/a/10622758/5989906)
Z = Z.astype(np.int32, copy=False) # & unutbu (https://stackoverflow.com/a/4396247/5989906)
print(Z) Z = (np.random.rand(10)*100).astype(np.float32)
Y = Z.view(np.int32)
Y[:] = Z
print(Y)
``` ```
#### 54. How to read the following file? (★★☆) #### 54. How to read the following file? (★★☆)

View File

@@ -866,7 +866,7 @@
"metadata": {}, "metadata": {},
"source": [ "source": [
"#### 53. How to convert a float (32 bits) array into an integer (32 bits) in place? \n", "#### 53. How to convert a float (32 bits) array into an integer (32 bits) in place? \n",
"(**hint**: astype(copy=False))" "(**hint**: view and [:] = )"
] ]
}, },
{ {
@@ -1611,7 +1611,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.4" "version": "3.7.6"
} }
}, },
"nbformat": 4, "nbformat": 4,

View File

@@ -351,7 +351,7 @@ np.sqrt(-1) == np.emath.sqrt(-1)
#### 53. How to convert a float (32 bits) array into an integer (32 bits) in place? #### 53. How to convert a float (32 bits) array into an integer (32 bits) in place?
(**hint**: astype(copy=False)) (**hint**: view and [:] = )