{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import marbles.core\n", "from marbles.mixins import mixins\n", "\n", "import pandas as pd\n", "import numpy as np\n", "from datetime import datetime, timedelta\n", "\n", "class TimeSeriesTestCase(marbles.core.TestCase,mixins.MonotonicMixins):\n", " def setUp(self):\n", " self.df = pd.DataFrame({'dates':[datetime(2018,1,1),\n", " datetime(2018,2,1),\n", " datetime(2018,2,1)],\n", " 'ireland_unemployment':[6.2,6.1,6.0]})\n", " \n", " def tearDown(self):\n", " self.df = None\n", " \n", " def test_date_order(self):\n", " \n", " self.assertMonotonicIncreasing(sequence=self.df.dates,\n", " note = 'Dates need to increase monotonically')\n", " " ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "F\n", "======================================================================\n", "FAIL: test_date_order (__main__.TimeSeriesTestCase)\n", "----------------------------------------------------------------------\n", "marbles.core.marbles.ContextualAssertionError: Elements in 0 2018-01-01\n", "1 2018-02-01\n", "2 2018-02-01\n", "Name: dates, dtype: datetime64[ns] are not strictly monotonically increasing\n", "\n", "Source ():\n", " 19 \n", " > 20 self.assertMonotonicIncreasing(sequence=self.df.dates,\n", " 21 note = 'Dates need to increase monotonically')\n", " 22 \n", "Locals:\n", "\n", "Note:\n", "\tDates need to increase monotonically\n", "\n", "\n", "----------------------------------------------------------------------\n", "Ran 1 test in 0.007s\n", "\n", "FAILED (failures=1)\n" ] } ], "source": [ "if __name__ == '__main__':\n", " marbles.core.main(argv=['first-arg-is-ignored'], exit=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python [default]", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.4" } }, "nbformat": 4, "nbformat_minor": 2 }