Skip to content

Commit 1afc30d

Browse files
Merge pull request #3713 from plotly/no_exec_globals
stop fiddling with exec and globals
2 parents 27f6573 + a2f94ab commit 1afc30d

File tree

9 files changed

+446
-236
lines changed

9 files changed

+446
-236
lines changed

packages/python/plotly/_plotly_utils/colors/carto.py

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,37 @@ def swatches(template=None):
383383
"rgb(165, 170, 153)",
384384
]
385385

386-
# Prefix variable names with _ so that they will not be added to the swatches
387-
_contents = dict(globals())
388-
for _k, _cols in _contents.items():
389-
if _k.startswith("_") or _k.startswith("swatches") or _k.endswith("_r"):
390-
continue
391-
globals()[_k + "_r"] = _cols[::-1]
386+
Aggrnyl_r = Aggrnyl[::-1]
387+
Agsunset_r = Agsunset[::-1]
388+
Antique_r = Antique[::-1]
389+
Armyrose_r = Armyrose[::-1]
390+
Blugrn_r = Blugrn[::-1]
391+
Bluyl_r = Bluyl[::-1]
392+
Bold_r = Bold[::-1]
393+
Brwnyl_r = Brwnyl[::-1]
394+
Burg_r = Burg[::-1]
395+
Burgyl_r = Burgyl[::-1]
396+
Darkmint_r = Darkmint[::-1]
397+
Earth_r = Earth[::-1]
398+
Emrld_r = Emrld[::-1]
399+
Fall_r = Fall[::-1]
400+
Geyser_r = Geyser[::-1]
401+
Magenta_r = Magenta[::-1]
402+
Mint_r = Mint[::-1]
403+
Oryel_r = Oryel[::-1]
404+
Pastel_r = Pastel[::-1]
405+
Peach_r = Peach[::-1]
406+
Pinkyl_r = Pinkyl[::-1]
407+
Prism_r = Prism[::-1]
408+
Purp_r = Purp[::-1]
409+
Purpor_r = Purpor[::-1]
410+
Redor_r = Redor[::-1]
411+
Safe_r = Safe[::-1]
412+
Sunset_r = Sunset[::-1]
413+
Sunsetdark_r = Sunsetdark[::-1]
414+
Teal_r = Teal[::-1]
415+
Tealgrn_r = Tealgrn[::-1]
416+
Tealrose_r = Tealrose[::-1]
417+
Temps_r = Temps[::-1]
418+
Tropic_r = Tropic[::-1]
419+
Vivid_r = Vivid[::-1]

packages/python/plotly/_plotly_utils/colors/cmocean.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,21 @@ def swatches_continuous(template=None):
276276
"rgb(51, 13, 53)",
277277
]
278278

279-
# Prefix variable names with _ so that they will not be added to the swatches
280-
_contents = dict(globals())
281-
for _k, _cols in _contents.items():
282-
if _k.startswith("_") or _k.startswith("swatches") or _k.endswith("_r"):
283-
continue
284-
globals()[_k + "_r"] = _cols[::-1]
279+
algae_r = algae[::-1]
280+
amp_r = amp[::-1]
281+
balance_r = balance[::-1]
282+
curl_r = curl[::-1]
283+
deep_r = deep[::-1]
284+
delta_r = delta[::-1]
285+
dense_r = dense[::-1]
286+
gray_r = gray[::-1]
287+
haline_r = haline[::-1]
288+
ice_r = ice[::-1]
289+
matter_r = matter[::-1]
290+
oxy_r = oxy[::-1]
291+
phase_r = phase[::-1]
292+
solar_r = solar[::-1]
293+
speed_r = speed[::-1]
294+
tempo_r = tempo[::-1]
295+
thermal_r = thermal[::-1]
296+
turbid_r = turbid[::-1]

packages/python/plotly/_plotly_utils/colors/colorbrewer.py

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,38 @@ def swatches(template=None):
457457
"rgb(128,0,38)",
458458
]
459459

460-
# Prefix variable names with _ so that they will not be added to the swatches
461-
_contents = dict(globals())
462-
for _k, _cols in _contents.items():
463-
if _k.startswith("_") or _k.startswith("swatches") or _k.endswith("_r"):
464-
continue
465-
globals()[_k + "_r"] = _cols[::-1]
460+
Accent_r = Accent[::-1]
461+
Blues_r = Blues[::-1]
462+
BrBG_r = BrBG[::-1]
463+
BuGn_r = BuGn[::-1]
464+
BuPu_r = BuPu[::-1]
465+
Dark2_r = Dark2[::-1]
466+
GnBu_r = GnBu[::-1]
467+
Greens_r = Greens[::-1]
468+
Greys_r = Greys[::-1]
469+
OrRd_r = OrRd[::-1]
470+
Oranges_r = Oranges[::-1]
471+
PRGn_r = PRGn[::-1]
472+
Paired_r = Paired[::-1]
473+
Pastel1_r = Pastel1[::-1]
474+
Pastel2_r = Pastel2[::-1]
475+
PiYG_r = PiYG[::-1]
476+
PuBu_r = PuBu[::-1]
477+
PuBuGn_r = PuBuGn[::-1]
478+
PuOr_r = PuOr[::-1]
479+
PuRd_r = PuRd[::-1]
480+
Purples_r = Purples[::-1]
481+
RdBu_r = RdBu[::-1]
482+
RdGy_r = RdGy[::-1]
483+
RdPu_r = RdPu[::-1]
484+
RdYlBu_r = RdYlBu[::-1]
485+
RdYlGn_r = RdYlGn[::-1]
486+
Reds_r = Reds[::-1]
487+
Set1_r = Set1[::-1]
488+
Set2_r = Set2[::-1]
489+
Set3_r = Set3[::-1]
490+
Spectral_r = Spectral[::-1]
491+
YlGn_r = YlGn[::-1]
492+
YlGnBu_r = YlGnBu[::-1]
493+
YlOrBr_r = YlOrBr[::-1]
494+
YlOrRd_r = YlOrRd[::-1]

packages/python/plotly/_plotly_utils/colors/cyclical.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ def swatches_cyclical(template=None):
143143
"#ef55f1",
144144
]
145145

146-
# Prefix variable names with _ so that they will not be added to the swatches
147-
_contents = dict(globals())
148-
for _k, _cols in _contents.items():
149-
if _k.startswith("_") or _k.startswith("swatches") or _k.endswith("_r"):
150-
continue
151-
globals()[_k + "_r"] = _cols[::-1]
152-
146+
Edge_r = Edge[::-1]
147+
HSV_r = HSV[::-1]
148+
IceFire_r = IceFire[::-1]
149+
Phase_r = Phase[::-1]
150+
Twilight_r = Twilight[::-1]
151+
mrybm_r = mrybm[::-1]
152+
mygbm_r = mygbm[::-1]
153153

154154
__all__ = [
155155
"swatches",

packages/python/plotly/_plotly_utils/colors/diverging.py

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,44 @@
1616
RdYlBu,
1717
RdYlGn,
1818
Spectral,
19+
BrBG_r,
20+
PRGn_r,
21+
PiYG_r,
22+
PuOr_r,
23+
RdBu_r,
24+
RdGy_r,
25+
RdYlBu_r,
26+
RdYlGn_r,
27+
Spectral_r,
28+
)
29+
from .cmocean import ( # noqa: F401
30+
balance,
31+
delta,
32+
curl,
33+
oxy,
34+
balance_r,
35+
delta_r,
36+
curl_r,
37+
oxy_r,
38+
)
39+
from .carto import ( # noqa: F401
40+
Armyrose,
41+
Fall,
42+
Geyser,
43+
Temps,
44+
Tealrose,
45+
Tropic,
46+
Earth,
47+
Armyrose_r,
48+
Fall_r,
49+
Geyser_r,
50+
Temps_r,
51+
Tealrose_r,
52+
Tropic_r,
53+
Earth_r,
1954
)
20-
from .cmocean import balance, delta, curl, oxy # noqa: F401
21-
from .carto import Armyrose, Fall, Geyser, Temps, Tealrose, Tropic, Earth # noqa: F401
2255

23-
from .plotlyjs import Picnic, Portland # noqa: F401
56+
from .plotlyjs import Picnic, Portland, Picnic_r, Portland_r # noqa: F401
2457

2558
from ._swatches import _swatches, _swatches_continuous
2659

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

3972
swatches_continuous.__doc__ = _swatches_continuous.__doc__
4073

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

4975
__all__ = ["swatches"]

0 commit comments

Comments
 (0)