mirror of
https://github.com/ArthurDanjou/handson-ml3.git
synced 2026-01-14 12:14:36 +01:00
Fix a few remaining python 2/3 glitches
This commit is contained in:
@@ -377,7 +377,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"execution_count": 154,
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"scrolled": false
|
||||
@@ -523,8 +523,15 @@
|
||||
"f = np.array([[1,2],[1000, 2000]], dtype=np.int32)\n",
|
||||
"print(\"Array:\")\n",
|
||||
"print(f)\n",
|
||||
"print(\"Buffer type:\")\n",
|
||||
"print(type(f.data))\n",
|
||||
"\n",
|
||||
"if (hasattr(f.data, \"tobytes\")):\n",
|
||||
" data_bytes = f.data.tobytes() # in python 3, f.data is a memoryview\n",
|
||||
"else:\n",
|
||||
" data_bytes = memoryview(f.data).tobytes() # in python 2, f.data is a buffer\n",
|
||||
"print(\"Raw data:\")\n",
|
||||
"print(f.data.hex())"
|
||||
"print(repr(data_bytes))"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -2908,7 +2915,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython2",
|
||||
"version": "2.7.10"
|
||||
"version": "2.7.11"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
Reference in New Issue
Block a user