Skip to content

Commit e9db8ad

Browse files
committed
MNT: Try to stick to passing filenames to other libraries
This clarifies ownership around who needs to close the file.
1 parent 96c4c48 commit e9db8ad

4 files changed

Lines changed: 7 additions & 6 deletions

File tree

examples/plots/Mesonet_Stationplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
# Current observations can be downloaded here:
3333
# https://www.mesonet.org/index.php/weather/category/past_data_files
34-
data = pd.read_csv(get_test_data('mesonet_sample.txt'), na_values=' ')
34+
data = pd.read_csv(get_test_data('mesonet_sample.txt', as_file_obj=False), na_values=' ')
3535

3636
# Drop stations with missing values of data we want
3737
data = data.dropna(how='any', subset=['PRES', 'TAIR', 'TDEW', 'WDIR', 'WSPD'])

examples/plots/nhc_wind_probabilities.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
###########################
2424
# Read in the shapefile file containing the wind probabilities.
25-
wind_data = geopandas.read_file(get_test_data('nhc_wind_prob_2021082012.zip'))
25+
wind_data = geopandas.read_file(get_test_data('nhc_wind_prob_2021082012.zip', False))
2626

2727
###########################
2828
# Add the color scheme to the GeoDataFrame. This is the same color scheme used by the National
@@ -33,7 +33,7 @@
3333

3434
###########################
3535
# Read in the shapefile file containing the cities.
36-
cities = geopandas.read_file(get_test_data('us_cities.zip'))
36+
cities = geopandas.read_file(get_test_data('us_cities.zip', as_file_obj=False))
3737

3838
###########################
3939
# There are thousands of cities in the United States. We choose a few cities here that we want

examples/plots/spc_convective_outlook.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
###########################
2020
# Read in the geoJSON file containing the convective outlook.
21-
day1_outlook = geopandas.read_file(get_test_data('spc_day1otlk_20210317_1200_lyr.geojson'))
21+
day1_outlook = geopandas.read_file(get_test_data('spc_day1otlk_20210317_1200_lyr.geojson',
22+
as_file_obj=False))
2223

2324
###########################
2425
# Preview the data.

tests/plots/test_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def test_add_timestamp_xarray():
5454
"""Test that add_timestamp can work with xarray datetime accessor."""
5555
with autoclose_figure() as fig:
5656
ax = fig.add_subplot(1, 1, 1)
57-
ds = xr.open_dataset(get_test_data('AK-REGIONAL_8km_3.9_20160408_1445.gini'),
58-
engine='gini')
57+
ds = xr.open_dataset(get_test_data('AK-REGIONAL_8km_3.9_20160408_1445.gini',
58+
as_file_obj=False), engine='gini')
5959
txt = add_timestamp(ax, ds.time.dt, pretext='')
6060
assert txt.get_text() == '2016-04-08T14:45:20Z'
6161

0 commit comments

Comments
 (0)