From f26d1b94fb95fc0ded28f8e8c2cc1009ab164b5a Mon Sep 17 00:00:00 2001
From: Pawel
Date: Tue, 8 Mar 2022 00:33:35 +0000
Subject: [PATCH 01/11] adding MGH support
---
miutil/imio/nii.py | 62 ++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 60 insertions(+), 2 deletions(-)
diff --git a/miutil/imio/nii.py b/miutil/imio/nii.py
index aabbc7d..417aaea 100644
--- a/miutil/imio/nii.py
+++ b/miutil/imio/nii.py
@@ -55,11 +55,69 @@ def nii_gzip(imfile, outpath=""):
return fout
+
+def getmgh(fim, nan_replace=None, output='image'):
+ '''
+ Get image from `*.mgz` or `*.mgh` file (FreeSurfer).
+ Arguments:
+ fim: input file name for the MGH/Z image
+ output: option for choosing output: 'image', 'affine' matrix or
+ 'all' for a dictionary with all the info.
+ Return:
+ 'image': outputs just the image
+ 'affine': outputs just the affine matrix
+ 'all': outputs all as a dictionary
+ '''
+
+ mgh = nib.freesurfer.load(fspath(fim))
+
+ if output == 'image' or output == 'all':
+
+ imr = np.asanyarray(mgh.dataobj)
+ # replace NaNs if requested
+ if isinstance(nan_replace, numbers.Number):
+ imr[np.isnan(imr)] = nan_replace
+
+ imr = np.squeeze(imr)
+ dimno = imr.ndim
+
+ # > get orientations from the affine
+ ornt = nib.io_orientation(mgh.affine)
+ trnsp = tuple(np.flip(np.argsort(ornt[:, 0])))
+ flip = tuple(np.int8(ornt[:, 1]))
+
+ # > flip y-axis and z-axis and then transpose
+ if dimno == 4: # dynamic
+ imr = np.transpose(imr[::-flip[0], ::-flip[1], ::-flip[2], :], (3,) + trnsp)
+ elif dimno == 3: # static
+ imr = np.transpose(imr[::-flip[0], ::-flip[1], ::-flip[2]], trnsp)
+
+
+ # # > voxel size
+ # voxsize = mgh.header.get('pixdim')[1:mgh.header.get('dim')[0] + 1]
+ # # > rearrange voxel size according to the orientation
+ # voxsize = voxsize[np.array(trnsp)]
+
+
+ if output == 'all':
+ out = {
+ 'im': imr, 'affine': mgh.affine, 'fim': fim, 'dtype': mgh.get_data_dtype(), 'shape': imr.shape,
+ 'hdr': mgh.header, 'transpose': trnsp, 'flip': flip}
+ elif output == 'image':
+ out = imr
+ elif output == 'affine':
+ out = mgh.affine
+ else:
+ raise NameError("Unrecognised output request!")
+
+ return out
+
+
def getnii(fim, nan_replace=None, output='image'):
"""
- Get PET image from NIfTI file.
+ Get image from NIfTI file.
Arguments:
- fim: input file name for the nifty image
+ fim: input file name for the NIfTI image
nan_replace: the value to be used for replacing the NaNs in the image.
by default no change (None).
output: option for choosing output: image, affine matrix or
From 898e052173898f72423d4a294d6340bda35ce64a Mon Sep 17 00:00:00 2001
From: Pawel
Date: Tue, 8 Mar 2022 00:56:16 +0000
Subject: [PATCH 02/11] removed MGH
---
miutil/imio/nii.py | 57 ----------------------------------------------
1 file changed, 57 deletions(-)
diff --git a/miutil/imio/nii.py b/miutil/imio/nii.py
index 417aaea..e1aa802 100644
--- a/miutil/imio/nii.py
+++ b/miutil/imio/nii.py
@@ -56,63 +56,6 @@ def nii_gzip(imfile, outpath=""):
-def getmgh(fim, nan_replace=None, output='image'):
- '''
- Get image from `*.mgz` or `*.mgh` file (FreeSurfer).
- Arguments:
- fim: input file name for the MGH/Z image
- output: option for choosing output: 'image', 'affine' matrix or
- 'all' for a dictionary with all the info.
- Return:
- 'image': outputs just the image
- 'affine': outputs just the affine matrix
- 'all': outputs all as a dictionary
- '''
-
- mgh = nib.freesurfer.load(fspath(fim))
-
- if output == 'image' or output == 'all':
-
- imr = np.asanyarray(mgh.dataobj)
- # replace NaNs if requested
- if isinstance(nan_replace, numbers.Number):
- imr[np.isnan(imr)] = nan_replace
-
- imr = np.squeeze(imr)
- dimno = imr.ndim
-
- # > get orientations from the affine
- ornt = nib.io_orientation(mgh.affine)
- trnsp = tuple(np.flip(np.argsort(ornt[:, 0])))
- flip = tuple(np.int8(ornt[:, 1]))
-
- # > flip y-axis and z-axis and then transpose
- if dimno == 4: # dynamic
- imr = np.transpose(imr[::-flip[0], ::-flip[1], ::-flip[2], :], (3,) + trnsp)
- elif dimno == 3: # static
- imr = np.transpose(imr[::-flip[0], ::-flip[1], ::-flip[2]], trnsp)
-
-
- # # > voxel size
- # voxsize = mgh.header.get('pixdim')[1:mgh.header.get('dim')[0] + 1]
- # # > rearrange voxel size according to the orientation
- # voxsize = voxsize[np.array(trnsp)]
-
-
- if output == 'all':
- out = {
- 'im': imr, 'affine': mgh.affine, 'fim': fim, 'dtype': mgh.get_data_dtype(), 'shape': imr.shape,
- 'hdr': mgh.header, 'transpose': trnsp, 'flip': flip}
- elif output == 'image':
- out = imr
- elif output == 'affine':
- out = mgh.affine
- else:
- raise NameError("Unrecognised output request!")
-
- return out
-
-
def getnii(fim, nan_replace=None, output='image'):
"""
Get image from NIfTI file.
From b578747f65d4d3a0c24c0c535d7e1229e1150dd5 Mon Sep 17 00:00:00 2001
From: Casper da Costa-Luis
Date: Tue, 28 Mar 2023 20:13:09 +0100
Subject: [PATCH 03/11] mlab: PEP440 non-compliance work-around
- vis. https://github.com/pypa/setuptools/issues/3772
---
.github/workflows/test.yml | 2 +-
miutil/mlab/__init__.py | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 87c072a..4dc60da 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -65,7 +65,7 @@ jobs:
fetch-depth: 0
- name: Run setup-python
run: setup-python -p${{ matrix.python }}
- - run: pip install -U .[dev,nii,cuda,web,mbeautify]
+ - run: pip install -U .[dev,nii,cuda,web,mbeautify] 'setuptools<66' # ignore matlab engine PEP440 non-compliance https://github.com/pypa/setuptools/issues/3772
- run: pytest --durations-min=1
- uses: codecov/codecov-action@v3
- name: Post Run setup-python
diff --git a/miutil/mlab/__init__.py b/miutil/mlab/__init__.py
index c4a82e6..28bccf3 100644
--- a/miutil/mlab/__init__.py
+++ b/miutil/mlab/__init__.py
@@ -79,6 +79,7 @@ def get_engine(name=None):
It's likely you need to do:
cd "{matlabroot}\\extern\\engines\\python"
+ {exe} -m pip install 'setuptools<66'
{exe} setup.py build --build-base="BUILDDIR" install
- Fill in any temporary directory name for BUILDDIR
From 8091dc33f333ad422f9ba6c8477ef35a6e5044b8 Mon Sep 17 00:00:00 2001
From: Casper da Costa-Luis
Date: Sat, 13 May 2023 15:46:28 +0530
Subject: [PATCH 04/11] deps: pin min nibabel version
---
setup.cfg | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup.cfg b/setup.cfg
index b8a215c..81e47a9 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -52,7 +52,7 @@ dev=
pytest-cov
pytest-timeout
pytest-xdist
-nii=nibabel; numpy
+nii=nibabel>=4.0; numpy
plot=matplotlib; numpy; scipy
cuda=argopt; pynvml
web=requests
From 5ad6313e8a914e0b44c769b3bfde633fd776d484 Mon Sep 17 00:00:00 2001
From: Casper da Costa-Luis
Date: Sat, 13 May 2023 11:50:05 +0100
Subject: [PATCH 05/11] mlab: install fallback to pip
---
miutil/mlab/__init__.py | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/miutil/mlab/__init__.py b/miutil/mlab/__init__.py
index 28bccf3..dcc5257 100644
--- a/miutil/mlab/__init__.py
+++ b/miutil/mlab/__init__.py
@@ -127,7 +127,8 @@ def matlabroot(default=None):
def _install_engine():
src = path.join(matlabroot(), "extern", "engines", "python")
- with open(path.join(src, "setup.py")) as fd: # check version support
+ with open(path.join(src, "setup.py")) as fd:
+ # check version support
supported = literal_eval(
re.search(r"supported_version.*?=\s*(.*?)$", fd.read(), flags=re.M).group(1))
if ".".join(map(str, sys.version_info[:2])) not in map(str, supported):
@@ -142,7 +143,18 @@ def _install_engine():
return check_output_u8(cmd, cwd=src)
except CalledProcessError:
log.warning("Normal install failed. Attempting `--user` install.")
- return check_output_u8(cmd + ["--user"], cwd=src)
+ try:
+ return check_output_u8(cmd + ["--user"], cwd=src)
+ except CalledProcessError:
+ ml_ver = src.split(path.sep)[-4].lstrip("R")
+ if ml_ver < '2020b':
+ raise
+ eng_ver = {
+ '2020b': '9.9', '2021a': '9.10', '2021b': '9.11', '2022a': '9.12',
+ '2022b': '9.13', '2023a': '9.14'}
+ pin = f"=={eng_ver[ml_ver]}.*" if ml_ver in eng_ver else ""
+ return check_output_u8([
+ sys.executable, "-m", "pip", "install", "matlabengine" + pin])
@lru_cache()
From 91d68f02f0d20f7cd574caa740557d938d02c6fb Mon Sep 17 00:00:00 2001
From: Casper da Costa-Luis
Date: Sat, 13 May 2023 11:53:15 +0100
Subject: [PATCH 06/11] mlab: improve install error message
---
miutil/mlab/__init__.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/miutil/mlab/__init__.py b/miutil/mlab/__init__.py
index dcc5257..4ba2939 100644
--- a/miutil/mlab/__init__.py
+++ b/miutil/mlab/__init__.py
@@ -78,7 +78,7 @@ def get_engine(name=None):
install-matlab-engine-api-for-python-in-nondefault-locations.html
It's likely you need to do:
- cd "{matlabroot}\\extern\\engines\\python"
+ cd "{setup_dir}"
{exe} -m pip install 'setuptools<66'
{exe} setup.py build --build-base="BUILDDIR" install
@@ -88,7 +88,9 @@ def get_engine(name=None):
to the above command.
Alternatively, use `get_runtime()` instead of `get_engine()`.
- """).format(matlabroot=matlabroot(default="matlabroot"), exe=sys.executable))
+ """).format(
+ setup_dir=path.join(matlabroot(default="matlabroot"), "extern", "engines",
+ "python"), exe=sys.executable))
log.debug("Starting MATLAB")
try:
eng = engine.connect_matlab(name=name or getenv("SPM12_MATLAB_ENGINE", None))
From 7064e8035ff7ffbed4379eb2932dd1c7beb466cb Mon Sep 17 00:00:00 2001
From: Casper da Costa-Luis
Date: Tue, 30 May 2023 22:04:37 +0530
Subject: [PATCH 07/11] lint
---
miutil/imio/nii.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/miutil/imio/nii.py b/miutil/imio/nii.py
index 35bba6a..95d7c66 100644
--- a/miutil/imio/nii.py
+++ b/miutil/imio/nii.py
@@ -55,7 +55,6 @@ def nii_gzip(imfile, outpath=""):
return fout
-
def getnii(fim, nan_replace=None, output='image'):
"""
Get image from NIfTI file.
From 27d5543fb73bd2154735069a010618a3441860d1 Mon Sep 17 00:00:00 2001
From: Casper da Costa-Luis
Date: Tue, 30 May 2023 11:00:49 +0530
Subject: [PATCH 08/11] mlab: fix py3.8+ install
---
miutil/mlab/__init__.py | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/miutil/mlab/__init__.py b/miutil/mlab/__init__.py
index 4ba2939..6dd3605 100644
--- a/miutil/mlab/__init__.py
+++ b/miutil/mlab/__init__.py
@@ -80,17 +80,15 @@ def get_engine(name=None):
cd "{setup_dir}"
{exe} -m pip install 'setuptools<66'
- {exe} setup.py build --build-base="BUILDDIR" install
+ {exe} setup.py build --build-base="BUILDDIR" install --prefix="{pre}"
- Fill in any temporary directory name for BUILDDIR
(e.g. /tmp/builddir).
- - If installation fails due to write permissions, try appending `--user`
- to the above command.
Alternatively, use `get_runtime()` instead of `get_engine()`.
""").format(
setup_dir=path.join(matlabroot(default="matlabroot"), "extern", "engines",
- "python"), exe=sys.executable))
+ "python"), exe=sys.executable, pre=sys.prefix))
log.debug("Starting MATLAB")
try:
eng = engine.connect_matlab(name=name or getenv("SPM12_MATLAB_ENGINE", None))
@@ -142,7 +140,7 @@ def _install_engine():
with tmpdir() as td:
cmd = [sys.executable, "setup.py", "build", "--build-base", td, "install"]
try:
- return check_output_u8(cmd, cwd=src)
+ return check_output_u8(cmd + ["--prefix", sys.prefix], cwd=src)
except CalledProcessError:
log.warning("Normal install failed. Attempting `--user` install.")
try:
From 8b5d2472816b0beaa3cf7ba40e86474a34bd65fa Mon Sep 17 00:00:00 2001
From: Casper da Costa-Luis
Date: Tue, 30 May 2023 22:46:49 +0530
Subject: [PATCH 09/11] build: migrate setup.{cfg,py} => pyproject.toml
---
.pre-commit-config.yaml | 3 +-
LICENCE.md | 2 +-
pyproject.toml | 88 +++++++++++++++++++++++++++++++++++++++
setup.cfg | 92 -----------------------------------------
setup.py | 3 --
5 files changed, 91 insertions(+), 97 deletions(-)
delete mode 100644 setup.cfg
delete mode 100644 setup.py
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index fb0c654..c1ef057 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -36,9 +36,10 @@ repos:
- flake8-comprehensions
- flake8-debugger
- flake8-isort
+ - flake8-pyproject
- flake8-string-format
- repo: https://github.com/google/yapf
- rev: v0.32.0
+ rev: v0.33.0
hooks:
- id: yapf
args: [-i]
diff --git a/LICENCE.md b/LICENCE.md
index ee3b9f9..3c0414b 100644
--- a/LICENCE.md
+++ b/LICENCE.md
@@ -1,4 +1,4 @@
-Copyright 2020 AMYPAD
+Copyright 2020-23 AMYPAD
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this project except in compliance with the License.
diff --git a/pyproject.toml b/pyproject.toml
index 0055d2f..bd16133 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,94 @@
[build-system]
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]
+build-backend = "setuptools.build_meta"
[tool.setuptools_scm]
write_to = "miutil/_dist_ver.py"
write_to_template = "__version__ = '{version}'\n"
+
+[tool.setuptools.packages.find]
+exclude = ["tests"]
+
+[project.urls]
+documentation = "https://github.com/AMYPAD/miutil/#miutil"
+repository = "https://github.com/AMYPAD/miutil"
+changelog = "https://github.com/AMYPAD/miutil/releases"
+
+[project]
+name = "miutil"
+dynamic = ["version"]
+maintainers = [{name = "Casper da Costa-Luis", email = "casper.dcl@physics.org"}]
+description = "Medical imaging utilities for the AMYPAD and NiftyPET projects"
+readme = "README.rst"
+requires-python = ">=3.7"
+keywords = ["fMRI", "PET", "SPECT", "EEG", "MEG"]
+license = {text = "Apache-2.0"}
+classifiers = [
+ "Development Status :: 4 - Beta",
+ "Intended Audience :: Developers",
+ "Environment :: GPU",
+ "Environment :: GPU :: NVIDIA CUDA",
+ "Intended Audience :: Education",
+ "Intended Audience :: Healthcare Industry",
+ "Intended Audience :: Science/Research",
+ "License :: OSI Approved :: Apache Software License",
+ "Operating System :: Microsoft :: Windows",
+ "Operating System :: POSIX :: Linux",
+ "Programming Language :: Other Scripting Engines",
+ "Programming Language :: Python :: 3",
+ "Programming Language :: Python :: 3.7",
+ "Programming Language :: Python :: 3.8",
+ "Programming Language :: Python :: 3.9",
+ "Programming Language :: Python :: 3.10",
+ "Programming Language :: Python :: 3.11",
+ "Programming Language :: Python :: 3 :: Only",
+ "Topic :: Scientific/Engineering :: Medical Science Apps.",
+ "Topic :: Software Development :: Libraries",
+ "Topic :: Software Development :: Libraries :: Python Modules",
+ "Topic :: Software Development :: User Interfaces",
+ "Topic :: System :: Installation/Setup",
+ "Topic :: Utilities"]
+dependencies = ["tqdm>=4.40.0"]
+
+[project.optional-dependencies]
+dev = ["pytest>=6", "pytest-cov", "pytest-timeout", "pytest-xdist"]
+nii = ["nibabel>=4.0", "numpy"]
+plot = ["matplotlib", "numpy", "scipy"]
+cuda = ["argopt", "pynvml"]
+web = ["requests"]
+mbeautify = ["argopt", "tqdm>=4.42.0", "requests"] # web
+
+[project.scripts]
+cuinfo = "miutil.cuinfo:main"
+mbeautify = "miutil.mlab.beautify:main"
+
+[tool.flake8]
+max_line_length = 99
+extend_ignore = ["E261"]
+exclude = [".git", "__pycache__", "build", "dist", ".eggs"]
+
+[tool.yapf]
+spaces_before_comment = [15, 20]
+arithmetic_precedence_indication = true
+allow_split_before_dict_value = false
+coalesce_brackets = true
+column_limit = 99
+each_dict_entry_on_separate_line = false
+space_between_ending_comma_and_closing_bracket = false
+split_before_named_assigns = false
+split_before_closing_bracket = false
+blank_line_before_nested_class_or_def = false
+
+[tool.isort]
+profile = "black"
+line_length = 99
+multi_line_output = 4
+known_first_party = ["miutil", "tests"]
+
+[tool.pytest.ini_options]
+minversion = "6.0"
+timeout = 15
+log_level = "INFO"
+python_files = ["tests/test_*.py"]
+testpaths = ["tests"]
+addopts = "-v --tb=short -rxs -W=error --log-level=debug -n=auto --durations=0 --cov=miutil --cov-report=term-missing --cov-report=xml"
diff --git a/setup.cfg b/setup.cfg
deleted file mode 100644
index 81e47a9..0000000
--- a/setup.cfg
+++ /dev/null
@@ -1,92 +0,0 @@
-[metadata]
-name=miutil
-description=Medical imaging utilities for the AMYPAD and NiftyPET projects
-long_description=file: README.rst
-long_description_content_type=text/x-rst
-license=Apache-2.0
-license_file=LICENCE.md
-url=https://github.com/AMYPAD/miutil
-project_urls=
- Changelog=https://github.com/AMYPAD/miutil/releases
- Documentation=https://github.com/AMYPAD/miutil/#miutil
-maintainer=Casper da Costa-Luis
-maintainer_email=casper.dcl@physics.org
-keywords=fMRI, PET, SPECT, EEG, MEG
-platforms=any
-provides=miutil
-classifiers=
- Development Status :: 4 - Beta
- Intended Audience :: Developers
- Environment :: GPU
- Environment :: GPU :: NVIDIA CUDA
- Intended Audience :: Education
- Intended Audience :: Healthcare Industry
- Intended Audience :: Science/Research
- License :: OSI Approved :: Apache Software License
- Operating System :: Microsoft :: Windows
- Operating System :: POSIX :: Linux
- Programming Language :: Other Scripting Engines
- Programming Language :: Python :: 3
- Programming Language :: Python :: 3.7
- Programming Language :: Python :: 3.8
- Programming Language :: Python :: 3.9
- Programming Language :: Python :: 3.10
- Programming Language :: Python :: 3.11
- Programming Language :: Python :: 3 :: Only
- Topic :: Scientific/Engineering :: Medical Science Apps.
- Topic :: Software Development :: Libraries
- Topic :: Software Development :: Libraries :: Python Modules
- Topic :: Software Development :: User Interfaces
- Topic :: System :: Installation/Setup
- Topic :: Utilities
-[options]
-setup_requires=setuptools>=42; wheel; setuptools_scm[toml]>=3.4
-install_requires=
- tqdm>=4.40.0
-packages=find:
-python_requires=>=3.7
-[options.extras_require]
-dev=
- pre-commit
- pytest
- pytest-cov
- pytest-timeout
- pytest-xdist
-nii=nibabel>=4.0; numpy
-plot=matplotlib; numpy; scipy
-cuda=argopt; pynvml
-web=requests
-mbeautify=argopt; tqdm>=4.42.0; %(web)s
-[options.entry_points]
-console_scripts=
- cuinfo=miutil.cuinfo:main
- mbeautify=miutil.mlab.beautify:main
-[options.packages.find]
-exclude=tests
-
-[flake8]
-max_line_length=99
-extend-ignore=E228,E261,P1
-exclude=.git,__pycache__,build,dist,.eggs
-
-[yapf]
-spaces_before_comment=15, 20
-arithmetic_precedence_indication=true
-allow_split_before_dict_value=false
-coalesce_brackets=True
-column_limit=99
-each_dict_entry_on_separate_line=False
-space_between_ending_comma_and_closing_bracket=False
-split_before_named_assigns=False
-split_before_closing_bracket=False
-blank_line_before_nested_class_or_def=False
-
-[isort]
-profile=black
-line_length=99
-multi_line_output=4
-known_first_party=miutil,tests
-
-[tool:pytest]
-timeout=15
-addopts=-v --tb=short -rxs -W=error --log-level=debug -n=auto --durations=0 --cov=miutil --cov-report=term-missing --cov-report=xml
diff --git a/setup.py b/setup.py
deleted file mode 100644
index d5d43d7..0000000
--- a/setup.py
+++ /dev/null
@@ -1,3 +0,0 @@
-from setuptools import setup
-
-setup(use_scm_version=True)
From c564f1ca03187a21c194c7cc2bd958019cdf9a5c Mon Sep 17 00:00:00 2001
From: Casper da Costa-Luis
Date: Tue, 30 May 2023 22:47:05 +0530
Subject: [PATCH 10/11] lint
---
miutil/cuinfo.py | 2 +-
miutil/mlab/__init__.py | 4 ++--
miutil/plot.py | 6 +++---
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/miutil/cuinfo.py b/miutil/cuinfo.py
index 90170cc..0e701e9 100755
--- a/miutil/cuinfo.py
+++ b/miutil/cuinfo.py
@@ -89,7 +89,7 @@ def main(*args, **kwargs):
noargs = False
if noargs:
for dev_id in devices:
- print("Device {:2d}:{}:compute capability:{:d}.{:d}".format(
+ print("Device {:2d}:{}:compute capability:{:d}.{:d}".format( # NOQA: P101
dev_id, name(dev_id), *compute_capability(dev_id)))
diff --git a/miutil/mlab/__init__.py b/miutil/mlab/__init__.py
index 6dd3605..f7d2d7b 100644
--- a/miutil/mlab/__init__.py
+++ b/miutil/mlab/__init__.py
@@ -189,8 +189,8 @@ def get_runtime(cache="~/.mcr", version=99):
raise NotImplementedError(
dedent("""\
Don't yet know how to handle
- {}
- for {!r}.
+ {0}
+ for {1!r}.
""").format(fspath(install), system()))
else:
raise IndexError(version)
diff --git a/miutil/plot.py b/miutil/plot.py
index 83f0b61..63c167b 100644
--- a/miutil/plot.py
+++ b/miutil/plot.py
@@ -78,7 +78,7 @@ def __init__(self, vol, view='t', fig=None, titles=None, order=0, sharexy=None,
3: single volume
4: multiple volumes
5: multiple RGB volumes
- but got {}
+ but got {0}
""".format(ndim)))
view = view.lower()
@@ -100,7 +100,7 @@ def __init__(self, vol, view='t', fig=None, titles=None, order=0, sharexy=None,
self.axs = [axs] if len(vol) == 1 else list(axs.flat)
for ax, i, t in zip(self.axs, vol, self.titles):
ax.imshow(i[self.index], **kwargs)
- ax.set_title(t or "slice #{}".format(self.index))
+ ax.set_title(t or f"slice #{self.index}")
self.vols = vol
# line profiles
self.order = order
@@ -137,7 +137,7 @@ def set_index(self, index):
self.index = int(index) % self.index_max
for ax, vol, t in zip(self.axs, self.vols, self.titles):
ax.images[0].set_array(vol[self.index])
- ax.set_title(t or "slice #{}".format(self.index))
+ ax.set_title(t or f"slice #{self.index}")
for ann in self._annotes:
ann.remove()
self._annotes = []
From 6f3d76ed787ee14b93b5638989acf1b2f70bcf47 Mon Sep 17 00:00:00 2001
From: Casper da Costa-Luis
Date: Tue, 30 May 2023 23:58:12 +0530
Subject: [PATCH 11/11] build: fix deploy
---
.github/workflows/test.yml | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 4dc60da..d0629b8 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -85,8 +85,7 @@ jobs:
- id: dist
uses: casperdcl/deploy-pypi@v2
with:
- requirements: twine setuptools wheel setuptools_scm[toml]
- build: true
+ pip: true
gpg_key: ${{ secrets.GPG_KEY }}
password: ${{ secrets.PYPI_TOKEN }}
upload: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}