本文整理汇总了Python中matplotlib.cbook.dedent函数的典型用法代码示例。如果您正苦于以下问题:Python dedent函数的具体用法?Python dedent怎么用?Python dedent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dedent函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: parse_options
def parse_options():
doc = (__doc__ and __doc__.split("\n\n")) or " "
op = OptionParser(
description=doc[0].strip(),
usage="%prog [options] [--] [backends and switches]",
# epilog='\n'.join(doc[1:]) # epilog not supported on my python2.4 machine: JDH
)
op.disable_interspersed_args()
op.set_defaults(dirs="pylab,api,units,mplot3d", clean=False, coverage=False, valgrind=False)
op.add_option(
"-d",
"--dirs",
"--directories",
type="string",
dest="dirs",
help=dedent(
"""
Run only the tests in these directories; comma-separated list of
one or more of: pylab (or pylab_examples), api, units, mplot3d"""
),
)
op.add_option(
"-b",
"--backends",
type="string",
dest="backends",
help=dedent(
"""
Run tests only for these backends; comma-separated list of
one or more of: agg, ps, svg, pdf, template, cairo,
Default is everything except cairo."""
),
)
op.add_option("--clean", action="store_true", dest="clean", help="Remove result directories, run no tests")
op.add_option("-c", "--coverage", action="store_true", dest="coverage", help="Run in coverage.py")
op.add_option("-v", "--valgrind", action="store_true", dest="valgrind", help="Run in valgrind")
options, args = op.parse_args()
switches = [x for x in args if x.startswith("--")]
backends = [x.lower() for x in args if not x.startswith("--")]
if options.backends:
backends += [be.lower() for be in options.backends.split(",")]
result = Bunch(
dirs=options.dirs.split(","),
backends=backends or ["agg", "ps", "svg", "pdf", "template"],
clean=options.clean,
coverage=options.coverage,
valgrind=options.valgrind,
switches=switches,
)
if "pylab_examples" in result.dirs:
result.dirs[result.dirs.index("pylab_examples")] = "pylab"
# print(result)
return result
开发者ID:efiring,项目名称:matplotlib,代码行数:55,代码来源:backend_driver.py
示例2: __call__
def __call__(self, func):
if func.__doc__:
doc = func.__doc__
if self.auto_dedent:
doc = dedent(doc)
func.__doc__ = self._format(doc)
return func
开发者ID:eyurtsev,项目名称:FlowCytometryTools,代码行数:7,代码来源:docstring.py
示例3: parse_options
def parse_options():
doc = (__doc__ and __doc__.split('\n\n')) or " "
op = OptionParser(description=doc[0].strip(),
usage='%prog [options] [--] [backends and switches]',
#epilog='\n'.join(doc[1:]) # epilog not supported on my python2.4 machine: JDH
)
op.disable_interspersed_args()
op.set_defaults(dirs='pylab,api,units,mplot3d',
clean=False, coverage=False, valgrind=False)
op.add_option('-d', '--dirs', '--directories', type='string',
dest='dirs', help=dedent('''
Run only the tests in these directories; comma-separated list of
one or more of: pylab (or pylab_examples), api, units, mplot3d'''))
op.add_option('-b', '--backends', type='string', dest='backends',
help=dedent('''
Run tests only for these backends; comma-separated list of
one or more of: agg, ps, svg, pdf, template, cairo,
cairo.png, cairo.ps, cairo.pdf, cairo.svg. Default is everything
except cairo.'''))
op.add_option('--clean', action='store_true', dest='clean',
help='Remove result directories, run no tests')
op.add_option('-c', '--coverage', action='store_true', dest='coverage',
help='Run in coverage.py')
op.add_option('-v', '--valgrind', action='store_true', dest='valgrind',
help='Run in valgrind')
options, args = op.parse_args()
switches = [x for x in args if x.startswith('--')]
backends = [x.lower() for x in args if not x.startswith('--')]
if options.backends:
backends += map(string.lower, options.backends.split(','))
result = Bunch(
dirs = options.dirs.split(','),
backends = backends or ['agg', 'ps', 'svg', 'pdf', 'template'],
clean = options.clean,
coverage = options.coverage,
valgrind = options.valgrind,
switches = switches)
if 'pylab_examples' in result.dirs:
result.dirs[result.dirs.index('pylab_examples')] = 'pylab'
#print result
return result
开发者ID:AlexSzatmary,项目名称:matplotlib,代码行数:43,代码来源:backend_driver.py
示例4: get_scale_docs
def get_scale_docs():
"""
Helper function for generating docstrings related to scales.
"""
docs = []
for name in get_scale_names():
scale_class = _scale_mapping[name]
docs.append(" '%s'" % name)
docs.append("")
class_docs = dedent(scale_class.__init__.__doc__)
class_docs = "".join([" %s\n" % x for x in class_docs.split("\n")])
docs.append(class_docs)
docs.append("")
return "\n".join(docs)
开发者ID:Kojoley,项目名称:matplotlib,代码行数:14,代码来源:scale.py
示例5: test_lazy_imports
def test_lazy_imports():
source = dedent("""
import sys
import matplotlib.figure
import matplotlib.backend_bases
import matplotlib.pyplot
assert 'matplotlib._png' not in sys.modules
assert 'matplotlib._tri' not in sys.modules
assert 'matplotlib._qhull' not in sys.modules
assert 'matplotlib._contour' not in sys.modules
assert 'urllib.request' not in sys.modules
""")
subprocess.check_call([
sys.executable,
'-c',
source
])
开发者ID:HubertHolin,项目名称:matplotlib,代码行数:20,代码来源:test_basic.py
示例6: scale_factory
def scale_factory(scale, axis, **kwargs):
"""
Return a scale class by name.
ACCEPTS: [ %(names)s ]
"""
scale = scale.lower()
if scale is None:
scale = 'linear'
if scale not in _scale_mapping:
raise ValueError("Unknown scale type '%s'" % scale)
return _scale_mapping[scale](axis, **kwargs)
scale_factory.__doc__ = dedent(scale_factory.__doc__) % \
{'names': " | ".join(get_scale_names())}
def register_scale(scale_class):
"""
Register a new kind of scale.
*scale_class* must be a subclass of :class:`ScaleBase`.
"""
_scale_mapping[scale_class.name] = scale_class
def get_scale_docs():
"""
Helper function for generating docstrings related to scales.
开发者ID:AdamHeck,项目名称:matplotlib,代码行数:30,代码来源:scale.py
示例7: frequency
spec = spec[:, 0]
return spec, freqs
# Split out these keyword docs so that they can be used elsewhere
docstring.interpd.update(Spectral=cbook.dedent("""
Fs : scalar
The sampling frequency (samples per time unit). It is used
to calculate the Fourier frequencies, freqs, in cycles per time
unit. The default value is 2.
window : callable or ndarray
A function or a vector of length *NFFT*. To create window vectors see
`window_hanning`, `window_none`, `numpy.blackman`, `numpy.hamming`,
`numpy.bartlett`, `scipy.signal`, `scipy.signal.get_window`, etc. The
default is `window_hanning`. If a function is passed as the argument,
it must take a data segment as an argument and return the windowed
version of the segment.
sides : {'default', 'onesided', 'twosided'}
Specifies which sides of the spectrum to return. Default gives the
default behavior, which returns one-sided for real data and both
for complex data. 'onesided' forces the return of a one-sided
spectrum, while 'twosided' forces two-sided.
"""))
docstring.interpd.update(Single_Spectrum=cbook.dedent("""
pad_to : int
The number of points to which the data segment is padded when
performing the FFT. While not increasing the actual resolution of
开发者ID:NelleV,项目名称:matplotlib,代码行数:32,代码来源:mlab.py
示例8: dedent
def dedent(func):
"Dedent a docstring (if present)"
func.__doc__ = func.__doc__ and cbook.dedent(func.__doc__)
return func
开发者ID:ethanhelfman,项目名称:InstaGet,代码行数:4,代码来源:docstring.py
示例9: scale_factory
def scale_factory(scale, axis, **kwargs):
"""
Return a scale class by name.
ACCEPTS: [ %(names)s ]
"""
scale = scale.lower()
if scale is None:
scale = 'linear'
if scale not in _scale_mapping:
raise ValueError("Unknown scale type '%s'" % scale)
return _scale_mapping[scale](axis, **kwargs)
scale_factory.__doc__ = cbook.dedent(scale_factory.__doc__) % \
{'names': " | ".join(get_scale_names())}
def register_scale(scale_class):
"""
Register a new kind of scale.
*scale_class* must be a subclass of :class:`ScaleBase`.
"""
_scale_mapping[scale_class.name] = scale_class
def get_scale_docs():
"""
Helper function for generating docstrings related to scales.
开发者ID:adnanb59,项目名称:matplotlib,代码行数:30,代码来源:scale.py
示例10: __init__
def __init__(self,projparams,llcrnrlon,llcrnrlat,
urcrnrlon,urcrnrlat,urcrnrislatlon=True):
"""
initialize a Proj class instance.
Input 'projparams' is a dictionary containing proj map
projection control parameter key/value pairs.
See the proj documentation (http://www.remotesensing.org/proj/)
for details.
llcrnrlon,llcrnrlat are lon and lat (in degrees) of lower
left hand corner of projection region.
urcrnrlon,urcrnrlat are lon and lat (in degrees) of upper
right hand corner of projection region if urcrnrislatlon=True
(default). Otherwise, urcrnrlon,urcrnrlat are x,y in projection
coordinates (units meters), assuming the lower left corner is x=0,y=0.
"""
self.projparams = projparams
self.projection = projparams['proj']
# rmajor is the semi-major axis.
# rminor is the semi-minor axis.
# esq is eccentricity squared.
try:
self.rmajor = projparams['a']
self.rminor = projparams['b']
except:
try:
self.rmajor = projparams['R']
except:
self.rmajor = projparams['bR_a']
self.rminor = self.rmajor
if self.rmajor == self.rminor:
self.ellipsoid = False
else:
self.ellipsoid = True
self.flattening = (self.rmajor-self.rminor)/self.rmajor
self.esq = (self.rmajor**2 - self.rminor**2)/self.rmajor**2
self.llcrnrlon = llcrnrlon
self.llcrnrlat = llcrnrlat
if self.projection == 'cyl':
llcrnrx = llcrnrlon
llcrnry = llcrnrlat
elif self.projection == 'ob_tran':
self._proj4 = pyproj.Proj(projparams)
llcrnrx,llcrnry = self(llcrnrlon,llcrnrlat)
llcrnrx = _rad2dg*llcrnrx; llcrnry = _rad2dg*llcrnry
if llcrnrx < 0: llcrnrx = llcrnrx + 360
elif self.projection in 'ortho':
if (llcrnrlon == -180 and llcrnrlat == -90 and
urcrnrlon == 180 and urcrnrlat == 90):
self._fulldisk = True
self._proj4 = pyproj.Proj(projparams)
llcrnrx = -self.rmajor
llcrnry = -self.rmajor
self._width = 0.5*(self.rmajor+self.rminor)
self._height = 0.5*(self.rmajor+self.rminor)
urcrnrx = -llcrnrx
urcrnry = -llcrnry
else:
self._fulldisk = False
self._proj4 = pyproj.Proj(projparams)
llcrnrx, llcrnry = self(llcrnrlon,llcrnrlat)
if llcrnrx > 1.e20 or llcrnry > 1.e20:
raise ValueError(_lower_left_out_of_bounds)
elif self.projection == 'aeqd' and\
(llcrnrlon == -180 and llcrnrlat == -90 and urcrnrlon == 180 and\
urcrnrlat == 90):
self._fulldisk = True
self._proj4 = pyproj.Proj(projparams)
# raise an exception for ellipsoids - there appears to be a bug
# in proj4 that causes the inverse transform to fail for points
# more than 90 degrees of arc away from center point for ellipsoids
# (works fine for spheres) - below is an example
#from pyproj import Proj
#p1 = Proj(proj='aeqd',a=6378137.00,b=6356752.3142,lat_0=0,lon_0=0)
#x,y= p1(91,0)
#lon,lat = p1(x,y,inverse=True) # lon is 89 instead of 91
if self.ellipsoid:
msg = dedent("""
full disk (whole world) Azimuthal Equidistant projection can
only be drawn for a perfect sphere""")
raise ValueError(msg)
llcrnrx = -np.pi*self.rmajor
llcrnry = -np.pi*self.rmajor
self._width = -llcrnrx
self._height = -llcrnry
urcrnrx = -llcrnrx
urcrnry = -llcrnry
elif self.projection == 'geos':
self._proj4 = pyproj.Proj(projparams)
# find major and minor axes of ellipse defining map proj region.
# h is measured from surface of earth at equator.
h = projparams['h'] + self.rmajor
# latitude of horizon on central meridian
lonmax = 90.-(180./np.pi)*np.arcsin(self.rmajor/h)
# longitude of horizon on equator
latmax = 90.-(180./np.pi)*np.arcsin(self.rminor/h)
# truncate to nearest hundredth of a degree (to make sure
# they aren't slightly over the horizon)
#.........这里部分代码省略.........
开发者ID:AvlWx2014,项目名称:basemap,代码行数:101,代码来源:proj.py
示例11: ValueError
"""
Return a scale class by name.
ACCEPTS: [ %(names)s ]
"""
scale = scale.lower()
if scale is None:
scale = "linear"
if scale not in _scale_mapping:
raise ValueError("Unknown scale type '%s'" % scale)
return _scale_mapping[scale](axis, **kwargs)
scale_factory.__doc__ = dedent(scale_factory.__doc__) % {"names": " | ".join(get_scale_names())}
def register_scale(scale_class):
"""
Register a new kind of scale.
*scale_class* must be a subclass of :class:`ScaleBase`.
"""
_scale_mapping[scale_class.name] = scale_class
def get_scale_docs():
"""
Helper function for generating docstrings related to scales.
"""
开发者ID:Kojoley,项目名称:matplotlib,代码行数:31,代码来源:scale.py
注:本文中的matplotlib.cbook.dedent函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论