diff --git a/9-data-analysis-python/5-sea-level-predictor/README.md b/9-data-analysis-python/5-sea-level-predictor/README.md new file mode 100644 index 0000000..f89ce47 --- /dev/null +++ b/9-data-analysis-python/5-sea-level-predictor/README.md @@ -0,0 +1,3 @@ +# Sea Level Predictor + +This is the boilerplate for the Sea Level Predictor project. Instructions for building your project can be found at https://www.freecodecamp.org/learn/data-analysis-with-python/data-analysis-with-python-projects/sea-level-predictor diff --git a/9-data-analysis-python/5-sea-level-predictor/epa-sea-level.csv b/9-data-analysis-python/5-sea-level-predictor/epa-sea-level.csv new file mode 100644 index 0000000..7ad553c --- /dev/null +++ b/9-data-analysis-python/5-sea-level-predictor/epa-sea-level.csv @@ -0,0 +1,135 @@ +Year,CSIRO Adjusted Sea Level,Lower Error Bound,Upper Error Bound,NOAA Adjusted Sea Level +1880,0,-0.952755905,0.952755905, +1881,0.220472441,-0.732283464,1.173228345, +1882,-0.440944881,-1.346456692,0.464566929, +1883,-0.232283464,-1.129921259,0.66535433, +1884,0.590551181,-0.283464567,1.464566928, +1885,0.531496062,-0.330708661,1.393700786, +1886,0.437007874,-0.381889763,1.255905511, +1887,0.216535433,-0.602362204,1.03543307, +1888,0.299212598,-0.519685039,1.118110235, +1889,0.362204724,-0.456692913,1.181102361, +1890,0.440944881,-0.374015748,1.255905511, +1891,0.374015748,-0.440944881,1.188976377, +1892,0.499999999,-0.31496063,1.314960629, +1893,0.685039369,-0.114173228,1.484251967, +1894,0.303149606,-0.547244094,1.153543306, +1895,0.767716535,-0.082677165,1.618110235, +1896,0.468503937,-0.366141732,1.303149605, +1897,0.673228346,-0.145669291,1.492125983, +1898,1.043307086,0.267716535,1.818897636, +1899,1.338582676,0.574803149,2.102362203, +1900,1.125984251,0.405511811,1.846456691, +1901,1.110236219,0.417322834,1.803149604, +1902,1.291338581,0.61023622,1.972440943, +1903,1.606299211,0.937007873,2.275590549, +1904,1.2007874,0.53543307,1.86614173, +1905,0.984251968,0.377952756,1.590551179, +1906,1.251968503,0.673228346,1.83070866, +1907,1.196850392,0.61023622,1.783464565, +1908,1.098425196,0.527559055,1.669291337, +1909,1.27559055,0.700787401,1.850393699, +1910,1.271653542,0.696850393,1.846456691, +1911,1.598425195,1.039370078,2.157480313, +1912,1.476377951,0.917322834,2.035433069, +1913,1.547244093,0.992125983,2.102362203, +1914,1.795275589,1.251968503,2.338582675, +1915,2.10629921,1.57086614,2.641732281, +1916,2.031496061,1.519685038,2.543307084, +1917,1.854330707,1.350393699,2.358267714, +1918,1.791338581,1.291338581,2.29133858, +1919,1.854330707,1.354330707,2.354330706, +1920,1.905511809,1.393700786,2.417322832, +1921,1.988188974,1.472440943,2.503937005, +1922,1.952755904,1.433070865,2.472440942, +1923,1.999999998,1.488188975,2.511811021, +1924,1.712598423,1.196850392,2.228346454, +1925,1.791338581,1.255905511,2.326771651, +1926,2.047244092,1.507874014,2.586614171, +1927,2.003937006,1.496062991,2.511811021, +1928,1.850393699,1.366141731,2.334645667, +1929,1.905511809,1.429133857,2.381889761, +1930,2.062992124,1.590551179,2.535433068, +1931,2.047244092,1.566929132,2.527559053, +1932,2.271653541,1.803149604,2.740157478, +1933,2.440944879,1.976377951,2.905511808, +1934,2.228346454,1.759842518,2.696850391, +1935,2.448818895,1.980314959,2.917322832, +1936,2.295275588,1.83070866,2.759842517, +1937,2.519685037,2.055118108,2.984251965, +1938,2.622047241,2.157480313,3.08661417, +1939,2.826771651,2.346456691,3.307086611, +1940,2.618110234,2.18110236,3.055118107, +1941,3.098425194,2.673228344,3.523622044, +1942,3.098425194,2.673228344,3.523622044, +1943,3.098425194,2.673228344,3.523622044, +1944,2.84645669,2.425196848,3.267716532, +1945,2.95669291,2.535433068,3.377952752, +1946,3.251968501,2.834645666,3.669291335, +1947,3.374015745,2.996062989,3.7519685, +1948,3.562992122,3.19685039,3.929133854, +1949,3.51181102,3.181102359,3.842519681, +1950,3.598425193,3.287401571,3.909448815, +1951,3.972440941,3.665354327,4.279527555, +1952,3.870078736,3.56692913,4.173228342, +1953,4.043307082,3.748031492,4.338582673, +1954,3.929133854,3.64173228,4.216535429, +1955,3.964566925,3.685039366,4.244094484, +1956,3.763779524,3.488188973,4.039370075, +1957,4.291338578,4.019685035,4.562992121, +1958,4.346456688,4.086614169,4.606299208, +1959,4.358267712,4.102362201,4.614173224, +1960,4.503937003,4.244094484,4.763779523, +1961,4.748031491,4.488188972,5.007874011, +1962,4.543307082,4.283464563,4.803149601, +1963,4.480314956,4.220472437,4.740157475, +1964,4.169291334,3.905511807,4.433070862, +1965,4.610236216,4.346456688,4.874015743, +1966,4.397637791,4.137795271,4.65748031, +1967,4.452755901,4.196850389,4.708661413, +1968,4.484251964,4.220472437,4.748031491, +1969,4.751968499,4.476377948,5.02755905, +1970,4.67716535,4.401574799,4.9527559, +1971,4.881889759,4.610236216,5.153543302, +1972,5.240157475,4.968503932,5.511811018, +1973,5.003937003,4.736220468,5.271653538, +1974,5.472440939,5.204724404,5.740157474, +1975,5.409448813,5.145669286,5.673228341, +1976,5.370078735,5.1023622,5.63779527, +1977,5.303149601,5.043307081,5.56299212, +1978,5.555118105,5.291338577,5.818897632, +1979,5.362204719,5.098425192,5.625984246, +1980,5.598425191,5.34251968,5.854330703, +1981,6.086614167,5.830708655,6.342519679, +1982,5.858267711,5.610236215,6.106299206, +1983,6.188976372,5.93307086,6.444881883, +1984,6.153543301,5.905511805,6.401574797, +1985,5.74803149,5.499999994,5.996062986, +1986,5.771653537,5.523622042,6.019685033, +1987,5.795275585,5.551181097,6.039370073, +1988,5.980314955,5.732283459,6.22834645, +1989,6.157480309,5.905511805,6.409448812, +1990,6.232283458,5.972440939,6.492125978, +1991,6.334645663,6.074803143,6.594488182, +1992,6.35826771,6.094488183,6.622047237, +1993,6.291338576,6.027559049,6.555118104,6.297493046 +1994,6.499999993,6.236220466,6.763779521,6.310933553 +1995,6.618110229,6.354330702,6.881889757,6.452568661 +1996,6.787401568,6.523622041,7.051181095,6.62763131 +1997,7.066929127,6.803149599,7.330708654,6.733920367 +1998,6.665354324,6.393700781,6.937007867,6.865806069 +1999,7.011811016,6.736220466,7.287401567,6.848689771 +2000,7.062992119,6.791338576,7.334645662,6.920582014 +2001,7.287401567,7.019685032,7.555118103,7.087460011 +2002,7.381889756,7.110236213,7.653543299,7.319697525 +2003,7.759842512,7.484251961,8.035433063,7.488352718 +2004,7.740157472,7.464566922,8.015748023,7.507932839 +2005,7.74409448,7.472440937,8.015748023,7.644563144 +2006,7.917322827,7.645669284,8.18897637,7.697420009 +2007,7.996062984,7.712598417,8.279527551,7.70214715 +2008,8.350393692,8.078740149,8.622047235,7.90736541 +2009,8.586614164,8.311023614,8.862204715,8.04635409 +2010,8.901574794,8.618110227,9.185039361,8.122972567 +2011,8.96456692,8.661417314,9.267716526,8.053065004 +2012,9.326771644,8.992125975,9.661417313,8.457057629 +2013,8.980314951,8.622047235,9.338582668,8.546648227 \ No newline at end of file diff --git a/9-data-analysis-python/5-sea-level-predictor/main.py b/9-data-analysis-python/5-sea-level-predictor/main.py new file mode 100644 index 0000000..e3fa261 --- /dev/null +++ b/9-data-analysis-python/5-sea-level-predictor/main.py @@ -0,0 +1,9 @@ +# This entrypoint file to be used in development. Start by reading README.md +import sea_level_predictor +from unittest import main + +# Test your function by calling it here +sea_level_predictor.draw_plot() + +# Run unit tests automatically +main(module='test_module', exit=False) \ No newline at end of file diff --git a/9-data-analysis-python/5-sea-level-predictor/poetry.lock b/9-data-analysis-python/5-sea-level-predictor/poetry.lock new file mode 100644 index 0000000..ba1acc2 --- /dev/null +++ b/9-data-analysis-python/5-sea-level-predictor/poetry.lock @@ -0,0 +1,70 @@ +[[package]] +category = "main" +description = "NumPy is the fundamental package for array computing with Python." +name = "numpy" +optional = false +python-versions = ">=3.5" +version = "1.17.4" + +[[package]] +category = "main" +description = "Powerful data structures for data analysis, time series, and statistics" +name = "pandas" +optional = false +python-versions = ">=3.5.3" +version = "0.25.3" + +[package.dependencies] +numpy = ">=1.13.3" +python-dateutil = ">=2.6.1" +pytz = ">=2017.2" + +[[package]] +category = "main" +description = "Extensions to the standard Python datetime module" +name = "python-dateutil" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" +version = "2.8.1" + +[package.dependencies] +six = ">=1.5" + +[[package]] +category = "main" +description = "World timezone definitions, modern and historical" +name = "pytz" +optional = false +python-versions = "*" +version = "2019.3" + +[[package]] +category = "main" +description = "SciPy: Scientific Library for Python" +name = "scipy" +optional = false +python-versions = ">=3.5" +version = "1.4.1" + +[package.dependencies] +numpy = ">=1.13.3" + +[[package]] +category = "main" +description = "Python 2 and 3 compatibility utilities" +name = "six" +optional = false +python-versions = ">=2.6, !=3.0.*, !=3.1.*" +version = "1.13.0" + +[metadata] +content-hash = "2b7d90476e9a0bb8e18181af41a4cac15addc5d71a9834f08f8fae9eb3711690" +python-versions = "^3.7" + +[metadata.hashes] +numpy = ["0a7a1dd123aecc9f0076934288ceed7fd9a81ba3919f11a855a7887cbe82a02f", "0c0763787133dfeec19904c22c7e358b231c87ba3206b211652f8cbe1241deb6", "3d52298d0be333583739f1aec9026f3b09fdfe3ddf7c7028cb16d9d2af1cca7e", "43bb4b70585f1c2d153e45323a886839f98af8bfa810f7014b20be714c37c447", "475963c5b9e116c38ad7347e154e5651d05a2286d86455671f5b1eebba5feb76", "64874913367f18eb3013b16123c9fed113962e75d809fca5b78ebfbb73ed93ba", "683828e50c339fc9e68720396f2de14253992c495fdddef77a1e17de55f1decc", "6ca4000c4a6f95a78c33c7dadbb9495c10880be9c89316aa536eac359ab820ae", "75fd817b7061f6378e4659dd792c84c0b60533e867f83e0d1e52d5d8e53df88c", "7d81d784bdbed30137aca242ab307f3e65c8d93f4c7b7d8f322110b2e90177f9", "8d0af8d3664f142414fd5b15cabfd3b6cc3ef242a3c7a7493257025be5a6955f", "9679831005fb16c6df3dd35d17aa31dc0d4d7573d84f0b44cc481490a65c7725", "a8f67ebfae9f575d85fa859b54d3bdecaeece74e3274b0b5c5f804d7ca789fe1", "acbf5c52db4adb366c064d0b7c7899e3e778d89db585feadd23b06b587d64761", "ada4805ed51f5bcaa3a06d3dd94939351869c095e30a2b54264f5a5004b52170", "c7354e8f0eca5c110b7e978034cd86ed98a7a5ffcf69ca97535445a595e07b8e", "e2e9d8c87120ba2c591f60e32736b82b67f72c37ba88a4c23c81b5b8fa49c018", "e467c57121fe1b78a8f68dd9255fbb3bb3f4f7547c6b9e109f31d14569f490c3", "ede47b98de79565fcd7f2decb475e2dcc85ee4097743e551fe26cfc7eb3ff143", "f58913e9227400f1395c7b800503ebfdb0772f1c33ff8cb4d6451c06cabdf316", "fe39f5fd4103ec4ca3cb8600b19216cd1ff316b4990f4c0b6057ad982c0a34d5"] +pandas = ["00dff3a8e337f5ed7ad295d98a31821d3d0fe7792da82d78d7fd79b89c03ea9d", "22361b1597c8c2ffd697aa9bf85423afa9e1fcfa6b1ea821054a244d5f24d75e", "255920e63850dc512ce356233081098554d641ba99c3767dde9e9f35630f994b", "26382aab9c119735908d94d2c5c08020a4a0a82969b7e5eefb92f902b3b30ad7", "33970f4cacdd9a0ddb8f21e151bfb9f178afb7c36eb7c25b9094c02876f385c2", "4545467a637e0e1393f7d05d61dace89689ad6d6f66f267f86fff737b702cce9", "52da74df8a9c9a103af0a72c9d5fdc8e0183a90884278db7f386b5692a2220a4", "61741f5aeb252f39c3031d11405305b6d10ce663c53bc3112705d7ad66c013d0", "6a3ac2c87e4e32a969921d1428525f09462770c349147aa8e9ab95f88c71ec71", "7458c48e3d15b8aaa7d575be60e1e4dd70348efcd9376656b72fecd55c59a4c3", "78bf638993219311377ce9836b3dc05f627a666d0dbc8cec37c0ff3c9ada673b", "8153705d6545fd9eb6dd2bc79301bff08825d2e2f716d5dced48daafc2d0b81f", "975c461accd14e89d71772e89108a050fa824c0b87a67d34cedf245f6681fc17", "9962957a27bfb70ab64103d0a7b42fa59c642fb4ed4cb75d0227b7bb9228535d", "adc3d3a3f9e59a38d923e90e20c4922fc62d1e5a03d083440468c6d8f3f1ae0a", "bbe3eb765a0b1e578833d243e2814b60c825b7fdbf4cdfe8e8aae8a08ed56ecf", "df8864824b1fe488cf778c3650ee59c3a0d8f42e53707de167ba6b4f7d35f133", "e45055c30a608076e31a9fcd780a956ed3b1fa20db61561b8d88b79259f526f7", "ee50c2142cdcf41995655d499a157d0a812fce55c97d9aad13bc1eef837ed36c"] +python-dateutil = ["73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c", "75bb3f31ea686f1197762692a9ee6a7550b59fc6ca3a1f4b5d7e32fb98e2da2a"] +pytz = ["1c557d7d0e871de1f5ccd5833f60fb2550652da6be2693c1e02300743d21500d", "b02c06db6cf09c12dd25137e563b31700d3b80fcc4ad23abb7a315f2789819be"] +scipy = ["00af72998a46c25bdb5824d2b729e7dabec0c765f9deb0b504f928591f5ff9d4", "0902a620a381f101e184a958459b36d3ee50f5effd186db76e131cbefcbb96f7", "1e3190466d669d658233e8a583b854f6386dd62d655539b77b3fa25bfb2abb70", "2cce3f9847a1a51019e8c5b47620da93950e58ebc611f13e0d11f4980ca5fecb", "3092857f36b690a321a662fe5496cb816a7f4eecd875e1d36793d92d3f884073", "386086e2972ed2db17cebf88610aab7d7f6e2c0ca30042dc9a89cf18dcc363fa", "71eb180f22c49066f25d6df16f8709f215723317cc951d99e54dc88020ea57be", "770254a280d741dd3436919d47e35712fb081a6ff8bafc0f319382b954b77802", "787cc50cab3020a865640aba3485e9fbd161d4d3b0d03a967df1a2881320512d", "8a07760d5c7f3a92e440ad3aedcc98891e915ce857664282ae3c0220f3301eb6", "8d3bc3993b8e4be7eade6dcc6fd59a412d96d3a33fa42b0fa45dc9e24495ede9", "9508a7c628a165c2c835f2497837bf6ac80eb25291055f56c129df3c943cbaf8", "a144811318853a23d32a07bc7fd5561ff0cac5da643d96ed94a4ffe967d89672", "a1aae70d52d0b074d8121333bc807a485f9f1e6a69742010b33780df2e60cfe0", "a2d6df9eb074af7f08866598e4ef068a2b310d98f87dc23bd1b90ec7bdcec802", "bb517872058a1f087c4528e7429b4a44533a902644987e7b2fe35ecc223bc408", "c5cac0c0387272ee0e789e94a570ac51deb01c796b37fb2aad1fb13f85e2f97d", "cc971a82ea1170e677443108703a2ec9ff0f70752258d0e9f5433d00dda01f59", "dba8306f6da99e37ea08c08fef6e274b5bf8567bb094d1dbe86a20e532aca088", "dc60bb302f48acf6da8ca4444cfa17d52c63c5415302a9ee77b3b21618090521", "dee1bbf3a6c8f73b6b218cb28eed8dd13347ea2f87d572ce19b289d6fd3fbc59"] +six = ["1f1b7d42e254082a9db6279deae68afb421ceba6158efa6131de7b3003ee93fd", "30f610279e8b2578cab6db20741130331735c781b56053c59c4076da27f06b66"] diff --git a/9-data-analysis-python/5-sea-level-predictor/pyproject.toml b/9-data-analysis-python/5-sea-level-predictor/pyproject.toml new file mode 100644 index 0000000..ab957fa --- /dev/null +++ b/9-data-analysis-python/5-sea-level-predictor/pyproject.toml @@ -0,0 +1,11 @@ +[tool] +[tool.poetry] +authors = ["Your Name "] +name = "root" +version = "0.0.0" +description = "" + +[tool.poetry.dependencies] +pandas = "*" +python = "^3.7" +scipy = "*" diff --git a/9-data-analysis-python/5-sea-level-predictor/sea_level_plot.png b/9-data-analysis-python/5-sea-level-predictor/sea_level_plot.png new file mode 100644 index 0000000..22523ac Binary files /dev/null and b/9-data-analysis-python/5-sea-level-predictor/sea_level_plot.png differ diff --git a/9-data-analysis-python/5-sea-level-predictor/sea_level_predictor.py b/9-data-analysis-python/5-sea-level-predictor/sea_level_predictor.py new file mode 100644 index 0000000..61cc7e8 --- /dev/null +++ b/9-data-analysis-python/5-sea-level-predictor/sea_level_predictor.py @@ -0,0 +1,35 @@ +import pandas as pd +import matplotlib.pyplot as plt +import numpy as np +from scipy.stats import linregress + +def draw_plot(): + # Read data from file + df = pd.read_csv('epa-sea-level.csv') + + # Create scatter plot + plt.figure(figsize=(16, 6)) + + + plt.scatter(df['Year'], df['CSIRO Adjusted Sea Level']) + + # Create first line of best fit + res = linregress(df['Year'], df['CSIRO Adjusted Sea Level']) + plt.plot(np.arange(1880, 2051), res.intercept + res.slope * np.arange(1880, 2051), 'g') + + # Create second line of best fit + df = df.loc[df['Year'] >= 2000] + + res = linregress(df['Year'], df['CSIRO Adjusted Sea Level']) + + plt.plot(np.arange(2000, 2051), res.intercept + res.slope * np.arange(2000, 2051), 'r') + + # Add labels and title + plt.xlabel('Year') + plt.ylabel('Sea Level (inches)') + plt.title('Rise in Sea Level') + plt.xlim(1850, 2075) + + # Save plot and return data for testing (DO NOT MODIFY) + plt.savefig('sea_level_plot.png') + return plt.gca() \ No newline at end of file diff --git a/9-data-analysis-python/5-sea-level-predictor/test_module.py b/9-data-analysis-python/5-sea-level-predictor/test_module.py new file mode 100644 index 0000000..24630d1 --- /dev/null +++ b/9-data-analysis-python/5-sea-level-predictor/test_module.py @@ -0,0 +1,41 @@ +import unittest +import sea_level_predictor +import matplotlib as mpl +import numpy as np + + +# the test case +class LinePlotTestCase(unittest.TestCase): + def setUp(self): + self.ax = sea_level_predictor.draw_plot() + + def test_plot_title(self): + actual = self.ax.get_title() + expected = "Rise in Sea Level" + self.assertEqual(actual, expected, "Expected line plot title to be 'Rise in Sea Level'") + + def test_plot_labels(self): + actual = self.ax.get_xlabel() + expected = "Year" + self.assertEqual(actual, expected, "Expected line plot xlabel to be 'Year'") + actual = self.ax.get_ylabel() + expected = "Sea Level (inches)" + self.assertEqual(actual, expected, "Expected line plot ylabel to be 'Sea Level (inches)'") + actual = self.ax.get_xticks().tolist() + expected = [1850.0, 1875.0, 1900.0, 1925.0, 1950.0, 1975.0, 2000.0, 2025.0, 2050.0, 2075.0] + self.assertEqual(actual, expected, "Expected x tick labels to be '1850.0, 1875.0, 1900.0, 1925.0, 1950.0, 1975.0, 2000.0, 2025.0, 2050.0, 2075.0'") + + def test_plot_data_points(self): + actual = self.ax.get_children()[0].get_offsets().data.tolist() + expected = [[1880.0, 0.0], [1881.0, 0.220472441], [1882.0, -0.440944881], [1883.0, -0.232283464], [1884.0, 0.590551181], [1885.0, 0.531496062], [1886.0, 0.437007874], [1887.0, 0.216535433], [1888.0, 0.299212598], [1889.0, 0.362204724], [1890.0, 0.440944881], [1891.0, 0.374015748], [1892.0, 0.499999999], [1893.0, 0.685039369], [1894.0, 0.303149606], [1895.0, 0.767716535], [1896.0, 0.468503937], [1897.0, 0.673228346], [1898.0, 1.043307086], [1899.0, 1.338582676], [1900.0, 1.125984251], [1901.0, 1.110236219], [1902.0, 1.291338581], [1903.0, 1.606299211], [1904.0, 1.2007874], [1905.0, 0.984251968], [1906.0, 1.251968503], [1907.0, 1.196850392], [1908.0, 1.098425196], [1909.0, 1.27559055], [1910.0, 1.271653542], [1911.0, 1.598425195], [1912.0, 1.476377951], [1913.0, 1.547244093], [1914.0, 1.795275589], [1915.0, 2.10629921], [1916.0, 2.031496061], [1917.0, 1.854330707], [1918.0, 1.791338581], [1919.0, 1.854330707], [1920.0, 1.905511809], [1921.0, 1.988188974], [1922.0, 1.952755904], [1923.0, 1.999999998], [1924.0, 1.712598423], [1925.0, 1.791338581], [1926.0, 2.047244092], [1927.0, 2.003937006], [1928.0, 1.850393699], [1929.0, 1.905511809], [1930.0, 2.062992124], [1931.0, 2.047244092], [1932.0, 2.271653541], [1933.0, 2.440944879], [1934.0, 2.228346454], [1935.0, 2.448818895], [1936.0, 2.295275588], [1937.0, 2.519685037], [1938.0, 2.622047241], [1939.0, 2.826771651], [1940.0, 2.618110234], [1941.0, 3.098425194], [1942.0, 3.098425194], [1943.0, 3.098425194], [1944.0, 2.84645669], [1945.0, 2.95669291], [1946.0, 3.251968501], [1947.0, 3.374015745], [1948.0, 3.562992122], [1949.0, 3.51181102], [1950.0, 3.598425193], [1951.0, 3.972440941], [1952.0, 3.870078736], [1953.0, 4.043307082], [1954.0, 3.929133854], [1955.0, 3.964566925], [1956.0, 3.763779524], [1957.0, 4.291338578], [1958.0, 4.346456688], [1959.0, 4.358267712], [1960.0, 4.503937003], [1961.0, 4.748031491], [1962.0, 4.543307082], [1963.0, 4.480314956], [1964.0, 4.169291334], [1965.0, 4.610236216], [1966.0, 4.397637791], [1967.0, 4.452755901], [1968.0, 4.484251964], [1969.0, 4.751968499], [1970.0, 4.67716535], [1971.0, 4.881889759], [1972.0, 5.240157475], [1973.0, 5.003937003], [1974.0, 5.472440939], [1975.0, 5.409448813], [1976.0, 5.370078735], [1977.0, 5.303149601], [1978.0, 5.555118105], [1979.0, 5.362204719], [1980.0, 5.598425191], [1981.0, 6.086614167], [1982.0, 5.858267711], [1983.0, 6.188976372], [1984.0, 6.153543301], [1985.0, 5.74803149], [1986.0, 5.771653537], [1987.0, 5.795275585], [1988.0, 5.980314955], [1989.0, 6.157480309], [1990.0, 6.232283458], [1991.0, 6.334645663], [1992.0, 6.35826771], [1993.0, 6.291338576], [1994.0, 6.499999993], [1995.0, 6.618110229], [1996.0, 6.787401568], [1997.0, 7.066929127], [1998.0, 6.665354324], [1999.0, 7.011811016], [2000.0, 7.062992119], [2001.0, 7.287401567], [2002.0, 7.381889756], [2003.0, 7.759842512], [2004.0, 7.740157472], [2005.0, 7.74409448], [2006.0, 7.917322827], [2007.0, 7.996062984], [2008.0, 8.350393692], [2009.0, 8.586614164], [2010.0, 8.901574794], [2011.0, 8.96456692], [2012.0, 9.326771644], [2013.0, 8.980314951]] + np.testing.assert_almost_equal(actual, expected, 7, "Expected different data points in scatter plot.") + def test_plot_lines(self): + actual = self.ax.get_lines()[0].get_ydata().tolist() + expected = [-0.5421240249263661, -0.4790794409142336, -0.41603485690208686, -0.3529902728899543, -0.2899456888778218, -0.22690110486568926, -0.16385652085355673, -0.1008119368414242, -0.037767352829277456, 0.025277231182855076, 0.08832181519498761, 0.15136639920712014, 0.21441098321925267, 0.2774555672313852, 0.34050015124351773, 0.4035447352556645, 0.466589319267797, 0.5296339032799295, 0.5926784872920621, 0.6557230713041946, 0.7187676553163271, 0.7818122393284739, 0.8448568233406064, 0.9079014073527389, 0.9709459913648715, 1.033990575377004, 1.0970351593891365, 1.1600797434012833, 1.2231243274134158, 1.2861689114255483, 1.3492134954376809, 1.4122580794498134, 1.475302663461946, 1.5383472474740927, 1.6013918314862252, 1.6644364154983577, 1.7274809995104903, 1.7905255835226228, 1.8535701675347553, 1.9166147515468879, 1.9796593355590346, 2.042703919571167, 2.1057485035832997, 2.168793087595432, 2.2318376716075647, 2.2948822556196973, 2.357926839631844, 2.4209714236439766, 2.484016007656109, 2.5470605916682416, 2.610105175680374, 2.6731497596925067, 2.7361943437046534, 2.799238927716786, 2.8622835117289185, 2.925328095741051, 2.9883726797531835, 3.051417263765316, 3.1144618477774486, 3.1775064317895954, 3.240551015801728, 3.3035955998138604, 3.366640183825993, 3.4296847678381255, 3.492729351850258, 3.5557739358624048, 3.6188185198745373, 3.68186310388667, 3.7449076878988024, 3.807952271910935, 3.8709968559230674, 3.934041439935214, 3.9970860239473467, 4.060130607959479, 4.123175191971612, 4.186219775983744, 4.249264359995877, 4.312308944008024, 4.375353528020156, 4.438398112032289, 4.501442696044421, 4.564487280056554, 4.627531864068686, 4.690576448080819, 4.7536210320929655, 4.816665616105098, 4.879710200117231, 4.942754784129363, 5.005799368141496, 5.068843952153628, 5.131888536165775, 5.194933120177907, 5.25797770419004, 5.3210222882021725, 5.384066872214305, 5.4471114562264376, 5.510156040238584, 5.573200624250717, 5.636245208262849, 5.699289792274982, 5.762334376287114, 5.825378960299247, 5.8884235443113795, 5.951468128323526, 6.014512712335659, 6.077557296347791, 6.140601880359924, 6.203646464372056, 6.266691048384189, 6.329735632396336, 6.392780216408468, 6.455824800420601, 6.518869384432733, 6.581913968444866, 6.644958552456998, 6.708003136469145, 6.771047720481278, 6.83409230449341, 6.897136888505543, 6.960181472517675, 7.023226056529808, 7.086270640541954, 7.149315224554087, 7.2123598085662195, 7.275404392578352, 7.338448976590485, 7.401493560602617, 7.46453814461475, 7.527582728626896, 7.590627312639029, 7.653671896651161, 7.716716480663294, 7.7797610646754265, 7.842805648687559, 7.905850232699706, 7.968894816711838, 8.03193940072397, 8.094983984736103, 8.158028568748236, 8.221073152760368, 8.284117736772515, 8.347162320784648, 8.41020690479678, 8.473251488808913, 8.536296072821045, 8.599340656833178, 8.66238524084531, 8.725429824857457, 8.78847440886959, 8.851518992881722, 8.914563576893855, 8.977608160905987, 9.040652744918134, 9.103697328930252, 9.166741912942399, 9.229786496954517, 9.292831080966664, 9.35587566497881, 9.41892024899093, 9.481964833003076, 9.545009417015194, 9.608054001027341, 9.671098585039488, 9.734143169051606, 9.797187753063753, 9.860232337075871, 9.923276921088018, 9.986321505100136, 10.049366089112283, 10.11241067312443, 10.175455257136548] + np.testing.assert_almost_equal(actual, expected, 7, "Expected different line for first line of best fit.") + actual = self.ax.get_lines()[1].get_ydata().tolist() + expected = [7.06107985777146, 7.227507131103323, 7.393934404435242, 7.560361677767105, 7.726788951098968, 7.89321622443083, 8.059643497762693, 8.226070771094555, 8.392498044426418, 8.55892531775828, 8.725352591090143, 8.891779864422006, 9.058207137753925, 9.224634411085788, 9.39106168441765, 9.557488957749513, 9.723916231081375, 9.890343504413238, 10.0567707777451, 10.223198051076963, 10.389625324408826, 10.556052597740688, 10.72247987107255, 10.88890714440447, 11.055334417736333, 11.221761691068195, 11.388188964400058, 11.55461623773192, 11.721043511063783, 11.887470784395646, 12.053898057727508, 12.220325331059371, 12.386752604391233, 12.553179877723153, 12.719607151055015, 12.886034424386878, 13.05246169771874, 13.218888971050603, 13.385316244382466, 13.551743517714328, 13.718170791046191, 13.884598064378054, 14.051025337709916, 14.217452611041836, 14.383879884373698, 14.55030715770556, 14.716734431037423, 14.883161704369286, 15.049588977701148, 15.216016251033011, 15.382443524364874] + np.testing.assert_almost_equal(actual, expected, 7, "Expected different line for second line of best fit.") + +if __name__ == "__main__": + unittest.main()