@@ -12,7 +12,7 @@ def table_is_keyed_by_columns(table, column_names):
1212 # check for ill-condition
1313 missing_columns = set (column_names ) - set ([c for c in table .columns ])
1414 if len (missing_columns ) > 0 :
15- raise Exception ("missing columns: " + str (missing_columns ))
15+ raise KeyError ("missing columns: " + str (missing_columns ))
1616 # get rid of some corner cases
1717 if table .shape [0 ] < 2 :
1818 return True
@@ -33,16 +33,16 @@ class RecordMap:
3333 def __init__ (self , * , blocks_in = None , blocks_out = None ):
3434 if blocks_in is not None :
3535 if not isinstance (blocks_in , data_algebra .cdata .RecordSpecification ):
36- raise Exception (
36+ raise TypeError (
3737 "blocks_in should be a data_algebra.cdata.RecordSpecification"
3838 )
3939 if blocks_out is not None :
4040 if not isinstance (blocks_out , data_algebra .cdata .RecordSpecification ):
41- raise Exception (
41+ raise TypeError (
4242 "blocks_out should be a data_algebra.cdata.RecordSpecification"
4343 )
4444 if (blocks_in is None ) and (blocks_out is None ):
45- raise Exception (
45+ raise ValueError (
4646 "At least one of blocks_in or blocks_out should not be None"
4747 )
4848 self .blocks_in = blocks_in
@@ -54,7 +54,7 @@ def transform(
5454 self , X , * , check_blocks_in_keying = True , check_blocks_out_keying = False
5555 ):
5656 if not isinstance (X , pandas .DataFrame ):
57- raise Exception ("X should be a pandas.DataFrame" )
57+ raise TypeError ("X should be a pandas.DataFrame" )
5858 X = X .copy ()
5959 X .reset_index (inplace = True , drop = True )
6060 db_model = data_algebra .SQLite .SQLiteModel ()
@@ -66,14 +66,14 @@ def transform(
6666 self .blocks_in .record_keys
6767 ) - set (x1_descr .column_names )
6868 if len (missing_cols ) > 0 :
69- raise Exception ("missing required columns: " + str (missing_cols ))
69+ raise KeyError ("missing required columns: " + str (missing_cols ))
7070 # convert to row-records
7171 if check_blocks_in_keying :
7272 # table should be keyed by record_keys + control_table_keys
7373 if not table_is_keyed_by_columns (
7474 X , self .blocks_in .record_keys + self .blocks_in .control_table_keys
7575 ):
76- raise Exception (
76+ raise ValueError (
7777 "table is not keyed by blocks_in.record_keys + blocks_in.control_table_keys"
7878 )
7979 with sqlite3 .connect (":memory:" ) as conn :
@@ -88,11 +88,11 @@ def transform(
8888 )
8989 missing_cols = set (self .blocks_out .record_keys ) - set (x2_descr .column_names )
9090 if len (missing_cols ) > 0 :
91- raise Exception ("missing required columns: " + str (missing_cols ))
91+ raise KeyError ("missing required columns: " + str (missing_cols ))
9292 if check_blocks_out_keying :
9393 # table should be keyed by record_keys
9494 if not table_is_keyed_by_columns (X , self .blocks_out .record_keys ):
95- raise Exception ("table is not keyed by blocks_out.record_keys" )
95+ raise ValueError ("table is not keyed by blocks_out.record_keys" )
9696 # convert to block records
9797 with sqlite3 .connect (":memory:" ) as conn :
9898 temp_table = data_algebra .data_ops .TableDescription (
0 commit comments