Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address a number of DeprecationWarnings that are issued when running tests #2986

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def __getattr__(cls, name):

# General information about the project.
project = u"Satpy"
copyright = u"2009-{}, The PyTroll Team".format(dt.datetime.utcnow().strftime("%Y")) # noqa: A001
copyright = u"2009-{}, The PyTroll Team".format(dt.datetime.now(dt.UTC).strftime("%Y")) # noqa: A001

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion satpy/readers/hrpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def __init__(self, filename, filename_info, filetype_info):
self.channels = {i: None for i in AVHRR_CHANNEL_NAMES}
self.units = {i: "counts" for i in AVHRR_CHANNEL_NAMES}

self.year = filename_info.get("start_time", dt.datetime.utcnow()).year
self.year = filename_info.get("start_time", dt.datetime.now(dt.UTC)).year

@cached_property
def times(self):
Expand Down
4 changes: 2 additions & 2 deletions satpy/tests/reader_tests/test_satpy_cf_nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,15 @@ def cf_scene(datasets, common_attrs):
@pytest.fixture
def nc_filename(tmp_path):
"""Create an nc filename for viirs m band."""
now = dt.datetime.utcnow()
now = dt.datetime.now(dt.UTC)
filename = f"testingcfwriter{now:%Y%j%H%M%S}-viirs-mband-20201007075915-20201007080744.nc"
return str(tmp_path / filename)


@pytest.fixture
def nc_filename_i(tmp_path):
"""Create an nc filename for viirs i band."""
now = dt.datetime.utcnow()
now = dt.datetime.now(dt.UTC)
filename = f"testingcfwriter{now:%Y%j%H%M%S}-viirs-iband-20201007075915-20201007080744.nc"
return str(tmp_path / filename)

Expand Down
2 changes: 1 addition & 1 deletion satpy/tests/reader_tests/test_viirs_vgac_l1c_nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
@pytest.fixture
def nc_filename(tmp_path):
"""Create an nc test data file and return its filename."""
now = dt.datetime.utcnow()
now = dt.datetime.now(dt.UTC)
filename = f"VGAC_VJ10XMOD_A{now:%Y%j_%H%M}_n004946_K005.nc"
filename_str = str(tmp_path / filename)
# Create test data
Expand Down
2 changes: 1 addition & 1 deletion satpy/tests/scene_tests/test_saving.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_save_datasets_bad_writer(self, tmp_path):
da.zeros((100, 200), chunks=50),
dims=("y", "x"),
attrs={"name": "test",
"start_time": dt.datetime.utcnow()}
"start_time": dt.datetime.now(dt.UTC)}
)
scn = Scene()
scn["test"] = ds1
Expand Down
4 changes: 2 additions & 2 deletions satpy/tests/writer_tests/test_geotiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def _get_test_datasets_2d():
da.zeros((100, 200), chunks=50),
dims=("y", "x"),
attrs={"name": "test",
"start_time": dt.datetime.utcnow(),
"start_time": dt.datetime.now(dt.UTC),
"units": "K",
"area": adef}
)
Expand Down Expand Up @@ -72,7 +72,7 @@ def _get_test_datasets_3d():
dims=("bands", "y", "x"),
coords={"bands": ["R", "G", "B"]},
attrs={"name": "test",
"start_time": dt.datetime.utcnow(),
"start_time": dt.datetime.now(dt.UTC),
"area": adef}
)
return [ds1]
Expand Down
24 changes: 12 additions & 12 deletions satpy/tests/writer_tests/test_mitiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _get_test_datasets(self):
da.zeros((100, 200), chunks=50),
dims=("y", "x"),
attrs={"name": "1",
"start_time": dt.datetime.utcnow(),
"start_time": dt.datetime.now(dt.UTC),
"platform_name": "TEST_PLATFORM_NAME",
"sensor": "TEST_SENSOR_NAME",
"area": area_def,
Expand All @@ -91,7 +91,7 @@ def _get_test_datasets(self):
da.zeros((100, 200), chunks=50),
dims=("y", "x"),
attrs={"name": "4",
"start_time": dt.datetime.utcnow(),
"start_time": dt.datetime.now(dt.UTC),
"platform_name": "TEST_PLATFORM_NAME",
"sensor": "TEST_SENSOR_NAME",
"area": area_def,
Expand Down Expand Up @@ -132,7 +132,7 @@ def _get_test_datasets_sensor_set(self):
da.zeros((100, 200), chunks=50),
dims=("y", "x"),
attrs={"name": "1",
"start_time": dt.datetime.utcnow(),
"start_time": dt.datetime.now(dt.UTC),
"platform_name": "TEST_PLATFORM_NAME",
"sensor": {"TEST_SENSOR_NAME"},
"area": area_def,
Expand All @@ -155,7 +155,7 @@ def _get_test_datasets_sensor_set(self):
da.zeros((100, 200), chunks=50),
dims=("y", "x"),
attrs={"name": "4",
"start_time": dt.datetime.utcnow(),
"start_time": dt.datetime.now(dt.UTC),
"platform_name": "TEST_PLATFORM_NAME",
"sensor": {"TEST_SENSOR_NAME"},
"area": area_def,
Expand Down Expand Up @@ -197,7 +197,7 @@ def _get_test_dataset(self, bands=3):
da.zeros((bands, 100, 200), chunks=50),
dims=("bands", "y", "x"),
attrs={"name": "test",
"start_time": dt.datetime.utcnow(),
"start_time": dt.datetime.now(dt.UTC),
"platform_name": "TEST_PLATFORM_NAME",
"sensor": "TEST_SENSOR_NAME",
"area": area_def,
Expand Down Expand Up @@ -226,7 +226,7 @@ def _get_test_one_dataset(self):
da.zeros((100, 200), chunks=50),
dims=("y", "x"),
attrs={"name": "test",
"start_time": dt.datetime.utcnow(),
"start_time": dt.datetime.now(dt.UTC),
"platform_name": "TEST_PLATFORM_NAME",
"sensor": "avhrr",
"area": area_def,
Expand Down Expand Up @@ -255,7 +255,7 @@ def _get_test_one_dataset_sensor_set(self):
da.zeros((100, 200), chunks=50),
dims=("y", "x"),
attrs={"name": "test",
"start_time": dt.datetime.utcnow(),
"start_time": dt.datetime.now(dt.UTC),
"platform_name": "TEST_PLATFORM_NAME",
"sensor": {"avhrr"},
"area": area_def,
Expand Down Expand Up @@ -288,7 +288,7 @@ def _get_test_dataset_with_bad_values(self, bands=3):
ds1 = xr.DataArray(rgb_data,
dims=("bands", "y", "x"),
attrs={"name": "test",
"start_time": dt.datetime.utcnow(),
"start_time": dt.datetime.now(dt.UTC),
"platform_name": "TEST_PLATFORM_NAME",
"sensor": "TEST_SENSOR_NAME",
"area": area_def,
Expand Down Expand Up @@ -350,7 +350,7 @@ def _get_test_dataset_calibration(self, bands=6):
bands.append(p.attrs["name"])
data["bands"] = list(bands)
new_attrs = {"name": "datasets",
"start_time": dt.datetime.utcnow(),
"start_time": dt.datetime.now(dt.UTC),
"platform_name": "TEST_PLATFORM_NAME",
"sensor": "test-sensor",
"area": area_def,
Expand Down Expand Up @@ -427,7 +427,7 @@ def _get_test_dataset_calibration_one_dataset(self, bands=1):
for p in scene:
calibration.append(p.attrs["calibration"])
new_attrs = {"name": "datasets",
"start_time": dt.datetime.utcnow(),
"start_time": dt.datetime.now(dt.UTC),
"platform_name": "TEST_PLATFORM_NAME",
"sensor": "test-sensor",
"area": area_def,
Expand Down Expand Up @@ -472,7 +472,7 @@ def _get_test_dataset_three_bands_two_prereq(self, bands=3):
coords=[["R", "G", "B"], list(range(100)), list(range(200))],
dims=("bands", "y", "x"),
attrs={"name": "test",
"start_time": dt.datetime.utcnow(),
"start_time": dt.datetime.now(dt.UTC),
"platform_name": "TEST_PLATFORM_NAME",
"sensor": "TEST_SENSOR_NAME",
"area": area_def,
Expand Down Expand Up @@ -504,7 +504,7 @@ def _get_test_dataset_three_bands_prereq(self, bands=3):
coords=[["R", "G", "B"], list(range(100)), list(range(200))],
dims=("bands", "y", "x"),
attrs={"name": "test",
"start_time": dt.datetime.utcnow(),
"start_time": dt.datetime.now(dt.UTC),
"platform_name": "TEST_PLATFORM_NAME",
"sensor": "TEST_SENSOR_NAME",
"area": area_def,
Expand Down
2 changes: 1 addition & 1 deletion satpy/tests/writer_tests/test_simple_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _get_test_datasets():
da.zeros((100, 200), chunks=50),
dims=("y", "x"),
attrs={"name": "test",
"start_time": dt.datetime.utcnow()}
"start_time": dt.datetime.now(dt.UTC)}
)
return [ds1]

Expand Down
2 changes: 1 addition & 1 deletion satpy/writers/awips_tiled.py
Original file line number Diff line number Diff line change
Expand Up @@ -1775,7 +1775,7 @@ def create_debug_lettered_tiles(**writer_kwargs):
sector_info = writer.awips_sectors[sector_id]
area_def, arr = _create_debug_array(sector_info, save_kwargs["num_subtiles"])

now = dt.datetime.utcnow()
now = dt.datetime.now(dt.UTC)
product = xr.DataArray(da.from_array(arr, chunks="auto"), attrs=dict(
name="debug_{}".format(sector_id),
platform_name="DEBUG",
Expand Down
Loading