|
1434 | 1434 | }, |
1435 | 1435 | "outputs": [], |
1436 | 1436 | "source": [ |
1437 | | - "print(\"a:\", a)\n", |
1438 | | - "print(\"b:\", b)\n", |
1439 | | - "print(\"c:\", c)\n", |
1440 | | - "print(\"d:\", d)" |
| 1437 | + "print(\"a:\", a, sep=\"\\n\")\n", |
| 1438 | + "print(\"b:\", b, sep=\"\\n\")\n", |
| 1439 | + "print(\"c:\", c, sep=\"\\n\")\n", |
| 1440 | + "print(\"d:\", d, sep=\"\\n\")" |
1441 | 1441 | ] |
1442 | 1442 | }, |
1443 | 1443 | { |
|
1449 | 1449 | "tags": [] |
1450 | 1450 | }, |
1451 | 1451 | "source": [ |
1452 | | - "Be careful when using `numpy.copy` as it is shallow, and it will not copy object elements within arrays. For these corner cases, you need to use `copy.deepcopy`." |
| 1452 | + "Be careful when using `numpy.copy` as it is shallow, and it will not copy object elements within arrays. For these corner cases, you need to use `copy.deepcopy`. See the [python copy module](https://docs.python.org/3/library/copy.html)" |
1453 | 1453 | ] |
1454 | 1454 | }, |
1455 | 1455 | { |
|
1491 | 1491 | "tags": [] |
1492 | 1492 | }, |
1493 | 1493 | "source": [ |
1494 | | - "The ``dtype`` attribute identifies the type of the elements of the array." |
| 1494 | + "The [``dtype``](https://numpy.org/doc/stable/reference/arrays.dtypes.html) attribute identifies the type of the elements of the array." |
1495 | 1495 | ] |
1496 | 1496 | }, |
1497 | 1497 | { |
|
1594 | 1594 | "source": [ |
1595 | 1595 | "### More array attributes\n", |
1596 | 1596 | "\n", |
1597 | | - "* ``ndim``: Number of dimensions\n", |
1598 | | - "* ``size``: Total number of elements\n", |
1599 | | - "* ``itemsize``: Size of a single item (in bytes))\n", |
1600 | | - "* ``strides``: Bytes to step in each dimension\n", |
1601 | | - "* ``flags``: Contiguity of the data in the buffer\n", |
1602 | | - "* ``nbytes``: Size in bytes occupied in memory\n", |
1603 | | - "* ``data``: Read/write buffer containing the data" |
| 1597 | + "* [``ndim``](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.ndim.html): Number of dimensions\n", |
| 1598 | + "* [``size``](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.size.html): Total number of elements\n", |
| 1599 | + "* [``itemsize``](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.itemsize.html): Size of a single item (in bytes))\n", |
| 1600 | + "* [``strides``](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.strides.html): Bytes to step in each dimension\n", |
| 1601 | + "* [``flags``](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.flags.html): Contiguity of the data in the buffer\n", |
| 1602 | + "* [``nbytes``](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.nbytes.html): Size in bytes occupied in memory\n", |
| 1603 | + "* [``data``](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.data.html): Read/write buffer containing the data" |
1604 | 1604 | ] |
1605 | 1605 | }, |
1606 | 1606 | { |
|
1953 | 1953 | "source": [ |
1954 | 1954 | "## Exercise \n", |
1955 | 1955 | "\n", |
1956 | | - "Suppose we want to shrink the physical size of a 1000x1000 gray-value image by a factor 4, without changing the type of the pixels.\n", |
| 1956 | + "Suppose we want to shrink the physical size of a 100x100 gray-value image by a factor 4, without changing the type of the pixels.\n", |
1957 | 1957 | "A natural approach is to reduce the number of pixels by a factor 2 in each dimension. This operation is called **binning**. It consists in replacing each 2x2 square in the image by one single pixel value. The next question is: which value should be assigned to each pixel in the new image.\n", |
1958 | 1958 | "\n", |
1959 | 1959 | "\n", |
|
0 commit comments