{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Lesson 5 - Less Basics" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Original Tutorial [here](http://wiki.scipy.org/Tentative_NumPy_Tutorial)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Broadcasting rules" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Broadcasting allows universal functions to deal in a meaningful way with inputs\n", "that do not have exactly the same shape.\n", "\n", "The first rule of broadcasting is that if all input arrays do not have the same number of dimensions, a \"1\" will be repeatedly prepended to the shapes of the smaller arrays until all the arrays have the same number of dimensions.\n", "\n", "The second rule of broadcasting ensures that arrays with a size of 1 along a\n", "particular dimension act as if they had the size of the array with the largest shape along that dimension. The value of the array element is assumed to be the same along that dimension for the \"broadcast\" array.\n", "\n", "After application of the broadcasting rules, the sizes of all arrays must match. More details can be found in this documentation. " ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.9" } }, "nbformat": 4, "nbformat_minor": 0 }