Skip to content

Commit

Permalink
Replace "Number" hints with "Real".
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Dec 11, 2022
1 parent 4667b6b commit 07fffe4
Show file tree
Hide file tree
Showing 20 changed files with 87 additions and 91 deletions.
22 changes: 11 additions & 11 deletions colour/algebra/extrapolation.py
Expand Up @@ -28,8 +28,8 @@
DTypeNumber,
Literal,
NDArrayFloat,
Number,
Optional,
Real,
Type,
TypeInterpolator,
Union,
Expand Down Expand Up @@ -140,8 +140,8 @@ def __init__(
self,
interpolator: Optional[TypeInterpolator] = None,
method: Union[Literal["Linear", "Constant"], str] = "Linear",
left: Optional[Number] = None,
right: Optional[Number] = None,
left: Optional[Real] = None,
right: Optional[Real] = None,
dtype: Optional[Type[DTypeNumber]] = None,
*args: Any,
**kwargs: Any,
Expand All @@ -154,9 +154,9 @@ def __init__(
self.interpolator = optional(interpolator, self._interpolator)
self._method: Union[Literal["Linear", "Constant"], str] = "Linear"
self.method = optional(method, self._method)
self._right: Optional[Number] = None
self._right: Optional[Real] = None
self.right = right
self._left: Optional[Number] = None
self._left: Optional[Real] = None
self.left = left

self._dtype: Type[DTypeNumber] = dtype
Expand Down Expand Up @@ -229,7 +229,7 @@ def method(self, value: Union[Literal["Linear", "Constant"], str]):
self._method = value

@property
def left(self) -> Optional[Number]:
def left(self) -> Optional[Real]:
"""
Getter and setter property for left value to return for x < xi[0].
Expand All @@ -240,14 +240,14 @@ def left(self) -> Optional[Number]:
Returns
-------
:py:data:`None` or Number
:py:data:`None` or Real
Left value to return for x < xi[0].
"""

return self._left

@left.setter
def left(self, value: Optional[Number]):
def left(self, value: Optional[Real]):
"""Setter for the **self.left** property."""

if value is not None:
Expand All @@ -259,7 +259,7 @@ def left(self, value: Optional[Number]):
self._left = value

@property
def right(self) -> Optional[Number]:
def right(self) -> Optional[Real]:
"""
Getter and setter property for right value to return for x > xi[-1].
Expand All @@ -270,14 +270,14 @@ def right(self) -> Optional[Number]:
Returns
-------
:py:data:`None` or Number
:py:data:`None` or Real
Right value to return for x > xi[-1].
"""

return self._right

@right.setter
def right(self, value: Optional[Number]):
def right(self, value: Optional[Real]):
"""Setter for the **self.right** property."""

if value is not None:
Expand Down
32 changes: 16 additions & 16 deletions colour/colorimetry/spectrum.py
Expand Up @@ -49,8 +49,8 @@
List,
Literal,
NDArrayFloat,
Number,
Optional,
Real,
Sequence,
Self,
TYPE_CHECKING,
Expand Down Expand Up @@ -157,16 +157,16 @@ class SpectralShape:
SpectralShape(360, 830, 1)
"""

def __init__(self, start: Number, end: Number, interval: Number) -> None:
self._start: Number = 360
self._end: Number = 780
self._interval: Number = 1
def __init__(self, start: Real, end: Real, interval: Real) -> None:
self._start: Real = 360
self._end: Real = 780
self._interval: Real = 1
self.start = start
self.end = end
self.interval = interval

@property
def start(self) -> Number:
def start(self) -> Real:
"""
Getter and setter property for the spectral shape start.
Expand All @@ -177,14 +177,14 @@ def start(self) -> Number:
Returns
-------
Number
Real
Spectral shape start.
"""

return self._start

@start.setter
def start(self, value: Number):
def start(self, value: Real):
"""Setter for the **self.start** property."""

attest(
Expand All @@ -201,7 +201,7 @@ def start(self, value: Number):
self._start = value

@property
def end(self) -> Number:
def end(self) -> Real:
"""
Getter and setter property for the spectral shape end.
Expand All @@ -212,14 +212,14 @@ def end(self) -> Number:
Returns
-------
Number
Real
Spectral shape end.
"""

return self._end

@end.setter
def end(self, value: Number):
def end(self, value: Real):
"""Setter for the **self.end** property."""

attest(
Expand All @@ -236,7 +236,7 @@ def end(self, value: Number):
self._end = value

@property
def interval(self) -> Number:
def interval(self) -> Real:
"""
Getter and setter property for the spectral shape interval.
Expand All @@ -247,14 +247,14 @@ def interval(self) -> Number:
Returns
-------
Number
Real
Spectral shape interval.
"""

return self._interval

@interval.setter
def interval(self, value: Number):
def interval(self, value: Real):
"""Setter for the **self.interval** property."""

attest(
Expand Down Expand Up @@ -1577,7 +1577,7 @@ def trim(self, shape: SpectralShape) -> Self:

return self

def normalise(self, factor: Number = 1) -> Self:
def normalise(self, factor: Real = 1) -> Self:
"""
Normalise the spectral distribution using given normalization factor.
Expand Down Expand Up @@ -2592,7 +2592,7 @@ def trim(self, shape: SpectralShape) -> Self:

return self

def normalise(self, factor: Number = 1) -> Self:
def normalise(self, factor: Real = 1) -> Self:
"""
Normalise the multi-spectral distributions with given normalization
factor.
Expand Down
22 changes: 11 additions & 11 deletions colour/colorimetry/tristimulus_values.py
Expand Up @@ -52,8 +52,8 @@
ArrayLike,
Literal,
NDArrayFloat,
Number,
Optional,
Real,
Tuple,
Union,
cast,
Expand Down Expand Up @@ -277,7 +277,7 @@ def tristimulus_weighting_factors_ASTME2022(
cmfs: MultiSpectralDistributions,
illuminant: SpectralDistribution,
shape: SpectralShape,
k: Optional[Number] = None,
k: Optional[Real] = None,
) -> NDArrayFloat:
"""
Return a table of tristimulus weighting factors for given colour matching
Expand Down Expand Up @@ -448,7 +448,7 @@ def tristimulus_weighting_factors_ASTME2022(
W[i_cm, i] = W[i_cm, i] + S[j] * Y[j, i]

with sdiv_mode():
W *= cast(Number, optional(k_n, sdiv(100, np.sum(W, axis=0)[1])))
W *= optional(k_n, sdiv(100, np.sum(W, axis=0)[1]))

_CACHE_TRISTIMULUS_WEIGHTING_FACTORS[hash_key] = np.copy(W)

Expand Down Expand Up @@ -539,7 +539,7 @@ def sd_to_XYZ_integration(
sd: Union[ArrayLike, SpectralDistribution, MultiSpectralDistributions],
cmfs: Optional[MultiSpectralDistributions] = None,
illuminant: Optional[SpectralDistribution] = None,
k: Optional[Number] = None,
k: Optional[Real] = None,
shape: Optional[SpectralShape] = None,
) -> NDArrayFloat:
"""
Expand Down Expand Up @@ -723,7 +723,7 @@ def sd_to_XYZ_integration(

with sdiv_mode():
k = cast(
Number, optional(k, sdiv(100, (np.sum(XYZ_b[..., 1] * S) * d_w)))
Real, optional(k, sdiv(100, (np.sum(XYZ_b[..., 1] * S) * d_w)))
)

XYZ = k * np.dot(R * S, XYZ_b) * d_w
Expand All @@ -740,7 +740,7 @@ def sd_to_XYZ_tristimulus_weighting_factors_ASTME308(
sd: SpectralDistribution,
cmfs: Optional[MultiSpectralDistributions] = None,
illuminant: Optional[SpectralDistribution] = None,
k: Optional[Number] = None,
k: Optional[Real] = None,
) -> NDArrayFloat:
"""
Convert given spectral distribution to *CIE XYZ* tristimulus values
Expand Down Expand Up @@ -885,7 +885,7 @@ def sd_to_XYZ_ASTME308(
use_practice_range: bool = True,
mi_5nm_omission_method: bool = True,
mi_20nm_interpolation_method: bool = True,
k: Optional[Number] = None,
k: Optional[Real] = None,
) -> NDArrayFloat:
"""
Convert given spectral distribution to *CIE XYZ* tristimulus values using
Expand Down Expand Up @@ -1088,7 +1088,7 @@ def sd_to_XYZ(
sd: Union[ArrayLike, SpectralDistribution, MultiSpectralDistributions],
cmfs: Optional[MultiSpectralDistributions] = None,
illuminant: Optional[SpectralDistribution] = None,
k: Optional[Number] = None,
k: Optional[Real] = None,
method: Union[Literal["ASTM E308", "Integration"], str] = "ASTM E308",
**kwargs: Any,
) -> NDArrayFloat:
Expand Down Expand Up @@ -1276,7 +1276,7 @@ def msds_to_XYZ_integration(
msds: Union[ArrayLike, SpectralDistribution, MultiSpectralDistributions],
cmfs: Optional[MultiSpectralDistributions] = None,
illuminant: Optional[SpectralDistribution] = None,
k: Optional[Number] = None,
k: Optional[Real] = None,
shape: Optional[SpectralShape] = None,
) -> NDArrayFloat:
"""
Expand Down Expand Up @@ -1512,7 +1512,7 @@ def msds_to_XYZ_ASTME308(
msds: MultiSpectralDistributions,
cmfs: Optional[MultiSpectralDistributions] = None,
illuminant: Optional[SpectralDistribution] = None,
k: Optional[Number] = None,
k: Optional[Real] = None,
use_practice_range: bool = True,
mi_5nm_omission_method: bool = True,
mi_20nm_interpolation_method: bool = True,
Expand Down Expand Up @@ -1763,7 +1763,7 @@ def msds_to_XYZ(
msds: Union[ArrayLike, SpectralDistribution, MultiSpectralDistributions],
cmfs: Optional[MultiSpectralDistributions] = None,
illuminant: Optional[SpectralDistribution] = None,
k: Optional[Number] = None,
k: Optional[Real] = None,
method: Union[Literal["ASTM E308", "Integration"], str] = "ASTM E308",
**kwargs: Any,
) -> NDArrayFloat:
Expand Down
4 changes: 2 additions & 2 deletions colour/continuous/abstract.py
Expand Up @@ -21,8 +21,8 @@
DTypeFloat,
Literal,
NDArrayFloat,
Number,
Optional,
Real,
Self,
Type,
TypeExtrapolator,
Expand Down Expand Up @@ -747,7 +747,7 @@ def fill_nan(
method: Union[
Literal["Constant", "Interpolation"], str
] = "Interpolation",
default: Number = 0,
default: Real = 0,
) -> Self:
"""
Fill NaNs in independent domain variable :math:`x` and corresponding
Expand Down
4 changes: 2 additions & 2 deletions colour/continuous/multi_signals.py
Expand Up @@ -23,8 +23,8 @@
List,
Literal,
NDArrayFloat,
Number,
Optional,
Real,
Sequence,
Self,
TYPE_CHECKING,
Expand Down Expand Up @@ -1563,7 +1563,7 @@ def fill_nan(
method: Union[
Literal["Constant", "Interpolation"], str
] = "Interpolation",
default: Number = 0,
default: Real = 0,
) -> AbstractContinuousFunction:
"""
Fill NaNs in independent domain variable :math:`x` and corresponding
Expand Down
8 changes: 4 additions & 4 deletions colour/continuous/signal.py
Expand Up @@ -33,8 +33,8 @@
DTypeFloat,
Literal,
NDArrayFloat,
Number,
Optional,
Real,
Self,
TYPE_CHECKING,
Type,
Expand Down Expand Up @@ -928,7 +928,7 @@ def _fill_domain_nan(
method: Union[
Literal["Constant", "Interpolation"], str
] = "Interpolation",
default: Number = 0,
default: Real = 0,
):
"""
Fill NaNs in independent domain variable :math:`x` using given method.
Expand Down Expand Up @@ -956,7 +956,7 @@ def _fill_range_nan(
method: Union[
Literal["Constant", "Interpolation"], str
] = "Interpolation",
default: Number = 0,
default: Real = 0,
):
"""
Fill NaNs in corresponding range variable :math:`y` using given method.
Expand Down Expand Up @@ -1215,7 +1215,7 @@ def fill_nan(
method: Union[
Literal["Constant", "Interpolation"], str
] = "Interpolation",
default: Number = 0,
default: Real = 0,
) -> AbstractContinuousFunction:
"""
Fill NaNs in independent domain variable :math:`x` and corresponding
Expand Down
4 changes: 2 additions & 2 deletions colour/examples/examples_colour.py
Expand Up @@ -140,8 +140,8 @@
print("\n")

message_box(
'Definitions mixing "ArrayLike" and "Number" parameters expect the '
'"Number" parameters to have a dimension less than the "ArrayLike" '
'Definitions mixing "ArrayLike" and "Real" parameters expect the '
'"Real" parameters to have a dimension less than the "ArrayLike" '
"parameters."
)
XYZ_1 = np.array([28.00, 21.26, 5.27])
Expand Down

0 comments on commit 07fffe4

Please sign in to comment.