Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
42 changes: 42 additions & 0 deletions .github/workflows/run_demos_python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: run python demos

on:
push:
branches: ["*"]
pull_request:
branches: ["*"]

jobs:
demos:
continue-on-error: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
python-version: ["3.7"]

steps:
- name: Shallow clone GLMsingle
uses: actions/checkout@v3
with:
submodules: "recursive"
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install .
pip install -r requirements_dev.txt

- name: Display Python version and packages
run: |
python -c "import sys; print(sys.version)"
pip list

- name: Run tests and generate coverage report
run: pytest --nbmake --nbmake-timeout=3000 "./examples"
54 changes: 54 additions & 0 deletions .github/workflows/run_tests_python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: tests and coverage with python

on:
push:
branches: ["*"]
pull_request:
branches: ["*"]

jobs:
tests:
continue-on-error: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to test with different OS?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably higher priority is different python versions (since python versions seem to cause more problems)... I suppose, assuming that the tests can run pretty quickly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now set up to test in parallel python 3.7 to python 3.9 on ubuntu, mac, windows

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running the tests themselves takes about a minute in CI. But the whole takes a bit more time than this because of the set up and tear down

python-version: ["3.7", "3.8", "3.9", "3.10"]

steps:
- name: Shallow clone GLMsingle
uses: actions/checkout@v3
with:
submodules: "recursive"
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install .
pip install -r requirements_dev.txt

- name: Display Python version and packages
run: |
python -c "import sys; print(sys.version)"
pip list

- name: Prepare data
run: make tests/data/nsdcoreexampledataset.mat

- name: Run tests and generate coverage report
run: pytest -v --cov glmsingle --cov-report xml tests

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
flags: python
name: codecov-umbrella
fail_ci_if_error: true
verbose: true
16 changes: 8 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
numpy
scipy
sklearn
matplotlib
tqdm
fracridge
nibabel
h5py
fracridge>=1.4.3
h5py>=3.1.0
matplotlib>=3.3.4
nibabel>=3.2.2
numpy>=1.17.0
scikit-learn>=0.23.2
scipy>=1.5.4
tqdm>=4.63.1
Comment on lines +1 to +8
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have pinned the dependency minimum version for GLMsingle to be those that were installed by default when using python 3.6.

21 changes: 21 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[flake8]
max-line-length = 99

ignore = D203, W503

exclude =
.git,
docs,
__pycache__,
old,
build,
dist
'matlab/fracridge'

max-complexity = 10

[tool:pytest]
branch = True
source = glmsingle/*
include = glmsingle/*
testpaths = tests
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
packages=find_packages(),
include_package_data=True,
zip_safe=False,
install_requires=requires
install_requires=requires,
python_requires='>=3.6'
)
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Unit test package for glmsingle."""
34 changes: 34 additions & 0 deletions tests/test_glmsingleunit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from os.path import join
from os.path import abspath
from os.path import dirname
import scipy
import scipy.io as sio
from glmsingle.glmsingle import GLM_single

test_dir = dirname(abspath(__file__))
data_dir = join(test_dir, "data")
data_file = join(data_dir, "nsdcoreexampledataset.mat")

output_dir = join(test_dir, "outputs")


def test_smoke_test():

X = sio.loadmat(data_file)

data = []
design = []
for r in range(3): # range(len(X['data'][0])):
data.append(X["data"][0, r][50:70, 7:27, 0:1, :])
design.append(scipy.sparse.csr_matrix.toarray(X["design"][0, r]))

stimdur = X["stimdur"][0][0]
tr = X["tr"][0][0]

opt = {"wantmemoryoutputs": [1, 1, 1, 1]}

# OPTIONAL: PUT THIS IN?
# opt['wantlibrary'] = 0

glmsingle_obj = GLM_single(opt)
glmsingle_obj.fit(design, data, stimdur, tr, outputdir=join(output_dir, "python"))