Skip to content

Conversation

@Erol444
Copy link

@Erol444 Erol444 commented Aug 18, 2022

Initial PR of the Color class

@jack89roberts
Copy link
Collaborator

Great, thanks. Would you be able to add docstrings (in Sphinx format, e.g. see the get_colors docstring:

def get_colors(
n_colors,
exclude_colors=None,
return_excluded=False,
pastel_factor=0,
n_attempts=1000,
colorblind_type=None,
rng=None,
):
"""
Generate a list of n visually distinct colours.
:param n_colors: How many colours to generate
:param exclude_colors: A list of (r,g,b) colours that new colours should be distinct
from. If exclude_colours=None then exclude_colours will be set to avoid white
and black (exclude_colours=[(0,0,0), (1,1,1)]). (r,g,b) values should be floats
between 0 and 1.
:param return_excluded: If return_excluded=True then exclude_colors will be included
in the returned color list. Otherwise only the newly generated colors are
returned (default).
:param pastel_factor: float between 0 and 1. If pastel_factor>0 paler colours will
be generated.
:param n_attempts: number of random colours to generated to find most distinct
colour.
:param colorblind_type: Generate colours that are distinct with given type of
colourblindness. Can be:
* 'Normal': Normal vision
* 'Protanopia': Red-green colorblindness (1% males)
* 'Protanomaly': Red-green colorblindness (1% males, 0.01% females)
* 'Deuteranopia': Red-green colorblindness (1% males)
* 'Deuteranomaly': Red-green colorblindness (most common type: 6% males,
0.4% females)
* 'Tritanopia': Blue-yellow colourblindness (<1% males and females)
* 'Tritanomaly' Blue-yellow colourblindness (0.01% males and females)
* 'Achromatopsia': Total colourblindness
* 'Achromatomaly': Total colourblindness
:param rng: A random integer seed or random.Random state.
If unspecified the global random is used.
:return: colors - A list of (r,g,b) colors that are visually distinct to each other
and to the colours in exclude_colors. (r,g,b) values are floats between 0 and 1.
"""
)

@jack89roberts
Copy link
Collaborator

Could you also run isort on this when it's ready @Erol444 (and black and flake8)? It's causing the checks to fail at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants