Skip to content

stop fiddling with exec and globals #3713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 34 additions & 6 deletions packages/python/plotly/_plotly_utils/colors/carto.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,37 @@ def swatches(template=None):
"rgb(165, 170, 153)",
]

# Prefix variable names with _ so that they will not be added to the swatches
_contents = dict(globals())
for _k, _cols in _contents.items():
if _k.startswith("_") or _k.startswith("swatches") or _k.endswith("_r"):
continue
globals()[_k + "_r"] = _cols[::-1]
Aggrnyl_r = Aggrnyl[::-1]
Agsunset_r = Agsunset[::-1]
Antique_r = Antique[::-1]
Armyrose_r = Armyrose[::-1]
Blugrn_r = Blugrn[::-1]
Bluyl_r = Bluyl[::-1]
Bold_r = Bold[::-1]
Brwnyl_r = Brwnyl[::-1]
Burg_r = Burg[::-1]
Burgyl_r = Burgyl[::-1]
Darkmint_r = Darkmint[::-1]
Earth_r = Earth[::-1]
Emrld_r = Emrld[::-1]
Fall_r = Fall[::-1]
Geyser_r = Geyser[::-1]
Magenta_r = Magenta[::-1]
Mint_r = Mint[::-1]
Oryel_r = Oryel[::-1]
Pastel_r = Pastel[::-1]
Peach_r = Peach[::-1]
Pinkyl_r = Pinkyl[::-1]
Prism_r = Prism[::-1]
Purp_r = Purp[::-1]
Purpor_r = Purpor[::-1]
Redor_r = Redor[::-1]
Safe_r = Safe[::-1]
Sunset_r = Sunset[::-1]
Sunsetdark_r = Sunsetdark[::-1]
Teal_r = Teal[::-1]
Tealgrn_r = Tealgrn[::-1]
Tealrose_r = Tealrose[::-1]
Temps_r = Temps[::-1]
Tropic_r = Tropic[::-1]
Vivid_r = Vivid[::-1]
24 changes: 18 additions & 6 deletions packages/python/plotly/_plotly_utils/colors/cmocean.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,21 @@ def swatches_continuous(template=None):
"rgb(51, 13, 53)",
]

# Prefix variable names with _ so that they will not be added to the swatches
_contents = dict(globals())
for _k, _cols in _contents.items():
if _k.startswith("_") or _k.startswith("swatches") or _k.endswith("_r"):
continue
globals()[_k + "_r"] = _cols[::-1]
algae_r = algae[::-1]
amp_r = amp[::-1]
balance_r = balance[::-1]
curl_r = curl[::-1]
deep_r = deep[::-1]
delta_r = delta[::-1]
dense_r = dense[::-1]
gray_r = gray[::-1]
haline_r = haline[::-1]
ice_r = ice[::-1]
matter_r = matter[::-1]
oxy_r = oxy[::-1]
phase_r = phase[::-1]
solar_r = solar[::-1]
speed_r = speed[::-1]
tempo_r = tempo[::-1]
thermal_r = thermal[::-1]
turbid_r = turbid[::-1]
41 changes: 35 additions & 6 deletions packages/python/plotly/_plotly_utils/colors/colorbrewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,38 @@ def swatches(template=None):
"rgb(128,0,38)",
]

# Prefix variable names with _ so that they will not be added to the swatches
_contents = dict(globals())
for _k, _cols in _contents.items():
if _k.startswith("_") or _k.startswith("swatches") or _k.endswith("_r"):
continue
globals()[_k + "_r"] = _cols[::-1]
Accent_r = Accent[::-1]
Blues_r = Blues[::-1]
BrBG_r = BrBG[::-1]
BuGn_r = BuGn[::-1]
BuPu_r = BuPu[::-1]
Dark2_r = Dark2[::-1]
GnBu_r = GnBu[::-1]
Greens_r = Greens[::-1]
Greys_r = Greys[::-1]
OrRd_r = OrRd[::-1]
Oranges_r = Oranges[::-1]
PRGn_r = PRGn[::-1]
Paired_r = Paired[::-1]
Pastel1_r = Pastel1[::-1]
Pastel2_r = Pastel2[::-1]
PiYG_r = PiYG[::-1]
PuBu_r = PuBu[::-1]
PuBuGn_r = PuBuGn[::-1]
PuOr_r = PuOr[::-1]
PuRd_r = PuRd[::-1]
Purples_r = Purples[::-1]
RdBu_r = RdBu[::-1]
RdGy_r = RdGy[::-1]
RdPu_r = RdPu[::-1]
RdYlBu_r = RdYlBu[::-1]
RdYlGn_r = RdYlGn[::-1]
Reds_r = Reds[::-1]
Set1_r = Set1[::-1]
Set2_r = Set2[::-1]
Set3_r = Set3[::-1]
Spectral_r = Spectral[::-1]
YlGn_r = YlGn[::-1]
YlGnBu_r = YlGnBu[::-1]
YlOrBr_r = YlOrBr[::-1]
YlOrRd_r = YlOrRd[::-1]
14 changes: 7 additions & 7 deletions packages/python/plotly/_plotly_utils/colors/cyclical.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ def swatches_cyclical(template=None):
"#ef55f1",
]

# Prefix variable names with _ so that they will not be added to the swatches
_contents = dict(globals())
for _k, _cols in _contents.items():
if _k.startswith("_") or _k.startswith("swatches") or _k.endswith("_r"):
continue
globals()[_k + "_r"] = _cols[::-1]

Edge_r = Edge[::-1]
HSV_r = HSV[::-1]
IceFire_r = IceFire[::-1]
Phase_r = Phase[::-1]
Twilight_r = Twilight[::-1]
mrybm_r = mrybm[::-1]
mygbm_r = mygbm[::-1]

__all__ = [
"swatches",
Expand Down
46 changes: 36 additions & 10 deletions packages/python/plotly/_plotly_utils/colors/diverging.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,44 @@
RdYlBu,
RdYlGn,
Spectral,
BrBG_r,
PRGn_r,
PiYG_r,
PuOr_r,
RdBu_r,
RdGy_r,
RdYlBu_r,
RdYlGn_r,
Spectral_r,
)
from .cmocean import ( # noqa: F401
balance,
delta,
curl,
oxy,
balance_r,
delta_r,
curl_r,
oxy_r,
)
from .carto import ( # noqa: F401
Armyrose,
Fall,
Geyser,
Temps,
Tealrose,
Tropic,
Earth,
Armyrose_r,
Fall_r,
Geyser_r,
Temps_r,
Tealrose_r,
Tropic_r,
Earth_r,
)
from .cmocean import balance, delta, curl, oxy # noqa: F401
from .carto import Armyrose, Fall, Geyser, Temps, Tealrose, Tropic, Earth # noqa: F401

from .plotlyjs import Picnic, Portland # noqa: F401
from .plotlyjs import Picnic, Portland, Picnic_r, Portland_r # noqa: F401

from ._swatches import _swatches, _swatches_continuous

Expand All @@ -38,12 +71,5 @@ def swatches_continuous(template=None):

swatches_continuous.__doc__ = _swatches_continuous.__doc__

# Prefix variable names with _ so that they will not be added to the swatches
_contents = dict(globals())
for _k, _cols in _contents.items():
if _k.startswith("_") or _k.startswith("swatches") or _k.endswith("_r"):
continue
globals()[_k + "_r"] = _cols[::-1]


__all__ = ["swatches"]
Loading