<s> import unittest <EOL> from main import Dora <EOL> import pandas as pd <EOL> class TestDora ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . dora = Dora ( ) <EOL> self . dora . configure ( output = '<STR_LIT:A>' , data = '<STR_LIT>' ) <EOL> def test_configure ( self ) : <EOL> data = pd . read_csv ( '<STR_LIT>' ) <EOL> self . assertEqual ( self . dora . output , '<STR_LIT:A>' ) <EOL> self . assertTrue ( self . dora . data . equals ( data ) ) <EOL> def test_remove_feature ( self ) : <EOL> self . dora . remove_feature ( '<STR_LIT>' ) <EOL> self . assertFalse ( '<STR_LIT>' in self . dora . data . columns ) <EOL> def test_extract_feature ( self ) : <EOL> self . dora . extract_feature ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> lambda x : x * <NUM_LIT:2> <EOL> ) <EOL> actual_column = list ( self . dora . data [ '<STR_LIT>' ] ) <EOL> expected_column = [ <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> ] <EOL> self . assertEqual ( actual_column , expected_column ) <EOL> def test_impute_missing_values ( self ) : <EOL> del self . dora . data [ '<STR_LIT:D>' ] <EOL> self . dora . impute_missing_values ( ) <EOL> actual_column = list ( self . dora . data [ '<STR_LIT:B>' ] ) <EOL> expected_column = [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> self . assertEqual ( actual_column , expected_column ) <EOL> def test_scale_input_values ( self ) : <EOL> del self . dora . data [ '<STR_LIT:D>' ] , self . dora . data [ '<STR_LIT:B>' ] <EOL> self . dora . scale_input_values ( ) <EOL> actual_column = list ( self . dora . data [ '<STR_LIT:C>' ] ) <EOL> expected_column = [ - <NUM_LIT> , <NUM_LIT:0.0> , <NUM_LIT> ] <EOL> pairwise_diffs = map ( <EOL> lambda actual , expected : abs ( actual - expected ) , <EOL> actual_column , <EOL> expected_column <EOL> ) <EOL> total_diff = sum ( pairwise_diffs ) <EOL> self . assertAlmostEqual ( total_diff , <NUM_LIT:0> , places = <NUM_LIT:6> ) <EOL> def test_extract_ordinal_feature ( self ) : <EOL> self . dora . extract_ordinal_feature ( '<STR_LIT:D>' ) <EOL> features = self . dora . data . columns <EOL> self . assertTrue ( '<STR_LIT>' in features and '<STR_LIT>' in features ) <EOL> def test_input_columns ( self ) : <EOL> actual_input_columns = list ( self . dora . input_columns ( ) ) <EOL> expected_input_columns = list ( self . dora . data . columns ) <EOL> expected_input_columns . remove ( self . dora . output ) <EOL> self . assertEqual ( actual_input_columns , expected_input_columns ) <EOL> def test_logs ( self ) : <EOL> self . dora . extract_ordinal_feature ( '<STR_LIT:D>' ) <EOL> self . dora . impute_missing_values ( ) <EOL> self . dora . scale_input_values ( ) <EOL> actual_logs = self . dora . logs <EOL> expected_logs = [ <EOL> "<STR_LIT>" , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> self . assertEqual ( actual_logs , expected_logs ) <EOL> def test_snapshots ( self ) : <EOL> self . dora . snapshot ( '<STR_LIT:start>' ) <EOL> self . dora . extract_ordinal_feature ( '<STR_LIT:D>' ) <EOL> self . dora . use_snapshot ( '<STR_LIT:start>' ) <EOL> self . assertEqual ( self . dora . logs , [ ] ) <EOL> self . assertTrue ( self . dora . data . equals ( self . dora . initial_data ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
