<s> import laspy <EOL> from laspy . base import * <EOL> import laspy . file as File <EOL> import laspy . header as header <EOL> from uuid import UUID <EOL> import unittest <EOL> import os <EOL> import shutil <EOL> def flip_bit ( x ) : <EOL> return ( <NUM_LIT:1> * ( x == <NUM_LIT:0> ) ) <EOL> class LasReaderTestCase ( unittest . TestCase ) : <EOL> simple = "<STR_LIT>" <EOL> tempfile = "<STR_LIT>" <EOL> def setUp ( self ) : <EOL> shutil . copyfile ( self . simple , self . tempfile ) <EOL> self . FileObject = File . File ( self . tempfile ) <EOL> LasFile = self . FileObject <EOL> self . X = list ( LasFile . X ) <EOL> self . Y = list ( LasFile . Y ) <EOL> self . Z = list ( LasFile . Z ) <EOL> self . intensity = list ( LasFile . intensity ) <EOL> self . flag_byte = list ( LasFile . flag_byte ) <EOL> self . return_num = list ( LasFile . return_num ) <EOL> self . num_returns = list ( LasFile . num_returns ) <EOL> self . scan_dir_flag = list ( LasFile . scan_dir_flag ) <EOL> self . edge_flight_line = list ( LasFile . edge_flight_line ) <EOL> self . raw_classification = list ( LasFile . raw_classification ) <EOL> self . classification = list ( LasFile . classification ) <EOL> self . synthetic = list ( LasFile . synthetic ) <EOL> self . key_point = list ( LasFile . key_point ) <EOL> self . withheld = list ( LasFile . key_point ) <EOL> self . scan_angle_rank = list ( LasFile . scan_angle_rank ) <EOL> self . user_data = list ( LasFile . user_data ) <EOL> self . pt_src_id = list ( LasFile . pt_src_id ) <EOL> if LasFile . _header . data_format_id in ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ) : <EOL> self . gps_time = list ( LasFile . gps_time ) <EOL> if LasFile . _header . data_format_id in ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:5> ) : <EOL> self . red = list ( LasFile . red ) <EOL> self . green = list ( LasFile . green ) <EOL> self . blue = list ( LasFile . blue ) <EOL> if LasFile . _header . data_format_id in ( <NUM_LIT:4> , <NUM_LIT:5> ) : <EOL> self . wave_form_packet_Desc_index = list ( LasFile . wave_packet_desc_index ) <EOL> self . byte_offset_to_waveform = list ( LasFile . byte_offset_to_waveform ) <EOL> self . waveform_packet_size = list ( LasFile . waveform_packet_size ) <EOL> self . return_point_waveform_loc = list ( LasFile . return_point_waveform_loc ) <EOL> self . x_t = list ( LasFile . x_t ) <EOL> self . y_t = list ( LasFile . y_t ) <EOL> self . z_t = list ( LasFile . z_t ) <EOL> self . p1 = LasFile . read ( <NUM_LIT:100> ) <EOL> self . p2 = LasFile . read ( <NUM_LIT> ) <EOL> self . idx1 = <NUM_LIT:100> <EOL> self . idx2 = <NUM_LIT> <EOL> def test_x ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( self . p1 . X , <NUM_LIT> , self . X [ self . idx1 ] ) <EOL> self . assertEqual ( self . p2 . X , <NUM_LIT> , self . X [ self . idx2 ] ) <EOL> def test_y ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( self . p1 . Y , <NUM_LIT> , self . Y [ self . idx1 ] ) <EOL> self . assertEqual ( self . p2 . Y , <NUM_LIT> , self . Y [ self . idx2 ] ) <EOL> def test_z ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( self . p1 . Z , <NUM_LIT> , self . Z [ self . idx1 ] ) <EOL> self . assertEqual ( self . p2 . Z , <NUM_LIT> , self . Z [ self . idx2 ] ) <EOL> def test_intensity ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( self . p1 . intensity , <NUM_LIT> , <EOL> self . intensity [ self . idx1 ] ) <EOL> self . assertEqual ( self . p2 . intensity , <NUM_LIT:1> , <EOL> self . intensity [ self . idx2 ] ) <EOL> def test_bit_flags ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( self . p1 . flag_byte , self . flag_byte [ self . idx1 ] ) <EOL> self . assertEqual ( self . p2 . flag_byte , self . flag_byte [ self . idx2 ] ) <EOL> self . assertEqual ( self . p1 . return_num , <EOL> self . return_num [ self . idx1 ] , <NUM_LIT:1> ) <EOL> self . assertEqual ( self . p2 . return_num , <EOL> self . return_num [ self . idx2 ] , <NUM_LIT:2> ) <EOL> self . assertEqual ( self . p1 . num_returns , <EOL> self . num_returns [ self . idx1 ] , <NUM_LIT:1> ) <EOL> self . assertEqual ( self . p2 . num_returns , <EOL> self . num_returns [ self . idx2 ] , <NUM_LIT:2> ) <EOL> self . assertEqual ( self . p1 . scan_dir_flag , <EOL> self . scan_dir_flag [ self . idx1 ] , <NUM_LIT:0> ) <EOL> self . assertEqual ( self . p2 . scan_dir_flag , <EOL> self . scan_dir_flag [ self . idx2 ] , <NUM_LIT:1> ) <EOL> self . assertEqual ( self . p1 . edge_flight_line , <EOL> self . edge_flight_line [ self . idx1 ] , <NUM_LIT:0> ) <EOL> self . assertEqual ( self . p2 . edge_flight_line , <EOL> self . edge_flight_line [ self . idx2 ] , <NUM_LIT:0> ) <EOL> def test_scan_angle_rank ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( self . p1 . scan_angle_rank , <NUM_LIT:2> , <EOL> self . scan_angle_rank [ self . idx1 ] ) <EOL> self . assertEqual ( self . p2 . scan_angle_rank , <NUM_LIT:12> , <EOL> self . scan_angle_rank [ self . idx2 ] ) <EOL> def test_raw_classification ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( self . p1 . raw_classification , <NUM_LIT:1> , <EOL> self . raw_classification [ self . idx1 ] ) <EOL> self . assertEqual ( self . p2 . raw_classification , <NUM_LIT:2> , <EOL> self . raw_classification [ self . idx2 ] ) <EOL> def test_ptstrcid ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( self . p1 . pt_src_id , <NUM_LIT> , <EOL> self . pt_src_id [ self . idx1 ] ) <EOL> self . assertEqual ( self . p2 . pt_src_id , <NUM_LIT> , <EOL> self . pt_src_id [ self . idx2 ] ) <EOL> def test_GPSTime ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertTrue ( self . p1 . gps_time - <NUM_LIT:2> * <NUM_LIT> <EOL> + self . gps_time [ self . idx1 ] < <NUM_LIT> ) <EOL> self . assertTrue ( self . p2 . gps_time - <NUM_LIT:2> * <NUM_LIT> <EOL> + self . gps_time [ self . idx2 ] < <NUM_LIT> ) <EOL> def test_red ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( self . p1 . red , <NUM_LIT> , self . red [ self . idx1 ] ) <EOL> self . assertEqual ( self . p2 . red , <NUM_LIT> , self . red [ self . idx2 ] ) <EOL> def test_green ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( self . p1 . green , <NUM_LIT:100> , self . green [ self . idx1 ] ) <EOL> self . assertEqual ( self . p2 . green , <NUM_LIT> , self . green [ self . idx2 ] ) <EOL> def test_blue ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( self . p1 . blue , <NUM_LIT> , self . blue [ self . idx1 ] ) <EOL> self . assertEqual ( self . p2 . blue , <NUM_LIT> , self . blue [ self . idx2 ] ) <EOL> def test_iterator_and_slicing ( self ) : <EOL> """<STR_LIT>""" <EOL> k = <NUM_LIT:0> <EOL> LasFile = self . FileObject <EOL> for pt1 in LasFile : <EOL> pt2 = LasFile [ k ] <EOL> pt1 . make_nice ( ) <EOL> pt2 . make_nice ( ) <EOL> self . assertEqual ( pt1 . X , pt2 . X ) <EOL> self . assertEqual ( pt1 . Y , pt2 . Y ) <EOL> self . assertEqual ( pt1 . Z , pt2 . Z ) <EOL> self . assertEqual ( pt1 . gps_time , pt2 . gps_time ) <EOL> k += <NUM_LIT:1> <EOL> with self . assertRaises ( Exception ) : <EOL> LasFile [ <NUM_LIT> ] <EOL> def tearDown ( self ) : <EOL> self . FileObject . close ( ) <EOL> os . remove ( self . tempfile ) <EOL> class LasWriterTestCase ( unittest . TestCase ) : <EOL> simple = '<STR_LIT>' <EOL> tempfile = '<STR_LIT>' <EOL> output_tempfile = '<STR_LIT>' <EOL> def setUp ( self ) : <EOL> shutil . copyfile ( self . simple , self . tempfile ) <EOL> self . FileObject = File . File ( self . tempfile , mode = "<STR_LIT>" ) <EOL> def test_x ( self ) : <EOL> """<STR_LIT>""" <EOL> x = [ i + <NUM_LIT:1> for i in self . FileObject . X ] <EOL> self . FileObject . X = x <EOL> x2 = self . FileObject . get_x ( ) <EOL> self . assertTrue ( ( list ( x ) == list ( x2 ) ) ) <EOL> scaled_x = self . FileObject . x <EOL> self . FileObject . x = scaled_x <EOL> self . assertTrue ( all ( scaled_x == self . FileObject . x ) ) <EOL> def test_y ( self ) : <EOL> """<STR_LIT>""" <EOL> y = [ i + <NUM_LIT:1> for i in self . FileObject . Y ] <EOL> self . FileObject . Y = y <EOL> y2 = self . FileObject . get_y ( ) <EOL> self . assertTrue ( ( list ( y ) == list ( y2 ) ) ) <EOL> scaled_y = self . FileObject . y <EOL> self . FileObject . y = scaled_y <EOL> self . assertTrue ( all ( scaled_y == self . FileObject . y ) ) <EOL> def test_z ( self ) : <EOL> """<STR_LIT>""" <EOL> z = [ i + <NUM_LIT:1> for i in self . FileObject . Z ] <EOL> self . FileObject . Z = z <EOL> z2 = self . FileObject . get_z ( ) <EOL> self . assertTrue ( ( list ( z ) == list ( z2 ) ) ) <EOL> scaled_z = self . FileObject . z <EOL> self . FileObject . z = scaled_z <EOL> self . assertTrue ( all ( scaled_z == self . FileObject . z ) ) <EOL> def test_intensity ( self ) : <EOL> """<STR_LIT>""" <EOL> i = [ i + <NUM_LIT:1> for i in self . FileObject . intensity ] <EOL> self . FileObject . intensity = i <EOL> i2 = self . FileObject . intensity <EOL> self . assertTrue ( ( i == list ( i2 ) ) ) <EOL> def test_return_num ( self ) : <EOL> """<STR_LIT>""" <EOL> rn = [ i + <NUM_LIT:1> for i in self . FileObject . return_num ] <EOL> self . FileObject . return_num = rn <EOL> rn2 = self . FileObject . get_return_num ( ) <EOL> self . assertTrue ( ( rn == list ( rn2 ) ) ) <EOL> def test_overflow_return_num ( self ) : <EOL> """<STR_LIT>""" <EOL> rn = [ x + <NUM_LIT> for x in self . FileObject . return_num ] <EOL> with self . assertRaises ( Exception ) : <EOL> self . FileObject . return_num = rn <EOL> def test_num_returns ( self ) : <EOL> """<STR_LIT>""" <EOL> nr = [ i + <NUM_LIT:1> for i in self . FileObject . num_returns ] <EOL> self . FileObject . num_returns = nr <EOL> nr2 = self . FileObject . get_num_returns ( ) <EOL> self . assertTrue ( ( nr == list ( nr2 ) ) ) <EOL> def test_scan_dir_flag ( self ) : <EOL> """<STR_LIT>""" <EOL> sdf = [ flip_bit ( x ) for x in self . FileObject . scan_dir_flag ] <EOL> self . FileObject . scan_dir_flag = sdf <EOL> sdf2 = self . FileObject . get_scan_dir_flag ( ) <EOL> self . assertTrue ( ( sdf == list ( sdf2 ) ) ) <EOL> def test_edge_flight_line ( self ) : <EOL> """<STR_LIT>""" <EOL> efl = [ flip_bit ( x ) for x in self . FileObject . edge_flight_line ] <EOL> self . FileObject . edge_flight_line = efl <EOL> efl2 = self . FileObject . get_edge_flight_line ( ) <EOL> self . assertTrue ( ( efl == list ( efl2 ) ) ) <EOL> def test_classification ( self ) : <EOL> """<STR_LIT>""" <EOL> c1 = [ x + <NUM_LIT:1> for x in self . FileObject . classification ] <EOL> self . FileObject . classification = c1 <EOL> c2 = [ x for x in self . FileObject . get_classification ( ) ] <EOL> self . assertTrue ( ( c1 == c2 ) ) <EOL> def test_synthetic ( self ) : <EOL> """<STR_LIT>""" <EOL> s1 = [ flip_bit ( x ) for x in self . FileObject . synthetic ] <EOL> self . FileObject . synthetic = s1 <EOL> s2 = self . FileObject . get_synthetic ( ) <EOL> self . assertTrue ( ( s1 == list ( s2 ) ) ) <EOL> def test_key_point ( self ) : <EOL> """<STR_LIT>""" <EOL> k1 = [ flip_bit ( x ) for x in self . FileObject . key_point ] <EOL> self . FileObject . key_point = k1 <EOL> k2 = self . FileObject . get_key_point ( ) <EOL> self . assertTrue ( ( k1 == list ( k2 ) ) ) <EOL> def test_withheld ( self ) : <EOL> """<STR_LIT>""" <EOL> w1 = [ flip_bit ( x ) for x in self . FileObject . withheld ] <EOL> self . FileObject . withheld = w1 <EOL> w2 = self . FileObject . get_withheld ( ) <EOL> self . assertTrue ( ( w1 == list ( w2 ) ) ) <EOL> def test_scan_angle_rank ( self ) : <EOL> """<STR_LIT>""" <EOL> ar1 = [ i - <NUM_LIT:1> for i in self . FileObject . scan_angle_rank ] <EOL> ar1 = [ max ( <NUM_LIT:0> , x ) for x in ar1 ] <EOL> self . FileObject . scan_angle_rank = ar1 <EOL> ar2 = self . FileObject . get_scan_angle_rank ( ) <EOL> self . assertTrue ( ( ar1 == list ( ar2 ) ) ) <EOL> def test_user_data ( self ) : <EOL> """<STR_LIT>""" <EOL> ud1 = [ i + <NUM_LIT:1> for i in self . FileObject . user_data ] <EOL> self . FileObject . user_data = ud1 <EOL> ud2 = self . FileObject . get_user_data ( ) <EOL> self . assertTrue ( ( ud1 == list ( ud2 ) ) ) <EOL> def test_pt_src_id ( self ) : <EOL> """<STR_LIT>""" <EOL> p1 = [ i + <NUM_LIT:1> for i in self . FileObject . user_data ] <EOL> self . FileObject . user_data = p1 <EOL> p2 = self . FileObject . get_user_data ( ) <EOL> self . assertTrue ( ( p1 == list ( p2 ) ) ) <EOL> def test_gps_time ( self ) : <EOL> """<STR_LIT>""" <EOL> g1 = [ i + <NUM_LIT:1> for i in self . FileObject . gps_time ] <EOL> self . FileObject . gps_time = g1 <EOL> g2 = self . FileObject . get_gps_time ( ) <EOL> self . assertTrue ( ( g1 == list ( g2 ) ) ) <EOL> def test_red ( self ) : <EOL> """<STR_LIT>""" <EOL> r1 = [ i + <NUM_LIT:1> for i in self . FileObject . red ] <EOL> self . FileObject . red = r1 <EOL> r2 = self . FileObject . get_red ( ) <EOL> self . assertTrue ( ( r1 == list ( r2 ) ) ) <EOL> def test_green ( self ) : <EOL> """<STR_LIT>""" <EOL> g1 = [ i + <NUM_LIT:1> for i in self . FileObject . green ] <EOL> self . FileObject . green = g1 <EOL> g2 = self . FileObject . get_green ( ) <EOL> self . assertTrue ( ( g1 == list ( g2 ) ) ) <EOL> def test_blue ( self ) : <EOL> """<STR_LIT>""" <EOL> b1 = [ i + <NUM_LIT:1> for i in self . FileObject . blue ] <EOL> self . FileObject . blue = b1 <EOL> b2 = self . FileObject . get_blue ( ) <EOL> self . assertTrue ( ( b1 == list ( b2 ) ) ) <EOL> def test_vlr_defined_dimensions2 ( self ) : <EOL> """<STR_LIT>""" <EOL> File2 = File . File ( self . output_tempfile , mode = "<STR_LIT:w>" , header = self . FileObject . header ) <EOL> File2 . define_new_dimension ( "<STR_LIT>" , <NUM_LIT:5> , "<STR_LIT>" ) <EOL> File2 . X = self . FileObject . X <EOL> self . assertTrue ( File2 . test_dimension [ <NUM_LIT> ] == <NUM_LIT:0> ) <EOL> File2 . close ( ignore_header_changes = True ) <EOL> def tearDown ( self ) : <EOL> self . FileObject . close ( ) <EOL> os . remove ( self . tempfile ) <EOL> class LasHeaderWriterTestCase ( unittest . TestCase ) : <EOL> simple = os . path . abspath ( '<STR_LIT>' ) <EOL> simple14 = os . path . abspath ( '<STR_LIT>' ) <EOL> tempfile = os . path . abspath ( '<STR_LIT>' ) <EOL> tempfile2 = os . path . abspath ( '<STR_LIT>' ) <EOL> def setUp ( self ) : <EOL> shutil . copyfile ( self . simple , self . tempfile ) <EOL> self . FileObject = File . File ( self . tempfile , mode = "<STR_LIT>" ) <EOL> def test_file_src ( self ) : <EOL> """<STR_LIT>""" <EOL> f1 = self . FileObject . header . filesource_id + <NUM_LIT:1> <EOL> self . FileObject . header . filesource_id = f1 <EOL> f2 = self . FileObject . header . get_filesourceid ( ) <EOL> self . assertTrue ( f1 == f2 ) <EOL> def test_uuid ( self ) : <EOL> """<STR_LIT>""" <EOL> guid = self . FileObject . header . guid <EOL> guid2 = self . FileObject . header . project_id <EOL> self . assertEqual ( guid , guid2 ) <EOL> newGuid = UUID ( bytes = "<STR_LIT:1>" * <NUM_LIT:16> ) <EOL> self . FileObject . header . guid = newGuid <EOL> newGuid2 = self . FileObject . header . get_guid ( ) <EOL> self . assertEqual ( newGuid , newGuid2 ) <EOL> def test_glob_encode ( self ) : <EOL> """<STR_LIT>""" <EOL> g1 = self . FileObject . header . global_encoding + <NUM_LIT:1> <EOL> self . FileObject . header . global_encoding = g1 <EOL> g2 = self . FileObject . header . get_global_encoding ( ) <EOL> self . assertTrue ( g1 == g2 ) <EOL> def test_versions ( self ) : <EOL> """<STR_LIT>""" <EOL> v1 = self . FileObject . header . major_version <EOL> self . assertEqual ( v1 , <NUM_LIT:1> ) <EOL> with self . assertRaises ( laspy . util . LaspyException ) : <EOL> self . FileObject . header . major_version = <NUM_LIT:2> <EOL> def test_system_id ( self ) : <EOL> """<STR_LIT>""" <EOL> sys1 = self . FileObject . header . system_id <EOL> sys1 = "<STR_LIT>" + sys1 [ <NUM_LIT:10> : ] <EOL> self . FileObject . header . system_id = sys1 <EOL> sys2 = self . FileObject . header . get_systemid ( ) <EOL> self . assertEqual ( sys1 , sys2 ) <EOL> def test_software_id ( self ) : <EOL> """<STR_LIT>""" <EOL> s1 = self . FileObject . header . software_id <EOL> s1 = "<STR_LIT>" + s1 [ <NUM_LIT:7> : ] <EOL> self . FileObject . header . software_id = s1 <EOL> s2 = self . FileObject . header . get_softwareid ( ) <EOL> self . assertEqual ( s1 , s2 ) <EOL> with self . assertRaises ( laspy . util . LaspyException ) : <EOL> self . FileObject . header . software_id = "<STR_LIT>" <EOL> with self . assertRaises ( laspy . util . LaspyException ) : <EOL> self . FileObject . header . software_id = "<STR_LIT:1>" * <NUM_LIT:100> <EOL> def test_padding ( self ) : <EOL> """<STR_LIT>""" <EOL> x1 = list ( self . FileObject . X ) <EOL> self . FileObject . header . set_padding ( <NUM_LIT:10> ) <EOL> self . FileObject . header . set_padding ( <NUM_LIT:1000> ) <EOL> x2 = list ( self . FileObject . X ) <EOL> self . assertTrue ( ( list ( x1 ) == list ( x2 ) ) ) <EOL> def test_data_offset ( self ) : <EOL> """<STR_LIT>""" <EOL> x1 = list ( self . FileObject . X ) <EOL> self . FileObject . header . data_offset = <NUM_LIT> <EOL> self . assertEqual ( self . FileObject . header . get_dataoffset ( ) , <NUM_LIT> ) <EOL> x2 = list ( self . FileObject . X ) <EOL> self . assertTrue ( ( list ( x1 ) == list ( x2 ) ) ) <EOL> def test_date ( self ) : <EOL> """<STR_LIT>""" <EOL> d1 = self . FileObject . header . date <EOL> self . assertTrue ( d1 == None ) <EOL> from datetime import datetime <EOL> d2 = datetime ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT:10> ) <EOL> self . FileObject . header . date = d2 <EOL> d3 = self . FileObject . header . get_date ( ) <EOL> self . assertEqual ( d2 , d3 ) <EOL> def test_point_recs_by_return ( self ) : <EOL> """<STR_LIT>""" <EOL> r1 = [ x + <NUM_LIT:1> for x in self . FileObject . header . point_return_count ] <EOL> self . FileObject . header . point_return_count = r1 <EOL> r2 = self . FileObject . header . get_pointrecordsbyreturncount ( ) <EOL> self . assertTrue ( r1 == r2 ) <EOL> def test_min_max_update ( self ) : <EOL> """<STR_LIT>""" <EOL> x = list ( self . FileObject . X ) <EOL> x [ <NUM_LIT:0> ] = max ( x ) + <NUM_LIT:1> <EOL> y = list ( self . FileObject . Y ) <EOL> y [ <NUM_LIT:0> ] = max ( y ) + <NUM_LIT:1> <EOL> z = list ( self . FileObject . Z ) <EOL> z [ <NUM_LIT:0> ] = max ( z ) + <NUM_LIT:1> <EOL> self . FileObject . X = x <EOL> self . FileObject . Y = y <EOL> self . FileObject . Z = z <EOL> self . FileObject . header . update_min_max ( ) <EOL> file_max = self . FileObject . header . max <EOL> self . assertTrue ( file_max == [ self . FileObject . x [ <NUM_LIT:0> ] , self . FileObject . y [ <NUM_LIT:0> ] , self . FileObject . z [ <NUM_LIT:0> ] ] ) <EOL> def test_histogram ( self ) : <EOL> """<STR_LIT>""" <EOL> h1 = self . FileObject . header . point_return_count <EOL> self . FileObject . header . update_histogram ( ) <EOL> h2 = self . FileObject . header . point_return_count <EOL> self . assertTrue ( h1 == h2 ) <EOL> def test_offset ( self ) : <EOL> """<STR_LIT>""" <EOL> o1 = self . FileObject . header . offset <EOL> o1 [ <NUM_LIT:0> ] += <NUM_LIT:1> <EOL> self . FileObject . header . offset = o1 <EOL> o2 = self . FileObject . header . get_offset ( ) <EOL> self . assertTrue ( o1 == o2 ) <EOL> def test_scale ( self ) : <EOL> """<STR_LIT>""" <EOL> s1 = self . FileObject . header . scale <EOL> s1 [ <NUM_LIT:0> ] += <NUM_LIT:1> <EOL> self . FileObject . header . scale = s1 <EOL> s2 = list ( self . FileObject . header . get_scale ( ) ) <EOL> self . assertTrue ( s1 == s2 ) <EOL> def test_vlr_parsing_api ( self ) : <EOL> """<STR_LIT>""" <EOL> shutil . copyfile ( self . simple14 , self . tempfile2 ) <EOL> VLRFile = File . File ( self . tempfile2 , mode = "<STR_LIT>" ) <EOL> vlr0 = VLRFile . header . vlrs [ <NUM_LIT:0> ] <EOL> vlr0 . parsed_body [ - <NUM_LIT:1> ] += <NUM_LIT:1> <EOL> pb = vlr0 . parsed_body <EOL> vlr0 . pack_data ( ) <EOL> VLRFile . header . save_vlrs ( ) <EOL> VLRFile . close ( ) <EOL> VLRFile = File . File ( self . tempfile2 , mode = "<STR_LIT>" ) <EOL> self . assertTrue ( all ( pb == VLRFile . header . vlrs [ <NUM_LIT:0> ] . parsed_body ) ) <EOL> VLRFile . close ( ) <EOL> def tearDown ( self ) : <EOL> self . FileObject . close ( ) <EOL> os . remove ( self . tempfile ) <EOL> class LasWriteModeTestCase ( unittest . TestCase ) : <EOL> simple = '<STR_LIT>' <EOL> tempfile = '<STR_LIT>' <EOL> output_tempfile = '<STR_LIT>' <EOL> def setUp ( self ) : <EOL> shutil . copyfile ( self . simple , self . tempfile ) <EOL> self . File1 = File . File ( self . tempfile , mode = "<STR_LIT:r>" ) <EOL> def test_using_barebones_header ( self ) : <EOL> """<STR_LIT>""" <EOL> header_object = header . Header ( ) <EOL> File2 = File . File ( self . output_tempfile , mode = "<STR_LIT:w>" , <EOL> header = header_object ) <EOL> self . assertTrue ( File2 . header . version == "<STR_LIT>" ) <EOL> X = list ( self . File1 . X ) <EOL> Y = list ( self . File1 . Y ) <EOL> Z = list ( self . File1 . Z ) <EOL> File2 . X = X <EOL> File2 . Y = Y <EOL> File2 . Z = Z <EOL> self . assertTrue ( ( list ( X ) == list ( File2 . get_x ( ) ) ) ) <EOL> self . assertTrue ( ( list ( Y ) == list ( File2 . get_y ( ) ) ) ) <EOL> self . assertTrue ( ( list ( Z ) == list ( File2 . get_z ( ) ) ) ) <EOL> File2 . close ( ignore_header_changes = True ) <EOL> def test_using_existing_header ( self ) : <EOL> """<STR_LIT>""" <EOL> header_object = self . File1 . header <EOL> File2 = File . File ( self . output_tempfile , mode = "<STR_LIT:w>" , <EOL> header = header_object ) <EOL> X = list ( self . File1 . X ) <EOL> Y = list ( self . File1 . Y ) <EOL> Z = list ( self . File1 . Z ) <EOL> File2 . Z = Z <EOL> File2 . Y = Y <EOL> File2 . X = X <EOL> self . assertTrue ( ( list ( X ) == list ( File2 . get_x ( ) ) ) ) <EOL> self . assertTrue ( ( list ( Y ) == list ( File2 . get_y ( ) ) ) ) <EOL> self . assertTrue ( ( list ( Z ) == list ( File2 . get_z ( ) ) ) ) <EOL> File2 . close ( ignore_header_changes = True ) <EOL> def test_format_change_and_extra_bytes ( self ) : <EOL> """<STR_LIT>""" <EOL> File1 = self . File1 <EOL> new_header = File1 . header . copy ( ) <EOL> new_header . format = <NUM_LIT> <EOL> new_header . data_format_id = <NUM_LIT:0> <EOL> new_header . data_record_length = <NUM_LIT:50> <EOL> File2 = File . File ( self . output_tempfile , mode = "<STR_LIT:w>" , <EOL> header = new_header ) <EOL> for dim in File1 . point_format : <EOL> in_dim = File1 . reader . get_dimension ( dim . name ) <EOL> if dim . name in File2 . point_format . lookup : <EOL> File2 . writer . set_dimension ( dim . name , in_dim ) <EOL> File2 . extra_bytes = [ "<STR_LIT>" ] * len ( File2 ) <EOL> self . assertTrue ( "<STR_LIT>" in str ( File2 . get_extra_bytes ( ) [ <NUM_LIT> ] ) ) <EOL> File2 . close ( ignore_header_changes = True ) <EOL> def tearDown ( self ) : <EOL> self . File1 . close ( ) <EOL> os . remove ( self . tempfile ) <EOL> class LasV_13TestCase ( unittest . TestCase ) : <EOL> simple = '<STR_LIT>' <EOL> tempfile = '<STR_LIT>' <EOL> output_tempfile = '<STR_LIT>' <EOL> def setUp ( self ) : <EOL> shutil . copyfile ( self . simple , self . tempfile ) <EOL> self . File1 = File . File ( self . tempfile , mode = "<STR_LIT>" ) <EOL> def test_glob_encode ( self ) : <EOL> """<STR_LIT>""" <EOL> old = self . File1 . header . gps_time_type <EOL> self . assertTrue ( old == '<STR_LIT:0>' ) <EOL> self . File1 . header . gps_time_type = '<STR_LIT:1>' <EOL> self . assertEqual ( self . File1 . header . get_gps_time_type ( ) , '<STR_LIT:1>' ) <EOL> File2 = File . File ( self . output_tempfile , mode = "<STR_LIT:w>" , header = self . File1 . header ) <EOL> self . assertEqual ( self . File1 . header . waveform_data_packets_internal , <EOL> File2 . header . waveform_data_packets_internal ) <EOL> self . assertEqual ( self . File1 . header . waveform_data_packets_external , <EOL> File2 . header . waveform_data_packets_external ) <EOL> self . assertEqual ( self . File1 . header . synthetic_return_num , <EOL> File2 . header . synthetic_return_num ) <EOL> File2 . close ( ignore_header_changes = True ) <EOL> def test_evlr ( self ) : <EOL> """<STR_LIT>""" <EOL> File2 = File . File ( self . output_tempfile , mode = "<STR_LIT:w>" , header = self . File1 . header ) <EOL> self . assertEqual ( self . File1 . header . evlrs [ <NUM_LIT:0> ] . to_byte_string ( ) , <EOL> File2 . header . evlrs [ <NUM_LIT:0> ] . to_byte_string ( ) ) <EOL> File2 . close ( ignore_header_changes = True ) <EOL> def test_wave_packet_desc_index ( self ) : <EOL> """<STR_LIT>""" <EOL> test1 = self . File1 . wave_packet_desc_index <EOL> File2 = File . File ( self . output_tempfile , mode = "<STR_LIT:w>" , header = self . File1 . header ) <EOL> File2 . points = self . File1 . points <EOL> self . assertTrue ( all ( test1 == File2 . wave_packet_desc_index ) ) <EOL> File2 . wave_packet_desc_index += <NUM_LIT:1> <EOL> self . assertTrue ( all ( test1 != File2 . wave_packet_desc_index ) ) <EOL> File2 . close ( ignore_header_changes = True ) <EOL> def test_byte_offset_to_waveform_data ( self ) : <EOL> """<STR_LIT>""" <EOL> test1 = self . File1 . byte_offset_to_waveform_data <EOL> File2 = File . File ( self . output_tempfile , mode = "<STR_LIT:w>" , header = self . File1 . header ) <EOL> File2 . points = self . File1 . points <EOL> self . assertTrue ( all ( test1 == File2 . byte_offset_to_waveform_data ) ) <EOL> File2 . byte_offset_to_waveform_data += <NUM_LIT:1> <EOL> self . assertTrue ( all ( test1 != File2 . byte_offset_to_waveform_data ) ) <EOL> File2 . close ( ignore_header_changes = True ) <EOL> def test_waveform_packet_size ( self ) : <EOL> """<STR_LIT>""" <EOL> test1 = self . File1 . waveform_packet_size <EOL> File2 = File . File ( self . output_tempfile , mode = "<STR_LIT:w>" , header = self . File1 . header ) <EOL> File2 . points = self . File1 . points <EOL> self . assertTrue ( all ( test1 == File2 . waveform_packet_size ) ) <EOL> File2 . waveform_packet_size += <NUM_LIT:1> <EOL> self . assertTrue ( all ( test1 != File2 . waveform_packet_size ) ) <EOL> File2 . close ( ignore_header_changes = True ) <EOL> def test_return_point_waveform_loc ( self ) : <EOL> """<STR_LIT>""" <EOL> test1 = self . File1 . return_point_waveform_loc <EOL> File2 = File . File ( self . output_tempfile , mode = "<STR_LIT:w>" , header = self . File1 . header ) <EOL> File2 . points = self . File1 . points <EOL> self . assertTrue ( all ( test1 == File2 . return_point_waveform_loc ) ) <EOL> File2 . return_point_waveform_loc += <NUM_LIT:1> <EOL> self . assertTrue ( all ( test1 != File2 . return_point_waveform_loc ) ) <EOL> File2 . close ( ignore_header_changes = True ) <EOL> def test_x_t ( self ) : <EOL> """<STR_LIT>""" <EOL> test1 = self . File1 . x_t <EOL> File2 = File . File ( self . output_tempfile , mode = "<STR_LIT:w>" , header = self . File1 . header ) <EOL> File2 . points = self . File1 . points <EOL> self . assertTrue ( all ( test1 == File2 . x_t ) ) <EOL> File2 . x_t += <NUM_LIT:1> <EOL> self . assertTrue ( all ( test1 != File2 . x_t ) ) <EOL> File2 . close ( ignore_header_changes = True ) <EOL> def test_y_t ( self ) : <EOL> """<STR_LIT>""" <EOL> test1 = self . File1 . y_t <EOL> File2 = File . File ( self . output_tempfile , mode = "<STR_LIT:w>" , header = self . File1 . header ) <EOL> File2 . points = self . File1 . points <EOL> self . assertTrue ( all ( test1 == File2 . y_t ) ) <EOL> File2 . y_t += <NUM_LIT:1> <EOL> self . assertTrue ( all ( test1 != File2 . y_t ) ) <EOL> File2 . close ( ignore_header_changes = True ) <EOL> def test_z_t ( self ) : <EOL> """<STR_LIT>""" <EOL> test1 = self . File1 . z_t <EOL> File2 = File . File ( self . output_tempfile , mode = "<STR_LIT:w>" , header = self . File1 . header ) <EOL> File2 . points = self . File1 . points <EOL> self . assertTrue ( all ( test1 == File2 . z_t ) ) <EOL> File2 . z_t += <NUM_LIT:1> <EOL> self . assertTrue ( all ( test1 != File2 . z_t ) ) <EOL> File2 . close ( ignore_header_changes = True ) <EOL> def tearDown ( self ) : <EOL> self . File1 . close ( ) <EOL> os . remove ( self . tempfile ) <EOL> class LasV_14TestCase ( unittest . TestCase ) : <EOL> simple = '<STR_LIT>' <EOL> tempfile = '<STR_LIT>' <EOL> output_tempfile = '<STR_LIT>' <EOL> def setUp ( self ) : <EOL> shutil . copyfile ( self . simple , self . tempfile ) <EOL> self . File1 = File . File ( self . tempfile , mode = "<STR_LIT>" ) <EOL> def test_glob_encode ( self ) : <EOL> """<STR_LIT>""" <EOL> old = self . File1 . header . gps_time_type <EOL> self . assertTrue ( old == '<STR_LIT:0>' ) <EOL> self . File1 . header . gps_time_type = '<STR_LIT:1>' <EOL> self . assertEqual ( self . File1 . header . get_gps_time_type ( ) , '<STR_LIT:1>' ) <EOL> File2 = File . File ( self . output_tempfile , mode = "<STR_LIT:w>" , header = self . File1 . header ) <EOL> self . assertEqual ( self . File1 . header . waveform_data_packets_internal , <EOL> File2 . header . waveform_data_packets_internal ) <EOL> self . assertEqual ( self . File1 . header . waveform_data_packets_external , <EOL> File2 . header . waveform_data_packets_external ) <EOL> self . assertEqual ( self . File1 . header . synthetic_return_num , <EOL> File2 . header . synthetic_return_num ) <EOL> File2 . close ( ignore_header_changes = True ) <EOL> def test_glob_encode_bits ( self ) : <EOL> b1 = self . File1 . header . gps_time_type <EOL> b2 = self . File1 . header . waveform_data_packets_internal <EOL> b3 = self . File1 . header . waveform_data_packets_external <EOL> b4 = self . File1 . header . synthetic_return_num <EOL> b5 = self . File1 . header . wkt <EOL> bf1 = <NUM_LIT:1> - int ( b1 ) <EOL> bf2 = <NUM_LIT:1> - int ( b2 ) <EOL> bf3 = <NUM_LIT:1> - int ( b3 ) <EOL> bf4 = <NUM_LIT:1> - int ( b4 ) <EOL> bf5 = <NUM_LIT:1> - int ( b5 ) <EOL> self . File1 . header . gps_time_type = bf1 <EOL> self . File1 . header . waveform_data_packets_internal = bf2 <EOL> self . File1 . header . waveform_data_packets_external = bf3 <EOL> self . File1 . header . synthetic_return_num = bf4 <EOL> self . File1 . header . wkt = bf5 <EOL> self . assertEqual ( self . File1 . header . gps_time_type , str ( bf1 ) ) <EOL> self . assertEqual ( self . File1 . header . waveform_data_packets_internal , str ( bf2 ) ) <EOL> self . assertEqual ( self . File1 . header . waveform_data_packets_external , str ( bf3 ) ) <EOL> self . assertEqual ( self . File1 . header . synthetic_return_num , str ( bf4 ) ) <EOL> self . assertEqual ( self . File1 . header . wkt , str ( bf5 ) ) <EOL> def test_evlr ( self ) : <EOL> """<STR_LIT>""" <EOL> File2 = File . File ( self . output_tempfile , mode = "<STR_LIT:w>" , header = self . File1 . header ) <EOL> self . assertEqual ( self . File1 . header . evlrs [ <NUM_LIT:0> ] . to_byte_string ( ) , <EOL> File2 . header . evlrs [ <NUM_LIT:0> ] . to_byte_string ( ) ) <EOL> File2 . points = self . File1 . points <EOL> outevlrs = [ ] <EOL> [ outevlrs . append ( File2 . header . evlrs [ <NUM_LIT:0> ] ) for i in xrange ( <NUM_LIT:50> ) ] <EOL> File2 . header . evlrs = outevlrs <EOL> File2 . close ( ) <EOL> File2 = File . File ( self . output_tempfile , mode = "<STR_LIT:r>" ) <EOL> self . assertTrue ( len ( File2 . header . evlrs ) == <NUM_LIT:50> ) <EOL> File2 . close ( ignore_header_changes = True ) <EOL> def test_classification_variables ( self ) : <EOL> """<STR_LIT>""" <EOL> classification = self . File1 . classification <EOL> classification_flags = self . File1 . classification_flags <EOL> scanner_channel = self . File1 . scanner_channel <EOL> scan_dir_flag = self . File1 . scan_dir_flag <EOL> edge_flight_line = self . File1 . edge_flight_line <EOL> return_num = self . File1 . return_num <EOL> num_returns = self . File1 . num_returns <EOL> File2 = File . File ( self . output_tempfile , mode = "<STR_LIT:w>" , header = self . File1 . header ) <EOL> File2 . classification = classification <EOL> File2 . classification_flags = classification_flags <EOL> File2 . scan_dir_flag = scan_dir_flag <EOL> File2 . scanner_channel = scanner_channel <EOL> File2 . edge_flight_line = edge_flight_line <EOL> File2 . return_num = return_num <EOL> File2 . num_returns = num_returns <EOL> self . assertTrue ( all ( num_returns == File2 . get_num_returns ( ) ) ) <EOL> self . assertTrue ( all ( return_num == File2 . get_return_num ( ) ) ) <EOL> self . assertTrue ( all ( edge_flight_line == File2 . get_edge_flight_line ( ) ) ) <EOL> self . assertTrue ( all ( scan_dir_flag == File2 . get_scan_dir_flag ( ) ) ) <EOL> self . assertTrue ( all ( classification_flags == File2 . get_classification_flags ( ) ) ) <EOL> self . assertTrue ( all ( classification == File2 . get_classification ( ) ) ) <EOL> self . assertTrue ( all ( scanner_channel == File2 . get_scanner_channel ( ) ) ) <EOL> File2 . close ( ignore_header_changes = True ) <EOL> def test_vlr_defined_dimensions ( self ) : <EOL> """<STR_LIT>""" <EOL> new_header = self . File1 . header . copy ( ) <EOL> new_dim_record1 = header . ExtraBytesStruct ( name = "<STR_LIT>" , data_type = <NUM_LIT:5> ) <EOL> new_dim_record2 = header . ExtraBytesStruct ( name = "<STR_LIT>" , data_type = <NUM_LIT> ) <EOL> new_dim_record3 = header . ExtraBytesStruct ( name = "<STR_LIT>" , data_type = <NUM_LIT> ) <EOL> new_VLR_rec = header . VLR ( user_id = "<STR_LIT>" , record_id = <NUM_LIT:4> , <EOL> VLR_body = ( new_dim_record1 . to_byte_string ( ) + new_dim_record2 . to_byte_string ( ) + new_dim_record3 . to_byte_string ( ) ) ) <EOL> new_header . data_record_length += ( <NUM_LIT> ) <EOL> File2 = File . File ( self . output_tempfile , mode = "<STR_LIT:w>" , header = new_header , vlrs = [ new_VLR_rec ] , evlrs = self . File1 . header . evlrs ) <EOL> File2 . X = self . File1 . X <EOL> File2 . _writer . set_dimension ( "<STR_LIT>" , [ <NUM_LIT:4> ] * len ( self . File1 ) ) <EOL> File2 . _writer . set_dimension ( "<STR_LIT>" , [ "<STR_LIT>" ] * len ( self . File1 ) ) <EOL> File2 . _writer . set_dimension ( "<STR_LIT>" , [ [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ] * len ( self . File1 ) ) <EOL> self . assertTrue ( all ( np . array ( [ "<STR_LIT>" ] * len ( self . File1 ) ) == File2 . test_dimension_5678 ) ) <EOL> self . assertTrue ( all ( np . array ( [ <NUM_LIT:4> ] * len ( self . File1 ) ) == File2 . test_dimension_1234 ) ) <EOL> self . assertTrue ( list ( File2 . test_dimension_9 [ <NUM_LIT:100> ] ) == [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> File2 . close ( ignore_header_changes = True ) <EOL> def test_vlr_defined_dimensions2 ( self ) : <EOL> """<STR_LIT>""" <EOL> File2 = File . File ( self . output_tempfile , mode = "<STR_LIT:w>" , header = self . File1 . header ) <EOL> File2 . define_new_dimension ( "<STR_LIT>" , <NUM_LIT:5> , "<STR_LIT>" ) <EOL> File2 . define_new_dimension ( "<STR_LIT>" , <NUM_LIT:5> , "<STR_LIT>" ) <EOL> File2 . X = self . File1 . X <EOL> self . assertTrue ( File2 . test_dimension [ <NUM_LIT> ] == <NUM_LIT:0> ) <EOL> self . assertTrue ( File2 . test_dimension2 [ <NUM_LIT> ] == <NUM_LIT:0> ) <EOL> File2 . close ( ignore_header_changes = True ) <EOL> def tearDown ( self ) : <EOL> self . File1 . close ( ) <EOL> os . remove ( self . tempfile ) <EOL> class LasLazReaderTestCase ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> pass <EOL> def test_read_data ( self ) : <EOL> """<STR_LIT>""" <EOL> simple = '<STR_LIT>' <EOL> File1 = File . File ( simple , mode = "<STR_LIT:r>" ) <EOL> self . assertTrue ( len ( File1 . X ) == <NUM_LIT> ) <EOL> File1 . close ( ) <EOL> def tearDown ( self ) : <EOL> pass <EOL> def test_laspy ( ) : <EOL> reader = unittest . TestLoader ( ) . loadTestsFromTestCase ( LasReaderTestCase ) <EOL> writer = unittest . TestLoader ( ) . loadTestsFromTestCase ( LasWriterTestCase ) <EOL> header_writer = unittest . TestLoader ( ) . loadTestsFromTestCase ( LasHeaderWriterTestCase ) <EOL> write_mode = unittest . TestLoader ( ) . loadTestsFromTestCase ( LasWriteModeTestCase ) <EOL> las13 = unittest . TestLoader ( ) . loadTestsFromTestCase ( LasV_13TestCase ) <EOL> las14 = unittest . TestLoader ( ) . loadTestsFromTestCase ( LasV_14TestCase ) <EOL> laz = unittest . TestLoader ( ) . loadTestsFromTestCase ( LasLazReaderTestCase ) <EOL> return unittest . TestSuite ( [ reader , writer , header_writer , write_mode , <EOL> las13 , las14 , laz ] ) </s>
