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

PR: Use uv and hatch. #1300

Merged
merged 7 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
12 changes: 5 additions & 7 deletions .github/workflows/continuous-integration-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,18 @@ jobs:
run: |
sudo apt-get update
sudo apt-get --yes install graphviz graphviz-dev latexmk texlive-full
- name: Install Poetry
- name: Install uv
run: |
curl -sSL https://install.python-poetry.org | POETRY_HOME=$HOME/.poetry python3 -
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
pip install uv
shell: bash
- name: Install Package Dependencies
run: |
poetry run python -m pip install --upgrade pip
poetry install
poetry run python -c "import imageio;imageio.plugins.freeimage.download()"
uv sync --all-extras --no-dev
uv run python -c "import imageio;imageio.plugins.freeimage.download()"
shell: bash
- name: Build Documentation
run: |
poetry run invoke docs
uv run invoke docs
shell: bash
- uses: actions/upload-artifact@v4
with:
Expand Down
37 changes: 11 additions & 26 deletions .github/workflows/continuous-integration-quality-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,51 +42,36 @@ jobs:
run: |
sudo apt-get update
sudo apt-get --yes install graphviz graphviz-dev
- name: Install Poetry
- name: Install uv
run: |
curl -sSL https://install.python-poetry.org | POETRY_HOME=$HOME/.poetry python3 -
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
pip install uv
shell: bash
- name: Install Package Dependencies (macOs)
if: matrix.os == 'macOS-latest'
run: |
poetry run python -m pip install --upgrade pip
poetry install
- name: Install Package Dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
poetry run python -m pip install --upgrade pip
poetry install
poetry run python -c "import imageio;imageio.plugins.freeimage.download()"
shell: bash
- name: Install Package Dependencies (Windows)
if: matrix.os == 'windows-latest'
- name: Install Package Dependencies
run: |
poetry run python -m pip install --upgrade pip
poetry install
poetry run python -c "import imageio;imageio.plugins.freeimage.download()"
uv sync --all-extras --no-dev
uv run python -c "import imageio;imageio.plugins.freeimage.download()"
shell: bash
- name: Install OpenImageIO (macOs)
if: matrix.os == 'macOS-latest' && matrix.python-version == '3.12'
run: |
brew install openimageio
find /Users/runner/Library/Caches/pypoetry/virtualenvs/ -path "/Users/runner/Library/Caches/pypoetry/virtualenvs/*/lib/python3.12/site-packages" -type d -exec ln -s /opt/homebrew/Cellar/openimageio/*/lib/python*/site-packages/OpenImageIO/OpenImageIO*.so {}/OpenImageIO.so \;
poetry run python -c "import OpenImageIO;print(OpenImageIO.__version__)"
ln -s /opt/homebrew/Cellar/openimageio/*/lib/python*/site-packages/OpenImageIO/OpenImageIO*.so ./.venv/lib/python3.12/site-packages/OpenImageIO.so
uv run python -c "import OpenImageIO;print(OpenImageIO.__version__)"
shell: bash
- name: Pre-Commit (All Files)
run: |
poetry run pre-commit run --all-files
uv run pre-commit run --all-files
shell: bash
- name: Test Optimised Python Execution
run: |
poetry run python -OO -c "import $CI_PACKAGE"
uv run python -OO -c "import $CI_PACKAGE"
shell: bash
- name: Test with Pytest
run: |
poetry run python -W ignore -m pytest --doctest-modules --ignore=$CI_PACKAGE/examples --cov=$CI_PACKAGE $CI_PACKAGE
uv 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.12'
run: |
if [ -z "$COVERALLS_REPO_TOKEN" ]; then echo \"COVERALLS_REPO_TOKEN\" secret is undefined!; else poetry run coveralls; fi
if [ -z "$COVERALLS_REPO_TOKEN" ]; then echo \"COVERALLS_REPO_TOKEN\" secret is undefined!; else uv run coveralls; fi
shell: bash
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:
pip install -r requirements.txt
- name: Static Type Checking
run: |
pyright --skipunannotated
pyright --threads --skipunannotated
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
.fleet
.idea
.ipynb_checkpoints
.python-version
.vs
.vscode
.sandbox
Expand All @@ -20,5 +21,5 @@ docs/_static/Examples_*.png
docs/_static/Plotting_*.png
docs/_static/Tutorial_*.png
docs/generated
poetry.lock
references
uv.lock
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ Chromatic Adaptation - ``colour.adaptation``
.. code-block:: python

sorted(colour.CHROMATIC_ADAPTATION_METHODS)

.. code-block:: text

['CIE 1994', 'CMCCAT2000', 'Fairchild 1990', 'Von Kries', 'Zhai 2018', 'vK20']
Expand Down
88 changes: 51 additions & 37 deletions TODO.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,64 +6,70 @@ TODO

- colour/__init__.py

- Line 878 : # TODO: Remove legacy printing support when deemed appropriate.
- Line 914 : # TODO: Remove legacy printing support when deemed appropriate.


- colour/colorimetry/spectrum.py

- Line 1190 : # TODO: Provide support for fractional interval like 0.1, etc...
- Line 1176 : # TODO: Provide support for fractional interval like 0.1, etc...


- colour/colorimetry/tristimulus_values.py

- Line 1071 : # TODO: Investigate code vectorisation.
- Line 1050 : # TODO: Investigate code vectorisation.


- colour/appearance/ciecam02.py

- Line 377 : # TODO: Compute hue composition.
- Line 369 : # TODO: Compute hue composition.


- colour/appearance/ciecam16.py

- Line 325 : # TODO: Compute hue composition.
- Line 322 : # TODO: Compute hue composition.


- colour/appearance/cam16.py

- Line 313 : # TODO: Compute hue composition.
- Line 308 : # TODO: Compute hue composition.


- colour/appearance/hellwig2022.py

- Line 355 : # TODO: Compute hue composition.
- Line 354 : # TODO: Compute hue composition.


- colour/appearance/hunt.py

- Line 487 : # TODO: Implement hue quadrature & composition computation.
- Line 518 : # TODO: Implement whiteness-blackness :math:`Q_{wb}` computation.
- Line 478 : # TODO: Implement hue quadrature & composition computation.
- Line 509 : # TODO: Implement whiteness-blackness :math:`Q_{wb}` computation.


- colour/appearance/rlab.py

- Line 287 : # TODO: Implement hue composition computation.
- Line 283 : # TODO: Implement hue composition computation.


- colour/appearance/nayatani95.py

- Line 311 : # TODO: Implement hue quadrature & composition computation.
- Line 324 : # TODO: Investigate components usage. M_RG, M_YB = tsplit(colourfulness_components(C_RG, C_YB, brightness_ideal_white))
- Line 307 : # TODO: Implement hue quadrature & composition computation.
- Line 318 : # TODO: Investigate components usage. M_RG, M_YB = tsplit(colourfulness_components(C_RG, C_YB, brightness_ideal_white))


- colour/appearance/llab.py

- Line 396 : # TODO: Implement hue composition computation.
- Line 362 : # TODO: Implement hue composition computation.


- colour/recovery/tests/test_jiang2013.py

- Line 63 : # TODO: Last eigen value seems to be very sensitive and produce differences on ARM.
- Line 66 : # TODO: Last eigen value seems to be very sensitive and produce differences on ARM.


- colour/io/fichet2021.py

- Line 644 : # TODO: Implement support for integration of bi-spectral component.
- Line 651 : # TODO: Implement support for re-binning component with non-uniform interval.


- colour/io/ocio.py
Expand All @@ -73,97 +79,105 @@ TODO

- colour/io/ctl.py

- Line 64 : # TODO: Reinstate coverage when "ctlrender" is trivially available cross-platform.
- Line 65 : # TODO: Reinstate coverage when "ctlrender" is trivially available cross-platform.


- colour/io/tests/test_ocio.py

- Line 39 : # TODO: Remove when "Pypi" wheel compatible with "ARM" on "macOS" is released.
- Line 37 : # TODO: Remove when "Pypi" wheel compatible with "ARM" on "macOS" is released.


- colour/io/tests/test_ctl.py

- Line 41 : # TODO: Reinstate coverage when "ctlrender" is tivially available cross-platform.
- Line 39 : # TODO: Reinstate coverage when "ctlrender" is tivially available cross-platform.


- colour/io/tests/test_image.py

- Line 314 : # TODO: Investigate "OIIO" behaviour here: 1.0 != 15360.0 image = read_image_OpenImageIO( os.path.join(ROOT_RESOURCES, 'Colour_Logo.png'), 'float16') self.assertIs(image.dtype, np.dtype('float16')) self.assertEqual(np.min(image), 0.0) self.assertEqual(np.max(image), 1.0)
- Line 321 : # TODO: Investigate "OIIO" behaviour here: 1.0 != 15360.0 image = read_image_OpenImageIO( os.path.join(ROOT_RESOURCES, 'Colour_Logo.png'), 'float16') self.assertIs(image.dtype, np.dtype('float16')) self.assertEqual(np.min(image), 0.0) self.assertEqual(np.max(image), 1.0)


- colour/models/rgb/derivation.py

- Line 231 : # TODO: Investigate if we return an ndarray here with primaries and whitepoint stacked together.
- Line 230 : # TODO: Investigate if we return an ndarray here with primaries and whitepoint stacked together.


- colour/models/rgb/tests/test_rgb_colourspace.py

- Line 348 : # TODO: Remove tests when dropping deprecated signature support.
- Line 551 : # TODO: Remove tests when dropping deprecated signature support.
- Line 340 : # TODO: Remove tests when dropping deprecated signature support.
- Line 541 : # TODO: Remove tests when dropping deprecated signature support.


- colour/models/rgb/tests/test_derivation.py

- Line 339 : # TODO: Simplify that monster.
- Line 327 : # TODO: Simplify that monster.


- colour/utilities/verbose.py

- Line 669 : # TODO: Implement support for "pyproject.toml" file whenever "TOML" is supported in the standard library. NOTE: A few clauses are not reached and a few packages are not available during continuous integration and are thus ignored for coverage.
- Line 795 : # TODO: Implement support for "pyproject.toml" file whenever "TOML" is supported in the standard library. NOTE: A few clauses are not reached and a few packages are not available during continuous integration and are thus ignored for coverage.


- colour/utilities/network.py

- Line 587 : # TODO: Consider using an ordered set instead of a dict.
- Line 1064 : # TODO: Consider using ordered set.
- Line 1070 : # TODO: Consider using ordered set.
- Line 1907 : # TODO: Implement solid control flow based processing using a stack.


- colour/utilities/array.py

- Line 577 : # TODO: Remove when https://github.com/numpy/numpy/issues/5718 is addressed.
- Line 865 : # TODO: Investigate behaviour on Windows.
- Line 922 : # TODO: Annotate with "Union[Literal['ignore', 'reference', '1', '100'], str]" when Python 3.7 is dropped.
- Line 573 : # TODO: Remove when https://github.com/numpy/numpy/issues/5718 is addressed.
- Line 853 : # TODO: Investigate behaviour on Windows.
- Line 914 : # TODO: Annotate with "Union[Literal['ignore', 'reference', '1', '100'], str]" when Python 3.7 is dropped.


- colour/plotting/models.py

- Line 1939 : # TODO: Filter appropriate colour models. NOTE: "dtype=object" is required for ragged array support in "Numpy" 1.24.0.
- Line 1925 : # TODO: Filter appropriate colour models. NOTE: "dtype=object" is required for ragged array support in "Numpy" 1.24.0.


- colour/plotting/graph.py

- Line 88 : # TODO: Investigate API to trigger the conversion graph build.
- Line 86 : # TODO: Investigate API to trigger the conversion graph build.


- colour/plotting/common.py

- Line 870 : # TODO: Reassess according to https://github.com/matplotlib/matplotlib/issues/1077
- Line 989 : # TODO: Consider using "MutableMapping" here.
- Line 864 : # TODO: Reassess according to https://github.com/matplotlib/matplotlib/issues/1077
- Line 980 : # TODO: Consider using "MutableMapping" here.


- colour/characterisation/aces_it.py

- Line 397 : # TODO: Remove when removing the "colour.sd_blackbody" definition warning.
- Line 395 : # TODO: Remove when removing the "colour.sd_blackbody" definition warning.


- colour/characterisation/correction.py

- Line 461 : # TODO: Generalise polynomial expansion.
- Line 459 : # TODO: Generalise polynomial expansion.


- colour/notation/munsell.py

- Line 1251 : # TODO: Consider refactoring implementation.
- Line 1236 : # TODO: Consider refactoring implementation.


- colour/continuous/signal.py

- Line 424 : # TODO: Check for interpolator compatibility.
- Line 484 : # TODO: Check for extrapolator compatibility.
- Line 422 : # TODO: Check for interpolator compatibility.
- Line 482 : # TODO: Check for extrapolator compatibility.


- colour/hints/__init__.py

- Line 135 : # TODO: Revisit to use Protocol.
- Line 137 : # TODO: Revisit to use Protocol.


- colour/algebra/tests/test_interpolation.py

- Line 1176 : # TODO: Revisit if the interpolator can be applied on non-uniform "x" independent variable.
- Line 1168 : # TODO: Revisit if the interpolator can be applied on non-uniform "x" independent variable.

About
-----
Expand Down
22 changes: 11 additions & 11 deletions colour/blindness/machado2009.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,17 @@ def matrix_RGB_to_WSYBRG(

R, G, B = tsplit(primaries.values)

WS_R = np.trapz(R * WS, wavelengths) # pyright: ignore
WS_G = np.trapz(G * WS, wavelengths) # pyright: ignore
WS_B = np.trapz(B * WS, wavelengths) # pyright: ignore
WS_R = np.trapezoid(R * WS, wavelengths) # pyright: ignore
WS_G = np.trapezoid(G * WS, wavelengths) # pyright: ignore
WS_B = np.trapezoid(B * WS, wavelengths) # pyright: ignore

YB_R = np.trapz(R * YB, wavelengths) # pyright: ignore
YB_G = np.trapz(G * YB, wavelengths) # pyright: ignore
YB_B = np.trapz(B * YB, wavelengths) # pyright: ignore
YB_R = np.trapezoid(R * YB, wavelengths) # pyright: ignore
YB_G = np.trapezoid(G * YB, wavelengths) # pyright: ignore
YB_B = np.trapezoid(B * YB, wavelengths) # pyright: ignore

RG_R = np.trapz(R * RG, wavelengths) # pyright: ignore
RG_G = np.trapz(G * RG, wavelengths) # pyright: ignore
RG_B = np.trapz(B * RG, wavelengths) # pyright: ignore
RG_R = np.trapezoid(R * RG, wavelengths) # pyright: ignore
RG_G = np.trapezoid(G * RG, wavelengths) # pyright: ignore
RG_B = np.trapezoid(B * RG, wavelengths) # pyright: ignore

M_G = as_float_array(
[
Expand Down Expand Up @@ -219,8 +219,8 @@ def msds_cmfs_anomalous_trichromacy_Machado2009(
"deuteranomaly simulation."
)

area_L = np.trapz(L, cmfs.wavelengths) # pyright: ignore
area_M = np.trapz(M, cmfs.wavelengths) # pyright: ignore
area_L = np.trapezoid(L, cmfs.wavelengths) # pyright: ignore
area_M = np.trapezoid(M, cmfs.wavelengths) # pyright: ignore

def alpha(x: NDArrayFloat) -> NDArrayFloat:
"""Compute :math:`alpha` factor."""
Expand Down
6 changes: 3 additions & 3 deletions colour/colorimetry/photometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def luminous_flux(
extrapolator_kwargs={"method": "Constant", "left": 0, "right": 0},
)

flux = K_m * np.trapz(lef.values * sd.values, sd.wavelengths) # pyright: ignore
flux = K_m * np.trapezoid(lef.values * sd.values, sd.wavelengths) # pyright: ignore

return as_float_scalar(flux)

Expand Down Expand Up @@ -130,9 +130,9 @@ def luminous_efficiency(
extrapolator_kwargs={"method": "Constant", "left": 0, "right": 0},
)

efficiency = np.trapz( # pyright: ignore
efficiency = np.trapezoid( # pyright: ignore
lef.values * sd.values, sd.wavelengths
) / np.trapz( # pyright: ignore
) / np.trapezoid( # pyright: ignore
sd.values, sd.wavelengths
)

Expand Down
2 changes: 1 addition & 1 deletion colour/colorimetry/spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def __contains__(self, wavelength: ArrayLike) -> bool:

return bool(
np.all(
np.in1d( # pyright: ignore
np.isin( # pyright: ignore
np.around(
wavelength, # pyright: ignore
decimals,
Expand Down
Loading
Loading