def test_charts_cycleplot_exists(self):
     expected_df, expected_dict = hf.extract_nwis_df(test_json, interpolate=False)
     # Select first numeric column
     expected_df = expected_df.loc[
         :, expected_df.select_dtypes(include="number").columns[0]
     ]
     actual_fig, actual_ax = charts.cycleplot(expected_df)
     self.assertIsInstance(actual_fig, matplotlib.figure.Figure)
     self.assertIsInstance(actual_ax[0], matplotlib.axes.Axes)
Example #2
0
    def test_charts_cycleplot_parts(self):
        expected = hf.extract_nwis_df(test_json)

        actual_fig, actual_ax = charts.cycleplot(expected)

        actual_xscale = actual_ax[0].xaxis.get_scale()
        actual_yscale = actual_ax[0].yaxis.get_scale()
        actual_ylabel = actual_ax[0].yaxis.get_label_text()

        self.assertEqual(actual_xscale, 'linear')
        self.assertEqual(actual_yscale, 'linear')
        self.assertEqual(actual_ylabel, 'Stream Discharge (m³/s)')
    def test_charts_cycleplot_parts(self):
        expected_df, expected_dict = hf.extract_nwis_df(test_json, interpolate=False)
        actual_fig, actual_ax = charts.cycleplot(
            expected_df, legend_loc="center", title="test title"
        )

        actual_xscale = actual_ax[0].xaxis.get_scale()
        actual_yscale = actual_ax[0].yaxis.get_scale()
        actual_ylabel = actual_ax[0].yaxis.get_label_text()
        actual_legend = actual_ax[0].get_legend()
        actual_legend_loc = actual_legend._loc
        actual_title = (
            actual_fig._suptitle.get_text()
        )  # unofficial title accessor! A little wonky.

        self.assertEqual(actual_xscale, "linear")
        self.assertEqual(actual_yscale, "linear")
        self.assertEqual(actual_ylabel, "Discharge (ft³/s)")
        self.assertTrue(actual_legend)
        self.assertEqual(
            actual_legend_loc, 10
        )  # '10' is internal code for legend(loc = 'center')
        self.assertEqual(actual_title, "test title")
 def test_charts_cycleplot_raises_for_non_series(self):
     with self.assertRaises(ValueError):
         actual_fig, actual_ax = charts.cycleplot("nonsense")
 def test_charts_cycleplot_cycle_nonsense_raises_ValueError(self):
     expected_df, expected_dict = hf.extract_nwis_df(test_json, interpolate=False)
     with self.assertRaises(ValueError):
         actual_fig, actual_ax = charts.cycleplot(expected_df, "nonsense")
 def test_charts_cycleplot_cycle_diurnalhour(self):
     expected_df, expected_dict = hf.extract_nwis_df(test_json, interpolate=False)
     actual_fig, actual_ax = charts.cycleplot(expected_df, "diurnal-hour")
     self.assertIsInstance(actual_fig, matplotlib.figure.Figure)
     self.assertIsInstance(actual_ax[0], matplotlib.axes.Axes)
 def test_charts_cycleplot_compare_month(self):
     expected_df, expected_dict = hf.extract_nwis_df(test_json, interpolate=False)
     actual_fig, actual_ax = charts.cycleplot(expected_df, compare="month")
     self.assertIsInstance(actual_fig, matplotlib.figure.Figure)
     self.assertIsInstance(actual_ax[0], matplotlib.axes.Axes)
Example #8
0
 def test_charts_cycleplot_exists(self):
     expected = hf.extract_nwis_df(test_json)
     actual_fig, actual_ax = charts.cycleplot(expected)
     self.assertIsInstance(actual_fig, matplotlib.figure.Figure)
     self.assertIsInstance(actual_ax[0], matplotlib.axes.Axes)