SecretColors 1.2.3__tar.gz → 2.0.0__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.
Files changed (83) hide show
  1. {SecretColors-1.2.3 → secretcolors-2.0.0}/.gitignore +4 -0
  2. secretcolors-2.0.0/CHANGELOG.md +201 -0
  3. {SecretColors-1.2.3 → secretcolors-2.0.0}/LICENSE +0 -0
  4. secretcolors-2.0.0/PKG-INFO +68 -0
  5. {SecretColors-1.2.3 → secretcolors-2.0.0}/PYPI.md +4 -1
  6. secretcolors-2.0.0/README.md +468 -0
  7. secretcolors-2.0.0/SecretColors/__init__.py +21 -0
  8. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/cmaps/__init__.py +5 -0
  9. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/cmaps/brewer.py +125 -41
  10. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/cmaps/colorblind.py +0 -0
  11. secretcolors-2.0.0/SecretColors/cmaps/maps.py +375 -0
  12. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/cmaps/parent.py +116 -85
  13. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/cmaps/tableau.py +118 -41
  14. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/data/__init__.py +0 -0
  15. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/data/cmaps/__init__.py +0 -0
  16. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/data/cmaps/brewer.py +0 -0
  17. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/data/cmaps/colorblind.py +1 -1
  18. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/data/cmaps/tableau.py +0 -0
  19. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/data/constants.py +6 -2
  20. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/data/names/__init__.py +0 -0
  21. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/data/names/w3.py +0 -0
  22. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/data/names/x11.py +0 -0
  23. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/data/palettes/__init__.py +3 -1
  24. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/data/palettes/brewer.py +0 -0
  25. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/data/palettes/clarity.py +0 -0
  26. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/data/palettes/ibm.py +0 -0
  27. secretcolors-2.0.0/SecretColors/data/palettes/latitude.py +82 -0
  28. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/data/palettes/material.py +99 -0
  29. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/data/palettes/parent.py +0 -0
  30. secretcolors-2.0.0/SecretColors/data/palettes/spectrum.py +175 -0
  31. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/data/palettes/tableau.py +0 -0
  32. secretcolors-2.0.0/SecretColors/data/palettes/todo.py +12 -0
  33. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/data/rgb_xyz.py +16 -0
  34. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/helpers/__init__.py +0 -0
  35. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/helpers/decorators.py +3 -11
  36. secretcolors-2.0.0/SecretColors/helpers/logging.py +106 -0
  37. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/helpers/rxutils.py +33 -26
  38. secretcolors-2.0.0/SecretColors/image.py +177 -0
  39. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/models/__init__.py +0 -0
  40. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/models/base.py +11 -8
  41. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/models/objects.py +79 -36
  42. {SecretColors-1.2.3 → secretcolors-2.0.0}/SecretColors/models/palette.py +341 -302
  43. secretcolors-2.0.0/SecretColors/selection.py +258 -0
  44. secretcolors-2.0.0/SecretColors/utils.py +1064 -0
  45. secretcolors-2.0.0/pyproject.toml +62 -0
  46. {SecretColors-1.2.3 → secretcolors-2.0.0}/test/__init__.py +0 -0
  47. {SecretColors-1.2.3 → secretcolors-2.0.0}/test/test_base.py +0 -0
  48. secretcolors-2.0.0/test/test_cmaps.py +60 -0
  49. secretcolors-2.0.0/test/test_image.py +106 -0
  50. secretcolors-2.0.0/test/test_maps.py +242 -0
  51. secretcolors-2.0.0/test/test_objects.py +158 -0
  52. secretcolors-2.0.0/test/test_palette.py +212 -0
  53. secretcolors-2.0.0/test/test_selection.py +86 -0
  54. secretcolors-2.0.0/test/test_utils.py +289 -0
  55. SecretColors-1.2.3/.readthedocs.yml +0 -23
  56. SecretColors-1.2.3/CHANGELOG.md +0 -98
  57. SecretColors-1.2.3/MANIFEST.in +0 -1
  58. SecretColors-1.2.3/PKG-INFO +0 -44
  59. SecretColors-1.2.3/README.md +0 -188
  60. SecretColors-1.2.3/SecretColors/__init__.py +0 -10
  61. SecretColors-1.2.3/SecretColors/data/palettes/todo.py +0 -16
  62. SecretColors-1.2.3/SecretColors/helpers/logging.py +0 -101
  63. SecretColors-1.2.3/SecretColors/utils.py +0 -722
  64. SecretColors-1.2.3/SecretColors.egg-info/PKG-INFO +0 -44
  65. SecretColors-1.2.3/SecretColors.egg-info/SOURCES.txt +0 -61
  66. SecretColors-1.2.3/SecretColors.egg-info/dependency_links.txt +0 -1
  67. SecretColors-1.2.3/SecretColors.egg-info/requires.txt +0 -1
  68. SecretColors-1.2.3/SecretColors.egg-info/top_level.txt +0 -2
  69. SecretColors-1.2.3/docs/Makefile +0 -19
  70. SecretColors-1.2.3/docs/api.rst +0 -52
  71. SecretColors-1.2.3/docs/conf.py +0 -208
  72. SecretColors-1.2.3/docs/index.rst +0 -30
  73. SecretColors-1.2.3/docs/make.bat +0 -36
  74. SecretColors-1.2.3/docs/map_intro.rst +0 -28
  75. SecretColors-1.2.3/meta.yaml +0 -59
  76. SecretColors-1.2.3/requirements-test.txt +0 -7
  77. SecretColors-1.2.3/requirements.txt +0 -1
  78. SecretColors-1.2.3/setup.cfg +0 -4
  79. SecretColors-1.2.3/setup.py +0 -32
  80. SecretColors-1.2.3/test/test_objects.py +0 -90
  81. SecretColors-1.2.3/test/test_palette.py +0 -18
  82. SecretColors-1.2.3/test/test_utils.py +0 -53
  83. SecretColors-1.2.3/tox.ini +0 -21
@@ -105,3 +105,7 @@ venv.bak/
105
105
  .pypirc
106
106
  .idea/
107
107
  test.py
108
+ .DS_Store
109
+
110
+ # Serena Related
111
+ .serena/*
@@ -0,0 +1,201 @@
1
+ # Changelog
2
+ ## v2.0.0
3
+ ### New palettes and features
4
+ * New palettes: Adobe Spectrum (`Palette("spectrum")`) and Flexport Latitude
5
+ (`Palette("latitude")`).
6
+ * `SecretColors.image.extract_palette()` generates a color palette from an
7
+ image (needs `pip install "SecretColors[image]"`).
8
+ * CIE-L\*a\*b\* support: `xyz_to_lab`, `lab_to_xyz`, `rgb_to_lab`,
9
+ `lab_to_rgb`, `hex_to_lab`, `lab_to_hex`, `lab_to_lch`, `lch_to_lab`.
10
+ * `delta_e()` measures perceptual color difference (CIEDE2000 or CIE76).
11
+ * `rgb_to_xyz` / `xyz_to_rgb` accept `space=` for all 16 supported RGB
12
+ colorspaces (e.g. `pro_photo`, `wide_gamut`, `apple`). `rgb_spaces()`
13
+ lists them. Unknown colorspace or white reference raises `ValueError`
14
+ (earlier `AttributeError`).
15
+ * `distinct_colors(n)` picks colors which stay distinct for normal vision,
16
+ protanopia and deuteranopia and have enough contrast with the background.
17
+ `check_colors()` reports how distinct any set of colors is.
18
+ * `Palette.cycle()` yields colorblind-safe distinct colors in the same order
19
+ as `distinct_colors()`, so it can be used directly in loops. Earlier
20
+ sequence had red next to green and low contrast yellow. New `background`
21
+ and `colorblind_safe` arguments.
22
+ * WCAG accessibility: `contrast_ratio()` and `is_readable()`.
23
+ `relative_luminance()` accepts RGB tuples as well.
24
+ * Perceptual mixing: `mix()`, and `space="lab"` / `"lch"` option in
25
+ `color_in_between()`, `ColorString.blend()`, `cmaps.colors()` and
26
+ `cmaps.cmap()` for smoother gradients. `blend()` accepts `ratio`.
27
+ * Colors, lists of colors, palettes and `ColorWheel` show swatches in Jupyter
28
+ notebooks. Functions returning several colors return `ColorList`, a
29
+ regular `list` subclass. `ColorWheel.color` returns `ColorString`.
30
+ ### New colormap API
31
+ * `SecretColors.cmaps.register()` registers every colormap (and its
32
+ reversed `_r` version) in matplotlib with `sc.` prefix. Use them by name
33
+ anywhere matplotlib colormap names are accepted, e.g.
34
+ `plt.imshow(data, cmap="sc.greens")`.
35
+ * `SecretColors.cmaps.cmap(name, ...)` returns matplotlib colormap object
36
+ directly. matplotlib is imported automatically, no need to pass it.
37
+ * `SecretColors.cmaps.colors(name, ...)` returns plain hex colors which can
38
+ be used with any library (plotly, bokeh, altair, seaborn, CSS). It does not
39
+ need matplotlib.
40
+ * `SecretColors.cmaps.available()` lists all colormap names.
41
+ * Colorblind safe colormaps (Okabe-Ito `cud` and Paul Tol's schemes) are
42
+ now accessible.
43
+ * Diverging and sequential colormaps can be interpolated to any number of
44
+ colors and cropped with `start` / `end`.
45
+ * `ColorMap`, `BrewerMap` and `TableauMap` work as before. Passing
46
+ `matplotlib` to them is optional now.
47
+ ### Bug fixes
48
+ * Fixed invalid color in Paul Tol's `tol_bu_rd` colormap.
49
+ * `hexa` / `ahex` color modes now encode alpha on the 0-255 scale. Earlier,
50
+ fully opaque colors were written as `64` (~39% opacity) instead of `ff`.
51
+ * `Palette.random()` no longer crashes when more colors are requested than
52
+ the number of standard shades available.
53
+ * Iterating over a `Palette` (`for c in Palette()`) works.
54
+ * `Palette.random_gradient()` no longer randomly raises `IndexError`.
55
+ * `shade=0` is respected instead of being treated as "not provided".
56
+ * Fixed sRGB gamma transform (`apply_gamma_transform`).
57
+ * `hsv_to_rgb` accepts hue value of 1.
58
+ * `cmy_to_cmyk(1, 1, 1)` returns pure black instead of raising
59
+ `ZeroDivisionError`.
60
+ * `relative_luminance` / `text_color` accept 8-character hex codes.
61
+ * `xyz_to_rgb` / `xyz_to_adobe_rgb` accept XYZ values greater than 1, and
62
+ `rgb_to_xyz` / `adobe_rgb_to_xyz` no longer clip XYZ values at 1.
63
+ * `simulate_red_blindness` / `simulate_green_blindness` now follow the
64
+ published formula.
65
+ * `ColorWheel.rotate_saturation` / `rotate_lightness` clamp between 0-100%
66
+ instead of wrapping (e.g. white no longer turns black).
67
+ * `ColorMap.random_divergent()` respects `is_qualitative` and `is_reversed`.
68
+ * `BrewerMap` and `TableauMap` accept `log` and `seed` arguments like
69
+ `ColorMap`.
70
+ ### Behaviour changes
71
+ * Unknown palette names raise `ValueError` instead of silently falling back
72
+ to IBM palette.
73
+ * `ColorString` / `ColorTuple` no longer override `+`. Normal string / tuple
74
+ concatenation works again. Use `ColorString.blend(other)` to mix colors.
75
+ * Looking up colors from other palettes or named colors (e.g. `Palette.get
76
+ ("amber")`) no longer adds them to `Palette.colors`, `get_color_list` or
77
+ the pool used by `Palette.random()`.
78
+ * `seed` in `Palette` and `ColorMap` uses a private random generator; global
79
+ `random` state is not modified anymore.
80
+ * Logging uses the `SecretColors` logger, attaches handlers only once and no
81
+ longer changes global `warnings` filters.
82
+ * ColorMap errors raise `ValueError` instead of bare `Exception`.
83
+ * `rgb_to_srgb` / `srgb_to_rgb` are deprecated in favour of correctly named
84
+ `srgb_to_linear` / `linear_to_srgb`.
85
+ * `Palette.get_color_dict` / `Palette.get_color_list` are deprecated in
86
+ favour of `Palette.color_dict` / `Palette.color_list`.
87
+ * Removed `Palette.color_between` (deprecated since v1.2.0, use
88
+ `SecretColors.utils.color_in_between`) and `Palette.cmap_from` (deprecated
89
+ since v1.2.0, use `ColorMap.from_list`).
90
+ ### Packaging
91
+ * Moved to `pyproject.toml` (hatchling) and [uv](https://docs.astral.sh/uv/).
92
+ `setup.py` and `requirements*.txt` are removed.
93
+ * Requires Python 3.10+. Tested on Python 3.10 - 3.14.
94
+ * Optional extras: `pip install "SecretColors[matplotlib]"` (colormap
95
+ objects), `"SecretColors[image]"` (palettes from images) or
96
+ `"SecretColors[all]"` (everything). The core library has no dependencies.
97
+ * `SecretColors.__version__` is available.
98
+ * New documentation with user guide, palette and colormap galleries, upgrade
99
+ guide and light / dark theme: https://secretcolors.readthedocs.io
100
+ ## v1.2.6
101
+ Removed dependency on `numpy` (Thanks to [ri0t](https://github.com/ri0t))
102
+ ## v1.2.5
103
+ New Color Palette `material-accent` which supports accent colors of Google
104
+ Material Design Color Palette.
105
+ ## v1.2.3
106
+ Added new method to `Palette` class. `Palette.cycle()` will return a
107
+ generator to produce infinite color cycle. Read documentation for
108
+ further
109
+ details.
110
+ ## v1.2.2
111
+ Fixed bug where `Palette.random()` raising error if `no_of_colors`
112
+ parameter is greater than one.
113
+ ## v1.2.1
114
+ Removed the restrictions from `numpy` version [ see [Issue](https://github.com/secretBiology/SecretColors/issues/4) ]
115
+ ## v1.2.0
116
+ This is one of the major updates since the conception of this project. Many
117
+ changes are essential for robust functionality and proper code maintenance
118
+ . This
119
+ has introduced the following important changes
120
+ * Probably the most important change in this version is return values. Any
121
+ color you generate with this library will return `ColorString` or
122
+ `ColorTuple` (depending on `color_mode`) which are subclasses of `str` and
123
+ `tuple` respectively. This will NOT change anything in your workflow. Check the full documentation for its
124
+ use cases.
125
+ * `SecretColors.palettes` is now `SecretColors.models.palettes.Palette
126
+ `. However, if
127
+ you have used `from SecretColors import palette`, your code will NOT be
128
+ impacted. We recommend importing this way.
129
+ * `ColorMap` is now `SecretColors.cmaps.ColorMap`. You should import it as
130
+ `from SecretColors.cmaps import ColorMap`
131
+ * `Palette.color_between` is now deprecated. Use `utils.color_in_between
132
+ ` instead. Using this function will raise `AttributeError`.
133
+ * Using shade value less than 0 or greater than 100 will throw a `ValueError`.
134
+ * `allow_gray_shades` argument from `Palette` is deprecated and will be
135
+ ignored.
136
+ * `ignore_gray` and `force_gray` arguments from `Palette.random()` are
137
+ deprecated and will be ignored.
138
+ * `starting_shade` and `ending_shade` values (if not provided by user) will
139
+ be set to minimum and maximum shades available in that palette instead 0
140
+ and 100.
141
+
142
+ ### What's New?
143
+ * New return class `ColorString` and `ColorTuple`
144
+ * New `ColorWheel` for more scientific use
145
+ * New color palette: Tableau
146
+ * Rewritten `ColorMap` class with new usage and easy colormap access to
147
+ famous color palettes.
148
+ * New `Palette.get()` function which supports all X11 and W3 standard names.
149
+ * Many new RGB space conversions (including *XYZ, adobe, srgb, lab* etc)
150
+ * Many new utility methods (check documentation for details)
151
+ * And of course, fixed many bugs!
152
+
153
+ ### Known Issues
154
+ #### Pycharm type-hinting not working for 'color methods'
155
+
156
+ We have shifted to custom decorators for dynamically creating
157
+ documentation of many class methods. However, due to this change
158
+ , Pycharm will not show typehint for 'color methods' It is known [bug
159
+ ](https://youtrack.jetbrains.com/issue/PY-30190) in PyCharm regarding type hinting.
160
+
161
+ #### Converted RGB/CMYK values are not exact
162
+
163
+ This issue arises when one performs multiple conversion (specially the one
164
+ involving floating points). For example, take a look at following code,
165
+
166
+ ```python
167
+ from SecretColors.utils import rgb_to_hex, hex_to_rgb
168
+
169
+ r, g, b = 0.3, 0.5, 0.7
170
+ hex_color = rgb_to_hex(r, g, b) # hex_color: #4c80b2
171
+ hex_to_rgb(hex_color) # Retuns (0.2980392156862745, 0.5019607843137255, 0.6980392156862745)
172
+ ```
173
+
174
+ In the above code, conversion from RGB to HEX and then from HEX to RGB does
175
+ not give us the same output. This issue is very typical of any programming
176
+ language where we are dealing with float calculations. So you should use
177
+ some rounding logic if you want to compare it with original color
178
+
179
+ In case of conversion to HEX, we usually round the floats to nearest
180
+ integers with default `round` function.
181
+
182
+ However, our benchmarks and testing suggest that these values are accurate
183
+ with an error of '0.001'. We also check this during our testings. This much
184
+ precision should be good enough for most of the cases. In case, you want even
185
+ better precision, we kindly ask you to implement the method by yourself
186
+ instead of a depending method provided by `SecretColors`. In future,
187
+ we plan to take a look at this in more details. But for now,
188
+ the workaround is to make some rounding function like following
189
+
190
+
191
+
192
+ ```python
193
+ # Use precision for rounding according to your need
194
+ def rounded_rgb(*args):
195
+ return tuple(round(x,2) for x in args)
196
+
197
+ rounded_rgb(hex_to_rgb(hex_color)) # returns (0.3, 0.5, 0.7)
198
+ ```
199
+
200
+ Note: All CIE-XYZ conversion and colorblind simulation functions are still in
201
+ beta-testing. Do not use them in your production code
File without changes
@@ -0,0 +1,68 @@
1
+ Metadata-Version: 2.5
2
+ Name: SecretColors
3
+ Version: 2.0.0
4
+ Summary: A small package for fantastic color palette
5
+ Project-URL: Homepage, https://github.com/secretBiology/SecretColors
6
+ Project-URL: Documentation, https://secretcolors.readthedocs.io
7
+ Project-URL: Changelog, https://github.com/secretBiology/SecretColors/blob/master/CHANGELOG.md
8
+ Project-URL: Issues, https://github.com/secretBiology/SecretColors/issues
9
+ Author-email: Rohit Suratekar <rohitsuratekar@gmail.com>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: color,colormap,matplotlib,palette,visualization
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
24
+ Classifier: Topic :: Scientific/Engineering :: Visualization
25
+ Requires-Python: >=3.10
26
+ Provides-Extra: all
27
+ Requires-Dist: matplotlib>=3.10; extra == 'all'
28
+ Requires-Dist: pillow>=11.0; extra == 'all'
29
+ Provides-Extra: image
30
+ Requires-Dist: pillow>=11.0; extra == 'image'
31
+ Provides-Extra: matplotlib
32
+ Requires-Dist: matplotlib>=3.10; extra == 'matplotlib'
33
+ Description-Content-Type: text/markdown
34
+
35
+ ## SecretColors
36
+
37
+ Library generated for making plots with better color palette. It uses famous color palettes and adds few helpful functions.
38
+
39
+ Currently it supports following Color Palettes
40
+
41
+ - IBM Color Palette
42
+ - Google Material Design Color Palette
43
+ - ColorBrewer2 Color Palette
44
+ - VMWare Clarity Color Palette
45
+ - Tableau Color Palette
46
+
47
+ You can get output of colors in variety of color formats including `hex` , `rgb` , `hsl`, `rgba` etc.
48
+
49
+ Few sample plots and inspiration behind this library can be found in [WeirdData blog](https://weirddata.github.io/2019/06/11/secret-colors-2.html).
50
+
51
+ ### Installation
52
+
53
+ ```
54
+ uv add SecretColors # or: pip install SecretColors
55
+ uv add "SecretColors[matplotlib]" # with matplotlib for ColorMap classes
56
+ uv add "SecretColors[image]" # with Pillow for palettes from images
57
+ uv add "SecretColors[all]" # everything
58
+ ```
59
+
60
+ ### Documentation
61
+
62
+ Full documentation and API reference can be accessed via [ReadTheDocs](https://secretcolors.readthedocs.io)
63
+
64
+ For latest information regarding this library, visit our [website](https://github.com/secretBiology/SecretColors).
65
+
66
+ ### License
67
+
68
+ This library and its code is released under MIT License . Read full statement [here](https://github.com/secretBiology/SecretColors/blob/master/LICENSE).
@@ -17,7 +17,10 @@ Few sample plots and inspiration behind this library can be found in [WeirdData
17
17
  ### Installation
18
18
 
19
19
  ```
20
- pip install SecretColors
20
+ uv add SecretColors # or: pip install SecretColors
21
+ uv add "SecretColors[matplotlib]" # with matplotlib for ColorMap classes
22
+ uv add "SecretColors[image]" # with Pillow for palettes from images
23
+ uv add "SecretColors[all]" # everything
21
24
  ```
22
25
 
23
26
  ### Documentation