Skip to content

Commit

Permalink
Merge pull request #3 from lmcinnes/py39
Browse files Browse the repository at this point in the history
Update to provide python 3.9 support
  • Loading branch information
lmcinnes committed Nov 16, 2022
2 parents 413562e + ada8ad8 commit ff5038c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
9 changes: 9 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
18 changes: 9 additions & 9 deletions glasbey/_glasbey.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand All @@ -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
Expand Down Expand Up @@ -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=(
Expand Down Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions glasbey/_grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ 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

[options]
zip_safe = False
packages = glasbey
python_requires = >=3.10
python_requires = >=3.9
install_requires =
numpy>=1.21
numba>=0.56
Expand Down

0 comments on commit ff5038c

Please sign in to comment.