{ "metadata": { "name": "04-bloom-filters" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "See http://ivory.idyll.org/blog/2013-pycon-awesome-big-data-algorithms-talk.html" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## IPython Blocks\n", "\n", "Below, I will use IPython Blocks (https://github.com/jiffyclub/ipythonblocks) to demonstrate Bloom filters.\n", "\n", "IPython Blocks is a nifty little visualization tool built by Matt Davis @jiffyclub for use in teaching Python and programming basics. Here's a quick little demo --" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from ipythonblocks import BlockGrid" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [ "grid = BlockGrid(10,10, fill=(0,0,128))\n", "\n", "x = grid.shape[0]\n", "y = grid.shape[1]\n", "\n", "for block in grid:\n", " r = block.row * 255 / float(x)\n", " g = block.col * 255 / float(y)\n", " block.red = r\n", " block.green = g\n", " \n", "grid" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "