@@ -131,7 +131,7 @@ def compare_budget(
131131 lst_file1 = None
132132 if files1 is None :
133133 lst_file = get_entries_from_namefile (namefile1 , "list" )
134- lst_file1 = lst_file [0 ][0 ]
134+ lst_file1 = lst_file [0 ][0 ] if any ( lst_file ) else None
135135 else :
136136 if isinstance (files1 , str ):
137137 files1 = [files1 ]
@@ -145,7 +145,7 @@ def compare_budget(
145145 lst_file2 = None
146146 if files2 is None :
147147 lst_file = get_entries_from_namefile (namefile2 , "list" )
148- lst_file2 = lst_file [0 ][0 ]
148+ lst_file2 = lst_file [0 ][0 ] if any ( lst_file ) else None
149149 else :
150150 if isinstance (files2 , str ):
151151 files2 = [files2 ]
@@ -336,7 +336,7 @@ def compare_swrbudget(
336336 list1 = None
337337 if files1 is None :
338338 lst = get_entries_from_namefile (namefile1 , "list" )
339- list1 = lst [0 ][0 ]
339+ list1 = lst [0 ][0 ] if any ( lst ) else None
340340 else :
341341 for file in files1 :
342342 if (
@@ -348,7 +348,7 @@ def compare_swrbudget(
348348 list2 = None
349349 if files2 is None :
350350 lst = get_entries_from_namefile (namefile2 , "list" )
351- list2 = lst [0 ][0 ]
351+ list2 = lst [0 ][0 ] if any ( lst ) else None
352352 else :
353353 for file in files2 :
354354 if (
@@ -558,7 +558,7 @@ def compare_heads(
558558 if files1 is None :
559559 # Get oc info, and return if OC not included in models
560560 ocf1 = get_entries_from_namefile (namefile1 , "OC" )
561- if ocf1 [ 0 ][ 0 ] is None :
561+ if not any ( ocf1 ) is None :
562562 return True
563563
564564 hu1 , hfpth1 , du1 , _ = flopy .modflow .ModflowOc .get_ocoutput_units (
@@ -570,7 +570,8 @@ def compare_heads(
570570 iut = du1
571571 if iut != 0 :
572572 entries = get_entries_from_namefile (namefile1 , unit = abs (iut ))
573- hfpth1 , status1 = entries [0 ][0 ], entries [0 ][1 ]
573+ hfpth1 = entries [0 ][0 ] if any (entries ) else None
574+ status1 = entries [0 ][1 ] if any (entries ) else None
574575
575576 else :
576577 if isinstance (files1 , str ):
@@ -601,7 +602,7 @@ def compare_heads(
601602 if files2 is None :
602603 # Get oc info, and return if OC not included in models
603604 ocf2 = get_entries_from_namefile (namefile2 , "OC" )
604- if ocf2 [ 0 ][ 0 ] is None :
605+ if not any ( ocf2 ) :
605606 return True
606607
607608 hu2 , hfpth2 , du2 , dfpth2 = flopy .modflow .ModflowOc .get_ocoutput_units (
@@ -613,7 +614,8 @@ def compare_heads(
613614 iut = du2
614615 if iut != 0 :
615616 entries = get_entries_from_namefile (namefile2 , unit = abs (iut ))
616- hfpth2 , status2 = entries [0 ][0 ], entries [0 ][1 ]
617+ hfpth2 = entries [0 ][0 ] if any (entries ) else None
618+ status2 = entries [0 ][1 ] if any (entries ) else None
617619 else :
618620 if isinstance (files2 , str ):
619621 files2 = [files2 ]
@@ -950,7 +952,7 @@ def compare_concentrations(
950952 if files1 is None :
951953 for ext in valid_ext :
952954 ucn = get_entries_from_namefile (namefile1 , extension = ext )
953- ufpth = ucn [0 ][0 ]
955+ ufpth = ucn [0 ][0 ] if any ( ucn ) else None
954956 if ufpth is not None :
955957 ufpth1 = ufpth
956958 break
@@ -970,7 +972,7 @@ def compare_concentrations(
970972 if files2 is None :
971973 for ext in valid_ext :
972974 ucn = get_entries_from_namefile (namefile2 , extension = ext )
973- ufpth = ucn [0 ][0 ]
975+ ufpth = ucn [0 ][0 ] if any ( ucn ) else None
974976 if ufpth is not None :
975977 ufpth2 = ufpth
976978 break
@@ -1174,7 +1176,7 @@ def compare_stages(
11741176 if namefile1 is not None :
11751177 for ext in valid_ext :
11761178 stg = get_entries_from_namefile (namefile1 , extension = ext )
1177- sfpth = stg [0 ][0 ]
1179+ sfpth = stg [0 ][0 ] if any ( stg ) else None
11781180 if sfpth is not None :
11791181 sfpth1 = sfpth
11801182 break
@@ -1192,7 +1194,7 @@ def compare_stages(
11921194 if namefile2 is not None :
11931195 for ext in valid_ext :
11941196 stg = get_entries_from_namefile (namefile2 , extension = ext )
1195- sfpth = stg [0 ][0 ]
1197+ sfpth = stg [0 ][0 ] if any ( stg ) else None
11961198 if sfpth is not None :
11971199 sfpth2 = sfpth
11981200 break
0 commit comments