diff --git a/colour/blindness/machado2009.py b/colour/blindness/machado2009.py index bb815413f..8eaeb1826 100644 --- a/colour/blindness/machado2009.py +++ b/colour/blindness/machado2009.py @@ -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( [ @@ -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.""" diff --git a/colour/colorimetry/photometry.py b/colour/colorimetry/photometry.py index 3f12adf67..e90c369c6 100644 --- a/colour/colorimetry/photometry.py +++ b/colour/colorimetry/photometry.py @@ -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) @@ -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 ) diff --git a/colour/colorimetry/spectrum.py b/colour/colorimetry/spectrum.py index bf9b8c207..6ec7eb96e 100644 --- a/colour/colorimetry/spectrum.py +++ b/colour/colorimetry/spectrum.py @@ -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, diff --git a/colour/continuous/signal.py b/colour/continuous/signal.py index 8bde38f11..d49b5008d 100644 --- a/colour/continuous/signal.py +++ b/colour/continuous/signal.py @@ -794,7 +794,7 @@ def __setitem__(self, x: ArrayLike | slice, y: ArrayLike): y = np.resize(y, x.shape) # Matching domain, updating existing `self._range` values. - mask = np.in1d(x, self._domain) # pyright: ignore + mask = np.isin(x, self._domain) # pyright: ignore x_m = x[mask] indexes = np.searchsorted(self._domain, x_m) self._range[indexes] = y[mask] diff --git a/colour/notation/hexadecimal.py b/colour/notation/hexadecimal.py index 998dd9b8a..0a17d4cdb 100644 --- a/colour/notation/hexadecimal.py +++ b/colour/notation/hexadecimal.py @@ -120,7 +120,7 @@ def HEX_to_RGB(HEX: ArrayLike) -> NDArrayFloat: array([ 0.6666666..., 0.8666666..., 1. ]) """ - HEX = np.core.defchararray.lstrip(HEX, "#") # pyright: ignore + HEX = np.char.lstrip(HEX, "#") # pyright: ignore def to_RGB(x: list) -> list: """Convert given hexadecimal representation to *RGB*.""" diff --git a/colour/utilities/array.py b/colour/utilities/array.py index 19ce1492f..eec230bcd 100644 --- a/colour/utilities/array.py +++ b/colour/utilities/array.py @@ -239,7 +239,7 @@ class MixinDataclassArray(MixinDataclassIterable): - :class:`colour.utilities.MixinDataclassFields` """ - def __array__(self, dtype: Type[DTypeReal] | None = None) -> NDArray: + def __array__(self, dtype: Type[DTypeReal] | None = None, copy=None) -> NDArray: """ Implement support for :class:`dataclass`-like class conversion to :class:`numpy.ndarray` class. @@ -253,6 +253,9 @@ def __array__(self, dtype: Type[DTypeReal] | None = None) -> NDArray: :class:`numpy.dtype` to use for conversion to `np.ndarray`, default to the :class:`numpy.dtype` defined by :attr:`colour.constant.DTYPE_FLOAT_DEFAULT` attribute. + copy + Whether to return a copy of the underlying data, will always be + `True`, irrespective of the parameter value. Returns ------- @@ -2090,7 +2093,7 @@ def in_array(a: ArrayLike, b: ArrayLike, tolerance: Real = EPSILON) -> NDArray: -------- >>> a = np.array([0.50, 0.60]) >>> b = np.linspace(0, 10, 101) - >>> np.in1d(a, b) + >>> np.isin(a, b) array([ True, False], dtype=bool) >>> in_array(a, b) array([ True, True], dtype=bool) diff --git a/colour/utilities/tests/test_array.py b/colour/utilities/tests/test_array.py index 42476cb90..80d6f42ed 100644 --- a/colour/utilities/tests/test_array.py +++ b/colour/utilities/tests/test_array.py @@ -277,7 +277,7 @@ def test__array__(self): method. """ - np.testing.assert_array_equal(np.array(self._data), self._array) + np.testing.assert_array_equal(self._data, self._array) assert np.array(self._data, dtype=DTYPE_INT_DEFAULT).dtype == DTYPE_INT_DEFAULT @@ -344,61 +344,61 @@ def test_arithmetical_operation(self): """ np.testing.assert_allclose( - np.array(self._data.arithmetical_operation(10, "+", False)), + self._data.arithmetical_operation(10, "+", False), self._array + 10, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - np.array(self._data.arithmetical_operation(10, "-", False)), + self._data.arithmetical_operation(10, "-", False), self._array - 10, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - np.array(self._data.arithmetical_operation(10, "*", False)), + self._data.arithmetical_operation(10, "*", False), self._array * 10, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - np.array(self._data.arithmetical_operation(10, "/", False)), + self._data.arithmetical_operation(10, "/", False), self._array / 10, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - np.array(self._data.arithmetical_operation(10, "**", False)), + self._data.arithmetical_operation(10, "**", False), self._array**10, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - np.array(self._data + 10), + self._data + 10, self._array + 10, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - np.array(self._data - 10), + self._data - 10, self._array - 10, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - np.array(self._data * 10), + self._data * 10, self._array * 10, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - np.array(self._data / 10), + self._data / 10, self._array / 10, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - np.array(self._data**10), + self._data**10, self._array**10, atol=TOLERANCE_ABSOLUTE_TESTS, ) @@ -406,31 +406,31 @@ def test_arithmetical_operation(self): data = deepcopy(self._data) np.testing.assert_allclose( - np.array(data.arithmetical_operation(10, "+", True)), + data.arithmetical_operation(10, "+", True), self._array + 10, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - np.array(data.arithmetical_operation(10, "-", True)), + data.arithmetical_operation(10, "-", True), self._array, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - np.array(data.arithmetical_operation(10, "*", True)), + data.arithmetical_operation(10, "*", True), self._array * 10, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - np.array(data.arithmetical_operation(10, "/", True)), + data.arithmetical_operation(10, "/", True), self._array, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - np.array(data.arithmetical_operation(10, "**", True)), + data.arithmetical_operation(10, "**", True), self._array**10, atol=TOLERANCE_ABSOLUTE_TESTS, ) @@ -438,13 +438,13 @@ def test_arithmetical_operation(self): data = deepcopy(self._data) np.testing.assert_allclose( - np.array(data.arithmetical_operation(self._array, "+", False)), + data.arithmetical_operation(self._array, "+", False), data + self._array, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - np.array(data.arithmetical_operation(data, "+", False)), + data.arithmetical_operation(data, "+", False), data + data, atol=TOLERANCE_ABSOLUTE_TESTS, )