Skip to content

Commit

Permalink
STY: Assorted refurb suggestions (#831)
Browse files Browse the repository at this point in the history
* 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 <effigies@gmail.com>

---------

Co-authored-by: Chris Markiewicz <effigies@gmail.com>
  • Loading branch information
DimitriPapadopoulos and effigies authored Oct 24, 2023
1 parent 24cfcfa commit 16ccaa9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
1 change: 0 additions & 1 deletion docs/sphinxext/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,3 @@ def setup(app):
app.add_role('ghuser', ghuser_role)
app.add_role('ghcommit', ghcommit_role)
app.add_config_value('github_project_url', None, 'env')
return
4 changes: 2 additions & 2 deletions niworkflows/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
""" py.test configuration file """
import os
from pathlib import Path
from datetime import datetime as dt
import datetime as dt
import pytest
from templateflow.api import get as get_template
from niworkflows.testing import test_data_env, data_env_canary
Expand All @@ -34,7 +34,7 @@

def _run_interface_mock(objekt, runtime):
runtime.returncode = 0
runtime.endTime = dt.isoformat(dt.utcnow())
runtime.endTime = dt.datetime.isoformat(dt.datetime.now(dt.timezone.utc))

objekt._out_report = os.path.abspath(objekt.inputs.out_report)
objekt._post_run_hook(runtime)
Expand Down
12 changes: 5 additions & 7 deletions niworkflows/viz/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,7 @@ def _3d_in_file(in_file):

in_file = filemanip.filename_to_list(in_file)[0]

try:
in_file = nb.load(in_file)
except AttributeError:
in_file = in_file
in_file = nb.load(in_file)

if len(in_file.shape) == 3:
return in_file
Expand Down Expand Up @@ -589,9 +586,10 @@ def plot_melodic_components(
else:
mask_img = nb.load(report_mask)

mask_sl = []
for j in range(3):
mask_sl.append(transform_to_2d(mask_img.get_fdata(), j))
mask_sl = [
transform_to_2d(mask_img.get_fdata(), j)
for j in range(3)
]

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

0 comments on commit 16ccaa9

Please sign in to comment.