From 44ab9c142b5278033605b04ff7633c7c8f242c10 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Mon, 15 Jan 2024 20:03:59 +1300 Subject: [PATCH 1/9] Update `.pre-commit-config.yaml` file. --- .pre-commit-config.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 054a788..161342f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -46,7 +46,6 @@ repos: rev: "v3.1.0" hooks: - id: prettier - exclude: config-aces-reference.ocio.yaml - repo: https://github.com/pre-commit/pygrep-hooks rev: "v1.10.0" hooks: From df445280dced3a9b399810e2cb8c178297db5ee7 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sat, 20 Jan 2024 19:05:24 +1300 Subject: [PATCH 2/9] Unpin *Poetry* version from 1.4.0. --- .github/workflows/continuous-integration-documentation.yml | 2 -- .github/workflows/continuous-integration-quality-unit-tests.yml | 2 -- 2 files changed, 4 deletions(-) diff --git a/.github/workflows/continuous-integration-documentation.yml b/.github/workflows/continuous-integration-documentation.yml index 677f18a..7d33fd2 100644 --- a/.github/workflows/continuous-integration-documentation.yml +++ b/.github/workflows/continuous-integration-documentation.yml @@ -30,8 +30,6 @@ jobs: sudo apt-get update sudo apt-get --yes install latexmk texlive-full - name: Install Poetry - env: - POETRY_VERSION: 1.4.0 run: | curl -sSL https://install.python-poetry.org | POETRY_HOME=$HOME/.poetry python3 - echo "$HOME/.poetry/bin" >> $GITHUB_PATH diff --git a/.github/workflows/continuous-integration-quality-unit-tests.yml b/.github/workflows/continuous-integration-quality-unit-tests.yml index 33336dd..292f9da 100644 --- a/.github/workflows/continuous-integration-quality-unit-tests.yml +++ b/.github/workflows/continuous-integration-quality-unit-tests.yml @@ -31,8 +31,6 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Install Poetry - env: - POETRY_VERSION: 1.4.0 run: | curl -sSL https://install.python-poetry.org | POETRY_HOME=$HOME/.poetry python3 - echo "$HOME/.poetry/bin" >> $GITHUB_PATH From f5c68a43a8005009d03c789c09aa68f7a2a3a20e Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Wed, 24 Jan 2024 18:00:22 +1300 Subject: [PATCH 3/9] Pin `coverage` to version `>= 6, < 7`. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ecbdd1d..52fe541 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,7 @@ typing-extensions = ">= 4, < 5" matplotlib = ">= 3.5, != 3.5.0, != 3.5.1" [tool.poetry.group.dev.dependencies] -coverage = "!= 6.3" +coverage = ">= 6, < 7" coveralls = "*" invoke = "*" jupyter = "*" From 34ae2e0d925a5a04081d65f16fbd876839b5697a Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Wed, 24 Jan 2024 18:04:17 +1300 Subject: [PATCH 4/9] Ensure that *coveralls.io* upload uses `Python` 3.12. --- .github/workflows/continuous-integration-quality-unit-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration-quality-unit-tests.yml b/.github/workflows/continuous-integration-quality-unit-tests.yml index 292f9da..5b7f8d4 100644 --- a/.github/workflows/continuous-integration-quality-unit-tests.yml +++ b/.github/workflows/continuous-integration-quality-unit-tests.yml @@ -54,7 +54,7 @@ jobs: poetry run python -W ignore -m pytest --doctest-modules --ignore=$CI_PACKAGE/examples --cov=$CI_PACKAGE $CI_PACKAGE shell: bash - name: Upload Coverage to coveralls.io - if: matrix.os == 'macOS-latest' && matrix.python-version == '3.11' + if: matrix.os == 'macOS-latest' && matrix.python-version == '3.12' run: | if [ -z "$COVERALLS_REPO_TOKEN" ]; then echo \"COVERALLS_REPO_TOKEN\" secret is undefined!; else poetry run coveralls; fi shell: bash From 4584b626811ec5bb1231bc6587a6d0ce557ab995 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sat, 27 Jan 2024 13:52:56 +1300 Subject: [PATCH 5/9] Fix broken links in `README.rst` file. --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 8e38612..b3e48f0 100644 --- a/README.rst +++ b/README.rst @@ -12,7 +12,7 @@ Colour - Demosaicing :target: https://coveralls.io/r/colour-science/colour-demosaicing :alt: Coverage Status .. |codacy| image:: https://img.shields.io/codacy/grade/2862b4f2217742ae83c972d7e3af44d7/develop.svg?style=flat-square - :target: https://www.codacy.com/app/colour-science/colour-demosaicing + :target: https://app.codacy.com/gh/colour-science/colour-demosaicing :alt: Code Grade .. |version| image:: https://img.shields.io/pypi/v/colour-demosaicing.svg?style=flat-square :target: https://pypi.org/project/colour-demosaicing From 515df557d92b600d439830346f5eb5f028290df0 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Mon, 29 Jan 2024 17:14:46 +1300 Subject: [PATCH 6/9] Update `pyproject.toml` file. --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 52fe541..f0ab790 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -88,6 +88,9 @@ exclude = ''' )/ ''' +[tool.codespell] +skip = 'BIBLIOGRAPHY.bib,CONTRIBUTORS.rst,*.ipynb' + [tool.flynt] line_length=999 From 951a1752a66af3385d57663cc3e3befff7183db5 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Tue, 30 Jan 2024 17:51:00 +1300 Subject: [PATCH 7/9] Use `Ruff` format. --- .pre-commit-config.yaml | 10 +++------- colour_demosaicing/__init__.py | 8 ++------ .../bayer/demosaicing/tests/test_bilinear.py | 8 ++------ .../bayer/demosaicing/tests/test_malvar2004.py | 8 ++------ .../bayer/demosaicing/tests/test_menon2007.py | 8 ++------ .../bayer/tests/test_mosaicing.py | 8 ++------ docs/conf.py | 4 +--- pyproject.toml | 3 +++ tasks.py | 17 ++++------------- utilities/export_todo.py | 4 +--- 10 files changed, 22 insertions(+), 56 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 161342f..c213b30 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,18 +25,14 @@ repos: - id: flynt args: [--verbose] - repo: https://github.com/PyCQA/isort - rev: "5.12.0" + rev: "5.13.2" hooks: - id: isort - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.6" + rev: "v0.1.14" hooks: + - id: ruff-format - id: ruff - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.11.0 - hooks: - - id: black - language_version: python3.9 - repo: https://github.com/adamchainz/blacken-docs rev: 1.16.0 hooks: diff --git a/colour_demosaicing/__init__.py b/colour_demosaicing/__init__.py index fb1d9b3..1fdb7f8 100644 --- a/colour_demosaicing/__init__.py +++ b/colour_demosaicing/__init__.py @@ -56,9 +56,7 @@ __major_version__ = "0" __minor_version__ = "2" __change_version__ = "5" -__version__ = ".".join( - (__major_version__, __minor_version__, __change_version__) -) +__version__ = ".".join((__major_version__, __minor_version__, __change_version__)) try: _version: str = ( @@ -73,9 +71,7 @@ except Exception: _version: str = __version__ -colour.utilities.ANCILLARY_COLOUR_SCIENCE_PACKAGES[ # pyright: ignore - "colour-demosaicing" -] = _version +colour.utilities.ANCILLARY_COLOUR_SCIENCE_PACKAGES["colour-demosaicing"] = _version # pyright: ignore del _version diff --git a/colour_demosaicing/bayer/demosaicing/tests/test_bilinear.py b/colour_demosaicing/bayer/demosaicing/tests/test_bilinear.py index 386c7be..9a0991b 100644 --- a/colour_demosaicing/bayer/demosaicing/tests/test_bilinear.py +++ b/colour_demosaicing/bayer/demosaicing/tests/test_bilinear.py @@ -46,17 +46,13 @@ def test_demosaicing_CFA_Bayer_bilinear(self): """ for pattern in ("RGGB", "BGGR", "GRBG", "GBRG"): - CFA = os.path.join( - ROOT_RESOURCES_BAYER, f"Lighthouse_CFA_{pattern}.exr" - ) + CFA = os.path.join(ROOT_RESOURCES_BAYER, f"Lighthouse_CFA_{pattern}.exr") RGB = os.path.join( ROOT_RESOURCES_BAYER, f"Lighthouse_Bilinear_{pattern}.exr" ) np.testing.assert_allclose( - demosaicing_CFA_Bayer_bilinear( - read_image(str(CFA))[..., 0], pattern - ), + demosaicing_CFA_Bayer_bilinear(read_image(str(CFA))[..., 0], pattern), read_image(str(RGB)), atol=TOLERANCE_ABSOLUTE_TESTS, ) diff --git a/colour_demosaicing/bayer/demosaicing/tests/test_malvar2004.py b/colour_demosaicing/bayer/demosaicing/tests/test_malvar2004.py index 7eb5d59..5168027 100644 --- a/colour_demosaicing/bayer/demosaicing/tests/test_malvar2004.py +++ b/colour_demosaicing/bayer/demosaicing/tests/test_malvar2004.py @@ -46,17 +46,13 @@ def test_demosaicing_CFA_Bayer_Malvar2004(self): """ for pattern in ("RGGB", "BGGR", "GRBG", "GBRG"): - CFA = os.path.join( - ROOT_RESOURCES_BAYER, f"Lighthouse_CFA_{pattern}.exr" - ) + CFA = os.path.join(ROOT_RESOURCES_BAYER, f"Lighthouse_CFA_{pattern}.exr") RGB = os.path.join( ROOT_RESOURCES_BAYER, f"Lighthouse_Malvar2004_{pattern}.exr" ) np.testing.assert_allclose( - demosaicing_CFA_Bayer_Malvar2004( - read_image(str(CFA))[..., 0], pattern - ), + demosaicing_CFA_Bayer_Malvar2004(read_image(str(CFA))[..., 0], pattern), read_image(str(RGB)), atol=TOLERANCE_ABSOLUTE_TESTS, ) diff --git a/colour_demosaicing/bayer/demosaicing/tests/test_menon2007.py b/colour_demosaicing/bayer/demosaicing/tests/test_menon2007.py index b04bbd1..8a42d01 100644 --- a/colour_demosaicing/bayer/demosaicing/tests/test_menon2007.py +++ b/colour_demosaicing/bayer/demosaicing/tests/test_menon2007.py @@ -46,17 +46,13 @@ def test_demosaicing_CFA_Bayer_Menon2007(self): """ for pattern in ("RGGB", "BGGR", "GRBG", "GBRG"): - CFA = os.path.join( - ROOT_RESOURCES_BAYER, f"Lighthouse_CFA_{pattern}.exr" - ) + CFA = os.path.join(ROOT_RESOURCES_BAYER, f"Lighthouse_CFA_{pattern}.exr") RGB = os.path.join( ROOT_RESOURCES_BAYER, f"Lighthouse_Menon2007_{pattern}.exr" ) np.testing.assert_allclose( - demosaicing_CFA_Bayer_Menon2007( - read_image(str(CFA))[..., 0], pattern - ), + demosaicing_CFA_Bayer_Menon2007(read_image(str(CFA))[..., 0], pattern), read_image(str(RGB)), atol=TOLERANCE_ABSOLUTE_TESTS, ) diff --git a/colour_demosaicing/bayer/tests/test_mosaicing.py b/colour_demosaicing/bayer/tests/test_mosaicing.py index 562dc79..000f617 100644 --- a/colour_demosaicing/bayer/tests/test_mosaicing.py +++ b/colour_demosaicing/bayer/tests/test_mosaicing.py @@ -45,14 +45,10 @@ def test_mosaicing_CFA_Bayer(self): definition. """ - image = read_image( - str(os.path.join(ROOT_RESOURCES_BAYER, "Lighthouse.exr")) - ) + image = read_image(str(os.path.join(ROOT_RESOURCES_BAYER, "Lighthouse.exr"))) for pattern in ("RGGB", "BGGR", "GRBG", "GBRG"): - CFA = os.path.join( - ROOT_RESOURCES_BAYER, f"Lighthouse_CFA_{pattern}.exr" - ) + CFA = os.path.join(ROOT_RESOURCES_BAYER, f"Lighthouse_CFA_{pattern}.exr") np.testing.assert_allclose( mosaicing_CFA_Bayer(image, pattern), read_image(str(CFA))[..., 0], diff --git a/docs/conf.py b/docs/conf.py index cc0ea11..0ecb796 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -11,9 +11,7 @@ import colour_demosaicing as package # noqa: E402 -basename = re.sub( - "_(\\w)", lambda x: x.group(1).upper(), package.__name__.title() -) +basename = re.sub("_(\\w)", lambda x: x.group(1).upper(), package.__name__.title()) # -- General configuration ------------------------------------------------ extensions = [ diff --git a/pyproject.toml b/pyproject.toml index f0ab790..0857a71 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -208,6 +208,9 @@ convention = "numpy" "utilities/*" = ["EXE001", "INP"] "utilities/unicode_to_ascii.py" = ["RUF001"] +[tool.ruff.format] +docstring-code-format = true + [build-system] requires = [ "poetry_core>=1.0.0" ] build-backend = "poetry.core.masonry.api" diff --git a/tasks.py b/tasks.py index 1c327ce..1b86ded 100644 --- a/tasks.py +++ b/tasks.py @@ -135,9 +135,7 @@ def formatting( message_box('Cleaning up "BibTeX" file...') bibtex_path = BIBLIOGRAPHY_NAME with open(bibtex_path) as bibtex_file: - entries = ( - biblib.bib.Parser().parse(bibtex_file.read()).get_entries() - ) + entries = biblib.bib.Parser().parse(bibtex_file.read()).get_entries() for entry in sorted(entries.values(), key=lambda x: x.key): with contextlib.suppress(KeyError): @@ -267,9 +265,7 @@ def docs(ctx: Context, html: bool = True, pdf: bool = True): Whether to build the *PDF* documentation. """ - with ctx.prefix("export COLOUR_SCIENCE__DOCUMENTATION_BUILD=True"), ctx.cd( - "docs" - ): + with ctx.prefix("export COLOUR_SCIENCE__DOCUMENTATION_BUILD=True"), ctx.cd("docs"): if html: message_box('Building "HTML" documentation...') ctx.run("make html") @@ -368,10 +364,7 @@ def virtualise(ctx: Context, tests: bool = True): with ctx.cd(unique_name): ctx.run("poetry install") ctx.run("source $(poetry env info -p)/bin/activate") - ctx.run( - 'python -c "import imageio;' - 'imageio.plugins.freeimage.download()"' - ) + ctx.run('python -c "import imageio;imageio.plugins.freeimage.download()"') if tests: ctx.run( "poetry run pytest " @@ -422,9 +415,7 @@ def tag(ctx: Context): remote_tags = result.stdout.strip().split("\n") # pyright: ignore tags = set() for remote_tag in remote_tags: - tags.add( - remote_tag.split("refs/tags/")[1].replace("refs/tags/", "^{}") - ) + tags.add(remote_tag.split("refs/tags/")[1].replace("refs/tags/", "^{}")) version_tags = sorted(tags) if f"v{version}" in version_tags: raise RuntimeError( diff --git a/utilities/export_todo.py b/utilities/export_todo.py index 1efbe15..22c13b9 100755 --- a/utilities/export_todo.py +++ b/utilities/export_todo.py @@ -40,9 +40,7 @@ https://opensource.org/licenses/BSD-3-Clause | `https://github.com/colour-science/colour-demosaicing \ `__ -"""[ - 1: -] +"""[1:] def extract_todo_items(root_directory: str) -> dict: From 452f03aeb7e673b2fe3c219a956939136ca3db29 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Mon, 29 Jan 2024 20:14:29 +1300 Subject: [PATCH 8/9] Use `actions/checkout@v4`. --- .github/workflows/continuous-integration-documentation.yml | 2 +- .github/workflows/continuous-integration-quality-unit-tests.yml | 2 +- .../workflows/continuous-integration-static-type-checking.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/continuous-integration-documentation.yml b/.github/workflows/continuous-integration-documentation.yml index 7d33fd2..ab3f010 100644 --- a/.github/workflows/continuous-integration-documentation.yml +++ b/.github/workflows/continuous-integration-documentation.yml @@ -12,7 +12,7 @@ jobs: fail-fast: false runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Environment Variables run: | echo "CI_PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV diff --git a/.github/workflows/continuous-integration-quality-unit-tests.yml b/.github/workflows/continuous-integration-quality-unit-tests.yml index 5b7f8d4..a29fea5 100644 --- a/.github/workflows/continuous-integration-quality-unit-tests.yml +++ b/.github/workflows/continuous-integration-quality-unit-tests.yml @@ -12,7 +12,7 @@ jobs: fail-fast: false runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 with: submodules: true - name: Environment Variables diff --git a/.github/workflows/continuous-integration-static-type-checking.yml b/.github/workflows/continuous-integration-static-type-checking.yml index e74dd22..4bf6ee1 100644 --- a/.github/workflows/continuous-integration-static-type-checking.yml +++ b/.github/workflows/continuous-integration-static-type-checking.yml @@ -12,7 +12,7 @@ jobs: fail-fast: false runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Environment Variables run: | echo "CI_PACKAGE=colour_demosaicing" >> $GITHUB_ENV From b62a035114138a01cecec215a0ba6e5249a524ae Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Tue, 30 Jan 2024 21:42:51 +1300 Subject: [PATCH 9/9] Drop `black` settings in `pyproject.toml` file. --- pyproject.toml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0857a71..379d44a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,16 +78,6 @@ restructuredtext-lint = "*" sphinx = "*" sphinxcontrib-bibtex = "*" -[tool.black] -line-length = 79 -exclude = ''' -/( - \.git - | build - | dist -)/ -''' - [tool.codespell] skip = 'BIBLIOGRAPHY.bib,CONTRIBUTORS.rst,*.ipynb'