colourmap 1.2.1__tar.gz → 1.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {colourmap-1.2.1/colourmap.egg-info → colourmap-1.2.2}/PKG-INFO +4 -1
- {colourmap-1.2.1 → colourmap-1.2.2}/colourmap/__init__.py +3 -1
- {colourmap-1.2.1 → colourmap-1.2.2}/colourmap/colourmap.py +24 -3
- {colourmap-1.2.1 → colourmap-1.2.2/colourmap.egg-info}/PKG-INFO +4 -1
- colourmap-1.2.2/colourmap.egg-info/requires.txt +7 -0
- {colourmap-1.2.1 → colourmap-1.2.2}/pyproject.toml +9 -0
- {colourmap-1.2.1 → colourmap-1.2.2}/tests/test_colourmap.py +12 -5
- colourmap-1.2.1/colourmap.egg-info/requires.txt +0 -3
- {colourmap-1.2.1 → colourmap-1.2.2}/LICENSE +0 -0
- {colourmap-1.2.1 → colourmap-1.2.2}/MANIFEST.in +0 -0
- {colourmap-1.2.1 → colourmap-1.2.2}/README.md +0 -0
- {colourmap-1.2.1 → colourmap-1.2.2}/colourmap/examples.py +0 -0
- {colourmap-1.2.1 → colourmap-1.2.2}/colourmap.egg-info/SOURCES.txt +0 -0
- {colourmap-1.2.1 → colourmap-1.2.2}/colourmap.egg-info/dependency_links.txt +0 -0
- {colourmap-1.2.1 → colourmap-1.2.2}/colourmap.egg-info/top_level.txt +0 -0
- {colourmap-1.2.1 → colourmap-1.2.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: colourmap
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
4
4
|
Summary: Python package colourmap generates an N unique colors from the specified input colormap.
|
|
5
5
|
Author-email: Erdogan Taskesen <erdogant@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -20,6 +20,9 @@ License-File: LICENSE
|
|
|
20
20
|
Requires-Dist: matplotlib
|
|
21
21
|
Requires-Dist: numpy
|
|
22
22
|
Requires-Dist: scipy
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest; extra == "dev"
|
|
25
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
23
26
|
Dynamic: license-file
|
|
24
27
|
|
|
25
28
|
# colourmap
|
|
@@ -8,13 +8,15 @@ from colourmap.colourmap import (
|
|
|
8
8
|
hex2rgb,
|
|
9
9
|
hex2rgba,
|
|
10
10
|
is_hex_color,
|
|
11
|
+
is_hex,
|
|
12
|
+
is_rgb,
|
|
11
13
|
gradient_on_density_color,
|
|
12
14
|
check_logger,
|
|
13
15
|
)
|
|
14
16
|
|
|
15
17
|
__author__ = 'Erdogan Tasksen'
|
|
16
18
|
__email__ = 'erdogant@gmail.com'
|
|
17
|
-
__version__ = '1.2.
|
|
19
|
+
__version__ = '1.2.2'
|
|
18
20
|
|
|
19
21
|
# Setup root logger
|
|
20
22
|
_logger = logging.getLogger('colourmap')
|
|
@@ -54,6 +54,7 @@ def generate(N, cmap='Set1', method='matplotlib', keep_alpha=False, scheme='rgb'
|
|
|
54
54
|
Returns
|
|
55
55
|
-------
|
|
56
56
|
color_list : numpy array with colors that range between [0-1, 0-1, 0-1].
|
|
57
|
+
When N is zero, RGB output has shape (0, 3), or (0, 4) with alpha.
|
|
57
58
|
|
|
58
59
|
"""
|
|
59
60
|
# Set the logger
|
|
@@ -80,6 +81,8 @@ def generate(N, cmap='Set1', method='matplotlib', keep_alpha=False, scheme='rgb'
|
|
|
80
81
|
else:
|
|
81
82
|
colors = color_list
|
|
82
83
|
|
|
84
|
+
if scheme != 'hex' and len(colors)==0:
|
|
85
|
+
return np.empty((0, listlen))
|
|
83
86
|
return np.array(colors)
|
|
84
87
|
|
|
85
88
|
|
|
@@ -110,6 +113,8 @@ def rgb2hex(colors, keep_alpha=False):
|
|
|
110
113
|
"""
|
|
111
114
|
if isinstance(colors, list):
|
|
112
115
|
colors = np.array(colors)
|
|
116
|
+
if len(colors.shape)==1 and colors.size==0:
|
|
117
|
+
return np.array([], dtype=str)
|
|
113
118
|
if len(colors.shape)==1:
|
|
114
119
|
colors = np.array([colors])
|
|
115
120
|
|
|
@@ -212,9 +217,9 @@ def fromlist(y, X=None, cmap='Set1', gradient=None, method='matplotlib', scheme=
|
|
|
212
217
|
"""Generate colors from input list.
|
|
213
218
|
|
|
214
219
|
This function creates unique colors based on the input list y and the cmap.
|
|
215
|
-
When the gradient hex color is defined, such as '#000000', a gradient
|
|
216
|
-
|
|
217
|
-
|
|
220
|
+
When the gradient hex color is defined, such as '#000000', a gradient
|
|
221
|
+
coloring space is created between two colors: the start color of the
|
|
222
|
+
particular `y` (using `cmap`) and the end color defined by `gradient`.
|
|
218
223
|
|
|
219
224
|
Parameters
|
|
220
225
|
----------
|
|
@@ -406,7 +411,23 @@ def _color_dict(gradient):
|
|
|
406
411
|
return {'hex': hex_colors, 'rgb': rgb_colors}
|
|
407
412
|
|
|
408
413
|
|
|
414
|
+
# Check whether c contains RGB values
|
|
415
|
+
def is_rgb(color, verbose='info'):
|
|
416
|
+
is_rgb_bool = (
|
|
417
|
+
isinstance(color, (list, tuple, np.ndarray))
|
|
418
|
+
and np.asarray(color).ndim == 1
|
|
419
|
+
and len(color) == 3
|
|
420
|
+
and all(isinstance(v, (int, float, np.integer, np.floating)) for v in color)
|
|
421
|
+
)
|
|
422
|
+
return is_rgb_bool
|
|
423
|
+
|
|
424
|
+
|
|
409
425
|
def is_hex_color(color, verbose='info'):
|
|
426
|
+
logger.warning('This function is deprecated and will be removed in a future version. Please use `is_hex` instead.')
|
|
427
|
+
return is_hex(color, verbose=verbose)
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
def is_hex(color, verbose='info'):
|
|
410
431
|
"""Check whether the input is a valid hex color code.
|
|
411
432
|
|
|
412
433
|
verbose : int, (default: 'info')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: colourmap
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
4
4
|
Summary: Python package colourmap generates an N unique colors from the specified input colormap.
|
|
5
5
|
Author-email: Erdogan Taskesen <erdogant@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -20,6 +20,9 @@ License-File: LICENSE
|
|
|
20
20
|
Requires-Dist: matplotlib
|
|
21
21
|
Requires-Dist: numpy
|
|
22
22
|
Requires-Dist: scipy
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest; extra == "dev"
|
|
25
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
23
26
|
Dynamic: license-file
|
|
24
27
|
|
|
25
28
|
# colourmap
|
|
@@ -26,6 +26,12 @@ dependencies = [
|
|
|
26
26
|
'scipy',
|
|
27
27
|
]
|
|
28
28
|
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
dev = [
|
|
31
|
+
"pytest",
|
|
32
|
+
"pytest-cov",
|
|
33
|
+
]
|
|
34
|
+
|
|
29
35
|
[project.urls]
|
|
30
36
|
Homepage = "https://erdogant.github.io/colourmap"
|
|
31
37
|
Download = "https://github.com/erdogant/colourmap/archive/{version}.tar.gz"
|
|
@@ -34,5 +40,8 @@ Download = "https://github.com/erdogant/colourmap/archive/{version}.tar.gz"
|
|
|
34
40
|
packages = ["colourmap"]
|
|
35
41
|
include-package-data = true
|
|
36
42
|
|
|
43
|
+
# [tool.setuptools.package-data]
|
|
44
|
+
# colourmap = ["skills/**/*"]
|
|
45
|
+
|
|
37
46
|
[tool.setuptools.dynamic]
|
|
38
47
|
version = { attr = "colourmap.__version__" }
|
|
@@ -2,11 +2,11 @@ import colourmap
|
|
|
2
2
|
import numpy as np
|
|
3
3
|
|
|
4
4
|
def test_colourmap():
|
|
5
|
-
N
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
for N in range(10):
|
|
6
|
+
# Check size 1
|
|
7
|
+
assert colourmap.generate(N).shape==(N,3)
|
|
8
|
+
# Check size 2
|
|
9
|
+
assert colourmap.generate(N, keep_alpha=True).shape==(N,4)
|
|
10
10
|
# Check 3 conversion
|
|
11
11
|
colors=colourmap.generate(5, cmap='Set1')
|
|
12
12
|
assert np.all(colourmap.rgb2hex(colors)==['#e41a1c', '#4daf4a', '#ff7f00', '#a65628', '#999999'])
|
|
@@ -30,4 +30,11 @@ def test_colourmap():
|
|
|
30
30
|
assert len(out[1].values())==len(np.unique(y))
|
|
31
31
|
|
|
32
32
|
|
|
33
|
+
def test_empty_colors():
|
|
34
|
+
for colors in ([], np.array([]), np.empty((0, 3)), np.empty((0, 4))):
|
|
35
|
+
for keep_alpha in (False, True):
|
|
36
|
+
assert colourmap.rgb2hex(colors, keep_alpha=keep_alpha).shape==(0,)
|
|
37
|
+
|
|
38
|
+
for keep_alpha in (False, True):
|
|
39
|
+
assert colourmap.generate(0, scheme='hex', keep_alpha=keep_alpha).shape==(0,)
|
|
33
40
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|