<commit_before>{
 "metadata": {
  "name": "",
  "signature": "sha256:2cbdbaf083d9da9e539c91be4bcce65dd892d0af6df9e752172ecb56934be381"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "JIT Code Module 1, Lesson 4"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import numpy as np\n",
      "\n",
      "import matplotlib.pyplot as plt\n",
      "%matplotlib inline"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Last lesson we discussed navigating a rover through a maze and to its final destination. We learned how to use conditionals like `<`, `>`, and `==` to make decisions within our functions, and how to use `if`, `else`, and `elif` statements. In this unit, we will learn how to use loops to make our code more efficient and powerful. "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "def showMaze(maze):   \n",
      "    plt.figure(figsize=(10, 5))\n",
      "    plt.imshow(maze, cmap=plt.cm.gist_ncar, interpolation='none')\n",
      "    plt.xticks([]), plt.yticks([])\n",
      "    plt.show()\n",
      "    \n",
      "def direction_to_array(direction):\n",
      "    if direction == 0:\n",
      "        return np.array([0,-1])\n",
      "    elif direction == 1:\n",
      "        return np.array([-1,0])\n",
      "    elif direction == 2:\n",
      "        return np.array([0,1])\n",
      "    else:\n",
      "        return np.array([1,0])\n",
      "    \n",
      "def move_forward(location, direction, maze):\n",
      "    old_x, old_y = location\n",
      "    new_x, new_y = location + direction_to_array(direction)\n",
      "    \n",
      "    if maze[new_y][new_x] != 3 and maze[new_y][new_x] != 5:\n",
      "        maze[new_y][new_x] = 1.\n",
      "        return np.array([new_x,new_y])\n",
      "    else:\n",
      "        return location\n",
      "    \n",
      "def turn_right(direction):\n",
      "    direction -= 1\n",
      "    if direction < 0:\n",
      "        direction = 3\n",
      "    return direction\n",
      "\n",
      "def turn_left(direction):\n",
      "    direction += 1\n",
      "    if direction >= 4:\n",
      "        direction = 0\n",
      "    return direction"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 3
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from IPython.core.display import HTML\n",
      "def css_styling():\n",
      "    styles = open(\"../styles/customHTML.html\", \"r\").read()\n",
      "    return HTML(styles)\n",
      "css_styling()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "html": [
        "<link href='http://fonts.googleapis.com/css?family=Fenix' rel='stylesheet' type='text/css'>\n",
        "<link href='http://fonts.googleapis.com/css?family=Alegreya+Sans:100,300,400,500,700,800,900,100italic,300italic,400italic,500italic,700italic,800italic,900italic' rel='stylesheet' type='text/css'>\n",
        "<link href='http://fonts.googleapis.com/css?family=Source+Code+Pro:300,400' rel='stylesheet' type='text/css'>\n",
        "<link href='https://raw.githubusercontent.com/barbagroup/JITcode-MechE/master/styles/customCSS.css' type='text/css'>\n",
        "<style>\n",
        "</style>\n",
        "<script>\n",
        "    MathJax.Hub.Config({\n",
        "                        TeX: {\n",
        "                           extensions: [\"AMSmath.js\"]\n",
        "                           },\n",
        "                tex2jax: {\n",
        "                    inlineMath: [ ['$','$'], [\"\\\\(\",\"\\\\)\"] ],\n",
        "                    displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"] ]\n",
        "                },\n",
        "                displayAlign: 'center', // Change this to 'center' to center equations.\n",
        "                \"HTML-CSS\": {\n",
        "                    styles: {'.MathJax_Display': {\"margin\": 4}}\n",
        "                }\n",
        "        });\n",
        "</script>\n"
       ],
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 6,
       "text": [
        "<IPython.core.display.HTML at 0x10fe4f4d0>"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}<commit_msg>reverted a bunch of previous changes<commit_after>{
 "metadata": {
  "name": "",
  "signature": "sha256:3c96425655e2cbcfab4f2910f90bb553bf76da300c28fe5c4f08585ca77af04c"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "JIT Code Module 1, Lesson 4"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import numpy as np\n",
      "\n",
      "import matplotlib.pyplot as plt\n",
      "%matplotlib inline"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 27
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Last lesson we discussed navigating a rover through a maze and to its final destination. We learned how to use conditionals like `<`, `>`, and `==` to make decisions within our functions, and how to use `if`, `else`, and `elif` statements. In this unit, we will learn how to use loops to make our code more efficient and powerful. "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "def showMaze(maze):   \n",
      "    plt.figure(figsize=(10, 5))\n",
      "    plt.imshow(maze, cmap=plt.cm.gist_ncar, interpolation='none')\n",
      "    plt.xticks([]), plt.yticks([])\n",
      "    plt.show()\n",
      "    \n",
      "def direction_to_array(direction):\n",
      "    if direction == 0:\n",
      "        return np.array([0,-1])\n",
      "    elif direction == 1:\n",
      "        return np.array([-1,0])\n",
      "    elif direction == 2:\n",
      "        return np.array([0,1])\n",
      "    else:\n",
      "        return np.array([1,0])\n",
      "    \n",
      "def move_forward(location, direction, maze):\n",
      "    old_x, old_y = location\n",
      "    new_x, new_y = location + direction_to_array(direction)\n",
      "    \n",
      "    if maze[new_y][new_x] != 3 and maze[new_y][new_x] != 5:\n",
      "        maze[new_y][new_x] = 1.\n",
      "        return np.array([new_x,new_y])\n",
      "    else:\n",
      "        return location\n",
      "    \n",
      "def turn_right(direction):\n",
      "    direction -= 1\n",
      "    if direction < 0:\n",
      "        direction = 3\n",
      "    return direction\n",
      "\n",
      "def turn_left(direction):\n",
      "    direction += 1\n",
      "    if direction >= 4:\n",
      "        direction = 0\n",
      "    return direction"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 28
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from IPython.core.display import HTML\n",
      "def css_styling():\n",
      "    styles = open(\"../styles/custom.css\", \"r\").read()\n",
      "    return HTML(styles)\n",
      "css_styling()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "html": [
        "<link href='http://fonts.googleapis.com/css?family=Fenix' rel='stylesheet' type='text/css'>\n",
        "<link href='http://fonts.googleapis.com/css?family=Alegreya+Sans:100,300,400,500,700,800,900,100italic,300italic,400italic,500italic,700italic,800italic,900italic' rel='stylesheet' type='text/css'>\n",
        "<link href='http://fonts.googleapis.com/css?family=Source+Code+Pro:300,400' rel='stylesheet' type='text/css'>\n",
        "<style>\n",
        "    @font-face {\n",
        "        font-family: \"Computer Modern\";\n",
        "        src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunss.otf');\n",
        "    }\n",
        "    div.cell{\n",
        "        width:800px;\n",
        "        margin-left:16% !important;\n",
        "        margin-right:auto;\n",
        "    }\n",
        "    h1 {\n",
        "        font-family: 'Alegreya Sans', sans-serif;\n",
        "    }\n",
        "    h2 {\n",
        "        font-family: 'Fenix', serif;\n",
        "    }\n",
        "    h3{\n",
        "\t\tfont-family: 'Fenix', serif;\n",
        "        margin-top:12px;\n",
        "        margin-bottom: 3px;\n",
        "       }\n",
        "\th4{\n",
        "\t\tfont-family: 'Fenix', serif;\n",
        "       }\n",
        "    h5 {\n",
        "        font-family: 'Alegreya Sans', sans-serif;\n",
        "    }\t   \n",
        "    div.text_cell_render{\n",
        "        font-family: 'Alegreya Sans',Computer Modern, \"Helvetica Neue\", Arial, Helvetica, Geneva, sans-serif;\n",
        "        line-height: 135%;\n",
        "        font-size: 120%;\n",
        "        width:600px;\n",
        "        margin-left:auto;\n",
        "        margin-right:auto;\n",
        "    }\n",
        "    .CodeMirror{\n",
        "            font-family: \"Source Code Pro\";\n",
        "\t\t\tfont-size: 90%;\n",
        "    }\n",
        "/*    .prompt{\n",
        "        display: None;\n",
        "    }*/\n",
        "    .text_cell_render h1 {\n",
        "        font-weight: 200;\n",
        "        font-size: 50pt;\n",
        "\t\tline-height: 100%;\n",
        "        color:#CD2305;\n",
        "        margin-bottom: 0.5em;\n",
        "        margin-top: 0.5em;\n",
        "        display: block;\n",
        "    }\t\n",
        "    .text_cell_render h5 {\n",
        "        font-weight: 300;\n",
        "        font-size: 16pt;\n",
        "        color: #CD2305;\n",
        "        font-style: italic;\n",
        "        margin-bottom: .5em;\n",
        "        margin-top: 0.5em;\n",
        "        display: block;\n",
        "    }\n",
        "    \n",
        "    .warning{\n",
        "        color: rgb( 240, 20, 20 )\n",
        "    }  \n",
        "\n",
        "    code { \n",
        "        margin: 0 !important;\n",
        "        border: 1px solid #ddd !important;\n",
        "        background-color: #f8f8f8 !important;\n",
        "        border-radius: 3px !important;\n",
        "        padding: 0 !important;            \n",
        "\tfont-size: 12px;\n",
        "    }\n",
        "</style>\n",
        "<script>\n",
        "    MathJax.Hub.Config({\n",
        "                        TeX: {\n",
        "                           extensions: [\"AMSmath.js\"]\n",
        "                           },\n",
        "                tex2jax: {\n",
        "                    inlineMath: [ ['$','$'], [\"\\\\(\",\"\\\\)\"] ],\n",
        "                    displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"] ]\n",
        "                },\n",
        "                displayAlign: 'center', // Change this to 'center' to center equations.\n",
        "                \"HTML-CSS\": {\n",
        "                    styles: {'.MathJax_Display': {\"margin\": 4}}\n",
        "                }\n",
        "        });\n",
        "</script>\n"
       ],
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 30,
       "text": [
        "<IPython.core.display.HTML at 0x10ff65850>"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}
{'fraction_non_alphanumeric': 0.20219798380432985, 'fraction_numerical': 0.027268220128904314, 'mean_word_length': 1.5458561211611275, 'pattern_counts': {'":': 98, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6023825', 'n_tokens_mistral': 4419, 'n_tokens_neox': 4130, 'n_words': 729}