|
28 | 28 | import numpy.ma as ma
|
29 | 29 |
|
30 | 30 |
|
31 |
| - |
32 | 31 | import types
|
33 | 32 |
|
34 | 33 |
|
|
43 | 42 |
|
44 | 43 | if sys.version_info[0] >= 3:
|
45 | 44 | def unicode_safe(s):
|
46 |
| - import matplotlib |
47 |
| - |
48 | 45 | try:
|
49 | 46 | preferredencoding = locale.getpreferredencoding(
|
50 | 47 | matplotlib.rcParams['axes.formatter.use_locale']).strip()
|
@@ -79,7 +76,7 @@ def unicode_safe(s):
|
79 | 76 | return unicode(s, preferredencoding)
|
80 | 77 |
|
81 | 78 |
|
82 |
| -class converter: |
| 79 | +class converter(object): |
83 | 80 | """
|
84 | 81 | Base class for handling string -> python type with support for
|
85 | 82 | missing values
|
@@ -274,12 +271,14 @@ class CallbackRegistry:
|
274 | 271 | functions). This technique was shared by Peter Parente on his
|
275 | 272 | `"Mindtrove" blog
|
276 | 273 | <http://mindtrove.info/articles/python-weak-references/>`_.
|
| 274 | +
|
| 275 | + .. deprecated:: 1.3.0 |
277 | 276 | """
|
278 | 277 | def __init__(self, *args):
|
279 | 278 | if len(args):
|
280 | 279 | warnings.warn(
|
281 |
| - 'CallbackRegistry no longer requires a list of callback types.' |
282 |
| - ' Ignoring arguments', |
| 280 | + "CallbackRegistry no longer requires a list of callback " |
| 281 | + "types. Ignoring arguments. *args will be removed in 1.5", |
283 | 282 | mplDeprecation)
|
284 | 283 | self.callbacks = dict()
|
285 | 284 | self._cid = 0
|
@@ -538,7 +537,6 @@ def to_filehandle(fname, flag='rU', return_opened=False):
|
538 | 537 | """
|
539 | 538 | if is_string_like(fname):
|
540 | 539 | if fname.endswith('.gz'):
|
541 |
| - import gzip |
542 | 540 | # get rid of 'U' in flag for gzipped files.
|
543 | 541 | flag = flag.replace('U', '')
|
544 | 542 | fh = gzip.open(fname, flag)
|
@@ -581,7 +579,8 @@ def get_sample_data(fname, asfileobj=True):
|
581 | 579 | if matplotlib.rcParams['examples.directory']:
|
582 | 580 | root = matplotlib.rcParams['examples.directory']
|
583 | 581 | else:
|
584 |
| - root = os.path.join(os.path.dirname(__file__), "mpl-data", "sample_data") |
| 582 | + root = os.path.join(os.path.dirname(__file__), |
| 583 | + "mpl-data", "sample_data") |
585 | 584 | path = os.path.join(root, fname)
|
586 | 585 |
|
587 | 586 | if asfileobj:
|
@@ -1298,7 +1297,7 @@ def xy(self, i0=0, isub=1):
|
1298 | 1297 |
|
1299 | 1298 | def plot(self, i0=0, isub=1, fig=None):
|
1300 | 1299 | if fig is None:
|
1301 |
| - from pylab import figure, show |
| 1300 | + from pylab import figure |
1302 | 1301 | fig = figure()
|
1303 | 1302 |
|
1304 | 1303 | ax = fig.add_subplot(111)
|
@@ -1608,8 +1607,9 @@ def delete_masked_points(*args):
|
1608 | 1607 | return margs
|
1609 | 1608 |
|
1610 | 1609 |
|
| 1610 | +# FIXME I don't think this is used anywhere |
1611 | 1611 | def unmasked_index_ranges(mask, compressed=True):
|
1612 |
| - ''' |
| 1612 | + """ |
1613 | 1613 | Find index ranges where *mask* is *False*.
|
1614 | 1614 |
|
1615 | 1615 | *mask* will be flattened if it is not already 1-D.
|
@@ -1639,8 +1639,7 @@ def unmasked_index_ranges(mask, compressed=True):
|
1639 | 1639 |
|
1640 | 1640 | Prior to the transforms refactoring, this was used to support
|
1641 | 1641 | masked arrays in Line2D.
|
1642 |
| -
|
1643 |
| - ''' |
| 1642 | + """ |
1644 | 1643 | mask = mask.reshape(mask.size)
|
1645 | 1644 | m = np.concatenate(((1,), mask, (1,)))
|
1646 | 1645 | indices = np.arange(len(mask) + 1)
|
@@ -1668,79 +1667,6 @@ def unmasked_index_ranges(mask, compressed=True):
|
1668 | 1667 | ls_mapper.update([(ls[1], ls[0]) for ls in _linestyles])
|
1669 | 1668 |
|
1670 | 1669 |
|
1671 |
| -def less_simple_linear_interpolation(x, y, xi, extrap=False): |
1672 |
| - """ |
1673 |
| - This function has been moved to matplotlib.mlab -- please import |
1674 |
| - it from there |
1675 |
| - """ |
1676 |
| - # deprecated from cbook in 0.98.4 |
1677 |
| - warnings.warn('less_simple_linear_interpolation has been moved to ' |
1678 |
| - 'matplotlib.mlab -- please import it from there', |
1679 |
| - mplDeprecation) |
1680 |
| - import matplotlib.mlab as mlab |
1681 |
| - return mlab.less_simple_linear_interpolation(x, y, xi, extrap=extrap) |
1682 |
| - |
1683 |
| - |
1684 |
| -def vector_lengths(X, P=2.0, axis=None): |
1685 |
| - """ |
1686 |
| - This function has been moved to matplotlib.mlab -- please import |
1687 |
| - it from there |
1688 |
| - """ |
1689 |
| - # deprecated from cbook in 0.98.4 |
1690 |
| - warnings.warn('vector_lengths has been moved to matplotlib.mlab -- ' |
1691 |
| - 'please import it from there', mplDeprecation) |
1692 |
| - import matplotlib.mlab as mlab |
1693 |
| - return mlab.vector_lengths(X, P=2.0, axis=axis) |
1694 |
| - |
1695 |
| - |
1696 |
| -def distances_along_curve(X): |
1697 |
| - """ |
1698 |
| - This function has been moved to matplotlib.mlab -- please import |
1699 |
| - it from there |
1700 |
| - """ |
1701 |
| - # deprecated from cbook in 0.98.4 |
1702 |
| - warnings.warn('distances_along_curve has been moved to matplotlib.mlab ' |
1703 |
| - '-- please import it from there', mplDeprecation) |
1704 |
| - import matplotlib.mlab as mlab |
1705 |
| - return mlab.distances_along_curve(X) |
1706 |
| - |
1707 |
| - |
1708 |
| -def path_length(X): |
1709 |
| - """ |
1710 |
| - This function has been moved to matplotlib.mlab -- please import |
1711 |
| - it from there |
1712 |
| - """ |
1713 |
| - # deprecated from cbook in 0.98.4 |
1714 |
| - warnings.warn('path_length has been moved to matplotlib.mlab ' |
1715 |
| - '-- please import it from there', mplDeprecation) |
1716 |
| - import matplotlib.mlab as mlab |
1717 |
| - return mlab.path_length(X) |
1718 |
| - |
1719 |
| - |
1720 |
| -def is_closed_polygon(X): |
1721 |
| - """ |
1722 |
| - This function has been moved to matplotlib.mlab -- please import |
1723 |
| - it from there |
1724 |
| - """ |
1725 |
| - # deprecated from cbook in 0.98.4 |
1726 |
| - warnings.warn('is_closed_polygon has been moved to matplotlib.mlab ' |
1727 |
| - '-- please import it from there', mplDeprecation) |
1728 |
| - import matplotlib.mlab as mlab |
1729 |
| - return mlab.is_closed_polygon(X) |
1730 |
| - |
1731 |
| - |
1732 |
| -def quad2cubic(q0x, q0y, q1x, q1y, q2x, q2y): |
1733 |
| - """ |
1734 |
| - This function has been moved to matplotlib.mlab -- please import |
1735 |
| - it from there |
1736 |
| - """ |
1737 |
| - # deprecated from cbook in 0.98.4 |
1738 |
| - warnings.warn('quad2cubic has been moved to matplotlib.mlab -- please ' |
1739 |
| - 'import it from there', mplDeprecation) |
1740 |
| - import matplotlib.mlab as mlab |
1741 |
| - return mlab.quad2cubic(q0x, q0y, q1x, q1y, q2x, q2y) |
1742 |
| - |
1743 |
| - |
1744 | 1670 | def align_iterators(func, *iterables):
|
1745 | 1671 | """
|
1746 | 1672 | This generator takes a bunch of iterables that are ordered by func
|
@@ -1893,11 +1819,3 @@ def _check_output(*popenargs, **kwargs):
|
1893 | 1819 | check_output = subprocess.check_output
|
1894 | 1820 | else:
|
1895 | 1821 | check_output = _check_output
|
1896 |
| - |
1897 |
| - |
1898 |
| -if __name__ == '__main__': |
1899 |
| - assert(allequal([1, 1, 1])) |
1900 |
| - assert(not allequal([1, 1, 0])) |
1901 |
| - assert(allequal([])) |
1902 |
| - assert(allequal(('a', 'a'))) |
1903 |
| - assert(not allequal(('a', 'b'))) |
0 commit comments