Skip to content

Commit

Permalink
bump version, merge pull request #9 from AMYPAD/devel
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl authored Nov 29, 2020
2 parents 1bfed89 + 02ecc4b commit 931ab4d
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 43 deletions.
26 changes: 21 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,27 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: set PYSHA
run: echo "PYSHA=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v1
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PYSHA }}|${{ hashFiles('.pre-commit-config.yaml') }}
- run: pip install -U .[dev]
- run: python setup.py sdist bdist_wheel
- run: twine check dist/*
- run: flake8 .
- if: |
! startsWith(matrix.python, '2')
run: black --check .
- uses: reviewdog/action-setup@v1
- if: github.event_name != 'schedule'
run: |
set -o pipefail
pre-commit run -a flake8 | \
reviewdog -f=pep8 -name=flake8 -tee -reporter=github-check -filter-mode nofilter
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- if: startsWith(matrix.python, '3')
run: pre-commit run -a --show-diff-on-failure
- if: startsWith(matrix.python, '2')
run: pre-commit run -a --show-diff-on-failure isort
test:
runs-on: [self-hosted, matlab]
name: Test matlab
Expand All @@ -41,6 +55,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: casperdcl/deploy-pypi@v1
with:
build: true
Expand All @@ -60,7 +76,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: miutil ${{ github.ref }} beta
release_name: spm12 ${{ github.ref }} beta
body_path: _CHANGES.md
draft: true
- uses: actions/upload-release-asset@v1
Expand Down
32 changes: 32 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear
- flake8-comprehensions
- flake8-debugger
- flake8-string-format
repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
- hooks:
- id: black
repo: https://github.com/psf/black
rev: 19.10b0
- hooks:
- id: isort
repo: https://github.com/timothycrosley/isort
rev: 5.6.4
2 changes: 1 addition & 1 deletion LICENCE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Copyright 2020 AMYPAD

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
you may not use this project except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ build-backend = "setuptools.build_meta"
[tool.setuptools_scm]
write_to = "spm12/_dist_ver.py"
write_to_template = "__version__ = '{version}'\n"

[tool.black]
target-version = ['py27', 'py36']
27 changes: 17 additions & 10 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ platforms = any
provides = spm12
classifiers =
Development Status :: 4 - Beta
Intended Audience :: Developers
Intended Audience :: Education
Intended Audience :: Healthcare Industry
Intended Audience :: Science/Research
Expand All @@ -33,24 +34,23 @@ classifiers =
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Topic :: Scientific/Engineering :: Medical Science Apps.
Topic :: Software Development :: Libraries
Topic :: System :: Installation/Setup
[options]
zip_safe = False
setup_requires = setuptools>=42; setuptools_scm[toml]>=3.4
include_package_data = True
packages = find:
install_requires =
argopt
miutil[nii]>=0.1.0,!=0.4.0,!=0.4.1
setuptools # pkg_resources
brainweb>=1.6.2
numpy
scipy
[options.entry_points]
console_scripts =
spm12 = spm12.cli:main
include_package_data = True
packages = find:
[options.extras_require]
dev =
black; python_version >= "3.0"
flake8
pre-commit
twine
wheel
pytest
Expand All @@ -61,13 +61,20 @@ dev =
demo =
miutil[plot]>=0.3.0
matplotlib
[options.entry_points]
console_scripts =
spm12 = spm12.cli:main
[options.package_data]
* = *.md, *.rst, *.m

[bdist_wheel]
universal = 1

[flake8]
max_line_length = 88
extend-ignore = E203
extend-ignore = E203,P1
exclude = .git,__pycache__,build,dist,.eggs

[bdist_wheel]
universal = 1
[isort]
profile = black
known_first_party = spm12,tests
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from setuptools import setup

setup()
setup(use_scm_version=True)
3 changes: 2 additions & 1 deletion spm12/__main__.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
import sys

from .cli import main

if __name__ == "__main__":
if __name__ == "__main__": # pragma: no cover
sys.exit(main(sys.argv[1:]))
12 changes: 5 additions & 7 deletions spm12/regseg.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from textwrap import dedent
import errno
import logging
import os
import shutil
from textwrap import dedent

from miutil import create_dir, hasext
from miutil.imio import nii
import numpy as np
import scipy.ndimage as ndi
from miutil import create_dir, hasext
from miutil.imio import nii

from .utils import ensure_spm

Expand Down Expand Up @@ -302,13 +302,11 @@ def resample_spm(
fout = os.path.join(opth, fimout)
elif pickname == "ref":
fout = os.path.join(
opth,
"affine_ref-" + nii.file_parts(imrefu)[1] + fcomment + ".nii.gz",
opth, "affine_ref-" + nii.file_parts(imrefu)[1] + fcomment + ".nii.gz",
)
elif pickname == "flo":
fout = os.path.join(
opth,
"affine_flo-" + nii.file_parts(imflo)[1] + fcomment + ".nii.gz",
opth, "affine_flo-" + nii.file_parts(imflo)[1] + fcomment + ".nii.gz",
)
# change the file name
os.rename(fim + ".gz", fout)
Expand Down
9 changes: 5 additions & 4 deletions spm12/utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import logging
from functools import lru_cache, wraps
from os import path
from pkg_resources import resource_filename
from textwrap import dedent
import logging

from miutil.mlab import get_engine
from pkg_resources import resource_filename

__all__ = ["get_matlab", "ensure_spm"]
PATH_M = resource_filename(__name__, "")
Expand Down Expand Up @@ -32,9 +32,10 @@ def ensure_spm(name=None, cache="~/.spm12", version=12):
if not eng.exist("spm_jobman"):
log.warn("MATLAB could not find SPM.")
try:
from brainweb import get_file
from zipfile import ZipFile

from brainweb import get_file

log.info("Downloading to %s", cache)
fname = get_file(
"spm12.zip",
Expand All @@ -50,7 +51,7 @@ def ensure_spm(name=None, cache="~/.spm12", version=12):
if not eng.exist("spm_jobman"):
raise RuntimeError("MATLAB could not find SPM.")
log.info("Installed")
except: # NOQA: E722
except: # NOQA: E722,B001
raise ImportError(
dedent(
"""\
Expand Down
2 changes: 1 addition & 1 deletion tests/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from os import chdir, path
import sys
from os import chdir, path
from subprocess import check_call

chdir(path.dirname(path.dirname(path.abspath(__file__))))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pytest import skip
from miutil.mlab import matlabroot
from pytest import skip


def test_cli():
Expand Down
16 changes: 4 additions & 12 deletions tests/test_regseg.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from os import path, getenv
from os import getenv, path
from textwrap import dedent

from miutil import tmpdir
from miutil.imio import nii

import numpy as np
import pytest
from miutil import tmpdir
from miutil.imio import nii

from spm12 import regseg

Expand Down Expand Up @@ -53,14 +52,7 @@ def assert_equal_arrays(x, y, nmse_tol=0, denan=True):
y: {:.3g}/{:.3g}/{:.3g}({:.3g})
"""
).format(
x.min(),
x.mean(),
x.max(),
x.std(),
y.min(),
y.mean(),
y.max(),
y.std(),
x.min(), x.mean(), x.max(), x.std(), y.min(), y.mean(), y.max(), y.std(),
)
)

Expand Down

0 comments on commit 931ab4d

Please sign in to comment.