From 336a75e6068e190ae6c9914c159bfb101ced979b Mon Sep 17 00:00:00 2001 From: Dennis Sun Date: Tue, 11 Jun 2024 12:14:23 -0700 Subject: [PATCH] continue addressing pr comments --- arcadia_pycolor/cvd.py | 37 +++++++++++------------------- arcadia_pycolor/gradients.py | 23 +------------------ arcadia_pycolor/palettes.py | 15 +----------- examples/heatmap_setup.pdf | Bin 50264 -> 50264 bytes examples/heatmap_style_axis.pdf | Bin 52786 -> 52786 bytes examples/scatter_full_small.pdf | Bin 30280 -> 30280 bytes examples/scatter_full_wide.pdf | Bin 30899 -> 30899 bytes examples/scatter_half_small.pdf | Bin 30267 -> 30267 bytes examples/scatter_setup.pdf | Bin 25697 -> 25697 bytes examples/scatter_style_axis.pdf | Bin 30428 -> 30428 bytes examples/scatter_threeq_small.pdf | Bin 30198 -> 30198 bytes examples/scatter_threeq_wide.pdf | Bin 30597 -> 30597 bytes examples/violin_setup.pdf | Bin 28939 -> 28939 bytes examples/violin_style_axis.pdf | Bin 31697 -> 31697 bytes usage_example.ipynb | 36 ++++++++++++++--------------- 15 files changed, 34 insertions(+), 77 deletions(-) diff --git a/arcadia_pycolor/cvd.py b/arcadia_pycolor/cvd.py index 91c66f9..ed8677f 100644 --- a/arcadia_pycolor/cvd.py +++ b/arcadia_pycolor/cvd.py @@ -33,7 +33,7 @@ def _make_cvd_dict(cvd_type: str, severity: int = 100) -> dict: return cvd_space -def simulate_color_deficiency( +def simulate_color( colors: Union[HexCode, list[HexCode]], cvd_type: str = "d", severity: int = 100 ) -> Union[HexCode, list[HexCode]]: """ @@ -65,26 +65,20 @@ def simulate_color_deficiency( return returned_colors -def display_all_color_deficiencies( - colors: Union[HexCode | list[HexCode]], severity: int = 100 -) -> None: +def display_all_color(color: HexCode, severity: int = 100) -> None: """ - Display all color vision deficiency types for a single HexCode or list of HexCodes. + Display all color vision deficiency types for a single HexCode. Args: color (HexCode): color to simulate color vision deficiency on. severity (int): severity of the color vision deficiency, from 0 to 100. """ - cvd_colors = [colors] + [ - simulate_color_deficiency(colors, cvd_type, severity) for cvd_type in CVD_TYPES - ] + cvd_colors = [color] + [simulate_color(color, cvd_type, severity) for cvd_type in CVD_TYPES] for cvd_color in cvd_colors: print(cvd_color.swatch()) -def simulate_palette_deficiency( - palette: Palette, cvd_type: str = "d", severity: int = 100 -) -> Palette: +def simulate_palette(palette: Palette, cvd_type: str = "d", severity: int = 100) -> Palette: """ Simulates color vision deficiency on a Palette. @@ -93,13 +87,13 @@ def simulate_palette_deficiency( cvd_type (str): 'd' for deuteranomaly, 'p' for protanomaly, and 't' for tritanomaly. severity (int): severity of the color vision deficiency, from 0 to 100. """ - cvd_hex_colors = simulate_color_deficiency(palette.colors, cvd_type=cvd_type, severity=severity) + cvd_hex_colors = simulate_color(palette.colors, cvd_type=cvd_type, severity=severity) cvd_palette = Palette(f"{palette.name}_{cvd_type}", cvd_hex_colors) return cvd_palette -def display_all_palette_deficiencies(palette: Palette, severity: int = 100) -> None: +def display_all_palette(palette: Palette, severity: int = 100) -> None: """ Display all color vision deficiency types for a Palette. @@ -108,14 +102,14 @@ def display_all_palette_deficiencies(palette: Palette, severity: int = 100) -> N severity (int): severity of the color vision deficiency, from 0 to 100. """ cvd_palettes = [palette] + [ - simulate_palette_deficiency(palette, cvd_type, severity) for cvd_type in CVD_TYPES + simulate_palette(palette, cvd_type, severity) for cvd_type in CVD_TYPES ] for palette in cvd_palettes: print(palette.name) print(palette.swatch()) -def simulate_gradient_deficiency(gradient: Gradient, cvd_type="d", severity: int = 100) -> Gradient: +def simulate_gradient(gradient: Gradient, cvd_type="d", severity: int = 100) -> Gradient: """ Simulates color vision deficiency on a Gradient. @@ -124,15 +118,13 @@ def simulate_gradient_deficiency(gradient: Gradient, cvd_type="d", severity: int cvd_type (str): 'd' for deuteranomaly, 'p' for protanomaly, and 't' for tritanomaly. severity (int): severity of the color vision deficiency, from 0 to 100. """ - cvd_hex_colors = simulate_color_deficiency( - gradient.colors, cvd_type=cvd_type, severity=severity - ) + cvd_hex_colors = simulate_color(gradient.colors, cvd_type=cvd_type, severity=severity) cvd_gradient = Gradient(f"{gradient.name}_{cvd_type}", cvd_hex_colors, gradient.values) return cvd_gradient -def display_all_gradient_deficiencies(gradient: Gradient, severity: int = 100) -> None: +def display_all_gradient(gradient: Gradient, severity: int = 100) -> None: """ Display all color vision deficiency types for a Gradient. @@ -141,16 +133,15 @@ def display_all_gradient_deficiencies(gradient: Gradient, severity: int = 100) - severity (int): severity of the color vision deficiency, from 0 to 100. """ cvd_gradients = [gradient] + [ - simulate_gradient_deficiency(gradient, cvd_type, severity) for cvd_type in CVD_TYPES + simulate_gradient(gradient, cvd_type, severity) for cvd_type in CVD_TYPES ] for grad in cvd_gradients: print(grad.name) print(grad.swatch()) -def simulate_gradient_lightness(gradient: Gradient, severity: int = 100, **kwargs): +def display_all_gradient_lightness(gradient: Gradient, severity: int = 100, **kwargs): plot_gradient_lightness( - [gradient] - + [simulate_gradient_deficiency(gradient, cvd_type, severity) for cvd_type in CVD_TYPES], + [gradient] + [simulate_gradient(gradient, cvd_type, severity) for cvd_type in CVD_TYPES], **kwargs, ) diff --git a/arcadia_pycolor/gradients.py b/arcadia_pycolor/gradients.py index 4557a3c..9d0e448 100644 --- a/arcadia_pycolor/gradients.py +++ b/arcadia_pycolor/gradients.py @@ -135,25 +135,4 @@ [0.0, 0.21, 0.5, 0.6, 0.81, 1.0], ) - -_all_gradients = [ - viridis, - magma, - cividis, - reds, - oranges, - yellows, - greens, - teals, - blues, - purples, - magentas, - aegean_amber, - aster_canary, - lime_rose, - seaweed_tangerine, - poppies, - pansies, - dahlias, - lillies, -] +_all_gradients = [obj for obj in globals().values() if isinstance(obj, Gradient)] diff --git a/arcadia_pycolor/palettes.py b/arcadia_pycolor/palettes.py index a89593b..6f8ff97 100644 --- a/arcadia_pycolor/palettes.py +++ b/arcadia_pycolor/palettes.py @@ -140,17 +140,4 @@ ) all.name = "All" -_all_palettes = [ - core, - neutral, - accent, - light_accent, - accent_expanded, - light_accent_expanded, - accent_ordered, - light_ordered, - accent_all_ordered, - other, - named, - all, -] +_all_palettes = [obj for obj in globals().values() if isinstance(obj, Palette)] diff --git a/examples/heatmap_setup.pdf b/examples/heatmap_setup.pdf index 201531e64b86653c8498d8ea6e30e4175070649b..1399f0ce33050e23ece8923b8d38edde25bdbf13 100644 GIT binary patch delta 22 ecmcc7!F;2GdBe1W?1qL$24+TPo97)2!lL-X? delta 22 ecmcc7!F;2GdBe1W>;{HrrWQsPo97)2!_z4jJ diff --git a/examples/heatmap_style_axis.pdf b/examples/heatmap_style_axis.pdf index 5deecf00a000e3c3d6a60dbb0f4e9df90b35c617..f3fb52dfc22bfb26c529eb177e1865419c7dc0bd 100644 GIT binary patch delta 22 ecmdlqhk4T+<_%9yu^Sp18JHPaY<_*pof!ac5eXgu delta 22 ecmdlqhk4T+<_%9yu^SkgnOYcGZhn2rof!aca0w{@ diff --git a/examples/scatter_full_small.pdf b/examples/scatter_full_small.pdf index 466ec544bbe1288d6aa166f7d9c066a3c8c83a19..5eafc374f59662270bf73a33203705fbf7b6ae64 100644 GIT binary patch delta 22 ecmX@{hVjH3#tltH?1qL$24+T&m4GXnr}RS4?< delta 22 ecmX@{hVjH3#tltH>;{HrrWVEqn>&m4GXnr}e+caW diff --git a/examples/scatter_full_wide.pdf b/examples/scatter_full_wide.pdf index 647d4e290b05c9bfd712f5d8f3788a865925d360..d1ea00a8e6b4754b2084766fc608c638b8b7dd39 100644 GIT binary patch delta 22 ecmdn|k#X}!#tm;v*bNPh49tuyHh(GE&kO)}$O)tX delta 22 ecmdn|k#X}!#tm;v*bNNLOf8HoH-9PF&kO)~Ckd|r diff --git a/examples/scatter_half_small.pdf b/examples/scatter_half_small.pdf index 16c841f07155f4330aeb6084a35be92e9f62c78c..5972167674865b62761326b693664ede022babeb 100644 GIT binary patch delta 22 ecmdn}hH>{B#to%K?1qL$24={B#to%K>;{HrrWVGAn`?^pGXnr`c?h}y diff --git a/examples/scatter_setup.pdf b/examples/scatter_setup.pdf index 6b7f3c9baadd400d8b61df892a4e97039eb24bba..8db7d538c6e037192e684a0d6ae306fd97d9b169 100644 GIT binary patch delta 22 ecmaEOg7M)A#toYj*$oYi49twoHt$MY&IAB+83_3R delta 22 ecmaEOg7M)A#toYj*$oWMOf8JeH}6VZ&IAB+cnJgm diff --git a/examples/scatter_style_axis.pdf b/examples/scatter_style_axis.pdf index 168075b97122efbe0e8e97dec0b2a460ef19e911..403b420e7300cfd16b643ddc4e8736d32c319725 100644 GIT binary patch delta 22 ecmccfmhsM8#tmY{?1qL$24+U)n`MjlGXnr^u?Rf? delta 22 ecmccfmhsM8#tmY{>;{HrrWQsPn`MjlGXnr_5C}*B diff --git a/examples/scatter_threeq_small.pdf b/examples/scatter_threeq_small.pdf index 0a619ac72e92f866c0a61fd4591fc4b7d9e3efe9..7d0fc4e56518a6077629782b421840f62bdb6e94 100644 GIT binary patch delta 22 ecmezNn(^Cf#tjBV?1qL$24=%GXnr~M+lh! delta 22 ecmezNn(^Cf#tjBV>;{HrrWVGAo6U>%GXnr~rU;|} diff --git a/examples/scatter_threeq_wide.pdf b/examples/scatter_threeq_wide.pdf index a3591dc25d188d5f1944d49439ce27724d99613f..d9d36fb8c70223dec8f9c74d2751e077fa235f3f 100644 GIT binary patch delta 22 ecmZpD&)E8&al`&%c0)rW12ZGb&Bu!OGXnr@rwHc& delta 22 ecmZpD&)E8&al`&%b^}8*Qww8*&Bu!OGXnr@(Fo}P diff --git a/examples/violin_setup.pdf b/examples/violin_setup.pdf index 808518fb5035fc541ed652bc6754217be5dda6bc..62be7856d17cc6442f50f6265f34fefd9fa6f262 100644 GIT binary patch delta 22 dcmeBv#Mu3aaYJDqyP=_xftiun=8C+@OaNsV2m=5B delta 22 dcmeBv#Mu3aaYJDqyMdvZsfCgG=8C+@OaNtf2o3-M diff --git a/examples/violin_style_axis.pdf b/examples/violin_style_axis.pdf index 6da1c58c4ad387e4fa5041960b63eb3e7a685047..0821bd239d3260825276e0f73b6ee1fc207e61b9 100644 GIT binary patch delta 22 ecmccko$=y##to}0*bNPh49twoH*cztX9fUwm