colourmap 1.2.0__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.0/colourmap.egg-info → colourmap-1.2.2}/PKG-INFO +10 -25
- {colourmap-1.2.0 → colourmap-1.2.2}/colourmap/__init__.py +3 -1
- {colourmap-1.2.0 → colourmap-1.2.2}/colourmap/colourmap.py +24 -5
- {colourmap-1.2.0 → colourmap-1.2.2/colourmap.egg-info}/PKG-INFO +10 -25
- {colourmap-1.2.0 → colourmap-1.2.2}/colourmap.egg-info/SOURCES.txt +0 -1
- colourmap-1.2.2/colourmap.egg-info/requires.txt +7 -0
- {colourmap-1.2.0 → colourmap-1.2.2}/pyproject.toml +15 -2
- colourmap-1.2.2/setup.cfg +4 -0
- {colourmap-1.2.0 → colourmap-1.2.2}/tests/test_colourmap.py +12 -5
- colourmap-1.2.0/colourmap.egg-info/requires.txt +0 -3
- colourmap-1.2.0/setup.cfg +0 -15
- {colourmap-1.2.0 → colourmap-1.2.2}/LICENSE +0 -0
- {colourmap-1.2.0 → colourmap-1.2.2}/MANIFEST.in +0 -0
- {colourmap-1.2.0 → colourmap-1.2.2}/README.md +0 -0
- {colourmap-1.2.0 → colourmap-1.2.2}/colourmap/examples.py +0 -0
- {colourmap-1.2.0 → colourmap-1.2.2}/colourmap.egg-info/dependency_links.txt +0 -0
- {colourmap-1.2.0 → colourmap-1.2.2}/colourmap.egg-info/top_level.txt +0 -0
|
@@ -1,43 +1,28 @@
|
|
|
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
|
-
License: MIT
|
|
7
|
-
|
|
8
|
-
Copyright (c) 2020 Erdogan Taskesen
|
|
9
|
-
Colourmap generates an N unique colors from the specified input colormap.
|
|
10
|
-
|
|
11
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
-
in the Software without restriction, including without limitation the rights
|
|
14
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
-
furnished to do so, subject to the following conditions:
|
|
17
|
-
|
|
18
|
-
The above copyright notice and this permission notice shall be included in all
|
|
19
|
-
copies or substantial portions of the Software.
|
|
20
|
-
|
|
21
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
-
SOFTWARE.
|
|
28
|
-
|
|
6
|
+
License-Expression: MIT
|
|
29
7
|
Project-URL: Homepage, https://erdogant.github.io/colourmap
|
|
30
8
|
Project-URL: Download, https://github.com/erdogant/colourmap/archive/{version}.tar.gz
|
|
31
9
|
Keywords: Python,
|
|
32
10
|
Classifier: Programming Language :: Python :: 3
|
|
33
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
34
11
|
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Intended Audience :: Education
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Operating System :: Unix
|
|
15
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
16
|
+
Classifier: Operating System :: MacOS
|
|
35
17
|
Requires-Python: >=3
|
|
36
18
|
Description-Content-Type: text/markdown
|
|
37
19
|
License-File: LICENSE
|
|
38
20
|
Requires-Dist: matplotlib
|
|
39
21
|
Requires-Dist: numpy
|
|
40
22
|
Requires-Dist: scipy
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest; extra == "dev"
|
|
25
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
41
26
|
Dynamic: license-file
|
|
42
27
|
|
|
43
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')
|
|
@@ -13,8 +13,6 @@ import numpy as np
|
|
|
13
13
|
import logging
|
|
14
14
|
|
|
15
15
|
logger = logging.getLogger(__name__)
|
|
16
|
-
if not logger.hasHandlers():
|
|
17
|
-
logging.basicConfig(level=logging.INFO, format='[{asctime}] [{name}] [{levelname}] {msg}', style='{', datefmt='%d-%m-%Y %H:%M:%S')
|
|
18
16
|
|
|
19
17
|
|
|
20
18
|
# %% Main
|
|
@@ -56,6 +54,7 @@ def generate(N, cmap='Set1', method='matplotlib', keep_alpha=False, scheme='rgb'
|
|
|
56
54
|
Returns
|
|
57
55
|
-------
|
|
58
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.
|
|
59
58
|
|
|
60
59
|
"""
|
|
61
60
|
# Set the logger
|
|
@@ -82,6 +81,8 @@ def generate(N, cmap='Set1', method='matplotlib', keep_alpha=False, scheme='rgb'
|
|
|
82
81
|
else:
|
|
83
82
|
colors = color_list
|
|
84
83
|
|
|
84
|
+
if scheme != 'hex' and len(colors)==0:
|
|
85
|
+
return np.empty((0, listlen))
|
|
85
86
|
return np.array(colors)
|
|
86
87
|
|
|
87
88
|
|
|
@@ -112,6 +113,8 @@ def rgb2hex(colors, keep_alpha=False):
|
|
|
112
113
|
"""
|
|
113
114
|
if isinstance(colors, list):
|
|
114
115
|
colors = np.array(colors)
|
|
116
|
+
if len(colors.shape)==1 and colors.size==0:
|
|
117
|
+
return np.array([], dtype=str)
|
|
115
118
|
if len(colors.shape)==1:
|
|
116
119
|
colors = np.array([colors])
|
|
117
120
|
|
|
@@ -214,9 +217,9 @@ def fromlist(y, X=None, cmap='Set1', gradient=None, method='matplotlib', scheme=
|
|
|
214
217
|
"""Generate colors from input list.
|
|
215
218
|
|
|
216
219
|
This function creates unique colors based on the input list y and the cmap.
|
|
217
|
-
When the gradient hex color is defined, such as '#000000', a gradient
|
|
218
|
-
|
|
219
|
-
|
|
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`.
|
|
220
223
|
|
|
221
224
|
Parameters
|
|
222
225
|
----------
|
|
@@ -408,7 +411,23 @@ def _color_dict(gradient):
|
|
|
408
411
|
return {'hex': hex_colors, 'rgb': rgb_colors}
|
|
409
412
|
|
|
410
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
|
+
|
|
411
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'):
|
|
412
431
|
"""Check whether the input is a valid hex color code.
|
|
413
432
|
|
|
414
433
|
verbose : int, (default: 'info')
|
|
@@ -1,43 +1,28 @@
|
|
|
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
|
-
License: MIT
|
|
7
|
-
|
|
8
|
-
Copyright (c) 2020 Erdogan Taskesen
|
|
9
|
-
Colourmap generates an N unique colors from the specified input colormap.
|
|
10
|
-
|
|
11
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
-
in the Software without restriction, including without limitation the rights
|
|
14
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
-
furnished to do so, subject to the following conditions:
|
|
17
|
-
|
|
18
|
-
The above copyright notice and this permission notice shall be included in all
|
|
19
|
-
copies or substantial portions of the Software.
|
|
20
|
-
|
|
21
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
-
SOFTWARE.
|
|
28
|
-
|
|
6
|
+
License-Expression: MIT
|
|
29
7
|
Project-URL: Homepage, https://erdogant.github.io/colourmap
|
|
30
8
|
Project-URL: Download, https://github.com/erdogant/colourmap/archive/{version}.tar.gz
|
|
31
9
|
Keywords: Python,
|
|
32
10
|
Classifier: Programming Language :: Python :: 3
|
|
33
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
34
11
|
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Intended Audience :: Education
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Operating System :: Unix
|
|
15
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
16
|
+
Classifier: Operating System :: MacOS
|
|
35
17
|
Requires-Python: >=3
|
|
36
18
|
Description-Content-Type: text/markdown
|
|
37
19
|
License-File: LICENSE
|
|
38
20
|
Requires-Dist: matplotlib
|
|
39
21
|
Requires-Dist: numpy
|
|
40
22
|
Requires-Dist: scipy
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest; extra == "dev"
|
|
25
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
41
26
|
Dynamic: license-file
|
|
42
27
|
|
|
43
28
|
# colourmap
|
|
@@ -9,12 +9,16 @@ authors = [{ name = "Erdogan Taskesen", email = "erdogant@gmail.com" },]
|
|
|
9
9
|
description = "Python package colourmap generates an N unique colors from the specified input colormap."
|
|
10
10
|
readme = "README.md"
|
|
11
11
|
requires-python = ">=3"
|
|
12
|
-
license =
|
|
12
|
+
license = "MIT"
|
|
13
13
|
keywords = ["Python", ""]
|
|
14
14
|
classifiers = [
|
|
15
15
|
"Programming Language :: Python :: 3",
|
|
16
|
-
"License :: OSI Approved :: MIT License",
|
|
17
16
|
"Operating System :: OS Independent",
|
|
17
|
+
"Intended Audience :: Education",
|
|
18
|
+
"Intended Audience :: Science/Research",
|
|
19
|
+
"Operating System :: Unix",
|
|
20
|
+
"Operating System :: Microsoft :: Windows",
|
|
21
|
+
"Operating System :: MacOS",
|
|
18
22
|
]
|
|
19
23
|
dependencies = [
|
|
20
24
|
'matplotlib',
|
|
@@ -22,6 +26,12 @@ dependencies = [
|
|
|
22
26
|
'scipy',
|
|
23
27
|
]
|
|
24
28
|
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
dev = [
|
|
31
|
+
"pytest",
|
|
32
|
+
"pytest-cov",
|
|
33
|
+
]
|
|
34
|
+
|
|
25
35
|
[project.urls]
|
|
26
36
|
Homepage = "https://erdogant.github.io/colourmap"
|
|
27
37
|
Download = "https://github.com/erdogant/colourmap/archive/{version}.tar.gz"
|
|
@@ -30,5 +40,8 @@ Download = "https://github.com/erdogant/colourmap/archive/{version}.tar.gz"
|
|
|
30
40
|
packages = ["colourmap"]
|
|
31
41
|
include-package-data = true
|
|
32
42
|
|
|
43
|
+
# [tool.setuptools.package-data]
|
|
44
|
+
# colourmap = ["skills/**/*"]
|
|
45
|
+
|
|
33
46
|
[tool.setuptools.dynamic]
|
|
34
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
|
|
colourmap-1.2.0/setup.cfg
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
[metadata]
|
|
2
|
-
description_file = README.md
|
|
3
|
-
|
|
4
|
-
[versioneer]
|
|
5
|
-
VCS = git
|
|
6
|
-
style = pep440
|
|
7
|
-
versionfile_source = colourmap/_version.py
|
|
8
|
-
versionfile_build = colourmap/_version.py
|
|
9
|
-
tag_prefix =
|
|
10
|
-
parentdir_prefix = colourmap-
|
|
11
|
-
|
|
12
|
-
[egg_info]
|
|
13
|
-
tag_build =
|
|
14
|
-
tag_date = 0
|
|
15
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|