From 62de671c91419723ead88175bed76907cea2d46a Mon Sep 17 00:00:00 2001 From: Jiwoo Lee Date: Tue, 7 Nov 2023 13:54:42 -0800 Subject: [PATCH] pre-commit fix: do not use bare except --- pcmdi_metrics/sea_ice/generate_sector_masks.py | 10 ++++++---- pcmdi_metrics/sea_ice/ice_area_cmip5_ssmi_reg_rms.py | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pcmdi_metrics/sea_ice/generate_sector_masks.py b/pcmdi_metrics/sea_ice/generate_sector_masks.py index 857b4b70a..77d8fcb30 100644 --- a/pcmdi_metrics/sea_ice/generate_sector_masks.py +++ b/pcmdi_metrics/sea_ice/generate_sector_masks.py @@ -111,10 +111,12 @@ try: area = g("areacello") - except: + except Exception: area = g("areacella") area = MV.multiply(area, factor1) - area = MV.multiply(area, factor1) + area = MV.multiply( + area, factor1 + ) # Question from Jiwoo (2023-11-7): Why this line repeats two times? g.close() @@ -142,7 +144,7 @@ print(mod, MV.max(frac)) area = MV.multiply(area, frac) land_mask = MV.multiply(1, (1 - frac)) - except: + except Exception: frac = s("sftlf") if ( mod != "MIROC5" @@ -209,7 +211,7 @@ MV.greater_equal(lats, -90.0), MV.less(lats, -55.0) ) - except: + except Exception: "Failed for ", mod mods_failed.append(mod) diff --git a/pcmdi_metrics/sea_ice/ice_area_cmip5_ssmi_reg_rms.py b/pcmdi_metrics/sea_ice/ice_area_cmip5_ssmi_reg_rms.py index 2752bea6a..fa7e7ee71 100755 --- a/pcmdi_metrics/sea_ice/ice_area_cmip5_ssmi_reg_rms.py +++ b/pcmdi_metrics/sea_ice/ice_area_cmip5_ssmi_reg_rms.py @@ -408,7 +408,7 @@ def tgrid(t): data_np.append(val4 + val5) data_na.append(val6 + val7 + val8 + val9 + val11 + val12) data_ca.append(val10) - except: + except Exception: pass obs1_n[:, dl] = MV.array(data_n[0:324], id="sic") obs1_ca[:, dl] = MV.array(data_ca[0:324], id="sic") @@ -428,7 +428,7 @@ def tgrid(t): data_sa.append(val4) data_io.append(val5) data_sp.append(val6 + val7 + val8) - except: + except Exception: pass obs1_s[:, dl] = MV.array(data_s[0:324], id="sic") @@ -675,7 +675,7 @@ def tgrid(t): g = cdms.open(gfile) try: area = g("areacello") - except: + except Exception: area = g("areacella") area = MV.multiply(area, factor1) area = MV.multiply(area, factor1)