Skip to content

Commit be154ec

Browse files
authored
Merge pull request #200 from effigies/ci/fix_test_config
CI: Update test workflow with narrower job spec, more Python versions, concurrency
2 parents d2d5583 + 8be79f4 commit be154ec

File tree

9 files changed

+31
-19
lines changed

9 files changed

+31
-19
lines changed

.github/workflows/test.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
name: Test suite
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- "*"
9+
pull_request:
10+
branches:
11+
- master
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
417

518
jobs:
619
build:
@@ -9,13 +22,13 @@ jobs:
922
strategy:
1023
max-parallel: 4
1124
matrix:
12-
python-version: [3.7, 3.8]
25+
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
1326

1427
steps:
1528
- name: Checkout repo
16-
uses: actions/checkout@v1
29+
uses: actions/checkout@v3
1730
- name: Set up Python ${{ matrix.python-version }}
18-
uses: actions/setup-python@v1
31+
uses: actions/setup-python@v4
1932
with:
2033
python-version: ${{ matrix.python-version }}
2134
- name: Install
@@ -26,7 +39,7 @@ jobs:
2639
python -m pip install .
2740
- name: Lint
2841
run: |
29-
flake8 --ignore N802,N806,W504 --select W503 `find . -name \*.py | grep -v setup.py | grep -v version.py | grep -v __init__.py | grep -v /docs/`
42+
pipx run flake8 --ignore N802,N806,W504 --select W503 nitime/ tools/
3043
- name: Test
3144
run: |
3245
cd && mkdir for_test && cd for_test && pytest --pyargs nitime --cov-report term-missing --cov=AFQ

nitime/algorithms/cohere.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ def cache_fft(time_series, ij, lb=0, ub=None,
10051005
FFT_conj_slices = {}
10061006

10071007
for i_channel in all_channels:
1008-
Slices = np.zeros((n_slices, n_freqs), dtype=np.complex)
1008+
Slices = np.zeros((n_slices, n_freqs), dtype=complex)
10091009
for iSlice in range(n_slices):
10101010
thisSlice = time_series[i_channel,
10111011
i_times[iSlice]:i_times[iSlice] + NFFT]
@@ -1161,7 +1161,7 @@ def cache_to_relative_phase(cache, ij):
11611161
channels_i = max(1, max(ij_array[:, 0]) + 1)
11621162
channels_j = max(1, max(ij_array[:, 1]) + 1)
11631163
# Pre-allocate for speed:
1164-
Phi_xy = np.zeros((channels_i, channels_j, freqs), dtype=np.complex)
1164+
Phi_xy = np.zeros((channels_i, channels_j, freqs), dtype=complex)
11651165

11661166
# These checks take time, so do them up front, not in every iteration:
11671167
if list(FFT_slices.items())[0][1].shape[0] > 1:
@@ -1221,7 +1221,7 @@ def cache_to_coherency(cache, ij):
12211221

12221222
channels_i = max(1, max(ij_array[:, 0]) + 1)
12231223
channels_j = max(1, max(ij_array[:, 1]) + 1)
1224-
Cxy = np.zeros((channels_i, channels_j, freqs), dtype=np.complex)
1224+
Cxy = np.zeros((channels_i, channels_j, freqs), dtype=complex)
12251225

12261226
#These checks take time, so do them up front, not in every iteration:
12271227
if list(FFT_slices.items())[0][1].shape[0] > 1:

nitime/analysis/coherence.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,10 +653,10 @@ def coherency(self):
653653
if len(self.seed.shape) > 1:
654654
Cxy = np.empty((self.seed.data.shape[0],
655655
self.target.data.shape[0],
656-
self.frequencies.shape[0]), dtype=np.complex)
656+
self.frequencies.shape[0]), dtype=complex)
657657
else:
658658
Cxy = np.empty((self.target.data.shape[0],
659-
self.frequencies.shape[0]), dtype=np.complex)
659+
self.frequencies.shape[0]), dtype=complex)
660660

661661
#Get the fft window cache for the target time-series:
662662
cache = self.target_cache

nitime/analysis/correlation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def corrcoef(self):
147147

148148
# Preallocate results
149149
Cxy = np.empty((self.seed.data.shape[0],
150-
self.target.data.shape[0]), dtype=np.float)
150+
self.target.data.shape[0]), dtype=float)
151151

152152
for seed_idx, this_seed in enumerate(self.seed.data):
153153

nitime/analysis/spectral.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,8 @@ def iir(self):
418418

419419
wp = [lb_frac, ub_frac]
420420

421-
ws = [np.max([lb_frac - 0.1, 0]),
422-
np.min([ub_frac + 0.1, 1.0])]
421+
ws = [np.max([lb_frac - 0.1, 0.001]),
422+
np.min([ub_frac + 0.1, 0.999])]
423423

424424
# For the lowpass:
425425
elif lb_frac == 0:

nitime/fmri/io.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def time_series_from_file(nifti_files, coords=None, TR=None, normalize=None,
8888
if verbose:
8989
print("Reading %s" % nifti_files)
9090
im = load(nifti_files)
91-
data = im.get_data()
91+
data = im.get_fdata()
9292
# If coordinates are provided as input, read data only from these coordinates:
9393
if coords is not None:
9494
#If the input is the coords of several ROIs
@@ -118,7 +118,7 @@ def time_series_from_file(nifti_files, coords=None, TR=None, normalize=None,
118118
if verbose:
119119
print("Reading %s" % f)
120120
im = load(f)
121-
data = im.get_data()
121+
data = im.get_fdata()
122122
if coords is not None:
123123
#If the input is the coords of several ROIs
124124
if isinstance(coords, tuple) or isinstance(coords, list):

nitime/fmri/tests/test_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def test_time_series_from_file():
6565
npt.assert_equal(t4.sampling_interval,nitime.TimeArray(1.35))
6666

6767
# Test the default behavior:
68-
data = io.load(fmri_file1).get_data()
68+
data = io.load(fmri_file1).get_fdata()
6969
t5 = ts_ff(fmri_file1)
7070
npt.assert_equal(t5.shape, data.shape)
7171
npt.assert_equal(t5.sampling_interval, ts.TimeArray(1, time_unit='s'))

nitime/tests/test_algorithms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ def test_psd_matlab():
145145
ts = np.loadtxt(os.path.join(test_dir_path, 'tseries12.txt'))
146146

147147
#Complex signal!
148-
ts0 = ts[1] + ts[0] * np.complex(0, 1)
148+
ts0 = ts[1] + ts[0] * complex(0, 1)
149149

150150
NFFT = 256
151151
Fs = 1.0
152-
noverlap = NFFT / 2
152+
noverlap = NFFT // 2
153153

154154
fxx, f = mlab.psd(ts0, NFFT=NFFT, Fs=Fs, noverlap=noverlap,
155155
scale_by_freq=True)

requirements-dev.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ pytest
33
pytest-cov
44
nibabel
55
networkx
6-
flake8

0 commit comments

Comments
 (0)