├── .gitignore ├── 000-jupyter.ipynb ├── 001-creating-arrays.ipynb ├── 002-array-reshaping.ipynb ├── 010-indexing.ipynb ├── 011-indexing-example.ipynb ├── 020-indexing-exercise.ipynb ├── 021-indexing-exercise-solution.ipynb ├── 025-fancy-indexing.ipynb ├── 030-array-array-operations.ipynb ├── 032-array-multlipication.ipynb ├── 040-scalar-operations-and-plotting.ipynb ├── 050-array-modifying.ipynb ├── 051-array-modifying-exercise.ipynb ├── 060-axis-operations.ipynb ├── 070-boolean-indexing.ipynb ├── 071-logical-ops.ipynb ├── 080-broadcasting.ipynb ├── 081-grids.ipynb ├── 085-broadcasting-exercise.ipynb ├── 086-broadcasting-exercise-solution.ipynb ├── 110-alpha-masks.ipynb ├── 111-alpha-masks-exericse.ipynb ├── 112-alpha-masks-solution.ipynb ├── README.md ├── broadcast-examples ├── 1.png ├── 10.png ├── 11.png ├── 12.png ├── 13.png ├── 14.png ├── 15.png ├── 2.png ├── 3.png ├── 4.png ├── 5.png ├── 6.png ├── 7.png ├── 8.png └── 9.png ├── city-part.png ├── city-round1.png ├── city-round2.png ├── city.jpeg ├── environment.yml ├── pagoda.jpeg ├── pencils-part.png ├── pencils.jpeg ├── puppy1.jpeg └── puppy2.jpeg /.gitignore: -------------------------------------------------------------------------------- 1 | /.ipynb_checkpoints/ 2 | /.idea/ 3 | -------------------------------------------------------------------------------- /000-jupyter.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Jupyter Lab/Notebook Keyboard Shortcuts\n", 8 | "\n", 9 | "* `Enter`/`Esc`: Enter/Exit edit cell mode\n", 10 | "* `Ctrl`/`Alt`/`Shift`+`Enter`: Run cell\n", 11 | "* `a`/`b`: Add cell above/below\n", 12 | "* `dd`: Delete cell\n", 13 | "* `c`/`x`/`v`: Copy/Cut/Paste cell\n", 14 | "* `y`/`m`: Change cell to code/markdown" 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": 1, 20 | "metadata": {}, 21 | "outputs": [ 22 | { 23 | "data": { 24 | "text/plain": [ 25 | "2" 26 | ] 27 | }, 28 | "execution_count": 1, 29 | "metadata": {}, 30 | "output_type": "execute_result" 31 | } 32 | ], 33 | "source": [ 34 | "1 + 1" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": 2, 40 | "metadata": {}, 41 | "outputs": [], 42 | "source": [ 43 | "a = 10" 44 | ] 45 | }, 46 | { 47 | "cell_type": "code", 48 | "execution_count": 3, 49 | "metadata": {}, 50 | "outputs": [ 51 | { 52 | "data": { 53 | "text/plain": [ 54 | "10" 55 | ] 56 | }, 57 | "execution_count": 3, 58 | "metadata": {}, 59 | "output_type": "execute_result" 60 | } 61 | ], 62 | "source": [ 63 | "a" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 4, 69 | "metadata": {}, 70 | "outputs": [ 71 | { 72 | "data": { 73 | "text/plain": [ 74 | "20" 75 | ] 76 | }, 77 | "execution_count": 4, 78 | "metadata": {}, 79 | "output_type": "execute_result" 80 | } 81 | ], 82 | "source": [ 83 | "b = 20\n", 84 | "b" 85 | ] 86 | }, 87 | { 88 | "cell_type": "code", 89 | "execution_count": 5, 90 | "metadata": {}, 91 | "outputs": [ 92 | { 93 | "data": { 94 | "text/plain": [ 95 | "120" 96 | ] 97 | }, 98 | "execution_count": 5, 99 | "metadata": {}, 100 | "output_type": "execute_result" 101 | } 102 | ], 103 | "source": [ 104 | "b += 100\n", 105 | "b" 106 | ] 107 | }, 108 | { 109 | "cell_type": "code", 110 | "execution_count": 6, 111 | "metadata": {}, 112 | "outputs": [ 113 | { 114 | "name": "stdout", 115 | "output_type": "stream", 116 | "text": [ 117 | "hi\n", 118 | "hi\n", 119 | "hi\n" 120 | ] 121 | } 122 | ], 123 | "source": [ 124 | "print(\"hi\")\n", 125 | "print(\"hi\")\n", 126 | "print(\"hi\")" 127 | ] 128 | }, 129 | { 130 | "cell_type": "code", 131 | "execution_count": 7, 132 | "metadata": {}, 133 | "outputs": [], 134 | "source": [ 135 | "None" 136 | ] 137 | }, 138 | { 139 | "cell_type": "code", 140 | "execution_count": null, 141 | "metadata": {}, 142 | "outputs": [], 143 | "source": [] 144 | } 145 | ], 146 | "metadata": { 147 | "kernelspec": { 148 | "display_name": "Python 3", 149 | "language": "python", 150 | "name": "python3" 151 | }, 152 | "language_info": { 153 | "codemirror_mode": { 154 | "name": "ipython", 155 | "version": 3 156 | }, 157 | "file_extension": ".py", 158 | "mimetype": "text/x-python", 159 | "name": "python", 160 | "nbconvert_exporter": "python", 161 | "pygments_lexer": "ipython3", 162 | "version": "3.8.2" 163 | } 164 | }, 165 | "nbformat": 4, 166 | "nbformat_minor": 4 167 | } 168 | -------------------------------------------------------------------------------- /001-creating-arrays.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Creating a numpy array" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 1, 13 | "metadata": {}, 14 | "outputs": [], 15 | "source": [ 16 | "import numpy as np" 17 | ] 18 | }, 19 | { 20 | "cell_type": "markdown", 21 | "metadata": {}, 22 | "source": [ 23 | "## One dimensional:" 24 | ] 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": 2, 29 | "metadata": {}, 30 | "outputs": [], 31 | "source": [ 32 | "a = np.array([10, 20, 30])" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": 3, 38 | "metadata": {}, 39 | "outputs": [ 40 | { 41 | "data": { 42 | "text/plain": [ 43 | "array([10, 20, 30])" 44 | ] 45 | }, 46 | "execution_count": 3, 47 | "metadata": {}, 48 | "output_type": "execute_result" 49 | } 50 | ], 51 | "source": [ 52 | "a" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": 4, 58 | "metadata": {}, 59 | "outputs": [ 60 | { 61 | "data": { 62 | "text/plain": [ 63 | "numpy.ndarray" 64 | ] 65 | }, 66 | "execution_count": 4, 67 | "metadata": {}, 68 | "output_type": "execute_result" 69 | } 70 | ], 71 | "source": [ 72 | "type(a)" 73 | ] 74 | }, 75 | { 76 | "cell_type": "markdown", 77 | "metadata": {}, 78 | "source": [ 79 | "## Getting array information: data type, dimensions, shape and size" 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": 5, 85 | "metadata": {}, 86 | "outputs": [ 87 | { 88 | "data": { 89 | "text/plain": [ 90 | "dtype('int64')" 91 | ] 92 | }, 93 | "execution_count": 5, 94 | "metadata": {}, 95 | "output_type": "execute_result" 96 | } 97 | ], 98 | "source": [ 99 | "a.dtype" 100 | ] 101 | }, 102 | { 103 | "cell_type": "code", 104 | "execution_count": 6, 105 | "metadata": {}, 106 | "outputs": [ 107 | { 108 | "data": { 109 | "text/plain": [ 110 | "1" 111 | ] 112 | }, 113 | "execution_count": 6, 114 | "metadata": {}, 115 | "output_type": "execute_result" 116 | } 117 | ], 118 | "source": [ 119 | "a.ndim" 120 | ] 121 | }, 122 | { 123 | "cell_type": "code", 124 | "execution_count": 7, 125 | "metadata": {}, 126 | "outputs": [ 127 | { 128 | "data": { 129 | "text/plain": [ 130 | "(3,)" 131 | ] 132 | }, 133 | "execution_count": 7, 134 | "metadata": {}, 135 | "output_type": "execute_result" 136 | } 137 | ], 138 | "source": [ 139 | "a.shape" 140 | ] 141 | }, 142 | { 143 | "cell_type": "code", 144 | "execution_count": 8, 145 | "metadata": {}, 146 | "outputs": [ 147 | { 148 | "data": { 149 | "text/plain": [ 150 | "3" 151 | ] 152 | }, 153 | "execution_count": 8, 154 | "metadata": {}, 155 | "output_type": "execute_result" 156 | } 157 | ], 158 | "source": [ 159 | "a.size" 160 | ] 161 | }, 162 | { 163 | "cell_type": "code", 164 | "execution_count": 9, 165 | "metadata": {}, 166 | "outputs": [ 167 | { 168 | "data": { 169 | "text/plain": [ 170 | "24" 171 | ] 172 | }, 173 | "execution_count": 9, 174 | "metadata": {}, 175 | "output_type": "execute_result" 176 | } 177 | ], 178 | "source": [ 179 | "a.nbytes" 180 | ] 181 | }, 182 | { 183 | "cell_type": "markdown", 184 | "metadata": {}, 185 | "source": [ 186 | "## Two dimensional:" 187 | ] 188 | }, 189 | { 190 | "cell_type": "code", 191 | "execution_count": 10, 192 | "metadata": {}, 193 | "outputs": [], 194 | "source": [ 195 | "a2 = np.array([[1,2,3], [4,5,6]])" 196 | ] 197 | }, 198 | { 199 | "cell_type": "code", 200 | "execution_count": 11, 201 | "metadata": {}, 202 | "outputs": [ 203 | { 204 | "data": { 205 | "text/plain": [ 206 | "array([[1, 2, 3],\n", 207 | " [4, 5, 6]])" 208 | ] 209 | }, 210 | "execution_count": 11, 211 | "metadata": {}, 212 | "output_type": "execute_result" 213 | } 214 | ], 215 | "source": [ 216 | "a2" 217 | ] 218 | }, 219 | { 220 | "cell_type": "code", 221 | "execution_count": 12, 222 | "metadata": {}, 223 | "outputs": [ 224 | { 225 | "data": { 226 | "text/plain": [ 227 | "dtype('int64')" 228 | ] 229 | }, 230 | "execution_count": 12, 231 | "metadata": {}, 232 | "output_type": "execute_result" 233 | } 234 | ], 235 | "source": [ 236 | "a2.dtype" 237 | ] 238 | }, 239 | { 240 | "cell_type": "code", 241 | "execution_count": 13, 242 | "metadata": {}, 243 | "outputs": [ 244 | { 245 | "data": { 246 | "text/plain": [ 247 | "2" 248 | ] 249 | }, 250 | "execution_count": 13, 251 | "metadata": {}, 252 | "output_type": "execute_result" 253 | } 254 | ], 255 | "source": [ 256 | "a2.ndim" 257 | ] 258 | }, 259 | { 260 | "cell_type": "code", 261 | "execution_count": 14, 262 | "metadata": {}, 263 | "outputs": [ 264 | { 265 | "data": { 266 | "text/plain": [ 267 | "(2, 3)" 268 | ] 269 | }, 270 | "execution_count": 14, 271 | "metadata": {}, 272 | "output_type": "execute_result" 273 | } 274 | ], 275 | "source": [ 276 | "a2.shape" 277 | ] 278 | }, 279 | { 280 | "cell_type": "code", 281 | "execution_count": 15, 282 | "metadata": {}, 283 | "outputs": [ 284 | { 285 | "data": { 286 | "text/plain": [ 287 | "6" 288 | ] 289 | }, 290 | "execution_count": 15, 291 | "metadata": {}, 292 | "output_type": "execute_result" 293 | } 294 | ], 295 | "source": [ 296 | "a2.size" 297 | ] 298 | }, 299 | { 300 | "cell_type": "code", 301 | "execution_count": 16, 302 | "metadata": {}, 303 | "outputs": [ 304 | { 305 | "data": { 306 | "text/plain": [ 307 | "48" 308 | ] 309 | }, 310 | "execution_count": 16, 311 | "metadata": {}, 312 | "output_type": "execute_result" 313 | } 314 | ], 315 | "source": [ 316 | "a2.nbytes" 317 | ] 318 | }, 319 | { 320 | "cell_type": "markdown", 321 | "metadata": {}, 322 | "source": [ 323 | "## Important: Arrays must have regular shapes!!!" 324 | ] 325 | }, 326 | { 327 | "cell_type": "code", 328 | "execution_count": 17, 329 | "metadata": {}, 330 | "outputs": [ 331 | { 332 | "data": { 333 | "text/plain": [ 334 | "array([list([1, 2, 3]), list([4, 5])], dtype=object)" 335 | ] 336 | }, 337 | "execution_count": 17, 338 | "metadata": {}, 339 | "output_type": "execute_result" 340 | } 341 | ], 342 | "source": [ 343 | "np.array([[1,2,3], [4,5]]) # irregular shape: don't do this! " 344 | ] 345 | }, 346 | { 347 | "cell_type": "markdown", 348 | "metadata": {}, 349 | "source": [ 350 | "And also: array **size** usually does not change after creation." 351 | ] 352 | }, 353 | { 354 | "cell_type": "markdown", 355 | "metadata": {}, 356 | "source": [ 357 | "# Specifying data types with `dtype` and `astype()`" 358 | ] 359 | }, 360 | { 361 | "cell_type": "code", 362 | "execution_count": 18, 363 | "metadata": {}, 364 | "outputs": [ 365 | { 366 | "data": { 367 | "text/plain": [ 368 | "array([10, 20, 30])" 369 | ] 370 | }, 371 | "execution_count": 18, 372 | "metadata": {}, 373 | "output_type": "execute_result" 374 | } 375 | ], 376 | "source": [ 377 | "np.array([10, 20, 30])" 378 | ] 379 | }, 380 | { 381 | "cell_type": "code", 382 | "execution_count": 19, 383 | "metadata": {}, 384 | "outputs": [ 385 | { 386 | "data": { 387 | "text/plain": [ 388 | "array([10., 20., 30.])" 389 | ] 390 | }, 391 | "execution_count": 19, 392 | "metadata": {}, 393 | "output_type": "execute_result" 394 | } 395 | ], 396 | "source": [ 397 | "np.array([10, 20, 30], dtype=float)" 398 | ] 399 | }, 400 | { 401 | "cell_type": "code", 402 | "execution_count": 20, 403 | "metadata": {}, 404 | "outputs": [ 405 | { 406 | "data": { 407 | "text/plain": [ 408 | "array([10., 20., 30.])" 409 | ] 410 | }, 411 | "execution_count": 20, 412 | "metadata": {}, 413 | "output_type": "execute_result" 414 | } 415 | ], 416 | "source": [ 417 | "a.astype(float)" 418 | ] 419 | }, 420 | { 421 | "cell_type": "markdown", 422 | "metadata": {}, 423 | "source": [ 424 | "# More ways to create arrays" 425 | ] 426 | }, 427 | { 428 | "cell_type": "code", 429 | "execution_count": null, 430 | "metadata": {}, 431 | "outputs": [], 432 | "source": [] 433 | }, 434 | { 435 | "cell_type": "markdown", 436 | "metadata": {}, 437 | "source": [ 438 | "## `zeros()`, `ones()`, `empty()`" 439 | ] 440 | }, 441 | { 442 | "cell_type": "code", 443 | "execution_count": 21, 444 | "metadata": {}, 445 | "outputs": [ 446 | { 447 | "data": { 448 | "text/plain": [ 449 | "array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])" 450 | ] 451 | }, 452 | "execution_count": 21, 453 | "metadata": {}, 454 | "output_type": "execute_result" 455 | } 456 | ], 457 | "source": [ 458 | "np.zeros(10)" 459 | ] 460 | }, 461 | { 462 | "cell_type": "code", 463 | "execution_count": 22, 464 | "metadata": {}, 465 | "outputs": [ 466 | { 467 | "data": { 468 | "text/plain": [ 469 | "array([[0., 0., 0., 0., 0.],\n", 470 | " [0., 0., 0., 0., 0.],\n", 471 | " [0., 0., 0., 0., 0.]])" 472 | ] 473 | }, 474 | "execution_count": 22, 475 | "metadata": {}, 476 | "output_type": "execute_result" 477 | } 478 | ], 479 | "source": [ 480 | "np.zeros((3, 5))" 481 | ] 482 | }, 483 | { 484 | "cell_type": "code", 485 | "execution_count": 23, 486 | "metadata": {}, 487 | "outputs": [ 488 | { 489 | "data": { 490 | "text/plain": [ 491 | "array([[[0., 0., 0., 0., 0.],\n", 492 | " [0., 0., 0., 0., 0.],\n", 493 | " [0., 0., 0., 0., 0.]],\n", 494 | "\n", 495 | " [[0., 0., 0., 0., 0.],\n", 496 | " [0., 0., 0., 0., 0.],\n", 497 | " [0., 0., 0., 0., 0.]],\n", 498 | "\n", 499 | " [[0., 0., 0., 0., 0.],\n", 500 | " [0., 0., 0., 0., 0.],\n", 501 | " [0., 0., 0., 0., 0.]],\n", 502 | "\n", 503 | " [[0., 0., 0., 0., 0.],\n", 504 | " [0., 0., 0., 0., 0.],\n", 505 | " [0., 0., 0., 0., 0.]]])" 506 | ] 507 | }, 508 | "execution_count": 23, 509 | "metadata": {}, 510 | "output_type": "execute_result" 511 | } 512 | ], 513 | "source": [ 514 | "np.zeros((4, 3, 5))" 515 | ] 516 | }, 517 | { 518 | "cell_type": "code", 519 | "execution_count": 24, 520 | "metadata": {}, 521 | "outputs": [ 522 | { 523 | "data": { 524 | "text/plain": [ 525 | "array([1., 1., 1., 1.])" 526 | ] 527 | }, 528 | "execution_count": 24, 529 | "metadata": {}, 530 | "output_type": "execute_result" 531 | } 532 | ], 533 | "source": [ 534 | "np.ones(4)" 535 | ] 536 | }, 537 | { 538 | "cell_type": "code", 539 | "execution_count": 25, 540 | "metadata": {}, 541 | "outputs": [ 542 | { 543 | "data": { 544 | "text/plain": [ 545 | "array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])" 546 | ] 547 | }, 548 | "execution_count": 25, 549 | "metadata": {}, 550 | "output_type": "execute_result" 551 | } 552 | ], 553 | "source": [ 554 | "np.empty(10) # does not initalize memory" 555 | ] 556 | }, 557 | { 558 | "cell_type": "markdown", 559 | "metadata": {}, 560 | "source": [ 561 | "## `arange()`, `linspace()`" 562 | ] 563 | }, 564 | { 565 | "cell_type": "code", 566 | "execution_count": 26, 567 | "metadata": {}, 568 | "outputs": [], 569 | "source": [ 570 | "a3 = np.arange(20)" 571 | ] 572 | }, 573 | { 574 | "cell_type": "code", 575 | "execution_count": 27, 576 | "metadata": {}, 577 | "outputs": [ 578 | { 579 | "data": { 580 | "text/plain": [ 581 | "array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n", 582 | " 17, 18, 19])" 583 | ] 584 | }, 585 | "execution_count": 27, 586 | "metadata": {}, 587 | "output_type": "execute_result" 588 | } 589 | ], 590 | "source": [ 591 | "a3" 592 | ] 593 | }, 594 | { 595 | "cell_type": "code", 596 | "execution_count": 28, 597 | "metadata": {}, 598 | "outputs": [ 599 | { 600 | "data": { 601 | "text/plain": [ 602 | "array([0., 1., 2., 3., 4.])" 603 | ] 604 | }, 605 | "execution_count": 28, 606 | "metadata": {}, 607 | "output_type": "execute_result" 608 | } 609 | ], 610 | "source": [ 611 | "np.arange(5.) # creates floats!" 612 | ] 613 | }, 614 | { 615 | "cell_type": "code", 616 | "execution_count": 29, 617 | "metadata": {}, 618 | "outputs": [ 619 | { 620 | "data": { 621 | "text/plain": [ 622 | "array([10, 15, 20, 25, 30, 35])" 623 | ] 624 | }, 625 | "execution_count": 29, 626 | "metadata": {}, 627 | "output_type": "execute_result" 628 | } 629 | ], 630 | "source": [ 631 | "np.arange(10, 40, 5)" 632 | ] 633 | }, 634 | { 635 | "cell_type": "code", 636 | "execution_count": 30, 637 | "metadata": {}, 638 | "outputs": [ 639 | { 640 | "data": { 641 | "text/plain": [ 642 | "array([ 1. , 1.64285714, 2.28571429, 2.92857143, 3.57142857,\n", 643 | " 4.21428571, 4.85714286, 5.5 , 6.14285714, 6.78571429,\n", 644 | " 7.42857143, 8.07142857, 8.71428571, 9.35714286, 10. ])" 645 | ] 646 | }, 647 | "execution_count": 30, 648 | "metadata": {}, 649 | "output_type": "execute_result" 650 | } 651 | ], 652 | "source": [ 653 | "np.linspace(1, 10, 15)" 654 | ] 655 | }, 656 | { 657 | "cell_type": "markdown", 658 | "metadata": {}, 659 | "source": [ 660 | "## ...`eye()`, `diag()`" 661 | ] 662 | }, 663 | { 664 | "cell_type": "code", 665 | "execution_count": 31, 666 | "metadata": {}, 667 | "outputs": [ 668 | { 669 | "data": { 670 | "text/plain": [ 671 | "array([[1., 0., 0., 0., 0.],\n", 672 | " [0., 1., 0., 0., 0.],\n", 673 | " [0., 0., 1., 0., 0.],\n", 674 | " [0., 0., 0., 1., 0.],\n", 675 | " [0., 0., 0., 0., 1.]])" 676 | ] 677 | }, 678 | "execution_count": 31, 679 | "metadata": {}, 680 | "output_type": "execute_result" 681 | } 682 | ], 683 | "source": [ 684 | "np.eye(5)" 685 | ] 686 | }, 687 | { 688 | "cell_type": "code", 689 | "execution_count": null, 690 | "metadata": {}, 691 | "outputs": [], 692 | "source": [] 693 | }, 694 | { 695 | "cell_type": "code", 696 | "execution_count": 32, 697 | "metadata": {}, 698 | "outputs": [ 699 | { 700 | "data": { 701 | "text/plain": [ 702 | "array([[0., 0., 1., 0., 0., 0., 0., 0.],\n", 703 | " [0., 0., 0., 1., 0., 0., 0., 0.],\n", 704 | " [0., 0., 0., 0., 1., 0., 0., 0.],\n", 705 | " [0., 0., 0., 0., 0., 1., 0., 0.],\n", 706 | " [0., 0., 0., 0., 0., 0., 1., 0.],\n", 707 | " [0., 0., 0., 0., 0., 0., 0., 1.],\n", 708 | " [0., 0., 0., 0., 0., 0., 0., 0.],\n", 709 | " [0., 0., 0., 0., 0., 0., 0., 0.]])" 710 | ] 711 | }, 712 | "execution_count": 32, 713 | "metadata": {}, 714 | "output_type": "execute_result" 715 | } 716 | ], 717 | "source": [ 718 | "np.eye(8, k=2)" 719 | ] 720 | }, 721 | { 722 | "cell_type": "code", 723 | "execution_count": 33, 724 | "metadata": {}, 725 | "outputs": [ 726 | { 727 | "data": { 728 | "text/plain": [ 729 | "array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", 730 | " [0, 1, 0, 0, 0, 0, 0, 0, 0, 0],\n", 731 | " [0, 0, 2, 0, 0, 0, 0, 0, 0, 0],\n", 732 | " [0, 0, 0, 3, 0, 0, 0, 0, 0, 0],\n", 733 | " [0, 0, 0, 0, 4, 0, 0, 0, 0, 0],\n", 734 | " [0, 0, 0, 0, 0, 5, 0, 0, 0, 0],\n", 735 | " [0, 0, 0, 0, 0, 0, 6, 0, 0, 0],\n", 736 | " [0, 0, 0, 0, 0, 0, 0, 7, 0, 0],\n", 737 | " [0, 0, 0, 0, 0, 0, 0, 0, 8, 0],\n", 738 | " [0, 0, 0, 0, 0, 0, 0, 0, 0, 9]])" 739 | ] 740 | }, 741 | "execution_count": 33, 742 | "metadata": {}, 743 | "output_type": "execute_result" 744 | } 745 | ], 746 | "source": [ 747 | "np.diag(np.arange(10))" 748 | ] 749 | }, 750 | { 751 | "cell_type": "markdown", 752 | "metadata": {}, 753 | "source": [ 754 | "## `np.random.*`" 755 | ] 756 | }, 757 | { 758 | "cell_type": "code", 759 | "execution_count": 34, 760 | "metadata": {}, 761 | "outputs": [ 762 | { 763 | "data": { 764 | "text/plain": [ 765 | "array([0.52297285, 0.79754644, 0.36816662, 0.46000435, 0.64712376,\n", 766 | " 0.97199938, 0.65291903, 0.30065233, 0.10800028, 0.27023246])" 767 | ] 768 | }, 769 | "execution_count": 34, 770 | "metadata": {}, 771 | "output_type": "execute_result" 772 | } 773 | ], 774 | "source": [ 775 | "np.random.random(10)" 776 | ] 777 | }, 778 | { 779 | "cell_type": "code", 780 | "execution_count": 35, 781 | "metadata": {}, 782 | "outputs": [ 783 | { 784 | "data": { 785 | "text/plain": [ 786 | "array([[0.59258109, 0.35775893, 0.21164484, 0.88275613, 0.89120151],\n", 787 | " [0.60319397, 0.08085025, 0.07080682, 0.45673067, 0.77097745],\n", 788 | " [0.72088694, 0.09743378, 0.83669466, 0.15414018, 0.92524497]])" 789 | ] 790 | }, 791 | "execution_count": 35, 792 | "metadata": {}, 793 | "output_type": "execute_result" 794 | } 795 | ], 796 | "source": [ 797 | "np.random.random((3,5))" 798 | ] 799 | }, 800 | { 801 | "cell_type": "code", 802 | "execution_count": 36, 803 | "metadata": {}, 804 | "outputs": [ 805 | { 806 | "data": { 807 | "text/plain": [ 808 | "array([[3, 3, 9, 5, 8, 2],\n", 809 | " [9, 6, 1, 6, 4, 6],\n", 810 | " [8, 9, 3, 3, 3, 8],\n", 811 | " [8, 7, 4, 4, 0, 5]])" 812 | ] 813 | }, 814 | "execution_count": 36, 815 | "metadata": {}, 816 | "output_type": "execute_result" 817 | } 818 | ], 819 | "source": [ 820 | "np.random.randint(0, 10, (4, 6)) # creates ints from 0 to 9; excludes 10." 821 | ] 822 | }, 823 | { 824 | "cell_type": "code", 825 | "execution_count": 37, 826 | "metadata": {}, 827 | "outputs": [ 828 | { 829 | "data": { 830 | "text/plain": [ 831 | "array([4, 0, 6, 2, 7, 8, 1, 9, 5, 3])" 832 | ] 833 | }, 834 | "execution_count": 37, 835 | "metadata": {}, 836 | "output_type": "execute_result" 837 | } 838 | ], 839 | "source": [ 840 | "np.random.permutation(10) # random permutation of arange(10)" 841 | ] 842 | } 843 | ], 844 | "metadata": { 845 | "kernelspec": { 846 | "display_name": "Python 3", 847 | "language": "python", 848 | "name": "python3" 849 | }, 850 | "language_info": { 851 | "codemirror_mode": { 852 | "name": "ipython", 853 | "version": 3 854 | }, 855 | "file_extension": ".py", 856 | "mimetype": "text/x-python", 857 | "name": "python", 858 | "nbconvert_exporter": "python", 859 | "pygments_lexer": "ipython3", 860 | "version": "3.8.1" 861 | } 862 | }, 863 | "nbformat": 4, 864 | "nbformat_minor": 4 865 | } 866 | -------------------------------------------------------------------------------- /002-array-reshaping.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Changing the shape of Arrays" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 1, 13 | "metadata": {}, 14 | "outputs": [], 15 | "source": [ 16 | "import numpy as np" 17 | ] 18 | }, 19 | { 20 | "cell_type": "markdown", 21 | "metadata": {}, 22 | "source": [ 23 | "## Option 1: modify `shape`" 24 | ] 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": 2, 29 | "metadata": {}, 30 | "outputs": [], 31 | "source": [ 32 | "a = np.arange(24)" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": 3, 38 | "metadata": {}, 39 | "outputs": [ 40 | { 41 | "data": { 42 | "text/plain": [ 43 | "array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n", 44 | " 17, 18, 19, 20, 21, 22, 23])" 45 | ] 46 | }, 47 | "execution_count": 3, 48 | "metadata": {}, 49 | "output_type": "execute_result" 50 | } 51 | ], 52 | "source": [ 53 | "a" 54 | ] 55 | }, 56 | { 57 | "cell_type": "code", 58 | "execution_count": 4, 59 | "metadata": {}, 60 | "outputs": [], 61 | "source": [ 62 | "a.shape = (4,6)" 63 | ] 64 | }, 65 | { 66 | "cell_type": "code", 67 | "execution_count": 5, 68 | "metadata": {}, 69 | "outputs": [ 70 | { 71 | "data": { 72 | "text/plain": [ 73 | "array([[ 0, 1, 2, 3, 4, 5],\n", 74 | " [ 6, 7, 8, 9, 10, 11],\n", 75 | " [12, 13, 14, 15, 16, 17],\n", 76 | " [18, 19, 20, 21, 22, 23]])" 77 | ] 78 | }, 79 | "execution_count": 5, 80 | "metadata": {}, 81 | "output_type": "execute_result" 82 | } 83 | ], 84 | "source": [ 85 | "a" 86 | ] 87 | }, 88 | { 89 | "cell_type": "code", 90 | "execution_count": 6, 91 | "metadata": {}, 92 | "outputs": [], 93 | "source": [ 94 | "a.shape = (6,4)" 95 | ] 96 | }, 97 | { 98 | "cell_type": "code", 99 | "execution_count": 7, 100 | "metadata": {}, 101 | "outputs": [ 102 | { 103 | "data": { 104 | "text/plain": [ 105 | "array([[ 0, 1, 2, 3],\n", 106 | " [ 4, 5, 6, 7],\n", 107 | " [ 8, 9, 10, 11],\n", 108 | " [12, 13, 14, 15],\n", 109 | " [16, 17, 18, 19],\n", 110 | " [20, 21, 22, 23]])" 111 | ] 112 | }, 113 | "execution_count": 7, 114 | "metadata": {}, 115 | "output_type": "execute_result" 116 | } 117 | ], 118 | "source": [ 119 | "a" 120 | ] 121 | }, 122 | { 123 | "cell_type": "markdown", 124 | "metadata": {}, 125 | "source": [ 126 | "## Use `-1` for auto-calculating a dimension size" 127 | ] 128 | }, 129 | { 130 | "cell_type": "code", 131 | "execution_count": 8, 132 | "metadata": {}, 133 | "outputs": [], 134 | "source": [ 135 | "a.shape = (3,-1)" 136 | ] 137 | }, 138 | { 139 | "cell_type": "code", 140 | "execution_count": 9, 141 | "metadata": {}, 142 | "outputs": [ 143 | { 144 | "data": { 145 | "text/plain": [ 146 | "array([[ 0, 1, 2, 3, 4, 5, 6, 7],\n", 147 | " [ 8, 9, 10, 11, 12, 13, 14, 15],\n", 148 | " [16, 17, 18, 19, 20, 21, 22, 23]])" 149 | ] 150 | }, 151 | "execution_count": 9, 152 | "metadata": {}, 153 | "output_type": "execute_result" 154 | } 155 | ], 156 | "source": [ 157 | "a" 158 | ] 159 | }, 160 | { 161 | "cell_type": "markdown", 162 | "metadata": {}, 163 | "source": [ 164 | "## Option 2: Use `.reshape()`" 165 | ] 166 | }, 167 | { 168 | "cell_type": "code", 169 | "execution_count": 10, 170 | "metadata": {}, 171 | "outputs": [ 172 | { 173 | "data": { 174 | "text/plain": [ 175 | "array([[ 0, 1, 2, 3],\n", 176 | " [ 4, 5, 6, 7],\n", 177 | " [ 8, 9, 10, 11],\n", 178 | " [12, 13, 14, 15],\n", 179 | " [16, 17, 18, 19],\n", 180 | " [20, 21, 22, 23]])" 181 | ] 182 | }, 183 | "execution_count": 10, 184 | "metadata": {}, 185 | "output_type": "execute_result" 186 | } 187 | ], 188 | "source": [ 189 | "np.arange(24).reshape(6, 4)" 190 | ] 191 | }, 192 | { 193 | "cell_type": "code", 194 | "execution_count": 11, 195 | "metadata": {}, 196 | "outputs": [ 197 | { 198 | "data": { 199 | "text/plain": [ 200 | "array([[[ 0, 1, 2, 3],\n", 201 | " [ 4, 5, 6, 7]],\n", 202 | "\n", 203 | " [[ 8, 9, 10, 11],\n", 204 | " [12, 13, 14, 15]],\n", 205 | "\n", 206 | " [[16, 17, 18, 19],\n", 207 | " [20, 21, 22, 23]]])" 208 | ] 209 | }, 210 | "execution_count": 11, 211 | "metadata": {}, 212 | "output_type": "execute_result" 213 | } 214 | ], 215 | "source": [ 216 | "np.arange(24).reshape((3, 2, 4))" 217 | ] 218 | }, 219 | { 220 | "cell_type": "code", 221 | "execution_count": 12, 222 | "metadata": {}, 223 | "outputs": [ 224 | { 225 | "data": { 226 | "text/plain": [ 227 | "array([[ 0, 1, 2, 3, 4, 5, 6, 7],\n", 228 | " [ 8, 9, 10, 11, 12, 13, 14, 15],\n", 229 | " [16, 17, 18, 19, 20, 21, 22, 23]])" 230 | ] 231 | }, 232 | "execution_count": 12, 233 | "metadata": {}, 234 | "output_type": "execute_result" 235 | } 236 | ], 237 | "source": [ 238 | "np.arange(24).reshape((3, -1))\n" 239 | ] 240 | }, 241 | { 242 | "cell_type": "markdown", 243 | "metadata": {}, 244 | "source": [ 245 | "## `.ravel()`" 246 | ] 247 | }, 248 | { 249 | "cell_type": "code", 250 | "execution_count": 13, 251 | "metadata": {}, 252 | "outputs": [ 253 | { 254 | "data": { 255 | "text/plain": [ 256 | "array([[ 0, 1, 2, 3, 4, 5, 6, 7],\n", 257 | " [ 8, 9, 10, 11, 12, 13, 14, 15],\n", 258 | " [16, 17, 18, 19, 20, 21, 22, 23]])" 259 | ] 260 | }, 261 | "execution_count": 13, 262 | "metadata": {}, 263 | "output_type": "execute_result" 264 | } 265 | ], 266 | "source": [ 267 | "a" 268 | ] 269 | }, 270 | { 271 | "cell_type": "code", 272 | "execution_count": 14, 273 | "metadata": {}, 274 | "outputs": [ 275 | { 276 | "data": { 277 | "text/plain": [ 278 | "array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n", 279 | " 17, 18, 19, 20, 21, 22, 23])" 280 | ] 281 | }, 282 | "execution_count": 14, 283 | "metadata": {}, 284 | "output_type": "execute_result" 285 | } 286 | ], 287 | "source": [ 288 | "a.reshape(-1)" 289 | ] 290 | }, 291 | { 292 | "cell_type": "code", 293 | "execution_count": 15, 294 | "metadata": {}, 295 | "outputs": [ 296 | { 297 | "data": { 298 | "text/plain": [ 299 | "array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,\n", 300 | " 17, 18, 19, 20, 21, 22, 23])" 301 | ] 302 | }, 303 | "execution_count": 15, 304 | "metadata": {}, 305 | "output_type": "execute_result" 306 | } 307 | ], 308 | "source": [ 309 | "a.ravel() # the same" 310 | ] 311 | }, 312 | { 313 | "cell_type": "markdown", 314 | "metadata": {}, 315 | "source": [ 316 | "Note: `.reshape()` (and `.ravel()`) usually return **views**. Refer to docs for more info." 317 | ] 318 | } 319 | ], 320 | "metadata": { 321 | "kernelspec": { 322 | "display_name": "Python 3", 323 | "language": "python", 324 | "name": "python3" 325 | }, 326 | "language_info": { 327 | "codemirror_mode": { 328 | "name": "ipython", 329 | "version": 3 330 | }, 331 | "file_extension": ".py", 332 | "mimetype": "text/x-python", 333 | "name": "python", 334 | "nbconvert_exporter": "python", 335 | "pygments_lexer": "ipython3", 336 | "version": "3.8.1" 337 | } 338 | }, 339 | "nbformat": 4, 340 | "nbformat_minor": 4 341 | } 342 | -------------------------------------------------------------------------------- /010-indexing.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Accessing Array Data: Indexing and Views" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 1, 13 | "metadata": {}, 14 | "outputs": [], 15 | "source": [ 16 | "import numpy as np" 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 2, 22 | "metadata": {}, 23 | "outputs": [], 24 | "source": [ 25 | "a = np.linspace(10, 100, 10, dtype=int)" 26 | ] 27 | }, 28 | { 29 | "cell_type": "code", 30 | "execution_count": 3, 31 | "metadata": {}, 32 | "outputs": [ 33 | { 34 | "data": { 35 | "text/plain": [ 36 | "array([ 10, 20, 30, 40, 50, 60, 70, 80, 90, 100])" 37 | ] 38 | }, 39 | "execution_count": 3, 40 | "metadata": {}, 41 | "output_type": "execute_result" 42 | } 43 | ], 44 | "source": [ 45 | "a" 46 | ] 47 | }, 48 | { 49 | "cell_type": "markdown", 50 | "metadata": {}, 51 | "source": [ 52 | "## Accessing array items (scalars)" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": 4, 58 | "metadata": {}, 59 | "outputs": [ 60 | { 61 | "data": { 62 | "text/plain": [ 63 | "10" 64 | ] 65 | }, 66 | "execution_count": 4, 67 | "metadata": {}, 68 | "output_type": "execute_result" 69 | } 70 | ], 71 | "source": [ 72 | "a[0] # first item is #0" 73 | ] 74 | }, 75 | { 76 | "cell_type": "code", 77 | "execution_count": 5, 78 | "metadata": {}, 79 | "outputs": [ 80 | { 81 | "data": { 82 | "text/plain": [ 83 | "70" 84 | ] 85 | }, 86 | "execution_count": 5, 87 | "metadata": {}, 88 | "output_type": "execute_result" 89 | } 90 | ], 91 | "source": [ 92 | "a[6]" 93 | ] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "execution_count": 6, 98 | "metadata": {}, 99 | "outputs": [ 100 | { 101 | "ename": "IndexError", 102 | "evalue": "index 10 is out of bounds for axis 0 with size 10", 103 | "output_type": "error", 104 | "traceback": [ 105 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 106 | "\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)", 107 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0ma\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 108 | "\u001b[0;31mIndexError\u001b[0m: index 10 is out of bounds for axis 0 with size 10" 109 | ] 110 | } 111 | ], 112 | "source": [ 113 | "a[10]" 114 | ] 115 | }, 116 | { 117 | "cell_type": "markdown", 118 | "metadata": {}, 119 | "source": [ 120 | "### Reminder: negative indexing" 121 | ] 122 | }, 123 | { 124 | "cell_type": "code", 125 | "execution_count": 7, 126 | "metadata": {}, 127 | "outputs": [ 128 | { 129 | "data": { 130 | "text/plain": [ 131 | "100" 132 | ] 133 | }, 134 | "execution_count": 7, 135 | "metadata": {}, 136 | "output_type": "execute_result" 137 | } 138 | ], 139 | "source": [ 140 | "a[-1]" 141 | ] 142 | }, 143 | { 144 | "cell_type": "code", 145 | "execution_count": 8, 146 | "metadata": {}, 147 | "outputs": [ 148 | { 149 | "data": { 150 | "text/plain": [ 151 | "numpy.int64" 152 | ] 153 | }, 154 | "execution_count": 8, 155 | "metadata": {}, 156 | "output_type": "execute_result" 157 | } 158 | ], 159 | "source": [ 160 | "type(a[0])" 161 | ] 162 | }, 163 | { 164 | "cell_type": "markdown", 165 | "metadata": {}, 166 | "source": [ 167 | "## Creating slices" 168 | ] 169 | }, 170 | { 171 | "cell_type": "code", 172 | "execution_count": 9, 173 | "metadata": {}, 174 | "outputs": [], 175 | "source": [ 176 | "a_1 = a[2:4]" 177 | ] 178 | }, 179 | { 180 | "cell_type": "code", 181 | "execution_count": 10, 182 | "metadata": {}, 183 | "outputs": [ 184 | { 185 | "data": { 186 | "text/plain": [ 187 | "array([30, 40])" 188 | ] 189 | }, 190 | "execution_count": 10, 191 | "metadata": {}, 192 | "output_type": "execute_result" 193 | } 194 | ], 195 | "source": [ 196 | "a_1" 197 | ] 198 | }, 199 | { 200 | "cell_type": "markdown", 201 | "metadata": {}, 202 | "source": [ 203 | "## A slice is a **view** of an array!!!" 204 | ] 205 | }, 206 | { 207 | "cell_type": "code", 208 | "execution_count": 11, 209 | "metadata": {}, 210 | "outputs": [], 211 | "source": [ 212 | "a_1[0] = 9999" 213 | ] 214 | }, 215 | { 216 | "cell_type": "code", 217 | "execution_count": 12, 218 | "metadata": {}, 219 | "outputs": [ 220 | { 221 | "data": { 222 | "text/plain": [ 223 | "array([9999, 40])" 224 | ] 225 | }, 226 | "execution_count": 12, 227 | "metadata": {}, 228 | "output_type": "execute_result" 229 | } 230 | ], 231 | "source": [ 232 | "a_1" 233 | ] 234 | }, 235 | { 236 | "cell_type": "code", 237 | "execution_count": 13, 238 | "metadata": {}, 239 | "outputs": [ 240 | { 241 | "data": { 242 | "text/plain": [ 243 | "array([ 10, 20, 9999, 40, 50, 60, 70, 80, 90, 100])" 244 | ] 245 | }, 246 | "execution_count": 13, 247 | "metadata": {}, 248 | "output_type": "execute_result" 249 | } 250 | ], 251 | "source": [ 252 | "a" 253 | ] 254 | }, 255 | { 256 | "cell_type": "code", 257 | "execution_count": 14, 258 | "metadata": {}, 259 | "outputs": [ 260 | { 261 | "data": { 262 | "text/plain": [ 263 | " C_CONTIGUOUS : True\n", 264 | " F_CONTIGUOUS : True\n", 265 | " OWNDATA : False\n", 266 | " WRITEABLE : True\n", 267 | " ALIGNED : True\n", 268 | " UPDATEIFCOPY : False" 269 | ] 270 | }, 271 | "execution_count": 14, 272 | "metadata": {}, 273 | "output_type": "execute_result" 274 | } 275 | ], 276 | "source": [ 277 | "a_1.flags" 278 | ] 279 | }, 280 | { 281 | "cell_type": "code", 282 | "execution_count": 15, 283 | "metadata": {}, 284 | "outputs": [ 285 | { 286 | "data": { 287 | "text/plain": [ 288 | " C_CONTIGUOUS : True\n", 289 | " F_CONTIGUOUS : True\n", 290 | " OWNDATA : True\n", 291 | " WRITEABLE : True\n", 292 | " ALIGNED : True\n", 293 | " UPDATEIFCOPY : False" 294 | ] 295 | }, 296 | "execution_count": 15, 297 | "metadata": {}, 298 | "output_type": "execute_result" 299 | } 300 | ], 301 | "source": [ 302 | "a.flags" 303 | ] 304 | }, 305 | { 306 | "cell_type": "markdown", 307 | "metadata": {}, 308 | "source": [ 309 | "## Indexing in multi-dimensional arrays" 310 | ] 311 | }, 312 | { 313 | "cell_type": "code", 314 | "execution_count": 16, 315 | "metadata": {}, 316 | "outputs": [], 317 | "source": [ 318 | "b = np.arange(50).reshape(5, 10)" 319 | ] 320 | }, 321 | { 322 | "cell_type": "code", 323 | "execution_count": 17, 324 | "metadata": {}, 325 | "outputs": [ 326 | { 327 | "data": { 328 | "text/plain": [ 329 | "array([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],\n", 330 | " [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],\n", 331 | " [20, 21, 22, 23, 24, 25, 26, 27, 28, 29],\n", 332 | " [30, 31, 32, 33, 34, 35, 36, 37, 38, 39],\n", 333 | " [40, 41, 42, 43, 44, 45, 46, 47, 48, 49]])" 334 | ] 335 | }, 336 | "execution_count": 17, 337 | "metadata": {}, 338 | "output_type": "execute_result" 339 | } 340 | ], 341 | "source": [ 342 | "b" 343 | ] 344 | }, 345 | { 346 | "cell_type": "code", 347 | "execution_count": 18, 348 | "metadata": {}, 349 | "outputs": [ 350 | { 351 | "data": { 352 | "text/plain": [ 353 | "array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])" 354 | ] 355 | }, 356 | "execution_count": 18, 357 | "metadata": {}, 358 | "output_type": "execute_result" 359 | } 360 | ], 361 | "source": [ 362 | "b[0]" 363 | ] 364 | }, 365 | { 366 | "cell_type": "code", 367 | "execution_count": 19, 368 | "metadata": {}, 369 | "outputs": [], 370 | "source": [ 371 | "b[3,5] = 999" 372 | ] 373 | }, 374 | { 375 | "cell_type": "code", 376 | "execution_count": 20, 377 | "metadata": {}, 378 | "outputs": [ 379 | { 380 | "data": { 381 | "text/plain": [ 382 | "array([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],\n", 383 | " [ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],\n", 384 | " [ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29],\n", 385 | " [ 30, 31, 32, 33, 34, 999, 36, 37, 38, 39],\n", 386 | " [ 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]])" 387 | ] 388 | }, 389 | "execution_count": 20, 390 | "metadata": {}, 391 | "output_type": "execute_result" 392 | } 393 | ], 394 | "source": [ 395 | "b" 396 | ] 397 | }, 398 | { 399 | "cell_type": "code", 400 | "execution_count": 21, 401 | "metadata": {}, 402 | "outputs": [ 403 | { 404 | "data": { 405 | "text/plain": [ 406 | "array([ 0, 10, 20, 30, 40])" 407 | ] 408 | }, 409 | "execution_count": 21, 410 | "metadata": {}, 411 | "output_type": "execute_result" 412 | } 413 | ], 414 | "source": [ 415 | "b[:,0]" 416 | ] 417 | }, 418 | { 419 | "cell_type": "code", 420 | "execution_count": 22, 421 | "metadata": {}, 422 | "outputs": [], 423 | "source": [ 424 | "col1 = b[:,0]" 425 | ] 426 | }, 427 | { 428 | "cell_type": "code", 429 | "execution_count": 23, 430 | "metadata": {}, 431 | "outputs": [ 432 | { 433 | "data": { 434 | "text/plain": [ 435 | "array([ 0, 10, 20, 30, 40])" 436 | ] 437 | }, 438 | "execution_count": 23, 439 | "metadata": {}, 440 | "output_type": "execute_result" 441 | } 442 | ], 443 | "source": [ 444 | "col1" 445 | ] 446 | }, 447 | { 448 | "cell_type": "code", 449 | "execution_count": 24, 450 | "metadata": {}, 451 | "outputs": [], 452 | "source": [ 453 | "col1[3] = 1234" 454 | ] 455 | }, 456 | { 457 | "cell_type": "code", 458 | "execution_count": 25, 459 | "metadata": {}, 460 | "outputs": [ 461 | { 462 | "data": { 463 | "text/plain": [ 464 | "array([ 0, 10, 20, 1234, 40])" 465 | ] 466 | }, 467 | "execution_count": 25, 468 | "metadata": {}, 469 | "output_type": "execute_result" 470 | } 471 | ], 472 | "source": [ 473 | "col1" 474 | ] 475 | }, 476 | { 477 | "cell_type": "code", 478 | "execution_count": 26, 479 | "metadata": {}, 480 | "outputs": [ 481 | { 482 | "data": { 483 | "text/plain": [ 484 | "array([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],\n", 485 | " [ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],\n", 486 | " [ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29],\n", 487 | " [1234, 31, 32, 33, 34, 999, 36, 37, 38, 39],\n", 488 | " [ 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]])" 489 | ] 490 | }, 491 | "execution_count": 26, 492 | "metadata": {}, 493 | "output_type": "execute_result" 494 | } 495 | ], 496 | "source": [ 497 | "b" 498 | ] 499 | }, 500 | { 501 | "cell_type": "code", 502 | "execution_count": 27, 503 | "metadata": {}, 504 | "outputs": [ 505 | { 506 | "data": { 507 | "text/plain": [ 508 | "array([ 9, 19, 29, 39, 49])" 509 | ] 510 | }, 511 | "execution_count": 27, 512 | "metadata": {}, 513 | "output_type": "execute_result" 514 | } 515 | ], 516 | "source": [ 517 | "b[:,-1]" 518 | ] 519 | }, 520 | { 521 | "cell_type": "code", 522 | "execution_count": 28, 523 | "metadata": {}, 524 | "outputs": [ 525 | { 526 | "data": { 527 | "text/plain": [ 528 | "array([40, 41, 42, 43, 44, 45, 46, 47, 48, 49])" 529 | ] 530 | }, 531 | "execution_count": 28, 532 | "metadata": {}, 533 | "output_type": "execute_result" 534 | } 535 | ], 536 | "source": [ 537 | "b[-1]" 538 | ] 539 | } 540 | ], 541 | "metadata": { 542 | "kernelspec": { 543 | "display_name": "Python 3", 544 | "language": "python", 545 | "name": "python3" 546 | }, 547 | "language_info": { 548 | "codemirror_mode": { 549 | "name": "ipython", 550 | "version": 3 551 | }, 552 | "file_extension": ".py", 553 | "mimetype": "text/x-python", 554 | "name": "python", 555 | "nbconvert_exporter": "python", 556 | "pygments_lexer": "ipython3", 557 | "version": "3.8.1" 558 | } 559 | }, 560 | "nbformat": 4, 561 | "nbformat_minor": 4 562 | } 563 | -------------------------------------------------------------------------------- /020-indexing-exercise.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "%matplotlib inline\n", 10 | "import numpy as np\n", 11 | "from matplotlib import pyplot as plt" 12 | ] 13 | }, 14 | { 15 | "cell_type": "markdown", 16 | "metadata": {}, 17 | "source": [ 18 | "# Exercise: Indexing and Slicing\n", 19 | "\n", 20 | "Use `imread(filename)` to load an image file:" 21 | ] 22 | }, 23 | { 24 | "cell_type": "code", 25 | "execution_count": null, 26 | "metadata": {}, 27 | "outputs": [], 28 | "source": [ 29 | "a = plt.imread(\"pencils.jpeg\")" 30 | ] 31 | }, 32 | { 33 | "cell_type": "code", 34 | "execution_count": null, 35 | "metadata": {}, 36 | "outputs": [], 37 | "source": [ 38 | "a.shape, a.dtype" 39 | ] 40 | }, 41 | { 42 | "cell_type": "code", 43 | "execution_count": null, 44 | "metadata": {}, 45 | "outputs": [], 46 | "source": [ 47 | "plt.imshow(a);" 48 | ] 49 | }, 50 | { 51 | "cell_type": "markdown", 52 | "metadata": {}, 53 | "source": [ 54 | "## Part 0: show only this part of the image\n", 55 | "![partial image](pencils-part.png)\n", 56 | "\n" 57 | ] 58 | }, 59 | { 60 | "cell_type": "code", 61 | "execution_count": null, 62 | "metadata": {}, 63 | "outputs": [], 64 | "source": [] 65 | }, 66 | { 67 | "cell_type": "markdown", 68 | "metadata": {}, 69 | "source": [ 70 | "## Part 1: Show the image flipped vertically" 71 | ] 72 | }, 73 | { 74 | "cell_type": "code", 75 | "execution_count": null, 76 | "metadata": { 77 | "scrolled": true 78 | }, 79 | "outputs": [], 80 | "source": [] 81 | }, 82 | { 83 | "cell_type": "markdown", 84 | "metadata": {}, 85 | "source": [ 86 | "## Part 2: Show the image flipped horizontally" 87 | ] 88 | }, 89 | { 90 | "cell_type": "code", 91 | "execution_count": null, 92 | "metadata": {}, 93 | "outputs": [], 94 | "source": [] 95 | }, 96 | { 97 | "cell_type": "markdown", 98 | "metadata": {}, 99 | "source": [ 100 | "## Part 3: Show channels r,g and b \n" 101 | ] 102 | }, 103 | { 104 | "cell_type": "code", 105 | "execution_count": null, 106 | "metadata": {}, 107 | "outputs": [], 108 | "source": [] 109 | }, 110 | { 111 | "cell_type": "markdown", 112 | "metadata": {}, 113 | "source": [ 114 | "* (Bonus 1: Do the same, using a loop. Use `plt.show()` to show the current figure and start a new figure. Use `plt.title()` to show a title )\n", 115 | "* (Bonus 2: Use `imshow(..., vmin=..., vmax=...)` to disable normalization and stretch the scale.)" 116 | ] 117 | }, 118 | { 119 | "cell_type": "code", 120 | "execution_count": null, 121 | "metadata": {}, 122 | "outputs": [], 123 | "source": [] 124 | }, 125 | { 126 | "cell_type": "markdown", 127 | "metadata": {}, 128 | "source": [ 129 | "## Part 4: Show the image with channels R and B swapped." 130 | ] 131 | }, 132 | { 133 | "cell_type": "code", 134 | "execution_count": null, 135 | "metadata": {}, 136 | "outputs": [], 137 | "source": [] 138 | } 139 | ], 140 | "metadata": { 141 | "kernelspec": { 142 | "display_name": "Python 3", 143 | "language": "python", 144 | "name": "python3" 145 | }, 146 | "language_info": { 147 | "codemirror_mode": { 148 | "name": "ipython", 149 | "version": 3 150 | }, 151 | "file_extension": ".py", 152 | "mimetype": "text/x-python", 153 | "name": "python", 154 | "nbconvert_exporter": "python", 155 | "pygments_lexer": "ipython3", 156 | "version": "3.8.1" 157 | } 158 | }, 159 | "nbformat": 4, 160 | "nbformat_minor": 4 161 | } 162 | -------------------------------------------------------------------------------- /025-fancy-indexing.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import numpy as np" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "# Advanced Indexing (Fancy Indexing)" 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": 2, 22 | "metadata": {}, 23 | "outputs": [ 24 | { 25 | "data": { 26 | "text/plain": [ 27 | "array([12, 34, 56, 78, 90])" 28 | ] 29 | }, 30 | "execution_count": 2, 31 | "metadata": {}, 32 | "output_type": "execute_result" 33 | } 34 | ], 35 | "source": [ 36 | "a = np.array([12, 34, 56, 78, 90])\n", 37 | "a" 38 | ] 39 | }, 40 | { 41 | "cell_type": "markdown", 42 | "metadata": {}, 43 | "source": [ 44 | "## Advanced Indexing: Integers\n", 45 | "Advanced inexing can be triggered by using a list or an array while idexing:" 46 | ] 47 | }, 48 | { 49 | "cell_type": "code", 50 | "execution_count": 3, 51 | "metadata": {}, 52 | "outputs": [ 53 | { 54 | "data": { 55 | "text/plain": [ 56 | "array([12, 78, 90])" 57 | ] 58 | }, 59 | "execution_count": 3, 60 | "metadata": {}, 61 | "output_type": "execute_result" 62 | } 63 | ], 64 | "source": [ 65 | "a[[0, 3, 4]]" 66 | ] 67 | }, 68 | { 69 | "cell_type": "code", 70 | "execution_count": 4, 71 | "metadata": {}, 72 | "outputs": [ 73 | { 74 | "data": { 75 | "text/plain": [ 76 | "array([12, 78, 90])" 77 | ] 78 | }, 79 | "execution_count": 4, 80 | "metadata": {}, 81 | "output_type": "execute_result" 82 | } 83 | ], 84 | "source": [ 85 | "# the same:\n", 86 | "take = [0, 3, 4]\n", 87 | "a[take]" 88 | ] 89 | }, 90 | { 91 | "cell_type": "code", 92 | "execution_count": 5, 93 | "metadata": {}, 94 | "outputs": [ 95 | { 96 | "data": { 97 | "text/plain": [ 98 | "array([12, 78, 90])" 99 | ] 100 | }, 101 | "execution_count": 5, 102 | "metadata": {}, 103 | "output_type": "execute_result" 104 | } 105 | ], 106 | "source": [ 107 | "take = np.array([0, 3, 4])\n", 108 | "a[take]" 109 | ] 110 | }, 111 | { 112 | "cell_type": "markdown", 113 | "metadata": {}, 114 | "source": [ 115 | "The same index value can bu used more than once, to construct a new array in the same shape as the supplied list:" 116 | ] 117 | }, 118 | { 119 | "cell_type": "code", 120 | "execution_count": 6, 121 | "metadata": {}, 122 | "outputs": [ 123 | { 124 | "data": { 125 | "text/plain": [ 126 | "array([12, 34, 12, 56])" 127 | ] 128 | }, 129 | "execution_count": 6, 130 | "metadata": {}, 131 | "output_type": "execute_result" 132 | } 133 | ], 134 | "source": [ 135 | "a[[0, 1, 0, 2]]" 136 | ] 137 | }, 138 | { 139 | "cell_type": "code", 140 | "execution_count": 7, 141 | "metadata": {}, 142 | "outputs": [ 143 | { 144 | "name": "stdout", 145 | "output_type": "stream", 146 | "text": [ 147 | "(12,)\n", 148 | "[56 12 34 12 34 34 34 34 12 56 12 90]\n", 149 | "(12,)\n" 150 | ] 151 | } 152 | ], 153 | "source": [ 154 | "take = np.array([2, 0, 1, 0, 1, 1, 1, 1, 0, 2, 0, 4])\n", 155 | "print(take.shape)\n", 156 | "print(a[take])\n", 157 | "print(a[take].shape)" 158 | ] 159 | }, 160 | { 161 | "cell_type": "markdown", 162 | "metadata": {}, 163 | "source": [ 164 | "This works with multidimensional arrays as well!" 165 | ] 166 | }, 167 | { 168 | "cell_type": "code", 169 | "execution_count": 8, 170 | "metadata": {}, 171 | "outputs": [ 172 | { 173 | "data": { 174 | "text/plain": [ 175 | "array([[12, 34, 12],\n", 176 | " [34, 56, 34],\n", 177 | " [12, 34, 12]])" 178 | ] 179 | }, 180 | "execution_count": 8, 181 | "metadata": {}, 182 | "output_type": "execute_result" 183 | } 184 | ], 185 | "source": [ 186 | "take2 = np.array([\n", 187 | " [0, 1, 0], \n", 188 | " [1, 2, 1], \n", 189 | " [0, 1, 0],\n", 190 | "])\n", 191 | "a[take2]" 192 | ] 193 | }, 194 | { 195 | "cell_type": "markdown", 196 | "metadata": {}, 197 | "source": [ 198 | "Note: the examples above used a 1-d list or an array to trigger advanced indexing.\n", 199 | "Advanced indxing can be triggered even with a tuple for any axis containing a sequence:" 200 | ] 201 | }, 202 | { 203 | "cell_type": "code", 204 | "execution_count": 9, 205 | "metadata": {}, 206 | "outputs": [ 207 | { 208 | "data": { 209 | "text/plain": [ 210 | "array([[12, 34],\n", 211 | " [56, 34]])" 212 | ] 213 | }, 214 | "execution_count": 9, 215 | "metadata": {}, 216 | "output_type": "execute_result" 217 | } 218 | ], 219 | "source": [ 220 | "take2 = ([[0, 1], [2, 1]],)\n", 221 | "a[take2]" 222 | ] 223 | }, 224 | { 225 | "cell_type": "markdown", 226 | "metadata": {}, 227 | "source": [ 228 | "Important! In contrary to slices, fancy indexing always returns a COPY (and not a view) of the array:" 229 | ] 230 | }, 231 | { 232 | "cell_type": "code", 233 | "execution_count": 10, 234 | "metadata": {}, 235 | "outputs": [ 236 | { 237 | "data": { 238 | "text/plain": [ 239 | "False" 240 | ] 241 | }, 242 | "execution_count": 10, 243 | "metadata": {}, 244 | "output_type": "execute_result" 245 | } 246 | ], 247 | "source": [ 248 | "a[1:3].flags['OWNDATA']" 249 | ] 250 | }, 251 | { 252 | "cell_type": "code", 253 | "execution_count": 11, 254 | "metadata": {}, 255 | "outputs": [ 256 | { 257 | "data": { 258 | "text/plain": [ 259 | "True" 260 | ] 261 | }, 262 | "execution_count": 11, 263 | "metadata": {}, 264 | "output_type": "execute_result" 265 | } 266 | ], 267 | "source": [ 268 | "a[[1,3]].flags['OWNDATA']" 269 | ] 270 | }, 271 | { 272 | "cell_type": "markdown", 273 | "metadata": {}, 274 | "source": [ 275 | "## Fancy Indexing on Multi Dimensionsnal arrays" 276 | ] 277 | }, 278 | { 279 | "cell_type": "code", 280 | "execution_count": 12, 281 | "metadata": {}, 282 | "outputs": [ 283 | { 284 | "data": { 285 | "text/plain": [ 286 | "array([[ 0, 10, 20, 30, 40, 50, 60, 70, 80, 90],\n", 287 | " [100, 110, 120, 130, 140, 150, 160, 170, 180, 190],\n", 288 | " [200, 210, 220, 230, 240, 250, 260, 270, 280, 290],\n", 289 | " [300, 310, 320, 330, 340, 350, 360, 370, 380, 390],\n", 290 | " [400, 410, 420, 430, 440, 450, 460, 470, 480, 490]])" 291 | ] 292 | }, 293 | "execution_count": 12, 294 | "metadata": {}, 295 | "output_type": "execute_result" 296 | } 297 | ], 298 | "source": [ 299 | "b = np.arange(50).reshape(5, -1) * 10\n", 300 | "b" 301 | ] 302 | }, 303 | { 304 | "cell_type": "code", 305 | "execution_count": 13, 306 | "metadata": {}, 307 | "outputs": [ 308 | { 309 | "data": { 310 | "text/plain": [ 311 | "130" 312 | ] 313 | }, 314 | "execution_count": 13, 315 | "metadata": {}, 316 | "output_type": "execute_result" 317 | } 318 | ], 319 | "source": [ 320 | "b[1, 3]" 321 | ] 322 | }, 323 | { 324 | "cell_type": "code", 325 | "execution_count": 14, 326 | "metadata": {}, 327 | "outputs": [ 328 | { 329 | "data": { 330 | "text/plain": [ 331 | "250" 332 | ] 333 | }, 334 | "execution_count": 14, 335 | "metadata": {}, 336 | "output_type": "execute_result" 337 | } 338 | ], 339 | "source": [ 340 | "b[2, 5]" 341 | ] 342 | }, 343 | { 344 | "cell_type": "code", 345 | "execution_count": 15, 346 | "metadata": {}, 347 | "outputs": [ 348 | { 349 | "data": { 350 | "text/plain": [ 351 | "260" 352 | ] 353 | }, 354 | "execution_count": 15, 355 | "metadata": {}, 356 | "output_type": "execute_result" 357 | } 358 | ], 359 | "source": [ 360 | "b[2, 6]" 361 | ] 362 | }, 363 | { 364 | "cell_type": "markdown", 365 | "metadata": {}, 366 | "source": [ 367 | "To use fancy indexing to get items at indexes [1,3] and [2,5] and [2,6], values should be specified for each axis independently:" 368 | ] 369 | }, 370 | { 371 | "cell_type": "code", 372 | "execution_count": 16, 373 | "metadata": {}, 374 | "outputs": [ 375 | { 376 | "data": { 377 | "text/plain": [ 378 | "array([130, 250, 260])" 379 | ] 380 | }, 381 | "execution_count": 16, 382 | "metadata": {}, 383 | "output_type": "execute_result" 384 | } 385 | ], 386 | "source": [ 387 | "b[[1, 2, 2], [3, 5, 6]]" 388 | ] 389 | }, 390 | { 391 | "attachments": { 392 | "fbae1216-d476-4507-843e-0ab9f425e25d.png": { 393 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAigAAAB2CAIAAABtdP98AAAgAElEQVR4Ae1932sjy57f/gl5yD7oJT4JJo1f3A++RHiXtVjmQX6YQQ8maDjZSS/zognsoKU5IMEZISIW+t6DcsQIjnsD4grtsjKXa6LrZbFCzCKcJSNYHWgvgxHE4UovQrk+cAUXjA7eQIdvVXd19Y9qtaTulsZTYhj3z+rqz+db9a0f367P7+n8xxHgCHAEOAIcgRgR+L0Yn8UfxRHgCHAEOAIcAZ07Hm4EHAGOAEeAIxArAtzxxAo3fxhHgCPAEeAIcMfDbYAjwBHgCHAEYkWAO55Y4eYP4whwBDgCHAHueLgNcAQ4AhwBjkCsCHDHEyvc/GEcAY4AR4AjwB0PtwGOAEeAI8ARiBUB7nhihZs/jCPAEeAIcAS44+E2wBHgCHAEOAKxIsAdT6xw84dxBDgCHAGOwKfleGZapzflpHEEOAIcAY7Ap4zAJ+R45lotI6ZyXZvn6eUE85dSNBsTPqds1/EdjgBHgCPwmSEw70hmzSmka8O43/6TcTyzXj4lZGt236LrvZwg5ruz2Ww2nzuw8znluDLQ7qirSJmkKAhiWiqcDZ1PC5RG0Ivmw24tlxEFId9z3DLt1XKZFOQilc03tZnjdIi7036zIKWTgiAk01K5M6KTnmnNfBbnIpOr9W1NAfq6tbdnvbKUBtAFMZmWCvYXjpMR9CajZhbKakalwYiNEU1JkZoCbeS6Fr6xMYIeOe03y1IWE0O392JipJe3A+FAIzZG9Ll2BvYJz0+msnmVLgkxMjLsmFUTZMJWKVg5TKYlpUsbrj6fQ72p1TLc8VgFybE17xdSQsbDL4N3KfQdV+Ndn1Oe1/sdnHVySSGda/a1odZTpaQgSp2IqtvhWT4jCmIm63Y8CIWUVOtpQ63fzKcFIatG1FSZdXPJdK7W1TSt3ylnRCFVJj4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AiJ9+qghwx/NUmeXvtf0IcMez/RzxHEaCAHc8kcDKE+UIBEBg40M9QeYXP9/hoAAM8ktWRIA7nhWB47dxBDgCHAGOwGoIcMezGm78Lo4AR4AjwBFYEQHueFYEjt/GEeAIcAQ4AqshwB3ParjxuzgCHAGOAEdgRQS441kROH4bR4AjwBHgCKyGAHc8q+HG7+IIcAQ4AhyBFRHgjmdF4PhtHAGOAEeAI7AaAtzxrIYbv4sjwBHgCHAEVkSAO54VgeO3cQQ4AhwBjsBqCPx/QDre6XBOi+0AAAAASUVORK5CYII=" 394 | } 395 | }, 396 | "cell_type": "markdown", 397 | "metadata": {}, 398 | "source": [ 399 | "## Bonus: Advanced Fancy Indexing\n", 400 | "Let's say we want to get the data from rows 1,2,3 and columns 1,2,5,6,8:\n", 401 | "\n", 402 | "![image.png](attachment:fbae1216-d476-4507-843e-0ab9f425e25d.png)\n", 403 | "\n", 404 | "This will not work:" 405 | ] 406 | }, 407 | { 408 | "cell_type": "code", 409 | "execution_count": 17, 410 | "metadata": {}, 411 | "outputs": [ 412 | { 413 | "ename": "IndexError", 414 | "evalue": "shape mismatch: indexing arrays could not be broadcast together with shapes (3,) (5,) ", 415 | "output_type": "error", 416 | "traceback": [ 417 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 418 | "\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)", 419 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mb\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m6\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m8\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 420 | "\u001b[0;31mIndexError\u001b[0m: shape mismatch: indexing arrays could not be broadcast together with shapes (3,) (5,) " 421 | ] 422 | } 423 | ], 424 | "source": [ 425 | "b[[1,2,3], [1,2,5,6,8]]" 426 | ] 427 | }, 428 | { 429 | "cell_type": "markdown", 430 | "metadata": {}, 431 | "source": [ 432 | "This shortcut works, but it's considered complicated:" 433 | ] 434 | }, 435 | { 436 | "cell_type": "code", 437 | "execution_count": 18, 438 | "metadata": {}, 439 | "outputs": [ 440 | { 441 | "data": { 442 | "text/plain": [ 443 | "array([[110, 120, 150, 160, 180],\n", 444 | " [210, 220, 250, 260, 280],\n", 445 | " [310, 320, 350, 360, 380]])" 446 | ] 447 | }, 448 | "execution_count": 18, 449 | "metadata": {}, 450 | "output_type": "execute_result" 451 | } 452 | ], 453 | "source": [ 454 | "b[[1,2,3]][:,[1,2,5,6,8]]" 455 | ] 456 | }, 457 | { 458 | "cell_type": "markdown", 459 | "metadata": {}, 460 | "source": [ 461 | "Instead it is more common to use `np.ix_`:" 462 | ] 463 | }, 464 | { 465 | "cell_type": "code", 466 | "execution_count": 19, 467 | "metadata": {}, 468 | "outputs": [ 469 | { 470 | "data": { 471 | "text/plain": [ 472 | "(array([[1],\n", 473 | " [2],\n", 474 | " [3]]),\n", 475 | " array([[1, 2, 5, 6, 8]]))" 476 | ] 477 | }, 478 | "execution_count": 19, 479 | "metadata": {}, 480 | "output_type": "execute_result" 481 | } 482 | ], 483 | "source": [ 484 | "np.ix_([1,2,3], [1,2,5,6,8])" 485 | ] 486 | }, 487 | { 488 | "cell_type": "markdown", 489 | "metadata": {}, 490 | "source": [ 491 | "This result looks strange - but it can be used to fancy select across axes:" 492 | ] 493 | }, 494 | { 495 | "cell_type": "code", 496 | "execution_count": 20, 497 | "metadata": {}, 498 | "outputs": [ 499 | { 500 | "data": { 501 | "text/plain": [ 502 | "array([[110, 120, 150, 160, 180],\n", 503 | " [210, 220, 250, 260, 280],\n", 504 | " [310, 320, 350, 360, 380]])" 505 | ] 506 | }, 507 | "execution_count": 20, 508 | "metadata": {}, 509 | "output_type": "execute_result" 510 | } 511 | ], 512 | "source": [ 513 | "b[np.ix_([1,2,3], [1,2,5,6,8])]" 514 | ] 515 | } 516 | ], 517 | "metadata": { 518 | "kernelspec": { 519 | "display_name": "Python 3", 520 | "language": "python", 521 | "name": "python3" 522 | }, 523 | "language_info": { 524 | "codemirror_mode": { 525 | "name": "ipython", 526 | "version": 3 527 | }, 528 | "file_extension": ".py", 529 | "mimetype": "text/x-python", 530 | "name": "python", 531 | "nbconvert_exporter": "python", 532 | "pygments_lexer": "ipython3", 533 | "version": "3.8.2" 534 | } 535 | }, 536 | "nbformat": 4, 537 | "nbformat_minor": 4 538 | } 539 | -------------------------------------------------------------------------------- /030-array-array-operations.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import numpy as np" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "# Operations on arrays with the same size" 17 | ] 18 | }, 19 | { 20 | "cell_type": "markdown", 21 | "metadata": {}, 22 | "source": [ 23 | "## Arithmetic operations" 24 | ] 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": 2, 29 | "metadata": {}, 30 | "outputs": [], 31 | "source": [ 32 | "a1 = np.arange(20)\n", 33 | "a2 = np.linspace(100,200,20)" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": 3, 39 | "metadata": {}, 40 | "outputs": [ 41 | { 42 | "data": { 43 | "text/plain": [ 44 | "array([ 0. , 105.26315789, 221.05263158, 347.36842105,\n", 45 | " 484.21052632, 631.57894737, 789.47368421, 957.89473684,\n", 46 | " 1136.84210526, 1326.31578947, 1526.31578947, 1736.84210526,\n", 47 | " 1957.89473684, 2189.47368421, 2431.57894737, 2684.21052632,\n", 48 | " 2947.36842105, 3221.05263158, 3505.26315789, 3800. ])" 49 | ] 50 | }, 51 | "execution_count": 3, 52 | "metadata": {}, 53 | "output_type": "execute_result" 54 | } 55 | ], 56 | "source": [ 57 | "a1 * a2" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": 4, 63 | "metadata": {}, 64 | "outputs": [ 65 | { 66 | "data": { 67 | "text/plain": [ 68 | "array([100. , 106.26315789, 112.52631579, 118.78947368,\n", 69 | " 125.05263158, 131.31578947, 137.57894737, 143.84210526,\n", 70 | " 150.10526316, 156.36842105, 162.63157895, 168.89473684,\n", 71 | " 175.15789474, 181.42105263, 187.68421053, 193.94736842,\n", 72 | " 200.21052632, 206.47368421, 212.73684211, 219. ])" 73 | ] 74 | }, 75 | "execution_count": 4, 76 | "metadata": {}, 77 | "output_type": "execute_result" 78 | } 79 | ], 80 | "source": [ 81 | "a1 + a2" 82 | ] 83 | }, 84 | { 85 | "cell_type": "code", 86 | "execution_count": 5, 87 | "metadata": {}, 88 | "outputs": [ 89 | { 90 | "data": { 91 | "text/plain": [ 92 | "array([100. , 106.26315789, 112.52631579, 118.78947368,\n", 93 | " 125.05263158, 131.31578947, 137.57894737, 143.84210526,\n", 94 | " 150.10526316, 156.36842105, 162.63157895, 168.89473684,\n", 95 | " 175.15789474, 181.42105263, 187.68421053, 193.94736842,\n", 96 | " 200.21052632, 206.47368421, 212.73684211, 219. ])" 97 | ] 98 | }, 99 | "execution_count": 5, 100 | "metadata": {}, 101 | "output_type": "execute_result" 102 | } 103 | ], 104 | "source": [ 105 | "np.add(a1, a2) # same" 106 | ] 107 | }, 108 | { 109 | "cell_type": "markdown", 110 | "metadata": {}, 111 | "source": [ 112 | "## Comparison Operations" 113 | ] 114 | }, 115 | { 116 | "cell_type": "code", 117 | "execution_count": 6, 118 | "metadata": {}, 119 | "outputs": [], 120 | "source": [ 121 | "a3 = np.random.randint(5, size=15)\n", 122 | "a4 = np.random.randint(5, size=15)" 123 | ] 124 | }, 125 | { 126 | "cell_type": "code", 127 | "execution_count": 7, 128 | "metadata": {}, 129 | "outputs": [ 130 | { 131 | "name": "stdout", 132 | "output_type": "stream", 133 | "text": [ 134 | "[3 4 1 3 1 4 1 0 0 4 4 4 3 4 0]\n", 135 | "[2 1 0 1 1 4 2 2 1 0 2 2 1 3 1]\n", 136 | "[False False False False True True False False False False False False\n", 137 | " False False False]\n", 138 | "[False False False False False False True True True False False False\n", 139 | " False False True]\n", 140 | "[ True True True True True True False False False True True True\n", 141 | " True True False]\n" 142 | ] 143 | } 144 | ], 145 | "source": [ 146 | "print(a3)\n", 147 | "print(a4)\n", 148 | "print(a3 == a4)\n", 149 | "print(a3 < a4)\n", 150 | "print(a3 >= a4)" 151 | ] 152 | }, 153 | { 154 | "cell_type": "code", 155 | "execution_count": 8, 156 | "metadata": {}, 157 | "outputs": [], 158 | "source": [ 159 | "a3 = np.random.randint(5, size=(4, 6))\n", 160 | "a4 = np.random.randint(5, size=(4, 6))" 161 | ] 162 | }, 163 | { 164 | "cell_type": "code", 165 | "execution_count": 9, 166 | "metadata": {}, 167 | "outputs": [ 168 | { 169 | "name": "stdout", 170 | "output_type": "stream", 171 | "text": [ 172 | "[[3 0 0 3 0 2]\n", 173 | " [3 1 0 0 0 1]\n", 174 | " [2 0 1 2 4 1]\n", 175 | " [4 1 2 3 1 1]]\n", 176 | "[[1 4 1 0 3 0]\n", 177 | " [1 2 0 4 0 4]\n", 178 | " [2 4 2 3 1 0]\n", 179 | " [2 4 0 0 3 1]]\n", 180 | "[[False False False False False False]\n", 181 | " [False False True False True False]\n", 182 | " [ True False False False False False]\n", 183 | " [False False False False False True]]\n", 184 | "[[False True True False True False]\n", 185 | " [False True False True False True]\n", 186 | " [False True True True False False]\n", 187 | " [False True False False True False]]\n", 188 | "[[ True False False True False True]\n", 189 | " [ True False True False True False]\n", 190 | " [ True False False False True True]\n", 191 | " [ True False True True False True]]\n" 192 | ] 193 | } 194 | ], 195 | "source": [ 196 | "print(a3)\n", 197 | "print(a4)\n", 198 | "print(a3 == a4)\n", 199 | "print(a3 < a4)\n", 200 | "print(a3 >= a4)" 201 | ] 202 | }, 203 | { 204 | "cell_type": "markdown", 205 | "metadata": {}, 206 | "source": [ 207 | "### Note regarding scalar multiplication" 208 | ] 209 | }, 210 | { 211 | "cell_type": "code", 212 | "execution_count": 10, 213 | "metadata": {}, 214 | "outputs": [ 215 | { 216 | "data": { 217 | "text/plain": [ 218 | "array([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],\n", 219 | " [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],\n", 220 | " [20, 21, 22, 23, 24, 25, 26, 27, 28, 29],\n", 221 | " [30, 31, 32, 33, 34, 35, 36, 37, 38, 39],\n", 222 | " [40, 41, 42, 43, 44, 45, 46, 47, 48, 49],\n", 223 | " [50, 51, 52, 53, 54, 55, 56, 57, 58, 59],\n", 224 | " [60, 61, 62, 63, 64, 65, 66, 67, 68, 69],\n", 225 | " [70, 71, 72, 73, 74, 75, 76, 77, 78, 79],\n", 226 | " [80, 81, 82, 83, 84, 85, 86, 87, 88, 89],\n", 227 | " [90, 91, 92, 93, 94, 95, 96, 97, 98, 99]])" 228 | ] 229 | }, 230 | "execution_count": 10, 231 | "metadata": {}, 232 | "output_type": "execute_result" 233 | } 234 | ], 235 | "source": [ 236 | "a5 = np.arange(100).reshape(10,10)\n", 237 | "a5" 238 | ] 239 | }, 240 | { 241 | "cell_type": "code", 242 | "execution_count": 11, 243 | "metadata": {}, 244 | "outputs": [ 245 | { 246 | "data": { 247 | "text/plain": [ 248 | "array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", 249 | " [0, 1, 0, 0, 0, 0, 0, 0, 0, 0],\n", 250 | " [0, 0, 2, 0, 0, 0, 0, 0, 0, 0],\n", 251 | " [0, 0, 0, 3, 0, 0, 0, 0, 0, 0],\n", 252 | " [0, 0, 0, 0, 4, 0, 0, 0, 0, 0],\n", 253 | " [0, 0, 0, 0, 0, 5, 0, 0, 0, 0],\n", 254 | " [0, 0, 0, 0, 0, 0, 6, 0, 0, 0],\n", 255 | " [0, 0, 0, 0, 0, 0, 0, 7, 0, 0],\n", 256 | " [0, 0, 0, 0, 0, 0, 0, 0, 8, 0],\n", 257 | " [0, 0, 0, 0, 0, 0, 0, 0, 0, 9]])" 258 | ] 259 | }, 260 | "execution_count": 11, 261 | "metadata": {}, 262 | "output_type": "execute_result" 263 | } 264 | ], 265 | "source": [ 266 | "a6 = np.diag(np.arange(10))\n", 267 | "a6" 268 | ] 269 | }, 270 | { 271 | "cell_type": "code", 272 | "execution_count": 12, 273 | "metadata": {}, 274 | "outputs": [ 275 | { 276 | "data": { 277 | "text/plain": [ 278 | "array([[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", 279 | " [ 0, 11, 0, 0, 0, 0, 0, 0, 0, 0],\n", 280 | " [ 0, 0, 44, 0, 0, 0, 0, 0, 0, 0],\n", 281 | " [ 0, 0, 0, 99, 0, 0, 0, 0, 0, 0],\n", 282 | " [ 0, 0, 0, 0, 176, 0, 0, 0, 0, 0],\n", 283 | " [ 0, 0, 0, 0, 0, 275, 0, 0, 0, 0],\n", 284 | " [ 0, 0, 0, 0, 0, 0, 396, 0, 0, 0],\n", 285 | " [ 0, 0, 0, 0, 0, 0, 0, 539, 0, 0],\n", 286 | " [ 0, 0, 0, 0, 0, 0, 0, 0, 704, 0],\n", 287 | " [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 891]])" 288 | ] 289 | }, 290 | "execution_count": 12, 291 | "metadata": {}, 292 | "output_type": "execute_result" 293 | } 294 | ], 295 | "source": [ 296 | "a5 * a6 # scalar multiplication" 297 | ] 298 | } 299 | ], 300 | "metadata": { 301 | "kernelspec": { 302 | "display_name": "Python 3", 303 | "language": "python", 304 | "name": "python3" 305 | }, 306 | "language_info": { 307 | "codemirror_mode": { 308 | "name": "ipython", 309 | "version": 3 310 | }, 311 | "file_extension": ".py", 312 | "mimetype": "text/x-python", 313 | "name": "python", 314 | "nbconvert_exporter": "python", 315 | "pygments_lexer": "ipython3", 316 | "version": "3.8.1" 317 | } 318 | }, 319 | "nbformat": 4, 320 | "nbformat_minor": 4 321 | } 322 | -------------------------------------------------------------------------------- /032-array-multlipication.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import numpy as np" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "# Matrix Product\n", 17 | "* Simple usage: 2D arrays with shapes `(n,k)`,`(k,m)` -> `(n,m)`" 18 | ] 19 | }, 20 | { 21 | "cell_type": "code", 22 | "execution_count": 2, 23 | "metadata": {}, 24 | "outputs": [ 25 | { 26 | "data": { 27 | "text/plain": [ 28 | "array([[ 2010, 20100],\n", 29 | " [ 4030, 40300]])" 30 | ] 31 | }, 32 | "execution_count": 2, 33 | "metadata": {}, 34 | "output_type": "execute_result" 35 | } 36 | ], 37 | "source": [ 38 | "np.matmul([[1,2],\n", 39 | " [3,4]],\n", 40 | " [[10,100],\n", 41 | " [1000,10000]])" 42 | ] 43 | }, 44 | { 45 | "cell_type": "markdown", 46 | "metadata": {}, 47 | "source": [ 48 | "Or by using the `@` operator:" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": 3, 54 | "metadata": {}, 55 | "outputs": [ 56 | { 57 | "data": { 58 | "text/plain": [ 59 | "array([[ 2010, 20100],\n", 60 | " [ 4030, 40300]])" 61 | ] 62 | }, 63 | "execution_count": 3, 64 | "metadata": {}, 65 | "output_type": "execute_result" 66 | } 67 | ], 68 | "source": [ 69 | "a = np.array([[1, 2],\n", 70 | " [3, 4]])\n", 71 | "b = np.array([[10, 100],\n", 72 | " [1000, 10000]])\n", 73 | "a @ b" 74 | ] 75 | }, 76 | { 77 | "cell_type": "code", 78 | "execution_count": 4, 79 | "metadata": {}, 80 | "outputs": [ 81 | { 82 | "name": "stdout", 83 | "output_type": "stream", 84 | "text": [ 85 | "[[ 0 1 2 3 4 5 6 7 8 9]\n", 86 | " [10 11 12 13 14 15 16 17 18 19]\n", 87 | " [20 21 22 23 24 25 26 27 28 29]\n", 88 | " [30 31 32 33 34 35 36 37 38 39]\n", 89 | " [40 41 42 43 44 45 46 47 48 49]\n", 90 | " [50 51 52 53 54 55 56 57 58 59]\n", 91 | " [60 61 62 63 64 65 66 67 68 69]\n", 92 | " [70 71 72 73 74 75 76 77 78 79]\n", 93 | " [80 81 82 83 84 85 86 87 88 89]\n", 94 | " [90 91 92 93 94 95 96 97 98 99]]\n", 95 | "[[0 0 0 0 0 0 0 0 0 0]\n", 96 | " [0 1 0 0 0 0 0 0 0 0]\n", 97 | " [0 0 2 0 0 0 0 0 0 0]\n", 98 | " [0 0 0 3 0 0 0 0 0 0]\n", 99 | " [0 0 0 0 4 0 0 0 0 0]\n", 100 | " [0 0 0 0 0 5 0 0 0 0]\n", 101 | " [0 0 0 0 0 0 6 0 0 0]\n", 102 | " [0 0 0 0 0 0 0 7 0 0]\n", 103 | " [0 0 0 0 0 0 0 0 8 0]\n", 104 | " [0 0 0 0 0 0 0 0 0 9]]\n", 105 | "[[ 0 1 4 9 16 25 36 49 64 81]\n", 106 | " [ 0 11 24 39 56 75 96 119 144 171]\n", 107 | " [ 0 21 44 69 96 125 156 189 224 261]\n", 108 | " [ 0 31 64 99 136 175 216 259 304 351]\n", 109 | " [ 0 41 84 129 176 225 276 329 384 441]\n", 110 | " [ 0 51 104 159 216 275 336 399 464 531]\n", 111 | " [ 0 61 124 189 256 325 396 469 544 621]\n", 112 | " [ 0 71 144 219 296 375 456 539 624 711]\n", 113 | " [ 0 81 164 249 336 425 516 609 704 801]\n", 114 | " [ 0 91 184 279 376 475 576 679 784 891]]\n" 115 | ] 116 | } 117 | ], 118 | "source": [ 119 | "c = np.arange(100).reshape(10,10)\n", 120 | "print(c)\n", 121 | "d = np.diag(np.arange(10))\n", 122 | "print(d)\n", 123 | "print(c @ d)" 124 | ] 125 | }, 126 | { 127 | "cell_type": "markdown", 128 | "metadata": {}, 129 | "source": [ 130 | "Another example: `(3,1)` @ `(1,3)` -> `(3,3)`" 131 | ] 132 | }, 133 | { 134 | "cell_type": "code", 135 | "execution_count": 5, 136 | "metadata": {}, 137 | "outputs": [ 138 | { 139 | "data": { 140 | "text/plain": [ 141 | "array([[ 100, 1000, 10000],\n", 142 | " [ 200, 2000, 20000],\n", 143 | " [ 300, 3000, 30000]])" 144 | ] 145 | }, 146 | "execution_count": 5, 147 | "metadata": {}, 148 | "output_type": "execute_result" 149 | } 150 | ], 151 | "source": [ 152 | "np.matmul([[1],\n", 153 | " [2],\n", 154 | " [3]],\n", 155 | " [[100, 1000, 10000]])" 156 | ] 157 | }, 158 | { 159 | "cell_type": "markdown", 160 | "metadata": {}, 161 | "source": [ 162 | "Another example: `(3,2)` @ `(2,3)` -> `(3,3)`" 163 | ] 164 | }, 165 | { 166 | "cell_type": "code", 167 | "execution_count": 6, 168 | "metadata": {}, 169 | "outputs": [ 170 | { 171 | "data": { 172 | "text/plain": [ 173 | "array([[ 2001, 20010, 200100],\n", 174 | " [ 4003, 40030, 400300],\n", 175 | " [ 6005, 60050, 600500]])" 176 | ] 177 | }, 178 | "execution_count": 6, 179 | "metadata": {}, 180 | "output_type": "execute_result" 181 | } 182 | ], 183 | "source": [ 184 | "np.matmul([[1,2],\n", 185 | " [3,4],\n", 186 | " [5,6]],\n", 187 | " [[1, 10, 100],\n", 188 | " [1000, 10000, 100000]])" 189 | ] 190 | }, 191 | { 192 | "cell_type": "code", 193 | "execution_count": 7, 194 | "metadata": {}, 195 | "outputs": [ 196 | { 197 | "data": { 198 | "text/plain": [ 199 | "array([[ 100, 1000],\n", 200 | " [ 200, 2000]])" 201 | ] 202 | }, 203 | "execution_count": 7, 204 | "metadata": {}, 205 | "output_type": "execute_result" 206 | } 207 | ], 208 | "source": [ 209 | "np.matmul([[1],\n", 210 | " [2]],\n", 211 | " [[100,1000]])" 212 | ] 213 | }, 214 | { 215 | "cell_type": "code", 216 | "execution_count": 8, 217 | "metadata": {}, 218 | "outputs": [ 219 | { 220 | "data": { 221 | "text/plain": [ 222 | "array([[ 3020, 30200]])" 223 | ] 224 | }, 225 | "execution_count": 8, 226 | "metadata": {}, 227 | "output_type": "execute_result" 228 | } 229 | ], 230 | "source": [ 231 | "np.matmul([[2, 3]],\n", 232 | " [[10, 100],\n", 233 | " [1000, 10000]])\n" 234 | ] 235 | }, 236 | { 237 | "cell_type": "markdown", 238 | "metadata": {}, 239 | "source": [ 240 | "1D for a first parameter:`(k)` becomes `(1,k)`, but the `(1,*)` is removed from the result: `(k)`@`(k, m)` ---> `(1, k)`@`(k, m)` => `(1,m)` ---> `(m)" 241 | ] 242 | }, 243 | { 244 | "cell_type": "code", 245 | "execution_count": 9, 246 | "metadata": {}, 247 | "outputs": [ 248 | { 249 | "data": { 250 | "text/plain": [ 251 | "array([ 3020, 30200])" 252 | ] 253 | }, 254 | "execution_count": 9, 255 | "metadata": {}, 256 | "output_type": "execute_result" 257 | } 258 | ], 259 | "source": [ 260 | "np.matmul([2, 3],\n", 261 | " [[10, 100],\n", 262 | " [1000, 10000]])" 263 | ] 264 | }, 265 | { 266 | "cell_type": "markdown", 267 | "metadata": {}, 268 | "source": [ 269 | "1D for a second parameter: `(k)` becomes `(k, 1)`, but the `(*, 1)` is removed from the result: \n", 270 | " `(n, k)`@`(k)` ---> `(n, k)`@`(k, 1)` => `(n, 1)` ---> `(n) " 271 | ] 272 | }, 273 | { 274 | "cell_type": "code", 275 | "execution_count": 10, 276 | "metadata": {}, 277 | "outputs": [ 278 | { 279 | "data": { 280 | "text/plain": [ 281 | "array([[ 320],\n", 282 | " [32000]])" 283 | ] 284 | }, 285 | "execution_count": 10, 286 | "metadata": {}, 287 | "output_type": "execute_result" 288 | } 289 | ], 290 | "source": [ 291 | "np.matmul([[10, 100],\n", 292 | " [1000, 10000]], \n", 293 | " [[2], \n", 294 | " [3]])" 295 | ] 296 | }, 297 | { 298 | "cell_type": "code", 299 | "execution_count": 11, 300 | "metadata": {}, 301 | "outputs": [ 302 | { 303 | "data": { 304 | "text/plain": [ 305 | "array([ 320, 32000])" 306 | ] 307 | }, 308 | "execution_count": 11, 309 | "metadata": {}, 310 | "output_type": "execute_result" 311 | } 312 | ], 313 | "source": [ 314 | "np.matmul([[10, 100],\n", 315 | " [1000, 10000]], \n", 316 | " [2, 3])" 317 | ] 318 | }, 319 | { 320 | "cell_type": "markdown", 321 | "metadata": {}, 322 | "source": [ 323 | "And 1DX1D gives:" 324 | ] 325 | }, 326 | { 327 | "cell_type": "code", 328 | "execution_count": 12, 329 | "metadata": {}, 330 | "outputs": [ 331 | { 332 | "data": { 333 | "text/plain": [ 334 | "array([[50]])" 335 | ] 336 | }, 337 | "execution_count": 12, 338 | "metadata": {}, 339 | "output_type": "execute_result" 340 | } 341 | ], 342 | "source": [ 343 | "np.matmul([[10, 20]],\n", 344 | " [[1],\n", 345 | " [2]])" 346 | ] 347 | }, 348 | { 349 | "cell_type": "code", 350 | "execution_count": 13, 351 | "metadata": {}, 352 | "outputs": [ 353 | { 354 | "data": { 355 | "text/plain": [ 356 | "50" 357 | ] 358 | }, 359 | "execution_count": 13, 360 | "metadata": {}, 361 | "output_type": "execute_result" 362 | } 363 | ], 364 | "source": [ 365 | "np.matmul([10,20], [1,2])" 366 | ] 367 | }, 368 | { 369 | "cell_type": "markdown", 370 | "metadata": {}, 371 | "source": [ 372 | "`np.dot()` is very similar, but has an alternative matrix product with different broadcasting rules. Refer to help for more info:" 373 | ] 374 | }, 375 | { 376 | "cell_type": "code", 377 | "execution_count": 14, 378 | "metadata": {}, 379 | "outputs": [ 380 | { 381 | "name": "stdout", 382 | "output_type": "stream", 383 | "text": [ 384 | "matmul(x1, x2, /, out=None, *, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])\n", 385 | "\n", 386 | "Matrix product of two arrays.\n", 387 | "\n", 388 | "Parameters\n", 389 | "----------\n", 390 | "x1, x2 : array_like\n", 391 | " Input arrays, scalars not allowed.\n", 392 | "out : ndarray, optional\n", 393 | " A location into which the result is stored. If provided, it must have\n", 394 | " a shape that matches the signature `(n,k),(k,m)->(n,m)`. If not\n", 395 | " provided or None, a freshly-allocated array is returned.\n", 396 | "**kwargs\n", 397 | " For other keyword-only arguments, see the\n", 398 | " :ref:`ufunc docs `.\n", 399 | "\n", 400 | " .. versionadded:: 1.16\n", 401 | " Now handles ufunc kwargs\n", 402 | "\n", 403 | "Returns\n", 404 | "-------\n", 405 | "y : ndarray\n", 406 | " The matrix product of the inputs.\n", 407 | " This is a scalar only when both x1, x2 are 1-d vectors.\n", 408 | "\n", 409 | "Raises\n", 410 | "------\n", 411 | "ValueError\n", 412 | " If the last dimension of `a` is not the same size as\n", 413 | " the second-to-last dimension of `b`.\n", 414 | "\n", 415 | " If a scalar value is passed in.\n", 416 | "\n", 417 | "See Also\n", 418 | "--------\n", 419 | "vdot : Complex-conjugating dot product.\n", 420 | "tensordot : Sum products over arbitrary axes.\n", 421 | "einsum : Einstein summation convention.\n", 422 | "dot : alternative matrix product with different broadcasting rules.\n", 423 | "\n", 424 | "Notes\n", 425 | "-----\n", 426 | "\n", 427 | "The behavior depends on the arguments in the following way.\n", 428 | "\n", 429 | "- If both arguments are 2-D they are multiplied like conventional\n", 430 | " matrices.\n", 431 | "- If either argument is N-D, N > 2, it is treated as a stack of\n", 432 | " matrices residing in the last two indexes and broadcast accordingly.\n", 433 | "- If the first argument is 1-D, it is promoted to a matrix by\n", 434 | " prepending a 1 to its dimensions. After matrix multiplication\n", 435 | " the prepended 1 is removed.\n", 436 | "- If the second argument is 1-D, it is promoted to a matrix by\n", 437 | " appending a 1 to its dimensions. After matrix multiplication\n", 438 | " the appended 1 is removed.\n", 439 | "\n", 440 | "``matmul`` differs from ``dot`` in two important ways:\n", 441 | "\n", 442 | "- Multiplication by scalars is not allowed, use ``*`` instead.\n", 443 | "- Stacks of matrices are broadcast together as if the matrices\n", 444 | " were elements, respecting the signature ``(n,k),(k,m)->(n,m)``:\n", 445 | "\n", 446 | " >>> a = np.ones([9, 5, 7, 4])\n", 447 | " >>> c = np.ones([9, 5, 4, 3])\n", 448 | " >>> np.dot(a, c).shape\n", 449 | " (9, 5, 7, 9, 5, 3)\n", 450 | " >>> np.matmul(a, c).shape\n", 451 | " (9, 5, 7, 3)\n", 452 | " >>> # n is 7, k is 4, m is 3\n", 453 | "\n", 454 | "The matmul function implements the semantics of the `@` operator introduced\n", 455 | "in Python 3.5 following PEP465.\n", 456 | "\n", 457 | "Examples\n", 458 | "--------\n", 459 | "For 2-D arrays it is the matrix product:\n", 460 | "\n", 461 | ">>> a = np.array([[1, 0],\n", 462 | "... [0, 1]])\n", 463 | ">>> b = np.array([[4, 1],\n", 464 | "... [2, 2]])\n", 465 | ">>> np.matmul(a, b)\n", 466 | "array([[4, 1],\n", 467 | " [2, 2]])\n", 468 | "\n", 469 | "For 2-D mixed with 1-D, the result is the usual.\n", 470 | "\n", 471 | ">>> a = np.array([[1, 0],\n", 472 | "... [0, 1]])\n", 473 | ">>> b = np.array([1, 2])\n", 474 | ">>> np.matmul(a, b)\n", 475 | "array([1, 2])\n", 476 | ">>> np.matmul(b, a)\n", 477 | "array([1, 2])\n", 478 | "\n", 479 | "\n", 480 | "Broadcasting is conventional for stacks of arrays\n", 481 | "\n", 482 | ">>> a = np.arange(2 * 2 * 4).reshape((2, 2, 4))\n", 483 | ">>> b = np.arange(2 * 2 * 4).reshape((2, 4, 2))\n", 484 | ">>> np.matmul(a,b).shape\n", 485 | "(2, 2, 2)\n", 486 | ">>> np.matmul(a, b)[0, 1, 1]\n", 487 | "98\n", 488 | ">>> sum(a[0, 1, :] * b[0 , :, 1])\n", 489 | "98\n", 490 | "\n", 491 | "Vector, vector returns the scalar inner product, but neither argument\n", 492 | "is complex-conjugated:\n", 493 | "\n", 494 | ">>> np.matmul([2j, 3j], [2j, 3j])\n", 495 | "(-13+0j)\n", 496 | "\n", 497 | "Scalar multiplication raises an error.\n", 498 | "\n", 499 | ">>> np.matmul([1,2], 3)\n", 500 | "Traceback (most recent call last):\n", 501 | "...\n", 502 | "ValueError: matmul: Input operand 1 does not have enough dimensions ...\n", 503 | "\n", 504 | ".. versionadded:: 1.10.0\n" 505 | ] 506 | } 507 | ], 508 | "source": [ 509 | "print(np.matmul.__doc__)" 510 | ] 511 | }, 512 | { 513 | "cell_type": "code", 514 | "execution_count": 15, 515 | "metadata": {}, 516 | "outputs": [ 517 | { 518 | "name": "stdout", 519 | "output_type": "stream", 520 | "text": [ 521 | "Help on function dot in module numpy:\n", 522 | "\n", 523 | "dot(...)\n", 524 | " dot(a, b, out=None)\n", 525 | " \n", 526 | " Dot product of two arrays. Specifically,\n", 527 | " \n", 528 | " - If both `a` and `b` are 1-D arrays, it is inner product of vectors\n", 529 | " (without complex conjugation).\n", 530 | " \n", 531 | " - If both `a` and `b` are 2-D arrays, it is matrix multiplication,\n", 532 | " but using :func:`matmul` or ``a @ b`` is preferred.\n", 533 | " \n", 534 | " - If either `a` or `b` is 0-D (scalar), it is equivalent to :func:`multiply`\n", 535 | " and using ``numpy.multiply(a, b)`` or ``a * b`` is preferred.\n", 536 | " \n", 537 | " - If `a` is an N-D array and `b` is a 1-D array, it is a sum product over\n", 538 | " the last axis of `a` and `b`.\n", 539 | " \n", 540 | " - If `a` is an N-D array and `b` is an M-D array (where ``M>=2``), it is a\n", 541 | " sum product over the last axis of `a` and the second-to-last axis of `b`::\n", 542 | " \n", 543 | " dot(a, b)[i,j,k,m] = sum(a[i,j,:] * b[k,:,m])\n", 544 | " \n", 545 | " Parameters\n", 546 | " ----------\n", 547 | " a : array_like\n", 548 | " First argument.\n", 549 | " b : array_like\n", 550 | " Second argument.\n", 551 | " out : ndarray, optional\n", 552 | " Output argument. This must have the exact kind that would be returned\n", 553 | " if it was not used. In particular, it must have the right type, must be\n", 554 | " C-contiguous, and its dtype must be the dtype that would be returned\n", 555 | " for `dot(a,b)`. This is a performance feature. Therefore, if these\n", 556 | " conditions are not met, an exception is raised, instead of attempting\n", 557 | " to be flexible.\n", 558 | " \n", 559 | " Returns\n", 560 | " -------\n", 561 | " output : ndarray\n", 562 | " Returns the dot product of `a` and `b`. If `a` and `b` are both\n", 563 | " scalars or both 1-D arrays then a scalar is returned; otherwise\n", 564 | " an array is returned.\n", 565 | " If `out` is given, then it is returned.\n", 566 | " \n", 567 | " Raises\n", 568 | " ------\n", 569 | " ValueError\n", 570 | " If the last dimension of `a` is not the same size as\n", 571 | " the second-to-last dimension of `b`.\n", 572 | " \n", 573 | " See Also\n", 574 | " --------\n", 575 | " vdot : Complex-conjugating dot product.\n", 576 | " tensordot : Sum products over arbitrary axes.\n", 577 | " einsum : Einstein summation convention.\n", 578 | " matmul : '@' operator as method with out parameter.\n", 579 | " \n", 580 | " Examples\n", 581 | " --------\n", 582 | " >>> np.dot(3, 4)\n", 583 | " 12\n", 584 | " \n", 585 | " Neither argument is complex-conjugated:\n", 586 | " \n", 587 | " >>> np.dot([2j, 3j], [2j, 3j])\n", 588 | " (-13+0j)\n", 589 | " \n", 590 | " For 2-D arrays it is the matrix product:\n", 591 | " \n", 592 | " >>> a = [[1, 0], [0, 1]]\n", 593 | " >>> b = [[4, 1], [2, 2]]\n", 594 | " >>> np.dot(a, b)\n", 595 | " array([[4, 1],\n", 596 | " [2, 2]])\n", 597 | " \n", 598 | " >>> a = np.arange(3*4*5*6).reshape((3,4,5,6))\n", 599 | " >>> b = np.arange(3*4*5*6)[::-1].reshape((5,4,6,3))\n", 600 | " >>> np.dot(a, b)[2,3,2,1,2,2]\n", 601 | " 499128\n", 602 | " >>> sum(a[2,3,2,:] * b[1,2,:,2])\n", 603 | " 499128\n", 604 | "\n" 605 | ] 606 | } 607 | ], 608 | "source": [ 609 | "help(np.dot)" 610 | ] 611 | } 612 | ], 613 | "metadata": { 614 | "kernelspec": { 615 | "display_name": "Python 3", 616 | "language": "python", 617 | "name": "python3" 618 | }, 619 | "language_info": { 620 | "codemirror_mode": { 621 | "name": "ipython", 622 | "version": 3 623 | }, 624 | "file_extension": ".py", 625 | "mimetype": "text/x-python", 626 | "name": "python", 627 | "nbconvert_exporter": "python", 628 | "pygments_lexer": "ipython3", 629 | "version": "3.8.1" 630 | } 631 | }, 632 | "nbformat": 4, 633 | "nbformat_minor": 4 634 | } 635 | -------------------------------------------------------------------------------- /051-array-modifying-exercise.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Exercise: LED Panel\n", 8 | "" 9 | ] 10 | }, 11 | { 12 | "cell_type": "markdown", 13 | "metadata": {}, 14 | "source": [ 15 | "## Tips:" 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": 1, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "%matplotlib inline\n", 25 | "import numpy as np\n", 26 | "from matplotlib import pyplot as plt" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "metadata": {}, 33 | "outputs": [], 34 | "source": [ 35 | "a = np.arange(10)" 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "execution_count": 3, 41 | "metadata": {}, 42 | "outputs": [ 43 | { 44 | "data": { 45 | "text/plain": [ 46 | "array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])" 47 | ] 48 | }, 49 | "execution_count": 3, 50 | "metadata": {}, 51 | "output_type": "execute_result" 52 | } 53 | ], 54 | "source": [ 55 | "a" 56 | ] 57 | }, 58 | { 59 | "cell_type": "code", 60 | "execution_count": 4, 61 | "metadata": {}, 62 | "outputs": [ 63 | { 64 | "data": { 65 | "text/plain": [ 66 | "array([7, 8, 9, 0, 1, 2, 3, 4, 5, 6])" 67 | ] 68 | }, 69 | "execution_count": 4, 70 | "metadata": {}, 71 | "output_type": "execute_result" 72 | } 73 | ], 74 | "source": [ 75 | "np.roll(a, 3) # does not change a" 76 | ] 77 | }, 78 | { 79 | "cell_type": "code", 80 | "execution_count": 5, 81 | "metadata": {}, 82 | "outputs": [ 83 | { 84 | "data": { 85 | "text/plain": [ 86 | "array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])" 87 | ] 88 | }, 89 | "execution_count": 5, 90 | "metadata": {}, 91 | "output_type": "execute_result" 92 | } 93 | ], 94 | "source": [ 95 | "a" 96 | ] 97 | } 98 | ], 99 | "metadata": { 100 | "kernelspec": { 101 | "display_name": "Python 3", 102 | "language": "python", 103 | "name": "python3" 104 | }, 105 | "language_info": { 106 | "codemirror_mode": { 107 | "name": "ipython", 108 | "version": 3 109 | }, 110 | "file_extension": ".py", 111 | "mimetype": "text/x-python", 112 | "name": "python", 113 | "nbconvert_exporter": "python", 114 | "pygments_lexer": "ipython3", 115 | "version": "3.8.2" 116 | } 117 | }, 118 | "nbformat": 4, 119 | "nbformat_minor": 4 120 | } 121 | -------------------------------------------------------------------------------- /071-logical-ops.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "%matplotlib inline\n", 10 | "import numpy as np\n", 11 | "from matplotlib import pyplot as plt" 12 | ] 13 | }, 14 | { 15 | "cell_type": "code", 16 | "execution_count": 2, 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "data": { 21 | "text/plain": [ 22 | "array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])" 23 | ] 24 | }, 25 | "execution_count": 2, 26 | "metadata": {}, 27 | "output_type": "execute_result" 28 | } 29 | ], 30 | "source": [ 31 | "a = np.arange(10)\n", 32 | "a" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": 3, 38 | "metadata": {}, 39 | "outputs": [ 40 | { 41 | "data": { 42 | "text/plain": [ 43 | "array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])" 44 | ] 45 | }, 46 | "execution_count": 3, 47 | "metadata": {}, 48 | "output_type": "execute_result" 49 | } 50 | ], 51 | "source": [ 52 | "a" 53 | ] 54 | }, 55 | { 56 | "cell_type": "markdown", 57 | "metadata": {}, 58 | "source": [ 59 | "# Logical operations on arrays and scalars" 60 | ] 61 | }, 62 | { 63 | "cell_type": "code", 64 | "execution_count": 4, 65 | "metadata": {}, 66 | "outputs": [ 67 | { 68 | "data": { 69 | "text/plain": [ 70 | "array([False, False, True, False, False, False, False, False, False,\n", 71 | " False])" 72 | ] 73 | }, 74 | "execution_count": 4, 75 | "metadata": {}, 76 | "output_type": "execute_result" 77 | } 78 | ], 79 | "source": [ 80 | "a == 2" 81 | ] 82 | }, 83 | { 84 | "cell_type": "code", 85 | "execution_count": 5, 86 | "metadata": {}, 87 | "outputs": [ 88 | { 89 | "data": { 90 | "text/plain": [ 91 | "array([ True, True, True, True, False, False, False, False, False,\n", 92 | " False])" 93 | ] 94 | }, 95 | "execution_count": 5, 96 | "metadata": {}, 97 | "output_type": "execute_result" 98 | } 99 | ], 100 | "source": [ 101 | "a <= 3" 102 | ] 103 | }, 104 | { 105 | "cell_type": "code", 106 | "execution_count": 6, 107 | "metadata": {}, 108 | "outputs": [ 109 | { 110 | "data": { 111 | "text/plain": [ 112 | "array([ True, False, False, False, False, False, True, False, False,\n", 113 | " False])" 114 | ] 115 | }, 116 | "execution_count": 6, 117 | "metadata": {}, 118 | "output_type": "execute_result" 119 | } 120 | ], 121 | "source": [ 122 | "np.logical_and(a % 3 == 0, a % 2 == 0)" 123 | ] 124 | }, 125 | { 126 | "cell_type": "code", 127 | "execution_count": null, 128 | "metadata": {}, 129 | "outputs": [], 130 | "source": [] 131 | } 132 | ], 133 | "metadata": { 134 | "kernelspec": { 135 | "display_name": "Python 3", 136 | "language": "python", 137 | "name": "python3" 138 | }, 139 | "language_info": { 140 | "codemirror_mode": { 141 | "name": "ipython", 142 | "version": 3 143 | }, 144 | "file_extension": ".py", 145 | "mimetype": "text/x-python", 146 | "name": "python", 147 | "nbconvert_exporter": "python", 148 | "pygments_lexer": "ipython3", 149 | "version": "3.8.1" 150 | } 151 | }, 152 | "nbformat": 4, 153 | "nbformat_minor": 4 154 | } 155 | -------------------------------------------------------------------------------- /081-grids.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "%matplotlib inline\n", 10 | "import numpy as np\n", 11 | "from matplotlib import pyplot as plt" 12 | ] 13 | }, 14 | { 15 | "cell_type": "markdown", 16 | "metadata": {}, 17 | "source": [ 18 | "# Broadcasting Into Grids" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 2, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "a = np.array([100, 200 ,300])\n", 28 | "b = np.array([1, 2, 3, 4, 5])" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": 3, 34 | "metadata": {}, 35 | "outputs": [ 36 | { 37 | "data": { 38 | "text/plain": [ 39 | "(3,)" 40 | ] 41 | }, 42 | "execution_count": 3, 43 | "metadata": {}, 44 | "output_type": "execute_result" 45 | } 46 | ], 47 | "source": [ 48 | "a.shape" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": 4, 54 | "metadata": {}, 55 | "outputs": [ 56 | { 57 | "data": { 58 | "text/plain": [ 59 | "(5,)" 60 | ] 61 | }, 62 | "execution_count": 4, 63 | "metadata": {}, 64 | "output_type": "execute_result" 65 | } 66 | ], 67 | "source": [ 68 | "b.shape" 69 | ] 70 | }, 71 | { 72 | "cell_type": "code", 73 | "execution_count": 5, 74 | "metadata": {}, 75 | "outputs": [ 76 | { 77 | "ename": "ValueError", 78 | "evalue": "operands could not be broadcast together with shapes (3,) (5,) ", 79 | "output_type": "error", 80 | "traceback": [ 81 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 82 | "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", 83 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0ma\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 84 | "\u001b[0;31mValueError\u001b[0m: operands could not be broadcast together with shapes (3,) (5,) " 85 | ] 86 | } 87 | ], 88 | "source": [ 89 | "a + b" 90 | ] 91 | }, 92 | { 93 | "cell_type": "code", 94 | "execution_count": 6, 95 | "metadata": {}, 96 | "outputs": [ 97 | { 98 | "data": { 99 | "text/plain": [ 100 | "array([[100],\n", 101 | " [200],\n", 102 | " [300]])" 103 | ] 104 | }, 105 | "execution_count": 6, 106 | "metadata": {}, 107 | "output_type": "execute_result" 108 | } 109 | ], 110 | "source": [ 111 | "a[:,np.newaxis]" 112 | ] 113 | }, 114 | { 115 | "cell_type": "code", 116 | "execution_count": 7, 117 | "metadata": {}, 118 | "outputs": [ 119 | { 120 | "data": { 121 | "text/plain": [ 122 | "(3, 1)" 123 | ] 124 | }, 125 | "execution_count": 7, 126 | "metadata": {}, 127 | "output_type": "execute_result" 128 | } 129 | ], 130 | "source": [ 131 | "a[:,np.newaxis].shape" 132 | ] 133 | }, 134 | { 135 | "cell_type": "code", 136 | "execution_count": 8, 137 | "metadata": {}, 138 | "outputs": [ 139 | { 140 | "data": { 141 | "text/plain": [ 142 | "array([[101, 102, 103, 104, 105],\n", 143 | " [201, 202, 203, 204, 205],\n", 144 | " [301, 302, 303, 304, 305]])" 145 | ] 146 | }, 147 | "execution_count": 8, 148 | "metadata": {}, 149 | "output_type": "execute_result" 150 | } 151 | ], 152 | "source": [ 153 | "a[:,np.newaxis] + b" 154 | ] 155 | }, 156 | { 157 | "cell_type": "code", 158 | "execution_count": 9, 159 | "metadata": {}, 160 | "outputs": [ 161 | { 162 | "data": { 163 | "text/plain": [ 164 | "array([[1],\n", 165 | " [2],\n", 166 | " [3],\n", 167 | " [4],\n", 168 | " [5]])" 169 | ] 170 | }, 171 | "execution_count": 9, 172 | "metadata": {}, 173 | "output_type": "execute_result" 174 | } 175 | ], 176 | "source": [ 177 | "b[:,np.newaxis]" 178 | ] 179 | }, 180 | { 181 | "cell_type": "code", 182 | "execution_count": 10, 183 | "metadata": {}, 184 | "outputs": [ 185 | { 186 | "data": { 187 | "text/plain": [ 188 | "(5, 1)" 189 | ] 190 | }, 191 | "execution_count": 10, 192 | "metadata": {}, 193 | "output_type": "execute_result" 194 | } 195 | ], 196 | "source": [ 197 | "b[:,np.newaxis].shape" 198 | ] 199 | }, 200 | { 201 | "cell_type": "code", 202 | "execution_count": 11, 203 | "metadata": {}, 204 | "outputs": [ 205 | { 206 | "data": { 207 | "text/plain": [ 208 | "array([[101, 201, 301],\n", 209 | " [102, 202, 302],\n", 210 | " [103, 203, 303],\n", 211 | " [104, 204, 304],\n", 212 | " [105, 205, 305]])" 213 | ] 214 | }, 215 | "execution_count": 11, 216 | "metadata": {}, 217 | "output_type": "execute_result" 218 | } 219 | ], 220 | "source": [ 221 | "a + b[:,np.newaxis]" 222 | ] 223 | }, 224 | { 225 | "cell_type": "markdown", 226 | "metadata": {}, 227 | "source": [ 228 | "# Alternative: Using `np.*.outer` to create grids:" 229 | ] 230 | }, 231 | { 232 | "cell_type": "code", 233 | "execution_count": 12, 234 | "metadata": {}, 235 | "outputs": [ 236 | { 237 | "data": { 238 | "text/plain": [ 239 | "array([[100, 101, 102, 103, 104],\n", 240 | " [200, 201, 202, 203, 204],\n", 241 | " [300, 301, 302, 303, 304],\n", 242 | " [400, 401, 402, 403, 404]])" 243 | ] 244 | }, 245 | "execution_count": 12, 246 | "metadata": {}, 247 | "output_type": "execute_result" 248 | } 249 | ], 250 | "source": [ 251 | "np.arange(5) + np.arange(100,500,100)[:,np.newaxis]" 252 | ] 253 | }, 254 | { 255 | "cell_type": "code", 256 | "execution_count": 13, 257 | "metadata": {}, 258 | "outputs": [ 259 | { 260 | "data": { 261 | "text/plain": [ 262 | "array([[100, 200, 300, 400, 500],\n", 263 | " [101, 201, 301, 401, 501],\n", 264 | " [102, 202, 302, 402, 502],\n", 265 | " [103, 203, 303, 403, 503],\n", 266 | " [104, 204, 304, 404, 504]])" 267 | ] 268 | }, 269 | "execution_count": 13, 270 | "metadata": {}, 271 | "output_type": "execute_result" 272 | } 273 | ], 274 | "source": [ 275 | "np.add.outer(np.arange(5), np.arange(100, 501, 100))" 276 | ] 277 | }, 278 | { 279 | "cell_type": "code", 280 | "execution_count": null, 281 | "metadata": {}, 282 | "outputs": [], 283 | "source": [] 284 | } 285 | ], 286 | "metadata": { 287 | "kernelspec": { 288 | "display_name": "Python 3", 289 | "language": "python", 290 | "name": "python3" 291 | }, 292 | "language_info": { 293 | "codemirror_mode": { 294 | "name": "ipython", 295 | "version": 3 296 | }, 297 | "file_extension": ".py", 298 | "mimetype": "text/x-python", 299 | "name": "python", 300 | "nbconvert_exporter": "python", 301 | "pygments_lexer": "ipython3", 302 | "version": "3.8.1" 303 | } 304 | }, 305 | "nbformat": 4, 306 | "nbformat_minor": 4 307 | } 308 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # `learn-numpy`: A collection of numpy notebooks :-) 2 | 3 | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/nonZero/learn-numpy/master) -------------------------------------------------------------------------------- /broadcast-examples/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/broadcast-examples/1.png -------------------------------------------------------------------------------- /broadcast-examples/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/broadcast-examples/10.png -------------------------------------------------------------------------------- /broadcast-examples/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/broadcast-examples/11.png -------------------------------------------------------------------------------- /broadcast-examples/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/broadcast-examples/12.png -------------------------------------------------------------------------------- /broadcast-examples/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/broadcast-examples/13.png -------------------------------------------------------------------------------- /broadcast-examples/14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/broadcast-examples/14.png -------------------------------------------------------------------------------- /broadcast-examples/15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/broadcast-examples/15.png -------------------------------------------------------------------------------- /broadcast-examples/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/broadcast-examples/2.png -------------------------------------------------------------------------------- /broadcast-examples/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/broadcast-examples/3.png -------------------------------------------------------------------------------- /broadcast-examples/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/broadcast-examples/4.png -------------------------------------------------------------------------------- /broadcast-examples/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/broadcast-examples/5.png -------------------------------------------------------------------------------- /broadcast-examples/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/broadcast-examples/6.png -------------------------------------------------------------------------------- /broadcast-examples/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/broadcast-examples/7.png -------------------------------------------------------------------------------- /broadcast-examples/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/broadcast-examples/8.png -------------------------------------------------------------------------------- /broadcast-examples/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/broadcast-examples/9.png -------------------------------------------------------------------------------- /city-part.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/city-part.png -------------------------------------------------------------------------------- /city-round1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/city-round1.png -------------------------------------------------------------------------------- /city-round2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/city-round2.png -------------------------------------------------------------------------------- /city.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/city.jpeg -------------------------------------------------------------------------------- /environment.yml: -------------------------------------------------------------------------------- 1 | name: environment 2 | 3 | dependencies: 4 | - numpy 5 | - matplotlib 6 | -------------------------------------------------------------------------------- /pagoda.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/pagoda.jpeg -------------------------------------------------------------------------------- /pencils-part.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/pencils-part.png -------------------------------------------------------------------------------- /pencils.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/pencils.jpeg -------------------------------------------------------------------------------- /puppy1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/puppy1.jpeg -------------------------------------------------------------------------------- /puppy2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonZero/learn-numpy/ece3b6dab3daefc0e5867baaf828b052aa2f61d1/puppy2.jpeg --------------------------------------------------------------------------------