Skip to content

Commit 6ce8068

Browse files
committed
Help the typechecker some more
1 parent fcfad5d commit 6ce8068

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

antarctica_today/compute_mean_climatology.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,8 @@ def create_partial_year_melt_anomaly_tif(
429429

430430
# Round to integers, if it isn't already.
431431
anomalies_int: numpy.ndarray = numpy.array(
432-
numpy.round(anomaly_this_season_so_far), dtype=numpy.int32
432+
numpy.round(anomaly_this_season_so_far),
433+
dtype=numpy.int32,
433434
)
434435

435436
# If dest_fname is None, create it.
@@ -591,9 +592,7 @@ def create_annual_melt_sum_tif(
591592
dt_list = list(datetimes_dict.keys())
592593

593594
if year == "all":
594-
years = numpy.unique([dt.year for dt in dt_list])
595-
years.sort()
596-
595+
years = sorted({dt.year for dt in dt_list})
597596
else:
598597
assert year == int(year)
599598
years = [year]

antarctica_today/melt_array_picklefile.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import pickle
1616
import re
1717
from pathlib import Path
18-
from typing import Any
18+
from typing import Any, Dict, Tuple
1919

2020
import numpy
2121
from osgeo import gdal
@@ -323,15 +323,15 @@ def _filter_out_erroneous_swaths(model_array, datetimes_dict):
323323

324324

325325
def read_gap_filled_melt_picklefile(
326-
picklefile=gap_filled_melt_picklefile, verbose=True
327-
):
326+
picklefile: Path = gap_filled_melt_picklefile,
327+
verbose: bool = True,
328+
) -> Tuple[numpy.ndarray, Dict[datetime.datetime, int]]:
328329
"""Read the gap-filled picklefile, return to user."""
329330
if verbose:
330331
print("Reading", picklefile)
331332

332-
f = open(picklefile, "rb")
333-
array, dt_dict = pickle.load(f)
334-
f.close()
333+
with open(picklefile, "rb") as f:
334+
array, dt_dict = pickle.load(f)
335335

336336
return array, dt_dict
337337

0 commit comments

Comments
 (0)