|
4 | 4 | """ |
5 | 5 | # SCM versioning |
6 | 6 | import pkg_resources as pkg |
7 | | -name = 'proplot' |
| 7 | + |
| 8 | +name = "proplot" |
8 | 9 | try: |
9 | 10 | version = __version__ = pkg.get_distribution(__name__).version |
10 | 11 | except pkg.DistributionNotFound: |
11 | | - version = __version__ = 'unknown' |
| 12 | + version = __version__ = "unknown" |
12 | 13 |
|
13 | 14 | # Import dependencies early to isolate import times |
14 | 15 | from . import internals, externals, tests # noqa: F401 |
15 | 16 | from .internals.benchmarks import _benchmark |
16 | | -with _benchmark('pyplot'): |
| 17 | + |
| 18 | +with _benchmark("pyplot"): |
17 | 19 | from matplotlib import pyplot # noqa: F401 |
18 | | -with _benchmark('cartopy'): |
| 20 | +with _benchmark("cartopy"): |
19 | 21 | try: |
20 | 22 | import cartopy # noqa: F401 |
21 | 23 | except ImportError: |
22 | 24 | pass |
23 | | -with _benchmark('basemap'): |
| 25 | +with _benchmark("basemap"): |
24 | 26 | try: |
25 | 27 | from mpl_toolkits import basemap # noqa: F401 |
26 | 28 | except ImportError: |
27 | 29 | pass |
28 | 30 |
|
29 | 31 | # Import everything to top level |
30 | | -with _benchmark('config'): |
| 32 | +with _benchmark("config"): |
31 | 33 | from .config import * # noqa: F401 F403 |
32 | | -with _benchmark('proj'): |
| 34 | +with _benchmark("proj"): |
33 | 35 | from .proj import * # noqa: F401 F403 |
34 | | -with _benchmark('utils'): |
| 36 | +with _benchmark("utils"): |
35 | 37 | from .utils import * # noqa: F401 F403 |
36 | | -with _benchmark('colors'): |
| 38 | +with _benchmark("colors"): |
37 | 39 | from .colors import * # noqa: F401 F403 |
38 | | -with _benchmark('ticker'): |
| 40 | +with _benchmark("ticker"): |
39 | 41 | from .ticker import * # noqa: F401 F403 |
40 | | -with _benchmark('scale'): |
| 42 | +with _benchmark("scale"): |
41 | 43 | from .scale import * # noqa: F401 F403 |
42 | | -with _benchmark('axes'): |
| 44 | +with _benchmark("axes"): |
43 | 45 | from .axes import * # noqa: F401 F403 |
44 | | -with _benchmark('gridspec'): |
| 46 | +with _benchmark("gridspec"): |
45 | 47 | from .gridspec import * # noqa: F401 F403 |
46 | | -with _benchmark('figure'): |
| 48 | +with _benchmark("figure"): |
47 | 49 | from .figure import * # noqa: F401 F403 |
48 | | -with _benchmark('constructor'): |
| 50 | +with _benchmark("constructor"): |
49 | 51 | from .constructor import * # noqa: F401 F403 |
50 | | -with _benchmark('ui'): |
| 52 | +with _benchmark("ui"): |
51 | 53 | from .ui import * # noqa: F401 F403 |
52 | | -with _benchmark('demos'): |
| 54 | +with _benchmark("demos"): |
53 | 55 | from .demos import * # noqa: F401 F403 |
54 | 56 |
|
55 | 57 | # Dynamically add registered classes to top-level namespace |
56 | 58 | from . import proj as crs # backwards compatibility # noqa: F401 |
57 | 59 | from .constructor import NORMS, LOCATORS, FORMATTERS, SCALES, PROJS |
| 60 | + |
58 | 61 | _globals = globals() |
59 | 62 | for _src in (NORMS, LOCATORS, FORMATTERS, SCALES, PROJS): |
60 | 63 | for _key, _cls in _src.items(): |
|
63 | 66 |
|
64 | 67 | # Register objects |
65 | 68 | from .config import register_cmaps, register_cycles, register_colors, register_fonts |
66 | | -with _benchmark('cmaps'): |
| 69 | + |
| 70 | +with _benchmark("cmaps"): |
67 | 71 | register_cmaps(default=True) |
68 | | -with _benchmark('cycles'): |
| 72 | +with _benchmark("cycles"): |
69 | 73 | register_cycles(default=True) |
70 | | -with _benchmark('colors'): |
| 74 | +with _benchmark("colors"): |
71 | 75 | register_colors(default=True) |
72 | | -with _benchmark('fonts'): |
| 76 | +with _benchmark("fonts"): |
73 | 77 | register_fonts(default=True) |
74 | 78 |
|
75 | 79 | # Validate colormap names and propagate 'cycle' to 'axes.prop_cycle' |
76 | 80 | # NOTE: cmap.sequential also updates siblings 'cmap' and 'image.cmap' |
77 | 81 | from .config import rc |
78 | 82 | from .internals import rcsetup, warnings |
| 83 | + |
79 | 84 | rcsetup.VALIDATE_REGISTERED_CMAPS = True |
80 | | -for _key in ('cycle', 'cmap.sequential', 'cmap.diverging', 'cmap.cyclic', 'cmap.qualitative'): # noqa: E501 |
| 85 | +for _key in ( |
| 86 | + "cycle", |
| 87 | + "cmap.sequential", |
| 88 | + "cmap.diverging", |
| 89 | + "cmap.cyclic", |
| 90 | + "cmap.qualitative", |
| 91 | +): # noqa: E501 |
81 | 92 | try: |
82 | 93 | rc[_key] = rc[_key] |
83 | 94 | except ValueError as err: |
84 | | - warnings._warn_proplot(f'Invalid user rc file setting: {err}') |
85 | | - rc[_key] = 'Greys' # fill value |
| 95 | + warnings._warn_proplot(f"Invalid user rc file setting: {err}") |
| 96 | + rc[_key] = "Greys" # fill value |
86 | 97 |
|
87 | 98 | # Validate color names now that colors are registered |
88 | 99 | # NOTE: This updates all settings with 'color' in name (harmless if it's not a color) |
89 | 100 | from .config import rc_proplot, rc_matplotlib |
| 101 | + |
90 | 102 | rcsetup.VALIDATE_REGISTERED_COLORS = True |
91 | 103 | for _src in (rc_proplot, rc_matplotlib): |
92 | 104 | for _key in _src: # loop through unsynced properties |
93 | | - if 'color' not in _key: |
| 105 | + if "color" not in _key: |
94 | 106 | continue |
95 | 107 | try: |
96 | 108 | _src[_key] = _src[_key] |
97 | 109 | except ValueError as err: |
98 | | - warnings._warn_proplot(f'Invalid user rc file setting: {err}') |
99 | | - _src[_key] = 'black' # fill value |
| 110 | + warnings._warn_proplot(f"Invalid user rc file setting: {err}") |
| 111 | + _src[_key] = "black" # fill value |
0 commit comments