Skip to content

Commit 16ccaa9

Browse files
STY: Assorted refurb suggestions (#831)
* MNT: remove no-op * MNT: use list comprehensions * MNT: `utcnow()` → `now(tz=timezone.utc)` https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow Because naive datetime objects are treated by many datetime methods as local times, it is preferred to use aware datetimes to represent times in UTC. As such, the recommended way to create an object representing the current time in UTC is by calling datetime.now(timezone.utc). Deprecated since version 3.12: Use datetime.now() with UTC instead. Co-authored-by: Chris Markiewicz <[email protected]> --------- Co-authored-by: Chris Markiewicz <[email protected]>
1 parent 24cfcfa commit 16ccaa9

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

docs/sphinxext/github.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,3 @@ def setup(app):
152152
app.add_role('ghuser', ghuser_role)
153153
app.add_role('ghcommit', ghcommit_role)
154154
app.add_config_value('github_project_url', None, 'env')
155-
return

niworkflows/tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
""" py.test configuration file """
2424
import os
2525
from pathlib import Path
26-
from datetime import datetime as dt
26+
import datetime as dt
2727
import pytest
2828
from templateflow.api import get as get_template
2929
from niworkflows.testing import test_data_env, data_env_canary
@@ -34,7 +34,7 @@
3434

3535
def _run_interface_mock(objekt, runtime):
3636
runtime.returncode = 0
37-
runtime.endTime = dt.isoformat(dt.utcnow())
37+
runtime.endTime = dt.datetime.isoformat(dt.datetime.now(dt.timezone.utc))
3838

3939
objekt._out_report = os.path.abspath(objekt.inputs.out_report)
4040
objekt._post_run_hook(runtime)

niworkflows/viz/utils.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,7 @@ def _3d_in_file(in_file):
212212

213213
in_file = filemanip.filename_to_list(in_file)[0]
214214

215-
try:
216-
in_file = nb.load(in_file)
217-
except AttributeError:
218-
in_file = in_file
215+
in_file = nb.load(in_file)
219216

220217
if len(in_file.shape) == 3:
221218
return in_file
@@ -589,9 +586,10 @@ def plot_melodic_components(
589586
else:
590587
mask_img = nb.load(report_mask)
591588

592-
mask_sl = []
593-
for j in range(3):
594-
mask_sl.append(transform_to_2d(mask_img.get_fdata(), j))
589+
mask_sl = [
590+
transform_to_2d(mask_img.get_fdata(), j)
591+
for j in range(3)
592+
]
595593

596594
timeseries = np.loadtxt(os.path.join(melodic_dir, "melodic_mix"))
597595
power = np.loadtxt(os.path.join(melodic_dir, "melodic_FTmix"))

0 commit comments

Comments
 (0)