diff --git a/index.ipynb b/index.ipynb index 821dd5a..73a0b15 100644 --- a/index.ipynb +++ b/index.ipynb @@ -32,7 +32,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", - "version": "2.7.10" + "version": "2.7.11" } }, "nbformat": 4, diff --git a/tools_matplotlib.ipynb b/tools_matplotlib.ipynb index 6d4eec0..419ae37 100644 --- a/tools_matplotlib.ipynb +++ b/tools_matplotlib.ipynb @@ -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, diff --git a/tools_numpy.ipynb b/tools_numpy.ipynb index a32e6de..0364c03 100644 --- a/tools_numpy.ipynb +++ b/tools_numpy.ipynb @@ -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,