Skip to content

Commit

Permalink
Merge pull request #291 from rochefort-lab/ci-rel_upgrade-tests-fix-reqs
Browse files Browse the repository at this point in the history
Add cap to numpy and shapely version support, fix tests, upgrade precommit
  • Loading branch information
scottclowe authored Sep 13, 2024
2 parents 8cf6a17 + 1641e43 commit a84c88d
Show file tree
Hide file tree
Showing 19 changed files with 71 additions and 69 deletions.
3 changes: 2 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ max-line-length = 99
extend-ignore = E203,E402,F401,D100,D101,D102,D103,D104,D105,D106,D107,D200
docstring-convention = numpy
# Ignore missing docstrings within unit testing functions.
per-file-ignores = **/tests/:D100,D101,D102,D103,D104,D105,D106,D107
# Ignore C420 Unnecessary dict comprehension
per-file-ignores = **/tests/:D100,D101,D102,D103,D104,D105,D106,D107,C420
4 changes: 2 additions & 2 deletions .github/workflows/gh-pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
notebooks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Determine default branch
run: |
Expand All @@ -21,7 +21,7 @@ jobs:
echo "default_branch_ref=refs/heads/$DEFAULT_BRANCH" >> $GITHUB_ENV
- name: Set up Python 3.6
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: "3.6"

Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip
- uses: pre-commit/[email protected]
24 changes: 11 additions & 13 deletions .github/workflows/test-release-candidate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,21 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10"]
include:
- os: ubuntu-latest
python-version: "2.7"
- os: macos-latest
python-version: "3.5"
python-version: "3.8"
- os: macos-latest
python-version: "3.9"
python-version: "3.10"
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

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

Expand Down Expand Up @@ -103,7 +101,7 @@ jobs:
python -m pytest --timeout=300 --cov=fissa --cov-report term --cov-report xml --junitxml=testresults.xml
- name: Upload unittest coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
flags: unittests
env_vars: OS,PYTHON
Expand Down Expand Up @@ -132,7 +130,7 @@ jobs:

- name: "Notebooks: Upload coverage to Codecov"
if: ${{ env.OS != 'windows-latest' || env.PYTHON != '3.6' }}
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
flags: nbsmoke
env_vars: OS,PYTHON
Expand All @@ -144,7 +142,7 @@ jobs:
python setup.py sdist bdist_wheel
- name: Store wheel artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.os }}-${{ matrix.python-version }}
path: dist/*
Expand All @@ -166,16 +164,16 @@ jobs:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Download wheel artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: wheel-*
path: dist/

- name: Store aggregated wheel artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: wheels
path: dist/*
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["2.7", "3.5", "3.10"]
python-version: ["3.8", "3.10"]
include:
- os: windows-latest
python-version: "3.10"
python-version: "3.8"
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

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

Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
python -m pytest --timeout=180 --cov=fissa --cov-report term --cov-report xml --junitxml=testresults.xml
- name: Upload unittest coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
flags: unittests
env_vars: OS,PYTHON
Expand All @@ -110,7 +110,7 @@ jobs:
run: python -m pytest --timeout=180 --nbsmoke-run ./examples/ --cov=fissa --cov-report term --cov-report xml --junitxml=nbsmoke.xml

- name: "Notebooks: Upload coverage to Codecov"
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
flags: nbsmoke
env_vars: OS,PYTHON
Expand Down
33 changes: 11 additions & 22 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.13.2
hooks:
- id: isort
name: isort
Expand All @@ -11,49 +11,37 @@ repos:
args: ["--profile=black"]

- repo: https://github.com/psf/black
rev: 21.12b0
rev: 24.8.0
hooks:
- id: black
args:
- "--target-version=py27"
- "--target-version=py35"
- "--target-version=py36"
- "--target-version=py37"
- "--target-version=py38"
- "--target-version=py39"
- "--target-version=py310"
types: [python]

- repo: https://github.com/asottile/blacken-docs
rev: v1.12.1
rev: 1.18.0
hooks:
- id: blacken-docs
additional_dependencies: [black==21.12b0]
additional_dependencies: [black==24.8.0]

- repo: https://github.com/kynan/nbstripout
rev: 0.5.0
rev: 0.7.1
hooks:
- id: nbstripout
args: ["--keep-count"]

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.3.1
rev: 1.8.7
hooks:
- id: nbqa-black
args:
- "--nbqa-mutate"
- "--target-version=py27"
- "--target-version=py35"
- "--target-version=py36"
- "--target-version=py37"
- "--target-version=py38"
- "--target-version=py39"
- "--target-version=py310"
additional_dependencies: [black==21.12b0]
additional_dependencies: [black==24.8.0]
- id: nbqa-flake8

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
Expand All @@ -66,7 +54,7 @@ repos:
types: [text]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -87,13 +75,14 @@ repos:
exclude: ^LICENSE|\.(html|csv|txt|svg|py)$
- id: pretty-format-json
args: ["--autofix", "--no-ensure-ascii", "--no-sort-keys"]
exclude_types: [jupyter]
- id: requirements-txt-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
exclude: \.(html|svg)$

- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: 7.1.1
hooks:
- id: flake8
additional_dependencies:
Expand Down
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def ensure_pandoc_installed(_):
os.environ["PATH"] += os.pathsep + pandoc_dir
if hasattr(pypandoc, "ensure_pandoc_installed"):
pypandoc.ensure_pandoc_installed(
quiet=True,
targetfolder=pandoc_dir,
delete_installer=True,
)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/SIMA example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"sequences = [sima.Sequence.create(\"TIFF\", tiff) for tiff in tiffs[:1]]\n",
"try:\n",
" dataset = sima.ImagingDataset(sequences, \"example.sima\")\n",
"except BaseException:\n",
"except Exception:\n",
" dataset = sima.ImagingDataset.load(\"example.sima\")"
]
},
Expand Down
2 changes: 1 addition & 1 deletion examples/SIMA example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"sequences = [sima.Sequence.create(\"TIFF\", tiff) for tiff in tiffs[:1]]\n",
"try:\n",
" dataset = sima.ImagingDataset(sequences, \"example.sima\")\n",
"except BaseException:\n",
"except Exception:\n",
" dataset = sima.ImagingDataset.load(\"example.sima\")"
]
},
Expand Down
13 changes: 8 additions & 5 deletions fissa/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@ def separate_trials(
message_extra = " for ROI {}".format(label)
warnings.warn(
"{}Found values below zero in raw signal{}. Offsetting so minimum is 0."
"".format(header, message_extra)
"".format(header, message_extra),
UserWarning,
stacklevel=2,
)
X -= X.min()

Expand Down Expand Up @@ -1177,7 +1179,7 @@ def separation_prep(self, redo=False):
self.load(fname)
if self.raw is not None:
return
except BaseException as err:
except Exception as err:
print("An error occurred while loading {}".format(fname))
print(err)
print("Extraction will be redone and {} overwritten".format(fname))
Expand Down Expand Up @@ -1321,7 +1323,7 @@ def save_prep(self, destination=None):
field: getattr(self, field)
for field in fields
if getattr(self, field) is not None
}
},
)

def separate(self, redo_prep=False, redo_sep=False):
Expand Down Expand Up @@ -1379,7 +1381,7 @@ def separate(self, redo_prep=False, redo_sep=False):
self.load(fname)
if self.result is not None:
return
except BaseException as err:
except Exception as err:
print("An error occurred while loading {}".format(fname))
print(err)
print(
Expand Down Expand Up @@ -1539,7 +1541,7 @@ def save_separated(self, destination=None):
field: getattr(self, field)
for field in fields
if getattr(self, field) is not None
}
},
)

def calc_deltaf(self, freq, use_raw_f0=True, across_trials=True):
Expand Down Expand Up @@ -1859,6 +1861,7 @@ def save_to_matlab(self, fname=None):
"The experiment.save_to_matlab() method is deprecated."
" Please use experiment.to_matfile() instead.",
DeprecationWarning,
stacklevel=2,
)
return self.to_matfile(fname=fname, legacy=True)

Expand Down
16 changes: 12 additions & 4 deletions fissa/extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,19 @@ def image2array(image):
" with {} dimensions (page shaped {})."
" All dimensions before the final two (height and"
" width) will be treated as time-like and flattened."
"".format(image, n_pages, page.ndim, page.shape)
"".format(image, n_pages, page.ndim, page.shape),
UserWarning,
stacklevel=2,
)
elif page.ndim > 3 and (np.array(page.shape[:-2]) > 1).sum() > 1:
warnings.warn(
"TIFF {} has at least one page with {} dimensions"
" (page shaped {})."
" All dimensions before the final two (height and"
" width) will be treated as time-like and flattened."
"".format(image, page.ndim, page.shape)
"".format(image, page.ndim, page.shape),
UserWarning,
stacklevel=2,
)
shp = [-1] + list(page.shape[-2:])
frames.append(page.reshape(shp))
Expand Down Expand Up @@ -327,15 +331,19 @@ def getmean(data):
" with {} dimensions (page shaped {})."
" All dimensions before the final two (height and"
" width) will be treated as time-like and flattened."
"".format("", n_pages, page.ndim, page.shape)
"".format("", n_pages, page.ndim, page.shape),
UserWarning,
stacklevel=2,
)
elif page.ndim > 3 and (np.array(page.shape[:-2]) > 1).sum() > 1:
warnings.warn(
"TIFF {} has at least one page with {} dimensions"
" (page shaped {})."
" All dimensions before the final two (height and"
" width) will be treated as time-like and flattened."
"".format("", page.ndim, page.shape)
"".format("", page.ndim, page.shape),
UserWarning,
stacklevel=2,
)
shp = [-1] + list(page.shape[-2:])
page = page.reshape(shp)
Expand Down
2 changes: 1 addition & 1 deletion fissa/neuropil.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def separate(
print("{}Trying a new random state.".format(prefix))
# Change to a new random_state
if random_state is not None:
random_state = (random_state + 1) % 2 ** 32
random_state = (random_state + 1) % 2**32

if estimator.n_iter_ == max_iter:
if verbosity >= 1:
Expand Down
2 changes: 1 addition & 1 deletion fissa/readimagejrois.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def _getcoords(z=0):
coords = _getcoords(z)
coords = coords.astype("float")
return {"polygons": coords}
except BaseException:
except Exception:
raise ValueError(
"read_imagej_roi: ROI type {} not supported".format(roi_type)
)
Expand Down
Loading

0 comments on commit a84c88d

Please sign in to comment.