from colorspace import RGB, hexcols, compare_colors
# Three RGB colors
a = RGB([0.5, 0.5], [0.1, 0.1], [0.9, 0.9])
b = RGB([0.5, 0.5], [0.1, 0.1], [0.9, 0.91])
compare_colors(a, b)np.False_
Documentation built with Python 3.11.10, pyp2qmd 0.1.1 and quarto 1.5.57 on GitHub.
Compares two sets of colors based on two color objects. The objects provided on argument a and b must inherit from colorobject. This can be any of the following classes: CIELAB, CIELUV, CIEXYZ, HLS, HSV, RGB, hexcols, polarLAB, polarLUV, or sRGB.
compare_colors(a, b, exact=False, _all=True,
atol=None)
acolorobject
colorobject.
bcolorobject
colorobject.
exactbool
False, check for colors being nearly equal (see atol). If set to True the coordinates must be identical. Note: in case a and b are hex colors (colorspace.colorlib.hexcols) strings will always be matched exactly.
_allbool
True; the function will return True if all colors are identical/nearly equal. If set to False the return will be a list of bool containing True and False for each pair of colors.
atolNone or float
exact = False, else atol = 1e-6 is used. If set to None the tolerance will automatically be set depending on the type of the objects. Defaults to None.
bool, list: Returns True if all colors of a are exactly equal or nearly equal (see arguments) to the colors in object b. If _all = False, a list of bool is returned indicating pair-wise comparison of all colors in a and b.
from colorspace import RGB, hexcols, compare_colors
# Three RGB colors
a = RGB([0.5, 0.5], [0.1, 0.1], [0.9, 0.9])
b = RGB([0.5, 0.5], [0.1, 0.1], [0.9, 0.91])
compare_colors(a, b)np.False_
# Same example using two sets of hexcolor objects
x = hexcols(["#ff00ff", "#003300"])
y = hexcols(["#ff00ff", "#003301"])
compare_colors(x, y)np.False_
TypeError: If a or b are not objects of a class which inherits from colorobject.
TypeError: If a and b are not of the same class.
ValueError: If a and b are not of the same length, i.e., do not contain the same number of colors.
TypeError: If exact or _all are not bool.
TypeError: If atol is neither None nor float.
ValueError: If atol is not larger than 0.