Fix a few remaining python 2/3 glitches

main
Aurélien Geron 2016-02-19 13:24:08 +01:00
parent 1d9aa457d3
commit d191442ff7
3 changed files with 13 additions and 6 deletions

View File

@ -32,7 +32,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
"version": "2.7.11"
}
},
"nbformat": 4,

View File

@ -63,7 +63,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 48,
"metadata": {
"collapsed": false
},
@ -1261,7 +1261,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
"version": "2.7.11"
}
},
"nbformat": 4,

View File

@ -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,