@@ -52,7 +52,7 @@ def _check_and_prepare_data(data, config):
52
52
columns = ('Open' , 'High' , 'Low' , 'Close' , 'Volume' )
53
53
if all ([c .lower () in data for c in columns [0 :4 ]]):
54
54
columns = ('open' , 'high' , 'low' , 'close' , 'volume' )
55
-
55
+
56
56
o , h , l , c , v = columns
57
57
cols = [o , h , l , c ]
58
58
@@ -100,7 +100,7 @@ def _get_valid_plot_types(plottype=None):
100
100
return _alias_types [plottype ]
101
101
else :
102
102
return plottype
103
-
103
+
104
104
105
105
def _mav_validator (mav_value ):
106
106
'''
@@ -143,12 +143,12 @@ def _valid_mav(value, is_period=True):
143
143
return False
144
144
145
145
def _colors_validator (value ):
146
- if not isinstance (value , list ):
146
+ if not isinstance (value , ( list , tuple , np . ndarray ) ):
147
147
return False
148
148
149
149
for v in value :
150
150
if v :
151
- if not ( isinstance ( v , dict ) or isinstance (v , str )):
151
+ if v is not None and not isinstance (v , ( dict , str )):
152
152
return False
153
153
154
154
return True
@@ -204,11 +204,11 @@ def _alines_validator(value, returnStandardizedValue=False):
204
204
A sequence of (line0, line1, line2), where:
205
205
206
206
linen = (x0, y0), (x1, y1), ... (xm, ym)
207
-
207
+
208
208
or the equivalent numpy array with two columns. Each line can be a different length.
209
209
210
210
The above is from the matplotlib LineCollection documentation.
211
- It basically says that the "segments" passed into the LineCollection constructor
211
+ It basically says that the "segments" passed into the LineCollection constructor
212
212
must be a Sequence of Sequences of 2 or more xy Pairs. However here in `mplfinance`
213
213
we want to allow that (seq of seq of xy pairs) _as well as_ just a sequence of pairs.
214
214
Therefore here in the validator we will allow both:
@@ -270,8 +270,8 @@ def _tlines_subvalidator(value):
270
270
def _bypass_kwarg_validation (value ):
271
271
''' For some kwargs, we either don't know enough, or
272
272
the validation is too complex to make it worth while,
273
- so we bypass kwarg validation. If the kwarg is
274
- invalid, then eventually an exception will be
273
+ so we bypass kwarg validation. If the kwarg is
274
+ invalid, then eventually an exception will be
275
275
raised at the time the kwarg value is actually used.
276
276
'''
277
277
return True
@@ -300,7 +300,7 @@ def _process_kwargs(kwargs, vkwargs):
300
300
Given a "valid kwargs table" and some kwargs, verify that each key-word
301
301
is valid per the kwargs table, and that the value of the kwarg is the
302
302
correct type. Fill a configuration dictionary with the default value
303
- for each kwarg, and then substitute in any values that were provided
303
+ for each kwarg, and then substitute in any values that were provided
304
304
as kwargs and return the configuration dictionary.
305
305
'''
306
306
# initialize configuration from valid_kwargs_table:
@@ -327,7 +327,7 @@ def _process_kwargs(kwargs, vkwargs):
327
327
328
328
# ---------------------------------------------------------------
329
329
# At this point in the loop, if we have not raised an exception,
330
- # then kwarg is valid as far as we can tell, therefore,
330
+ # then kwarg is valid as far as we can tell, therefore,
331
331
# go ahead and replace the appropriate value in config:
332
332
333
333
config [key ] = value
@@ -346,7 +346,7 @@ def _scale_padding_validator(value):
346
346
if key not in valid_keys :
347
347
raise ValueError ('Invalid key "' + str (key )+ '" found in `scale_padding` dict.' )
348
348
if not isinstance (value [key ],(int ,float )):
349
- raise ValueError ('`scale_padding` dict contains non-number at key "' + str (key )+ '"' )
349
+ raise ValueError ('`scale_padding` dict contains non-number at key "' + str (key )+ '"' )
350
350
return True
351
351
else :
352
352
raise ValueError ('`scale_padding` kwarg must be a number, or dict of (left,right,top,bottom) numbers.' )
@@ -372,9 +372,9 @@ def _yscale_validator(value):
372
372
373
373
def _check_for_external_axes (config ):
374
374
'''
375
- Check that all `fig` and `ax` kwargs are either ALL None,
375
+ Check that all `fig` and `ax` kwargs are either ALL None,
376
376
or ALL are valid instances of Figures/Axes:
377
-
377
+
378
378
An external Axes object can be passed in three places:
379
379
- mpf.plot() `ax=` kwarg
380
380
- mpf.plot() `volume=` kwarg
@@ -391,7 +391,7 @@ def _check_for_external_axes(config):
391
391
raise TypeError ('addplot must be `dict`, or `list of dict`, NOT ' + str (type (addplot )))
392
392
for apd in addplot :
393
393
ap_axlist .append (apd ['ax' ])
394
-
394
+
395
395
if len (ap_axlist ) > 0 :
396
396
if config ['ax' ] is None :
397
397
if not all ([ax is None for ax in ap_axlist ]):
@@ -416,6 +416,6 @@ def _check_for_external_axes(config):
416
416
raise ValueError ('`volume` must be of type `matplotlib.axis.Axes`' )
417
417
#if not isinstance(config['fig'],mpl.figure.Figure):
418
418
# raise ValueError('`fig` kwarg must be of type `matplotlib.figure.Figure`')
419
-
419
+
420
420
external_axes_mode = True if isinstance (config ['ax' ],mpl .axes .Axes ) else False
421
421
return external_axes_mode
0 commit comments