Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax improvements #3

Merged
merged 10 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 3 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
os: [ windows-latest, ubuntu-latest, macos-latest ]
python-version: [ "3.8", "3.11" ]
python-version: [ "3.11", "3.12" ]

steps:
- uses: actions/checkout@v3
Expand All @@ -31,11 +31,10 @@ jobs:
pip install .[dev]

- name: Test with pytest
run: |
pytest --cov=./ --cov-report=xml
run: pytest --cov=./ --cov-report=xml

- name: Upload coverage to Codecov
if: matrix.platform == 'ubuntu-latest' && matrix.python-version == '3.11'
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ coverage.xml
*.ai

# Virtual environment
.venv
.venv

# Visual Studio Code
.vscode

# Ruff
.ruff_cache/
13 changes: 10 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
repos:
- repo: /~https://github.com/psf/black
rev: 22.10.0
- repo: /~https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.2"
hooks:
- id: black
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: /~https://github.com/asottile/pyupgrade
rev: v3.15.2
hooks:
- id: pyupgrade
args: [--py311-plus]
61 changes: 50 additions & 11 deletions par_segmentation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,51 @@
from .funcs import *
from .interactive import *
from .legacy import *
from .model import *
from .quantifier import *
from .roi import *
from .funcs import (
asi,
bounded_mean_1d,
bounded_mean_2d,
direcslist,
dosage,
in_notebook,
interp_1d_array,
interp_2d_array,
load_image,
make_mask,
norm_roi,
organise_by_nd,
readnd,
rolling_ave_1d,
rolling_ave_2d,
rotate_roi,
rotated_embryo,
save_img,
save_img_jpeg,
straighten,
)
from .legacy import bg_subtraction, error_func, gaus, polycrop
from .quantifier import ImageQuant
from .roi import interp_roi, offset_coordinates, spline_roi

__all__ = []
__all__.extend(funcs.__all__)
__all__.extend(quantifier.__all__)
__all__.extend(roi.__all__)
__all__.extend(legacy.__all__)
__all__ = ["ImageQuant"]
__all__ += [
"load_image",
"save_img",
"save_img_jpeg",
"straighten",
"rotated_embryo",
"rotate_roi",
"norm_roi",
"interp_1d_array",
"interp_2d_array",
"rolling_ave_1d",
"rolling_ave_2d",
"bounded_mean_1d",
"bounded_mean_2d",
"asi",
"dosage",
"make_mask",
"readnd",
"organise_by_nd",
"direcslist",
"in_notebook",
]
__all__ += ["gaus", "error_func", "polycrop", "bg_subtraction"]
__all__ += ["spline_roi", "interp_roi", "offset_coordinates"]
5 changes: 3 additions & 2 deletions par_segmentation/_tgf_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"""

import enum
from typing import Sequence, Tuple, Union
from collections.abc import Sequence
from typing import Union

import numpy as np
import tensorflow as tf
Expand Down Expand Up @@ -282,7 +283,7 @@ def knot_weights(
cyclical: bool,
sparse_mode: bool = False,
name: str = "bspline_knot_weights",
) -> Union[tf.Tensor, Tuple[tf.Tensor, tf.Tensor]]:
) -> tf.Tensor | tuple[tf.Tensor, tf.Tensor]:
"""Function that converts cardinal B-spline positions to knot weights.
Note:
In the following, A1 to An are optional batch dimensions.
Expand Down
Loading
Loading