44
55import numpy as np
66import pandas as pd
7+ from pandas import DataFrame
78
89from gnssanalysis .filenames import convert_nominal_span , determine_properties_from_filename
910import gnssanalysis .gn_io .sp3 as sp3
@@ -1309,7 +1310,10 @@ def test_sp3_offline_sat_removal_standalone(self):
13091310 self .assertTrue (UnitTestBaseliner .verify (objects_to_verify ), "Hash verification should pass" )
13101311
13111312 def test_sp3_offline_sat_removal (self ):
1313+ objects_to_verify : list = []
1314+
13121315 sp3_df = sp3 .read_sp3 (offline_sat_test_data , pOnly = False , strict_mode = STRICT_OFF )
1316+ objects_to_verify .append (sp3_df )
13131317
13141318 # Confirm starting state of content
13151319 self .assertEqual (
@@ -1328,26 +1332,39 @@ def test_sp3_offline_sat_removal(self):
13281332 sp3_df .attrs ["HEADER" ].HEAD .SV_COUNT_STATED , "3" , "Header should have 2 SVs before removing offline"
13291333 )
13301334
1335+ df_snapshot = DataFrame (sp3_df )
13311336 # Now make the changes - this should also update the header
1332- sp3_df = sp3 .remove_offline_sats (sp3_df )
1337+ sp3_df_cleaned = sp3 .remove_offline_sats (sp3_df )
1338+ objects_to_verify .append (sp3_df_cleaned )
1339+ # Ensure the source DF did NOT get modified...
1340+ df_snapshot_after = DataFrame (sp3_df )
1341+ self .assertTrue (
1342+ df_snapshot .equals (df_snapshot_after ),
1343+ "Original DF should not be modified by function that returns a new copy" ,
1344+ )
13331345
13341346 # Check contents
13351347 self .assertEqual (
1336- sp3_df .index .get_level_values (1 ).unique ().array .tolist (),
1348+ sp3_df_cleaned .index .get_level_values (1 ).unique ().array .tolist (),
13371349 ["G02" , "G03" ],
13381350 "Should be two SVs after removing offline ones" ,
13391351 )
13401352
13411353 # Check header
13421354 self .assertEqual (
1343- sp3_df .attrs ["HEADER" ].SV_INFO .index .array .tolist (),
1355+ sp3_df_cleaned .attrs ["HEADER" ].SV_INFO .index .array .tolist (),
13441356 ["G02" , "G03" ],
13451357 "Should be two SVs in parsed header after removing offline ones" ,
13461358 )
13471359 self .assertEqual (
1348- sp3_df .attrs ["HEADER" ].HEAD .SV_COUNT_STATED , "2" , "Header should have 2 SVs after removing offline"
1360+ sp3_df_cleaned .attrs ["HEADER" ].HEAD .SV_COUNT_STATED , "2" , "Header should have 2 SVs after removing offline"
13491361 )
13501362
1363+ # UnitTestBaseliner.mode = "baseline"
1364+ # UnitTestBaseliner.create_baseline(objects_to_verify) # DO NOT commit this line un-commented.
1365+
1366+ self .assertTrue (UnitTestBaseliner .verify (objects_to_verify ), "Hash verification should pass" )
1367+
13511368 # sp3_test_data_truncated_cod_final is input_data2
13521369 def test_filter_by_svs (self ):
13531370 sp3_df = sp3 .read_sp3 (input_data2 , pOnly = False )
0 commit comments