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 Dec 23, 2022
2 parents e046a9e + abdd88f commit 45ae2be
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
12 changes: 8 additions & 4 deletions colour/colorimetry/spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import numpy as np
from collections.abc import Mapping


from colour.algebra import (
Extrapolator,
CubicSplineInterpolator,
Expand Down Expand Up @@ -2757,7 +2756,6 @@ def strict_labels(self, value): # pragma: no cover # noqa: D102
f"{__name__}._CACHE_RESHAPED_SDS_AND_MSDS"
)


TypeSpectralDistribution = TypeVar(
"TypeSpectralDistribution", bound="SpectralDistribution"
)
Expand Down Expand Up @@ -2884,6 +2882,7 @@ def reshape_msds(
def sds_and_msds_to_sds(
sds: Union[
Sequence[Union[SpectralDistribution, MultiSpectralDistributions]],
SpectralDistribution,
MultiSpectralDistributions,
]
) -> List[SpectralDistribution]:
Expand Down Expand Up @@ -2929,7 +2928,9 @@ def sds_and_msds_to_sds(
8
"""

if isinstance(sds, MultiSpectralDistributions):
if isinstance(sds, SpectralDistribution):
return sds_and_msds_to_sds([sds])
elif isinstance(sds, MultiSpectralDistributions):
sds_converted = sds.to_sds()
else:
sds_converted = []
Expand All @@ -2946,6 +2947,7 @@ def sds_and_msds_to_sds(
def sds_and_msds_to_msds(
sds: Union[
Sequence[Union[SpectralDistribution, MultiSpectralDistributions]],
SpectralDistribution,
MultiSpectralDistributions,
]
) -> MultiSpectralDistributions:
Expand Down Expand Up @@ -3028,7 +3030,9 @@ def sds_and_msds_to_msds(
extrapolator_kwargs={...})
"""

if isinstance(sds, MultiSpectralDistributions):
if isinstance(sds, SpectralDistribution):
return sds_and_msds_to_msds([sds])
elif isinstance(sds, MultiSpectralDistributions):
msds_converted = sds
else:
sds_converted = sds_and_msds_to_sds(sds)
Expand Down
3 changes: 3 additions & 0 deletions colour/colorimetry/tests/test_spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -1950,6 +1950,7 @@ def test_sds_and_msds_to_sds(self):
multi_sds_1 = MultiSpectralDistributions(DATA_MULTI_SAMPLE_ABRIDGED)
multi_sds_2 = MultiSpectralDistributions(DATA_MULTI_SAMPLE_ABRIDGED)

self.assertEqual(sds_and_msds_to_sds(sd_1), [sd_1])
self.assertEqual(
len(
sds_and_msds_to_sds(
Expand Down Expand Up @@ -1984,6 +1985,8 @@ def test_sds_and_msds_to_msds(self):
multi_sds_1 = MultiSpectralDistributions(DATA_MULTI_SAMPLE_ABRIDGED)
multi_sds_2 = MultiSpectralDistributions(DATA_MULTI_SAMPLE_ABRIDGED)

self.assertEqual(len(sds_and_msds_to_msds(sd_1)), 6)

self.assertEqual(sds_and_msds_to_msds(multi_sds_1), multi_sds_1)

multi_sds_0 = sds_and_msds_to_msds([multi_sds_1])
Expand Down
1 change: 1 addition & 0 deletions colour/colorimetry/uniformity.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
def spectral_uniformity(
sds: Union[
Sequence[Union[SpectralDistribution, MultiSpectralDistributions]],
SpectralDistribution,
MultiSpectralDistributions,
],
use_second_order_derivatives: bool = False,
Expand Down
1 change: 1 addition & 0 deletions colour/plotting/colorimetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ def plot_single_sd(
def plot_multi_sds(
sds: Union[
Sequence[Union[SpectralDistribution, MultiSpectralDistributions]],
SpectralDistribution,
MultiSpectralDistributions,
],
plot_kwargs: Optional[Union[dict, List[dict]]] = None,
Expand Down
1 change: 1 addition & 0 deletions colour/plotting/diagrams.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,7 @@ def plot_chromaticity_diagram_CIE1976UCS(
def plot_sds_in_chromaticity_diagram(
sds: Union[
Sequence[Union[SpectralDistribution, MultiSpectralDistributions]],
SpectralDistribution,
MultiSpectralDistributions,
],
cmfs: Union[
Expand Down
2 changes: 2 additions & 0 deletions colour/plotting/quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ def plot_single_sd_colour_rendering_index_bars(
def plot_multi_sds_colour_rendering_indexes_bars(
sds: Union[
Sequence[Union[SpectralDistribution, MultiSpectralDistributions]],
SpectralDistribution,
MultiSpectralDistributions,
],
**kwargs: Any,
Expand Down Expand Up @@ -428,6 +429,7 @@ def plot_single_sd_colour_quality_scale_bars(
def plot_multi_sds_colour_quality_scales_bars(
sds: Union[
Sequence[Union[SpectralDistribution, MultiSpectralDistributions]],
SpectralDistribution,
MultiSpectralDistributions,
],
method: Union[
Expand Down

0 comments on commit 45ae2be

Please sign in to comment.