Corey Morris commited on
Commit
ff055eb
1 Parent(s): 7a88af3

comparing current code to the saved file from the last commit

Browse files
Files changed (1) hide show
  1. test_regression.py +7 -27
test_regression.py CHANGED
@@ -7,37 +7,17 @@ import os
7
  class TestRegression(unittest.TestCase):
8
  def test_data_output_is_the_same(self):
9
 
10
- # # Run code and get output
11
- # df = ResultDataProcessor().data
12
-
13
- # # Save output to CSV
14
- # commit = '5603e9f51b643dbbb3da62943d5f26c48e11ae9b'
15
- # outfile = f'output_{commit}.csv'
16
- # df.to_csv(outfile)
17
-
18
- # # Checkout previous commit
19
- # prev_commit = '02b17021c8c2759ae08d23578b11bdb493941479'
20
- # checkout_command = f'git checkout {prev_commit}'
21
- # os.system(checkout_command)
22
-
23
- # # Rerun and save output
24
- # df = ResultDataProcessor().data
25
- # prev_outfile = f'output_{prev_commit}.csv'
26
- # prev_df.to_csv(prev_outfile)
27
-
28
- # # Diff outputs
29
- # import filecmp
30
- # assert filecmp.cmp(outfile, prev_outfile)
31
-
32
  df_current = ResultDataProcessor().data
33
 
34
- # Load the reference output file (generated manually from a previous commit)
35
- commit = '5b83d0bbaf92089fd7713e9e8edaa14c821b0dc7'
36
- reference_file = f'output_{commit}.csv'
37
- df_reference = pd.read_csv(reference_file)
 
 
38
 
39
  # Compare DataFrames, allowing for some tolerance in floating-point comparisons
40
- pd.testing.assert_frame_equal(df_current, df_reference, check_dtype=False, atol=1e-5)
41
 
42
 
43
  if __name__ == '__main__':
 
7
  class TestRegression(unittest.TestCase):
8
  def test_data_output_is_the_same(self):
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  df_current = ResultDataProcessor().data
11
 
12
+ # load the reference dataframe
13
+ last_commit = os.popen('git rev-parse HEAD').read().strip()
14
+ print(last_commit)
15
+ reference_file = f'output_{last_commit}.parquet'
16
+ df_reference = pd.read_parquet(reference_file)
17
+
18
 
19
  # Compare DataFrames, allowing for some tolerance in floating-point comparisons
20
+ pd.testing.assert_frame_equal(df_current, df_reference, check_dtype=True, atol=1e-5)
21
 
22
 
23
  if __name__ == '__main__':