Skip to content

Commit

Permalink
Merge branch 'feature/v0.4.3' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Mar 10, 2023
2 parents 2e38631 + 653aded commit 82e0390
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[run]
source = colour
concurrency = multiprocessing
sigterm = True
[report]
exclude_lines =
pragma: no cover
Expand Down
20 changes: 6 additions & 14 deletions .github/workflows/continuous-integration-quality-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ jobs:
matrix:
os: [macOS-latest, ubuntu-22.04, windows-latest]
python-version: [3.9, '3.10', 3.11]
exclude:
- os: windows-latest
python-version: 3.8
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -21,8 +18,6 @@ jobs:
echo "CI_PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV
echo "CI_PACKAGE=colour" >> $GITHUB_ENV
echo "CI_SHA=${{ github.sha }}" >> $GITHUB_ENV
echo "CI_OPENIMAGEIO_VERSION=2.4.5.0" >> $GITHUB_ENV
echo "CI_OPENIMAGEIO_ARTIFACT=https://github.com/colour-science/artifacts/releases/download/OpenImageIO-Release-2.4.5.0/OpenImageIO-Release-2.4.5.0.zip" >> $GITHUB_ENV
echo "COVERALLS_REPO_TOKEN=${{ secrets.COVERALLS_REPO_TOKEN }}" >> $GITHUB_ENV
echo "MPLBACKEND=AGG" >> $GITHUB_ENV
shell: bash
Expand Down Expand Up @@ -58,15 +53,12 @@ jobs:
poetry install --extras "meshing optional plotting"
poetry run python -c "import imageio;imageio.plugins.freeimage.download()"
shell: bash
- name: Install OpenImageIO (Ubuntu)
if: matrix.os == 'ubuntu-22.04' && matrix.python-version == '3.10'
- name: Install OpenImageIO (macOs)
if: matrix.os == 'macOS-latest' && matrix.python-version == '3.11'
run: |
curl -L $CI_OPENIMAGEIO_ARTIFACT -o OpenImageIO-Release-$CI_OPENIMAGEIO_VERSION.zip
unzip OpenImageIO-Release-$CI_OPENIMAGEIO_VERSION.zip -d OpenImageIO-Release-$CI_OPENIMAGEIO_VERSION
sudo cp OpenImageIO-Release-$CI_OPENIMAGEIO_VERSION/bin/* /usr/bin/
sudo cp -r OpenImageIO-Release-$CI_OPENIMAGEIO_VERSION/lib/* /usr/lib/
sudo rm -rf /usr/lib/python$CI_PYTHON_VERSION
cp -r OpenImageIO-Release-$CI_OPENIMAGEIO_VERSION/lib/python$CI_PYTHON_VERSION/site-packages/OpenImageIO $(poetry env info -p)/lib/python$CI_PYTHON_VERSION/site-packages/
brew install openimageio
ls /usr/local/Cellar/openimageio/*/lib/python*/site-packages/OpenImageIO/
ln -s /usr/local/Cellar/openimageio/*/lib/python*/site-packages/OpenImageIO/OpenImageIO*.so /Library/Frameworks/Python.framework/Versions/${{ matrix.python-version }}/lib/python${{ matrix.python-version }}/site-packages/OpenImageIO.so
shell: bash
- name: Pre-Commit (All Files)
run: |
Expand All @@ -81,7 +73,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 == 'ubuntu-22.04' && matrix.python-version == '3.10'
if: matrix.os == 'macOS-latest' && matrix.python-version == '3.11'
run: |
if [ -z "$COVERALLS_REPO_TOKEN" ]; then echo \"COVERALLS_REPO_TOKEN\" secret is undefined!; else poetry run coveralls; fi
shell: bash
65 changes: 62 additions & 3 deletions colour/graph/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
ZCAM_to_XYZ,
)
from colour.appearance.ciecam02 import CAM_KWARGS_CIECAM02_sRGB
from colour.temperature import CCT_to_uv, uv_to_CCT
from colour.temperature import CCT_to_mired, CCT_to_uv, mired_to_CCT, uv_to_CCT
from colour.utilities import (
as_float_array,
domain_range_scale,
Expand All @@ -190,6 +190,7 @@
tstack,
usage_warning,
validate_method,
zeros,
)

__author__ = "Colour Developers"
Expand All @@ -209,6 +210,8 @@
"JMh_Hellwig2022_to_Hellwig2022",
"XYZ_to_luminance",
"RGB_luminance_to_RGB",
"CCT_D_uv_to_mired",
"mired_to_CCT_D_uv",
"CONVERSION_SPECIFICATIONS_DATA",
"CONVERSION_GRAPH_NODE_LABELS",
"CONVERSION_SPECIFICATIONS",
Expand Down Expand Up @@ -530,6 +533,60 @@ def RGB_luminance_to_RGB(Y: ArrayLike) -> NDArrayFloat:
return tstack([Y, Y, Y])


def CCT_D_uv_to_mired(CCT_D_uv: ArrayLike) -> NDArrayFloat:
"""
Convert given correlated colour temperature :math:`T_{cp}` and
:math:`\\Delta_{uv}` to micro reciprocal degree (mired).
Parameters
----------
CCT_D_uv
Correlated colour temperature :math:`T_{cp}`, :math:`\\Delta_{uv}`.
Returns
-------
:class:`numpy.ndarray`
Micro reciprocal degree (mired).
Examples
--------
>>> CCT_D_uv = np.array([6500.0081378199056, 0.008333331244225])
>>> CCT_D_uv_to_mired(CCT_D_uv) # doctest: +ELLIPSIS
153.8459612...
"""

CCT, _D_uv = tsplit(CCT_D_uv)

return CCT_to_mired(CCT)


def mired_to_CCT_D_uv(mired: ArrayLike) -> NDArrayFloat:
"""
Convert given micro reciprocal degree (mired) to correlated colour
temperature :math:`T_{cp}` and :math:`\\Delta_{uv}`.
Parameters
----------
Micro reciprocal degree (mired).
Returns
-------
:class:`numpy.ndarray`
Correlated colour temperature :math:`T_{cp}`, :math:`\\Delta_{uv}`.
Examples
--------
>>> mired = 153.84596123527297
>>> mired_to_CCT_D_uv(mired) # doctest: +ELLIPSIS
array([ 6500.0081378..., 0. ])
"""

mired = as_float_array(mired)

return tstack([mired_to_CCT(mired), zeros(mired.shape)])


_ILLUMINANT_DEFAULT: str = "D65"
"""Default automatic colour conversion graph illuminant name."""

Expand Down Expand Up @@ -783,6 +840,8 @@ def RGB_luminance_to_RGB(Y: ArrayLike) -> NDArrayFloat:
# Colour Temperature
("CCT", "CIE UCS uv", CCT_to_uv),
("CIE UCS uv", "CCT", uv_to_CCT),
("CCT", "Mired", CCT_D_uv_to_mired),
("Mired", "CCT", mired_to_CCT_D_uv),
# Advanced Colorimetry
(
"CIE XYZ",
Expand Down Expand Up @@ -994,8 +1053,8 @@ def _conversion_path(source: str, target: str) -> List[Callable]:
--------
>>> _conversion_path("cie lab", "cct")
... # doctest: +ELLIPSIS
[<function Lab_to_XYZ at 0x...>, <function XYZ_to_xy at 0x...>, \
<function xy_to_UCS_uv at 0x...>, <function uv_to_CCT at 0x...>]
[<function Lab_to_XYZ at 0x...>, <function XYZ_to_UCS at 0x...>, \
<function UCS_to_uv at 0x...>, <function uv_to_CCT at 0x...>]
"""

import networkx as nx
Expand Down
3 changes: 2 additions & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ def tests(ctx: Context):
"pytest "
"--doctest-modules "
f"--ignore={PYTHON_PACKAGE_NAME}/examples "
f"--cov={PYTHON_PACKAGE_NAME} "
f"{PYTHON_PACKAGE_NAME}"
)

Expand Down Expand Up @@ -475,7 +476,7 @@ def virtualise(ctx: Context, tests: bool = True):
)
if tests:
ctx.run(
"poetry run py.test "
"poetry run pytest "
"--doctest-modules "
f"--ignore={PYTHON_PACKAGE_NAME}/examples "
f"{PYTHON_PACKAGE_NAME}",
Expand Down

0 comments on commit 82e0390

Please sign in to comment.