|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 1, |
| 6 | + "metadata": {}, |
| 7 | + "outputs": [], |
| 8 | + "source": [ |
| 9 | + "import marbles.core\n", |
| 10 | + "from marbles.mixins import mixins\n", |
| 11 | + "\n", |
| 12 | + "import pandas as pd\n", |
| 13 | + "import numpy as np\n", |
| 14 | + "from datetime import datetime, timedelta\n", |
| 15 | + "\n", |
| 16 | + "class TimeSeriesTestCase(marbles.core.TestCase,mixins.MonotonicMixins):\n", |
| 17 | + " def setUp(self):\n", |
| 18 | + " self.df = pd.DataFrame({'dates':[datetime(2018,1,1),\n", |
| 19 | + " datetime(2018,2,1),\n", |
| 20 | + " datetime(2018,2,1)],\n", |
| 21 | + " 'ireland_unemployment':[6.2,6.1,6.0]})\n", |
| 22 | + " \n", |
| 23 | + " def tearDown(self):\n", |
| 24 | + " self.df = None\n", |
| 25 | + " \n", |
| 26 | + " def test_date_order(self):\n", |
| 27 | + " \n", |
| 28 | + " self.assertMonotonicIncreasing(sequence=self.df.dates,\n", |
| 29 | + " note = 'Dates need to increase monotonically')\n", |
| 30 | + " " |
| 31 | + ] |
| 32 | + }, |
| 33 | + { |
| 34 | + "cell_type": "code", |
| 35 | + "execution_count": 2, |
| 36 | + "metadata": {}, |
| 37 | + "outputs": [ |
| 38 | + { |
| 39 | + "name": "stderr", |
| 40 | + "output_type": "stream", |
| 41 | + "text": [ |
| 42 | + "F\n", |
| 43 | + "======================================================================\n", |
| 44 | + "FAIL: test_date_order (__main__.TimeSeriesTestCase)\n", |
| 45 | + "----------------------------------------------------------------------\n", |
| 46 | + "marbles.core.marbles.ContextualAssertionError: Elements in 0 2018-01-01\n", |
| 47 | + "1 2018-02-01\n", |
| 48 | + "2 2018-02-01\n", |
| 49 | + "Name: dates, dtype: datetime64[ns] are not strictly monotonically increasing\n", |
| 50 | + "\n", |
| 51 | + "Source (<ipython-input-1-ebdbd8f0d69f>):\n", |
| 52 | + " 19 \n", |
| 53 | + " > 20 self.assertMonotonicIncreasing(sequence=self.df.dates,\n", |
| 54 | + " 21 note = 'Dates need to increase monotonically')\n", |
| 55 | + " 22 \n", |
| 56 | + "Locals:\n", |
| 57 | + "\n", |
| 58 | + "Note:\n", |
| 59 | + "\tDates need to increase monotonically\n", |
| 60 | + "\n", |
| 61 | + "\n", |
| 62 | + "----------------------------------------------------------------------\n", |
| 63 | + "Ran 1 test in 0.007s\n", |
| 64 | + "\n", |
| 65 | + "FAILED (failures=1)\n" |
| 66 | + ] |
| 67 | + } |
| 68 | + ], |
| 69 | + "source": [ |
| 70 | + "if __name__ == '__main__':\n", |
| 71 | + " marbles.core.main(argv=['first-arg-is-ignored'], exit=False)" |
| 72 | + ] |
| 73 | + }, |
| 74 | + { |
| 75 | + "cell_type": "code", |
| 76 | + "execution_count": null, |
| 77 | + "metadata": {}, |
| 78 | + "outputs": [], |
| 79 | + "source": [] |
| 80 | + } |
| 81 | + ], |
| 82 | + "metadata": { |
| 83 | + "anaconda-cloud": {}, |
| 84 | + "kernelspec": { |
| 85 | + "display_name": "Python [default]", |
| 86 | + "language": "python", |
| 87 | + "name": "python3" |
| 88 | + }, |
| 89 | + "language_info": { |
| 90 | + "codemirror_mode": { |
| 91 | + "name": "ipython", |
| 92 | + "version": 3 |
| 93 | + }, |
| 94 | + "file_extension": ".py", |
| 95 | + "mimetype": "text/x-python", |
| 96 | + "name": "python", |
| 97 | + "nbconvert_exporter": "python", |
| 98 | + "pygments_lexer": "ipython3", |
| 99 | + "version": "3.5.4" |
| 100 | + } |
| 101 | + }, |
| 102 | + "nbformat": 4, |
| 103 | + "nbformat_minor": 2 |
| 104 | +} |
0 commit comments