Пример #1
0
 def test_cli_plots_tkagg(self, backend_mock, df_from_input_mock, show_mock):
     backend_mock.return_value = 'macosx'
     df_in = pd.DataFrame({
         'x': range(1, 101),
         'y': range(1, 101),
     })
     df_from_input_mock.return_value = df_in
     sys.stdout = MagicMock()
     main()
     sys.stdout = sys.__stdout__
     self.assertTrue(show_mock.called)
Пример #2
0
    def test_cli_fit(self, df_from_input_mock, df_to_output_mock):
        df_in = pd.DataFrame({
            'x': range(1, 101),
            'y': range(1, 101),
        })
        df_from_input_mock.return_value = df_in
        main()

        df_out = df_to_output_mock.call_args_list[0][0][1]
        self.assertTrue(np.allclose(df_out.y, df_out.fit_))
        self.assertTrue(np.allclose(df_out.y * 0, df_out.resid_))
Пример #3
0
    def test_cli_fit(self, df_from_input_mock, df_to_output_mock):
        df_in = pd.DataFrame({
            'x': range(1, 101),
            'y': range(1, 101),
        })
        df_from_input_mock.return_value = df_in
        main()

        df_out = df_to_output_mock.call_args_list[0][0][1]
        self.assertTrue(np.allclose(df_out.y, df_out.fit_))
        self.assertTrue(np.allclose(df_out.y * 0, df_out.resid_))
Пример #4
0
 def test_cli_stats(self, df_from_input_mock, df_to_output_mock):
     df_in = pd.DataFrame({
         'x': range(1, 101),
         'y': range(1, 101),
     })
     df_from_input_mock.return_value = df_in
     write_mock = MagicMock()
     sys.stdout = MagicMock()
     sys.stdout.write = write_mock
     main()
     sys.stdout = sys.__stdout__
     out_str = write_mock.call_args_list[0][0][0].replace('\n', ' ')
     rex = re.compile(r'.*x\s+1\.0+')
     m = rex.match(out_str)
     self.assertTrue(True if m else False)
Пример #5
0
 def test_cli_stats(self, df_from_input_mock, df_to_output_mock):
     df_in = pd.DataFrame({
         'x': range(1, 101),
         'y': range(1, 101),
     })
     df_from_input_mock.return_value = df_in
     write_mock = MagicMock()
     sys.stdout = MagicMock()
     sys.stdout.write = write_mock
     main()
     sys.stdout = sys.__stdout__
     out_str = write_mock.call_args_list[0][0][0].replace('\n', ' ')
     rex = re.compile(r'.*x\s+1\.0+')
     m = rex.match(out_str)
     self.assertTrue(True if m else False)
Пример #6
0
 def test_cli_plots_osx(self, get_module_mock, df_from_input_mock):
     backend_mock = MagicMock(lower=MagicMock(return_value='macosx'))
     mpl_mock = MagicMock(get_backend=MagicMock(return_value=backend_mock))
     show_mock = MagicMock()
     plot_lib_mock = MagicMock(show=show_mock)
     get_module_mock.side_effect = [
         plot_lib_mock,
         mpl_mock,
         MagicMock(return_value=MagicMock()),
         MagicMock(return_value=MagicMock()),
     ]
     df_in = pd.DataFrame({
         'x': range(1, 101),
         'y': range(1, 101),
     })
     df_from_input_mock.return_value = df_in
     sys.stdout = MagicMock()
     main()
     sys.stdout = sys.__stdout__
     self.assertTrue(show_mock.called)
Пример #7
0
 def test_cli_plots_osx(self, get_module_mock, df_from_input_mock):
     backend_mock = MagicMock(lower=MagicMock(return_value='macosx'))
     mpl_mock = MagicMock(get_backend=MagicMock(return_value=backend_mock))
     show_mock = MagicMock()
     plot_lib_mock = MagicMock(show=show_mock)
     get_module_mock.side_effect = [
         plot_lib_mock,
         mpl_mock,
         MagicMock(return_value=MagicMock()),
         MagicMock(return_value=MagicMock()),
     ]
     df_in = pd.DataFrame({
         'x': range(1, 101),
         'y': range(1, 101),
     })
     df_from_input_mock.return_value = df_in
     sys.stdout = MagicMock()
     main()
     sys.stdout = sys.__stdout__
     self.assertTrue(show_mock.called)