Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 23bd9df

Browse files
committed
And some more.
1 parent bf67b92 commit 23bd9df

File tree

4 files changed

+37
-57
lines changed

4 files changed

+37
-57
lines changed

lib/matplotlib/cbook/__init__.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,25 @@
2929
import types
3030
import warnings
3131
from weakref import ref, WeakKeyDictionary
32-
from .deprecation import deprecated, warn_deprecated
33-
from .deprecation import mplDeprecation, MatplotlibDeprecationWarning
3432

3533
import numpy as np
3634

35+
import matplotlib
36+
from .deprecation import deprecated, warn_deprecated
37+
from .deprecation import mplDeprecation, MatplotlibDeprecationWarning
3738

38-
# On some systems, locale.getpreferredencoding returns None,
39-
# which can break unicode; and the sage project reports that
40-
# some systems have incorrect locale specifications, e.g.,
41-
# an encoding instead of a valid locale name. Another
42-
# pathological case that has been reported is an empty string.
43-
44-
# On some systems, getpreferredencoding sets the locale, which has
45-
# side effects. Passing False eliminates those side effects.
4639

4740
def unicode_safe(s):
48-
import matplotlib
4941

5042
if isinstance(s, bytes):
5143
try:
44+
# On some systems, locale.getpreferredencoding returns None,
45+
# which can break unicode; and the sage project reports that
46+
# some systems have incorrect locale specifications, e.g.,
47+
# an encoding instead of a valid locale name. Another
48+
# pathological case that has been reported is an empty string.
49+
# On some systems, getpreferredencoding sets the locale, which has
50+
# side effects. Passing False eliminates those side effects.
5251
preferredencoding = locale.getpreferredencoding(
5352
matplotlib.rcParams['axes.formatter.use_locale']).strip()
5453
if not preferredencoding:
@@ -644,8 +643,6 @@ def get_sample_data(fname, asfileobj=True):
644643
645644
If the filename ends in .gz, the file is implicitly ungzipped.
646645
"""
647-
import matplotlib
648-
649646
if matplotlib.rcParams['examples.directory']:
650647
root = matplotlib.rcParams['examples.directory']
651648
else:

lib/matplotlib/collections.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,8 @@
2323

2424
import numpy as np
2525
import matplotlib as mpl
26-
import matplotlib.cbook as cbook
27-
import matplotlib.colors as mcolors
28-
import matplotlib.cm as cm
29-
from matplotlib import docstring
30-
import matplotlib.transforms as transforms
31-
import matplotlib.artist as artist
32-
from matplotlib.artist import allow_rasterization
33-
import matplotlib.path as mpath
34-
from matplotlib import _path
35-
import matplotlib.mlab as mlab
36-
import matplotlib.lines as mlines
26+
from . import (_path, artist, cbook, cm, colors as mcolors, docstring,
27+
lines as mlines, mlab, path as mpath, transforms)
3728

3829
CIRCLE_AREA_FACTOR = 1.0 / np.sqrt(np.pi)
3930

@@ -264,7 +255,7 @@ def _prepare_points(self):
264255

265256
return transform, transOffset, offsets, paths
266257

267-
@allow_rasterization
258+
@artist.allow_rasterization
268259
def draw(self, renderer):
269260
if not self.get_visible():
270261
return
@@ -917,7 +908,7 @@ def set_sizes(self, sizes, dpi=72.0):
917908
self._transforms[:, 2, 2] = 1.0
918909
self.stale = True
919910

920-
@allow_rasterization
911+
@artist.allow_rasterization
921912
def draw(self, renderer):
922913
self.set_sizes(self._sizes, self.figure.dpi)
923914
Collection.draw(self, renderer)
@@ -1118,7 +1109,7 @@ def get_numsides(self):
11181109
def get_rotation(self):
11191110
return self._rotation
11201111

1121-
@allow_rasterization
1112+
@artist.allow_rasterization
11221113
def draw(self, renderer):
11231114
self.set_sizes(self._sizes, self.figure.dpi)
11241115
self._transforms = [
@@ -1691,7 +1682,7 @@ def _set_transforms(self):
16911682
m[:2, 2:] = 0
16921683
self.set_transform(_affine(m))
16931684

1694-
@allow_rasterization
1685+
@artist.allow_rasterization
16951686
def draw(self, renderer):
16961687
self._set_transforms()
16971688
Collection.draw(self, renderer)
@@ -1797,7 +1788,7 @@ def convert_mesh_to_paths(tri):
17971788
tri.y[triangles][..., np.newaxis]), axis=2)
17981789
return [Path(x) for x in verts]
17991790

1800-
@allow_rasterization
1791+
@artist.allow_rasterization
18011792
def draw(self, renderer):
18021793
if not self.get_visible():
18031794
return
@@ -1949,7 +1940,7 @@ def convert_mesh_to_triangles(self, meshWidth, meshHeight, coordinates):
19491940

19501941
return triangles, colors
19511942

1952-
@allow_rasterization
1943+
@artist.allow_rasterization
19531944
def draw(self, renderer):
19541945
if not self.get_visible():
19551946
return

lib/matplotlib/patches.py

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,19 @@
55

66
import six
77
from six.moves import map, zip
8-
import warnings
98

109
import math
10+
import warnings
1111

12-
import matplotlib as mpl
1312
import numpy as np
14-
import matplotlib.cbook as cbook
15-
import matplotlib.artist as artist
16-
from matplotlib.artist import allow_rasterization
17-
import matplotlib.colors as colors
18-
from matplotlib import docstring
19-
import matplotlib.transforms as transforms
20-
from matplotlib.path import Path
21-
import matplotlib.lines as mlines
22-
23-
from matplotlib.bezier import split_bezier_intersecting_with_closedpath
24-
from matplotlib.bezier import get_intersection, inside_circle, get_parallels
25-
from matplotlib.bezier import make_wedged_bezier2
26-
from matplotlib.bezier import split_path_inout, get_cos_sin
27-
from matplotlib.bezier import make_path_regular, concatenate_paths
2813

14+
import matplotlib as mpl
15+
from . import artist, cbook, colors, docstring, lines as mlines, transforms
16+
from .bezier import (
17+
concatenate_paths, get_cos_sin, get_intersection, get_parallels,
18+
inside_circle, make_path_regular, make_wedged_bezier2,
19+
split_bezier_intersecting_with_closedpath, split_path_inout)
20+
from .path import Path
2921

3022
_patch_alias_map = {
3123
'antialiased': ['aa'],
@@ -490,7 +482,7 @@ def get_hatch(self):
490482
'Return the current hatching pattern'
491483
return self._hatch
492484

493-
@allow_rasterization
485+
@artist.allow_rasterization
494486
def draw(self, renderer):
495487
'Draw the :class:`Patch` to the given *renderer*.'
496488
if not self.get_visible():
@@ -1579,7 +1571,7 @@ def __init__(self, xy, width, height, angle=0.0,
15791571
self.theta1 = theta1
15801572
self.theta2 = theta2
15811573

1582-
@allow_rasterization
1574+
@artist.allow_rasterization
15831575
def draw(self, renderer):
15841576
"""
15851577
Ellipses are normally drawn using an approximation that uses

lib/matplotlib/text.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414

1515
import numpy as np
1616

17-
from matplotlib import artist, cbook, docstring, rcParams
18-
from matplotlib.artist import Artist, allow_rasterization
19-
from matplotlib.font_manager import FontProperties
20-
from matplotlib.lines import Line2D
21-
from matplotlib.patches import FancyArrowPatch, FancyBboxPatch, Rectangle
22-
from matplotlib.textpath import TextPath # Unused, but imported by others.
23-
from matplotlib.transforms import (
17+
from . import artist, cbook, docstring, rcParams
18+
from .artist import Artist
19+
from .font_manager import FontProperties
20+
from .lines import Line2D
21+
from .patches import FancyArrowPatch, FancyBboxPatch, Rectangle
22+
from .textpath import TextPath # Unused, but imported by others.
23+
from .transforms import (
2424
Affine2D, Bbox, BboxBase, BboxTransformTo, IdentityTransform, Transform)
2525

2626

@@ -690,7 +690,7 @@ def _get_wrapped_text(self):
690690

691691
return wrapped_str + line
692692

693-
@allow_rasterization
693+
@artist.allow_rasterization
694694
def draw(self, renderer):
695695
"""
696696
Draws the :class:`Text` object to the given *renderer*.
@@ -2276,7 +2276,7 @@ def _update_position_xytext(self, renderer, xy_pixel):
22762276

22772277
self.arrow_patch.set_patchA(r)
22782278

2279-
@allow_rasterization
2279+
@artist.allow_rasterization
22802280
def draw(self, renderer):
22812281
"""
22822282
Draw the :class:`Annotation` object to the given *renderer*.

0 commit comments

Comments
 (0)