diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7f2d030..1280db4 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -10,6 +10,15 @@ trigger: # https://github.com/Microsoft/azure-pipelines-yaml/issues/20 strategy: matrix: + mac_py39: + imageName: 'macOS-latest' + python.version: '3.9' + linux_py39: + imageName: 'ubuntu-latest' + python.version: '3.9' + windows_py39: + imageName: 'windows-latest' + python.version: '3.9' mac_py310: imageName: 'macOS-latest' python.version: '3.10' diff --git a/glasbey/_glasbey.py b/glasbey/_glasbey.py index 6a62893..e535e23 100644 --- a/glasbey/_glasbey.py +++ b/glasbey/_glasbey.py @@ -16,7 +16,7 @@ def create_palette( palette_size: int = 256, *, - grid_size: int | Tuple[int, int, int] = 64, + grid_size: Union[int, Tuple[int, int, int]] = 64, as_hex: bool = True, grid_space: Literal["RGB", "JCh"] = "RGB", lightness_bounds: Tuple[float, float] = (10, 90), @@ -25,7 +25,7 @@ def create_palette( red_bounds: Tuple[float, float] = (0, 1), green_bounds: Tuple[float, float] = (0, 1), blue_bounds: Tuple[float, float] = (0, 1), -) -> List[str] | np.ndarray: +) -> Union[List[str], np.ndarray]: """Create a categorical color palette with ``palette_size`` many colours using the Glasbey algorithm with the given bounds on hue, chroma and lightness. This should generate a palette that maximizes the perceptual distances between colours in the palette up to the constraints on hue, chroma and lightness, and the granularity of the @@ -122,7 +122,7 @@ def extend_palette( palette, palette_size: int = 256, *, - grid_size: int | Tuple[int, int, int] = 64, # type: ignore + grid_size: Union[int, Tuple[int, int, int]] = 64, # type: ignore as_hex: bool = True, grid_space: Literal["RGB", "JCh"] = "RGB", lightness_bounds: Optional[Tuple[float, float]] = None, @@ -131,7 +131,7 @@ def extend_palette( red_bounds: Tuple[float, float] = (0, 1), green_bounds: Tuple[float, float] = (0, 1), blue_bounds: Tuple[float, float] = (0, 1), -) -> List[str] | np.ndarray: +) -> Union[List[str], np.ndarray]: """Extend an existing categorical color palette to have ``palette_size`` many colors using the Glasbey algorithm. This should generate a palette that maximizes the perceptual distances between colours in the palette up to the constraints on hue, chroma and lightness, and the granularity of the possible colour sampling grid. If the @@ -270,7 +270,7 @@ def create_theme_palette( hue_bend_scale: float = 6.0, max_hue_bend: float = 45.0, as_hex: bool = True, -) -> List[str] | List[Tuple[float, float, float]]: +) -> Union[List[str], List[Tuple[float, float, float]]]: """Create a color palette with a range of colors around a central theme color that vary smoothly in a range of lightness, chroma and (to less of a degree) hue. The goal is to generate a smooth color palette that provides some variation of colors while remaining relatively close to the base color. This is primarily for @@ -391,7 +391,7 @@ def create_block_palette( block_sizes: List[int], *, sort_block_sizes: bool = True, - grid_size: int | Tuple[int, int, int] = 64, # type: ignore + grid_size: Union[int, Tuple[int, int, int]] = 64, # type: ignore grid_space: Literal["RGB", "JCh"] = "RGB", generated_color_lightness_bounds: Tuple[float, float] = (30.0, 60.0), generated_color_chroma_bounds: Tuple[float, float] = (60.0, 90.0), @@ -405,7 +405,7 @@ def create_block_palette( hue_bend_scale: float = 6.0, max_hue_bend: float = 45.0, as_hex: bool = True, -) -> List[str] | List[Tuple[float, float, float]]: +) -> Union[List[str], List[Tuple[float, float, float]]]: """Create a categorical color palette in blocks using the Glasbey algorithm. This should generate a palette that maximizes the perceptual distances between blocks in the palette up to the constraints on hue, chroma and lightness, and the granularity of the possible colour sampling grid. In turn each @@ -497,7 +497,7 @@ def create_block_palette( else: block_sizes_for_generation = block_sizes - palette: List[str] | List[Tuple[float, float, float]] = [] # type: ignore + palette: Union[List[str], List[Tuple[float, float, float]]] = [] # type: ignore initial_color = create_palette( 1, lightness_bounds=( @@ -579,7 +579,7 @@ def create_block_palette( block_start_indices = np.hstack( ([0], np.cumsum(block_sizes_for_generation)[:-1]) ) - result: List[str] | List[Tuple[float, float, float]] = [] # type: ignore + result: Union[List[str], List[Tuple[float, float, float]]] = [] # type: ignore for i in np.argsort(block_order): size = block_sizes_for_generation[i] diff --git a/glasbey/_grids.py b/glasbey/_grids.py index afeaaef..95b6fd2 100644 --- a/glasbey/_grids.py +++ b/glasbey/_grids.py @@ -5,11 +5,11 @@ from colorspacious import cspace_convert -from typing import Tuple +from typing import Tuple, Union def rgb_grid( - grid_size: int | Tuple[int, int, int] = 64, + grid_size: Union[int, Tuple[int, int, int]] = 64, red_bounds: Tuple[float, float] = (0, 1), green_bounds: Tuple[float, float] = (0, 1), blue_bounds: Tuple[float, float] = (0, 1), @@ -93,7 +93,7 @@ def rgb_grid( def jch_grid( - grid_size: int | Tuple[int, int, int] = 64, + grid_size: Union[int, Tuple[int, int, int]] = 64, lightness_bounds: Tuple[float, float] = (10, 90), chroma_bounds: Tuple[float, float] = (10, 90), hue_bounds: Tuple[float, float] = (0, 360), diff --git a/setup.cfg b/setup.cfg index 270616f..2631cce 100644 --- a/setup.cfg +++ b/setup.cfg @@ -13,6 +13,7 @@ license = MIT License license_files = LICENSE classifiers = License :: OSI Approved :: MIT License + Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Development Status :: 4 - Beta Operating System :: OS Independent @@ -20,7 +21,7 @@ classifiers = [options] zip_safe = False packages = glasbey -python_requires = >=3.10 +python_requires = >=3.9 install_requires = numpy>=1.21 numba>=0.56