<s> """<STR_LIT>""" <EOL> import unittest <EOL> import numpy as np <EOL> from camera import * <EOL> import chumpy as ch <EOL> class TestCamera ( unittest . TestCase ) : <EOL> def get_cam_params ( self ) : <EOL> v_raw = np . sin ( np . arange ( <NUM_LIT> ) ) . reshape ( ( - <NUM_LIT:1> , <NUM_LIT:3> ) ) <EOL> v_raw [ : , <NUM_LIT:2> ] -= <NUM_LIT:2> <EOL> rt = ch . zeros ( <NUM_LIT:3> ) <EOL> t = ch . zeros ( <NUM_LIT:3> ) <EOL> f = ch . array ( [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> c = ch . array ( [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> k = ch . zeros ( <NUM_LIT:5> ) <EOL> cam_params = { '<STR_LIT:v>' : ch . Ch ( v_raw ) , '<STR_LIT>' : rt , '<STR_LIT:t>' : t , '<STR_LIT:f>' : f , '<STR_LIT:c>' : c , '<STR_LIT:k>' : k } <EOL> return cam_params <EOL> def test_project_points ( self ) : <EOL> self . project_points ( ProjectPoints ) <EOL> self . project_points ( ProjectPoints3D ) <EOL> def project_points ( self , cls ) : <EOL> cam_params = self . get_cam_params ( ) <EOL> for key , value in cam_params . items ( ) : <EOL> eps = ( np . random . random ( value . r . size ) - <NUM_LIT> ) * <NUM_LIT> <EOL> pp_dist = cls ( ** cam_params ) <EOL> old_val = pp_dist . r . copy ( ) <EOL> old_dr = pp_dist . dr_wrt ( value ) . dot ( eps ) <EOL> tmp = cam_params [ key ] . r . copy ( ) <EOL> tmp += eps . reshape ( tmp . shape ) <EOL> cam_params [ key ] = ch . Ch ( tmp ) <EOL> diff = ( ( cls ( ** cam_params ) . r - old_val ) ) <EOL> raw_dr_diff = np . abs ( old_dr . flatten ( ) - diff . flatten ( ) ) <EOL> med_diff = np . median ( raw_dr_diff ) <EOL> max_diff = np . max ( raw_dr_diff ) <EOL> self . assertLess ( med_diff , <NUM_LIT> ) <EOL> self . assertLess ( max_diff , <NUM_LIT> ) <EOL> pp_dist = cls ( ** cam_params ) <EOL> for name in ( '<STR_LIT>' , '<STR_LIT:t>' , '<STR_LIT:f>' , '<STR_LIT:c>' , '<STR_LIT:k>' ) : <EOL> aa = pp_dist . camera_mtx <EOL> setattr ( pp_dist , name , getattr ( pp_dist , name ) . r + <NUM_LIT:1> ) <EOL> bb = pp_dist . camera_mtx <EOL> if name in ( '<STR_LIT:f>' , '<STR_LIT:c>' ) : <EOL> self . assertTrue ( aa is not bb ) <EOL> else : <EOL> self . assertTrue ( aa is bb ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
