66from itertools import chain
77
88import numpy as np
9+ from numpy import typing as npt
910import scipy .interpolate as interp
1011import matplotlib as mpl
1112if os .name == 'posix' and 'DISPLAY' not in os .environ :
@@ -618,7 +619,7 @@ def adjust_hue(msh_sat, m_unsat):
618619
619620
620621 @staticmethod
621- def _hsv2rgb (hsv : np .ndarray ) -> np .ndarray :
622+ def _hsv2rgb (hsv : npt . NDArray [ np .floating ] ) -> npt . NDArray [ np .floating ] :
622623 """
623624 Hue Saturation Value to Red Green Blue.
624625
@@ -635,7 +636,7 @@ def _hsv2rgb(hsv: np.ndarray) -> np.ndarray:
635636 return np .array (colorsys .hsv_to_rgb (hsv [0 ]/ 360. ,hsv [1 ],hsv [2 ]))
636637
637638 @staticmethod
638- def _rgb2hsv (rgb : np .ndarray ) -> np .ndarray :
639+ def _rgb2hsv (rgb : npt . NDArray [ np .floating ] ) -> npt . NDArray [ np .floating ] :
639640 """
640641 Red Green Blue to Hue Saturation Value.
641642
@@ -654,7 +655,7 @@ def _rgb2hsv(rgb: np.ndarray) -> np.ndarray:
654655
655656
656657 @staticmethod
657- def _hsl2rgb (hsl : np .ndarray ) -> np .ndarray :
658+ def _hsl2rgb (hsl : npt . NDArray [ np .floating ] ) -> npt . NDArray [ np .floating ] :
658659 """
659660 Hue Saturation Luminance to Red Green Blue.
660661
@@ -671,7 +672,7 @@ def _hsl2rgb(hsl: np.ndarray) -> np.ndarray:
671672 return np .array (colorsys .hls_to_rgb (hsl [0 ]/ 360. ,hsl [2 ],hsl [1 ]))
672673
673674 @staticmethod
674- def _rgb2hsl (rgb : np .ndarray ) -> np .ndarray :
675+ def _rgb2hsl (rgb : npt . NDArray [ np .floating ] ) -> npt . NDArray [ np .floating ] :
675676 """
676677 Red Green Blue to Hue Saturation Luminance.
677678
@@ -690,7 +691,7 @@ def _rgb2hsl(rgb: np.ndarray) -> np.ndarray:
690691
691692
692693 @staticmethod
693- def _xyz2rgb (xyz : np .ndarray ) -> np .ndarray :
694+ def _xyz2rgb (xyz : npt . NDArray [ np .floating ] ) -> npt . NDArray [ np .floating ] :
694695 """
695696 CIEXYZ to Red Green Blue.
696697
@@ -719,7 +720,7 @@ def _xyz2rgb(xyz: np.ndarray) -> np.ndarray:
719720 return np .clip (rgb ,0. ,1. )
720721
721722 @staticmethod
722- def _rgb2xyz (rgb : np .ndarray ) -> np .ndarray :
723+ def _rgb2xyz (rgb : npt . NDArray [ np .floating ] ) -> npt . NDArray [ np .floating ] :
723724 """
724725 Red Green Blue to CIEXYZ.
725726
@@ -746,8 +747,8 @@ def _rgb2xyz(rgb: np.ndarray) -> np.ndarray:
746747
747748
748749 @staticmethod
749- def _lab2xyz (lab : np .ndarray ,
750- ref_white : np .ndarray = _REF_WHITE ) -> np .ndarray :
750+ def _lab2xyz (lab : npt . NDArray [ np .floating ] ,
751+ ref_white : npt . NDArray [ np .floating ] = _REF_WHITE ) -> npt . NDArray [ np .floating ] :
751752 """
752753 CIELAB to CIEXYZ.
753754
@@ -778,8 +779,8 @@ def _lab2xyz(lab: np.ndarray,
778779 ])* ref_white
779780
780781 @staticmethod
781- def _xyz2lab (xyz : np .ndarray ,
782- ref_white : np .ndarray = _REF_WHITE ) -> np .ndarray :
782+ def _xyz2lab (xyz : npt . NDArray [ np .floating ] ,
783+ ref_white : npt . NDArray [ np .floating ] = _REF_WHITE ) -> npt . NDArray [ np .floating ] :
783784 """
784785 CIEXYZ to CIELAB.
785786
@@ -812,7 +813,7 @@ def _xyz2lab(xyz: np.ndarray,
812813
813814
814815 @staticmethod
815- def _lab2msh (lab : np .ndarray ) -> np .ndarray :
816+ def _lab2msh (lab : npt . NDArray [ np .floating ] ) -> npt . NDArray [ np .floating ] :
816817 """
817818 CIELAB to Msh.
818819
@@ -839,7 +840,7 @@ def _lab2msh(lab: np.ndarray) -> np.ndarray:
839840 ])
840841
841842 @staticmethod
842- def _msh2lab (msh : np .ndarray ) -> np .ndarray :
843+ def _msh2lab (msh : npt . NDArray [ np .floating ] ) -> npt . NDArray [ np .floating ] :
843844 """
844845 Msh to CIELAB.
845846
@@ -865,7 +866,7 @@ def _msh2lab(msh: np.ndarray) -> np.ndarray:
865866 ])
866867
867868 @staticmethod
868- def _lab2rgb (lab : np .ndarray ) -> np .ndarray :
869+ def _lab2rgb (lab : npt . NDArray [ np .floating ] ) -> npt . NDArray [ np .floating ] :
869870 """
870871 CIELAB to Red Green Blue.
871872
@@ -882,7 +883,7 @@ def _lab2rgb(lab: np.ndarray) -> np.ndarray:
882883 return Colormap ._xyz2rgb (Colormap ._lab2xyz (lab ))
883884
884885 @staticmethod
885- def _rgb2lab (rgb : np .ndarray ) -> np .ndarray :
886+ def _rgb2lab (rgb : npt . NDArray [ np .floating ] ) -> npt . NDArray [ np .floating ] :
886887 """
887888 Red Green Blue to CIELAB.
888889
@@ -899,7 +900,7 @@ def _rgb2lab(rgb: np.ndarray) -> np.ndarray:
899900 return Colormap ._xyz2lab (Colormap ._rgb2xyz (rgb ))
900901
901902 @staticmethod
902- def _msh2rgb (msh : np .ndarray ) -> np .ndarray :
903+ def _msh2rgb (msh : npt . NDArray [ np .floating ] ) -> npt . NDArray [ np .floating ] :
903904 """
904905 Msh to Red Green Blue.
905906
@@ -916,7 +917,7 @@ def _msh2rgb(msh: np.ndarray) -> np.ndarray:
916917 return Colormap ._lab2rgb (Colormap ._msh2lab (msh ))
917918
918919 @staticmethod
919- def _rgb2msh (rgb : np .ndarray ) -> np .ndarray :
920+ def _rgb2msh (rgb : npt . NDArray [ np .floating ] ) -> npt . NDArray [ np .floating ] :
920921 """
921922 Red Green Blue to Msh.
922923
@@ -933,7 +934,7 @@ def _rgb2msh(rgb: np.ndarray) -> np.ndarray:
933934 return Colormap ._lab2msh (Colormap ._rgb2lab (rgb ))
934935
935936 @staticmethod
936- def _hsv2msh (hsv : np .ndarray ) -> np .ndarray :
937+ def _hsv2msh (hsv : npt . NDArray [ np .floating ] ) -> npt . NDArray [ np .floating ] :
937938 """
938939 Hue Saturation Value to msh.
939940
@@ -950,7 +951,7 @@ def _hsv2msh(hsv: np.ndarray) -> np.ndarray:
950951 return Colormap ._rgb2msh (Colormap ._hsv2rgb (hsv ))
951952
952953 @staticmethod
953- def _hsl2msh (hsl : np .ndarray ) -> np .ndarray :
954+ def _hsl2msh (hsl : npt . NDArray [ np .floating ] ) -> npt . NDArray [ np .floating ] :
954955 """
955956 Hue Saturation Luminance to Msh.
956957
@@ -967,7 +968,7 @@ def _hsl2msh(hsl: np.ndarray) -> np.ndarray:
967968 return Colormap ._rgb2msh (Colormap ._hsl2rgb (hsl ))
968969
969970 @staticmethod
970- def _xyz2msh (xyz : np .ndarray ) -> np .ndarray :
971+ def _xyz2msh (xyz : npt . NDArray [ np .floating ] ) -> npt . NDArray [ np .floating ] :
971972 """
972973 CIEXYZ to Msh.
973974
0 commit comments