Skip to content

Commit

Permalink
Merge branch 'feature/v0.4.5' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed May 10, 2024
2 parents bbcd4c6 + 4b0c38d commit b2d089c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 22 deletions.
4 changes: 2 additions & 2 deletions colour/constants/__init__.py
Expand Up @@ -7,7 +7,7 @@
)
from .common import (
PATTERN_FLOATING_POINT_NUMBER,
INTEGER_THRESHOLD,
THRESHOLD_INTEGER,
EPSILON,
DTYPE_INT_DEFAULT,
DTYPE_FLOAT_DEFAULT,
Expand All @@ -29,7 +29,7 @@
]
__all__ += [
"PATTERN_FLOATING_POINT_NUMBER",
"INTEGER_THRESHOLD",
"THRESHOLD_INTEGER",
"EPSILON",
"DTYPE_INT_DEFAULT",
"DTYPE_FLOAT_DEFAULT",
Expand Down
10 changes: 5 additions & 5 deletions colour/constants/common.py
Expand Up @@ -27,7 +27,7 @@

__all__ = [
"PATTERN_FLOATING_POINT_NUMBER",
"INTEGER_THRESHOLD",
"THRESHOLD_INTEGER",
"EPSILON",
"DTYPE_INT_DEFAULT",
"DTYPE_FLOAT_DEFAULT",
Expand All @@ -40,11 +40,11 @@
PATTERN_FLOATING_POINT_NUMBER: str = "[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?"
"""Floating point number regex matching pattern."""

INTEGER_THRESHOLD: float = 1e-3
THRESHOLD_INTEGER: float = 1e-3
if is_documentation_building(): # pragma: no cover
INTEGER_THRESHOLD = DocstringFloat(INTEGER_THRESHOLD)
INTEGER_THRESHOLD.__doc__ = """
int threshold value when checking if a float point number is almost an
THRESHOLD_INTEGER = DocstringFloat(THRESHOLD_INTEGER)
THRESHOLD_INTEGER.__doc__ = """
Integer threshold value when checking if a float point number is almost an
int.
"""

Expand Down
21 changes: 10 additions & 11 deletions colour/notation/munsell.py
Expand Up @@ -130,8 +130,8 @@
)
from colour.colorimetry import CCS_ILLUMINANTS, luminance_ASTMD1535
from colour.constants import (
INTEGER_THRESHOLD,
PATTERN_FLOATING_POINT_NUMBER,
THRESHOLD_INTEGER,
TOLERANCE_ABSOLUTE_DEFAULT,
TOLERANCE_RELATIVE_DEFAULT,
)
Expand Down Expand Up @@ -1073,7 +1073,7 @@ def _xyY_to_munsell_specification(xyY: ArrayLike) -> NDArrayFloat:
)
phi_input = np.degrees(phi_input)

grey_threshold = 1e-7
grey_threshold = THRESHOLD_INTEGER
if rho_input < grey_threshold:
return from_range_10(normalise_munsell_specification(value))

Expand All @@ -1098,7 +1098,7 @@ def _xyY_to_munsell_specification(xyY: ArrayLike) -> NDArrayFloat:
code_initial,
]

convergence_threshold = 1e-7
convergence_threshold = THRESHOLD_INTEGER / 1e4
iterations_maximum = 64
iterations = 0

Expand Down Expand Up @@ -2040,7 +2040,7 @@ def interpolation_method_from_renotation_ovoid(
)

attest(
abs(2 * (chroma / 2 - round(chroma / 2))) <= INTEGER_THRESHOLD,
abs(2 * (chroma / 2 - round(chroma / 2))) <= THRESHOLD_INTEGER,
f'"{specification}" specification chroma must be an int and '
f"multiple of 2!",
)
Expand Down Expand Up @@ -2322,7 +2322,7 @@ def xy_from_renotation_ovoid(specification: ArrayLike) -> NDArrayFloat:
)

attest(
abs(2 * (chroma / 2 - round(chroma / 2))) <= INTEGER_THRESHOLD,
abs(2 * (chroma / 2 - round(chroma / 2))) <= THRESHOLD_INTEGER,
f'"{specification}" specification chroma must be an int and '
f"multiple of 2!",
)
Expand All @@ -2331,13 +2331,12 @@ def xy_from_renotation_ovoid(specification: ArrayLike) -> NDArrayFloat:

# Checking if renotation data is available without interpolation using
# given threshold.
threshold = 1e-7
if (
abs(hue) < threshold
or abs(hue - 2.5) < threshold
or abs(hue - 5) < threshold
or abs(hue - 7.5) < threshold
or abs(hue - 10) < threshold
abs(hue) < THRESHOLD_INTEGER
or abs(hue - 2.5) < THRESHOLD_INTEGER
or abs(hue - 5) < THRESHOLD_INTEGER
or abs(hue - 7.5) < THRESHOLD_INTEGER
or abs(hue - 10) < THRESHOLD_INTEGER
):
hue = 2.5 * round(hue / 2.5)

Expand Down
6 changes: 3 additions & 3 deletions colour/utilities/common.py
Expand Up @@ -32,7 +32,7 @@

import numpy as np

from colour.constants import INTEGER_THRESHOLD
from colour.constants import THRESHOLD_INTEGER
from colour.hints import (
Any,
Callable,
Expand Down Expand Up @@ -1234,7 +1234,7 @@ def is_integer(a: Any) -> bool:
Notes
-----
- The determination threshold is defined by the
:attr:`colour.algebra.common.INTEGER_THRESHOLD` attribute.
:attr:`colour.algebra.common.THRESHOLD_INTEGER` attribute.
Examples
--------
Expand All @@ -1244,7 +1244,7 @@ def is_integer(a: Any) -> bool:
False
"""

return abs(a - np.around(a)) <= INTEGER_THRESHOLD
return abs(a - np.around(a)) <= THRESHOLD_INTEGER


def is_sibling(element: Any, mapping: Mapping) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion docs/colour.constants.rst
Expand Up @@ -40,7 +40,7 @@ Common
:toctree: generated/

PATTERN_FLOATING_POINT_NUMBER
INTEGER_THRESHOLD
THRESHOLD_INTEGER
EPSILON
DTYPE_INT_DEFAULT
DTYPE_FLOAT_DEFAULT
Expand Down

0 comments on commit b2d089c

Please sign in to comment.