36
36
# appended
37
37
PYPLOT_MAGIC_HEADER = '################# REMAINING CONTENT GENERATED BY boilerplate.py ##############\n '
38
38
39
- PYPLOT_PATH = os .path .join (os .path .dirname (__file__ ), 'lib' ,
40
- 'matplotlib' , 'pyplot.py' )
39
+ PYPLOT_PATH = os .path .join (os .path .dirname (__file__ ), 'lib' , 'matplotlib' ,
40
+ 'pyplot.py' )
41
41
42
42
43
43
AUTOGEN_MSG = """
@@ -150,7 +150,7 @@ def boilerplate_gen():
150
150
'vlines' ,
151
151
'xcorr' ,
152
152
'barbs' ,
153
- )
153
+ )
154
154
155
155
_misccommands = (
156
156
'cla' ,
@@ -164,25 +164,24 @@ def boilerplate_gen():
164
164
'tick_params' ,
165
165
'margins' ,
166
166
'autoscale' ,
167
- )
167
+ )
168
168
169
169
cmappable = {
170
- 'contour' : 'if %(ret)s._A is not None: sci(%(ret)s)' ,
170
+ 'contour' : 'if %(ret)s._A is not None: sci(%(ret)s)' ,
171
171
'contourf' : 'if %(ret)s._A is not None: sci(%(ret)s)' ,
172
- 'hexbin' : 'sci(%(ret)s)' ,
173
- 'scatter' : 'sci(%(ret)s)' ,
174
- 'pcolor' : 'sci(%(ret)s)' ,
172
+ 'hexbin' : 'sci(%(ret)s)' ,
173
+ 'scatter' : 'sci(%(ret)s)' ,
174
+ 'pcolor' : 'sci(%(ret)s)' ,
175
175
'pcolormesh' : 'sci(%(ret)s)' ,
176
- 'hist2d' : 'sci(%(ret)s[-1])' ,
177
- 'imshow' : 'sci(%(ret)s)' ,
176
+ 'hist2d' : 'sci(%(ret)s[-1])' ,
177
+ 'imshow' : 'sci(%(ret)s)' ,
178
178
#'spy' : 'sci(%(ret)s)', ### may return image or Line2D
179
- 'quiver' : 'sci(%(ret)s)' ,
180
- 'specgram' : 'sci(%(ret)s[-1])' ,
181
- 'streamplot' : 'sci(%(ret)s.lines)' ,
182
- 'tricontour' : 'if %(ret)s._A is not None: sci(%(ret)s)' ,
179
+ 'quiver' : 'sci(%(ret)s)' ,
180
+ 'specgram' : 'sci(%(ret)s[-1])' ,
181
+ 'streamplot' : 'sci(%(ret)s.lines)' ,
182
+ 'tricontour' : 'if %(ret)s._A is not None: sci(%(ret)s)' ,
183
183
'tricontourf' : 'if %(ret)s._A is not None: sci(%(ret)s)' ,
184
- 'tripcolor' : 'sci(%(ret)s)' ,
185
-
184
+ 'tripcolor' : 'sci(%(ret)s)' ,
186
185
}
187
186
188
187
def format_value (value ):
@@ -196,9 +195,9 @@ def format_value(value):
196
195
return '=mlab.' + value .__name__
197
196
if value .__name__ == 'mean' :
198
197
return '=np.' + value .__name__
199
- raise ValueError (('default value %s unknown to boilerplate.' + \
198
+ raise ValueError (('default value %s unknown to boilerplate.' +
200
199
'formatvalue' ) % value )
201
- return '=' + repr (value )
200
+ return '=' + repr (value )
202
201
203
202
text_wrapper = textwrap .TextWrapper (break_long_words = False )
204
203
@@ -214,7 +213,7 @@ def format_value(value):
214
213
215
214
# Get argspec of wrapped function
216
215
args , varargs , varkw , defaults = inspect .getargspec (getattr (Axes , func ))
217
- args .pop (0 ) # remove 'self' argument
216
+ args .pop (0 ) # remove 'self' argument
218
217
if defaults is None :
219
218
defaults = ()
220
219
else :
@@ -234,9 +233,9 @@ def format_value(value):
234
233
call .append ('%s=%s' % (arg , arg ))
235
234
236
235
if varargs is not None :
237
- call .append ('*' + varargs )
236
+ call .append ('*' + varargs )
238
237
if varkw is not None :
239
- call .append ('**' + varkw )
238
+ call .append ('**' + varkw )
240
239
call = ', ' .join (call )
241
240
242
241
text_wrapper .width = 80 - 19 - len (func )
@@ -257,7 +256,7 @@ def format_value(value):
257
256
# Now we can build the argspec for defining the wrapper
258
257
argspec = inspect .formatargspec (args , varargs , varkw , defaults ,
259
258
formatvalue = format_value )
260
- argspec = argspec [1 :- 1 ] # remove parens
259
+ argspec = argspec [1 :- 1 ] # remove parens
261
260
262
261
text_wrapper .width = 80 - 5 - len (func )
263
262
join_with = '\n ' + ' ' * (5 + len (func ))
@@ -268,9 +267,9 @@ def format_value(value):
268
267
washold , ret , ax = 'washold' , 'ret' , 'ax'
269
268
bad = set (args ) | set ((varargs , varkw ))
270
269
while washold in bad or ret in bad or ax in bad :
271
- washold = 'washold' + str (random .randrange (10 ** 12 ))
272
- ret = 'ret' + str (random .randrange (10 ** 12 ))
273
- ax = 'ax' + str (random .randrange (10 ** 12 ))
270
+ washold = 'washold' + str (random .randrange (10 ** 12 ))
271
+ ret = 'ret' + str (random .randrange (10 ** 12 ))
272
+ ax = 'ax' + str (random .randrange (10 ** 12 ))
274
273
275
274
# Since we can't avoid using some function names,
276
275
# bail out if they are used as argument names
@@ -287,10 +286,10 @@ def format_value(value):
287
286
'cool' ,
288
287
'copper' ,
289
288
'flag' ,
290
- 'gray' ,
289
+ 'gray' ,
291
290
'hot' ,
292
291
'hsv' ,
293
- 'jet' ,
292
+ 'jet' ,
294
293
'pink' ,
295
294
'prism' ,
296
295
'spring' ,
@@ -305,15 +304,15 @@ def format_value(value):
305
304
yield ''
306
305
yield '_setup_pyplot_info_docstrings()'
307
306
307
+
308
308
def build_pyplot ():
309
309
pyplot_path = os .path .join (os .path .dirname (__file__ ), 'lib' ,
310
310
'matplotlib' , 'pyplot.py' )
311
311
312
312
pyplot_orig = open (pyplot_path , 'r' ).readlines ()
313
313
314
-
315
314
try :
316
- pyplot_orig = pyplot_orig [:pyplot_orig .index (PYPLOT_MAGIC_HEADER )+ 1 ]
315
+ pyplot_orig = pyplot_orig [:pyplot_orig .index (PYPLOT_MAGIC_HEADER ) + 1 ]
317
316
except IndexError :
318
317
raise ValueError ('The pyplot.py file *must* have the exact line: %s' % PYPLOT_MAGIC_HEADER )
319
318
0 commit comments