def test_econ_visualizer_constructor(self):

        ev = EconVisualizer()
        self.assertEqual(ev.income, None)
        self.assertEqual(ev.countries, None)

        ev = EconVisualizer(income=self.income, countries=self.countries)
        self.assertEqual(ev.income.shape, self.income.shape)
        self.assertEqual(ev.countries.shape, self.countries.shape)

        with self.assertRaises(TypeError):
            EconVisualizer(income=12, countries=self.countries)
        with self.assertRaises(TypeError):
            EconVisualizer(income=self.income, countries=[])
    def test_graph_years(self):

        ev = EconVisualizer()
        with self.assertRaises(TypeError):
            ev.graph_years()
        with self.assertRaises(ValueError):
            ev.graph_years(1900)
        with self.assertRaises(ValueError):
            ev.graph_years([1900, 1200, 1902])
Example #3
0
            sys.exit(0)

        except EOFError:
            # Exit if the user enters Ctrl+D
            sys.exit(0)

        if user_input.lower() == 'finish':
            break

        try:
            year = int(user_input)
        except ValueError:
            print("year must be an integer. Try again?")
            continue

        try:
            graph_income(income, year)

        except ValueError:
            print('year ' + str(year) + " not in range. Try again?")

        except TypeError:
            print('year must be int-like. Try again?')
    """
    Here out of the while loop, the user had to exit the while loop by typing Finish.
    Now we generate graphs for the years 2007-2012.
    """
    ev = EconVisualizer(income, countries)
    ev.graph_years(list(range(2007, 2013)))
    print("Report completetd. See boxplots and histograms of reported data")
Example #4
0
        except EOFError:
            # Exit if the user enters Ctrl+D
            sys.exit(0)

        if user_input.lower() == "finish":
            break

        try:
            year = int(user_input)
        except ValueError:
            print("year must be an integer. Try again?")
            continue

        try:
            graph_income(income, year)

        except ValueError:
            print("year " + str(year) + " not in range. Try again?")

        except TypeError:
            print("year must be int-like. Try again?")

    """
    Here out of the while loop, the user had to exit the while loop by typing Finish.
    Now we generate graphs for the years 2007-2012.
    """
    ev = EconVisualizer(income, countries)
    ev.graph_years(list(range(2007, 2013)))
    print("Report completetd. See boxplots and histograms of reported data")
    def test_bar(self):

        ev = EconVisualizer(self.income, self.countries)
        ev._box(self.merged_df, visualize=False)

        ev = EconVisualizer()
        ev._box(self.merged_df, visualize=False)

        with self.assertRaises(TypeError):
            ev._box(10, visualize=False)
        with self.assertRaises(KeyError):
            ev._box(df=self.countries, visualize=False)
    def test_hist(self):

        ev = EconVisualizer(self.income, self.countries)
        ev._hist(self.merged_df, visualize=False)

        ev = EconVisualizer()
        ev._hist(self.merged_df, visualize=False)

        with self.assertRaises(TypeError):
            ev._hist(10, visualize=False)
        with self.assertRaises(ValueError):
            ev._hist(df=self.countries, visualize=False)