Comprehensive Python library providing algorithms and datasets for colour science computations, including chromatic adaptation, colour appearance models, colorimetry, and spectral analysis.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Fundamental physical constants, CIE standards, computational tolerances, and data type definitions used throughout the colour-science package for accurate colorimetric calculations.
Standard CIE constants for photometric and colorimetric calculations.
# Maximum luminous efficacy constants
CONSTANT_K_M: float # 683 lm/W - Maximum photopic luminous efficacy
CONSTANT_KP_M: float # 1700 lm/W - Maximum scotopic luminous efficacyFundamental physical constants from the Committee on Data for Science and Technology (CODATA).
# Fundamental constants
CONSTANT_AVOGADRO: float # 6.02214179e23 mol⁻¹ - Avogadro constant
CONSTANT_BOLTZMANN: float # 1.38065e-23 J/K - Boltzmann constant
CONSTANT_LIGHT_SPEED: float # 299792458 m/s - Speed of light in vacuum
CONSTANT_PLANCK: float # 6.62607e-34 J⋅s - Planck constantPrecision control and computational tolerances for numerical stability.
# Floating point precision
EPSILON: float # Machine epsilon for floating point comparisons
THRESHOLD_INTEGER: float # 1e-3 - Threshold for integer detection
# Regular expression patterns
PATTERN_FLOATING_POINT_NUMBER: str # Regex pattern for floating point numbersDefault data types for arrays and computational operations.
# Default data types
DTYPE_INT_DEFAULT: Type # Default integer data type
DTYPE_FLOAT_DEFAULT: DTypeFloat # Default floating point data typeTolerance thresholds for numerical comparisons and testing.
# Default tolerance values
TOLERANCE_ABSOLUTE_DEFAULT: float # Default absolute tolerance
TOLERANCE_RELATIVE_DEFAULT: float # Default relative tolerance
# Test-specific tolerances
TOLERANCE_ABSOLUTE_TESTS: float # Absolute tolerance for tests
TOLERANCE_RELATIVE_TESTS: float # Relative tolerance for testsfrom colour.constants import CONSTANT_PLANCK, CONSTANT_LIGHT_SPEED, CONSTANT_K_M
# Calculate photon energy
wavelength = 555e-9 # 555 nm in meters
frequency = CONSTANT_LIGHT_SPEED / wavelength
photon_energy = CONSTANT_PLANCK * frequency
# Use maximum luminous efficacy
luminous_flux = radiant_flux * CONSTANT_K_M * luminous_efficiencyfrom colour.constants import EPSILON, TOLERANCE_ABSOLUTE_DEFAULT
import numpy as np
# Safe floating point comparison
def is_equal(a, b, tolerance=TOLERANCE_ABSOLUTE_DEFAULT):
return abs(a - b) < tolerance
# Machine epsilon usage
if abs(value) < EPSILON:
value = 0.0 # Treat as zerofrom colour.constants import DTYPE_FLOAT_DEFAULT, DTYPE_INT_DEFAULT
import numpy as np
# Create arrays with default types
float_array = np.array([1.0, 2.0, 3.0], dtype=DTYPE_FLOAT_DEFAULT)
int_array = np.array([1, 2, 3], dtype=DTYPE_INT_DEFAULT)from colour.hints import DTypeFloat, Type, Union
from typing import Pattern
# Type aliases used in constants
DTypeFloat = Union[Type[np.float16], Type[np.float32], Type[np.float64]]# Core constants
from colour.constants import (
CONSTANT_K_M, CONSTANT_KP_M,
CONSTANT_AVOGADRO, CONSTANT_BOLTZMANN,
CONSTANT_LIGHT_SPEED, CONSTANT_PLANCK
)
# Computational constants
from colour.constants import (
EPSILON, THRESHOLD_INTEGER,
TOLERANCE_ABSOLUTE_DEFAULT, TOLERANCE_RELATIVE_DEFAULT,
DTYPE_INT_DEFAULT, DTYPE_FLOAT_DEFAULT
)
# Pattern matching
from colour.constants import PATTERN_FLOATING_POINT_NUMBERInstall with Tessl CLI
npx tessl i tessl/pypi-colour-science