Skip to content

Commit 6d2638f

Browse files
Merge pull request #36 from DanielGoldfarb/master
bypass kwarg validator; not implemented kwarg; update version and release notes
2 parents 24ca6c6 + 22f7024 commit 6d2638f

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ For more examples of using mplfinance, please see the jupyter notebooks in the *
555555

556556
| Version | Description | Release Date |
557557
|:---------|:-------------|:---------------|
558+
| 0.12.3a2 | - implement custom markers (issue#30)<br> - fix minor issue with chart `type` validator<br> -- Thank you Amir Atashin @amiaty for contributing the above.<br> - add internal functions: `_bypass_kwarg_validation()` and `_kwarg_not_implemented()` | 2020-02-21 |
558559
| 0.12.3a1 | - fix issue#28: math.log crash on zero in data<br> - remove "Implemented" field from kwarg dicts<br> - yahoo style show colors for `ohlc bars` | 2020-02-16 |
559560
| 0.12.3a0 | - kwarg `block=False` for non-blocking call to `mpf.plot()`<br> - customize aspect ratio, figure title, y-labels<br> - customize colors and other `style` aspects of plot<br> - `no_xgaps` now defaults to True: use `show_nontrading=True` to set no_xgaps to false<br> - secondary y-axis available to `make_addplot()`<br> - bug fix for volume widths | 2020-02-12 |
560561
| 0.12.0a3 | Increase mav limit from 3 to 7 different mavs | 2020-01-16 |

src/mplfinance/_arg_validators.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,23 @@ def _mav_validator(mav_value):
5656
return False
5757
return True
5858

59+
def _bypass_kwarg_validation(value):
60+
''' For some kwargs, we either don't know enough, or
61+
the validation is too complex to make it worth while,
62+
so we bypass kwarg validation. If the kwarg is
63+
invalid, then eventually an exception will be
64+
raised at the time the kwarg value is actually used.
65+
'''
66+
return True
67+
68+
def _kwarg_not_implemented(value):
69+
''' If you want to list a kwarg in a valid_kwargs dict for a given
70+
function, but you have not yet, or don't yet want to, implement
71+
the kwarg; or you simply want to (temporarily) disable the kwarg,
72+
then use this function as the kwarg validator
73+
'''
74+
raise NotImplementedError('kwarg NOT implemented.')
75+
5976
def _validate_vkwargs_dict(vkwargs):
6077
# Check that we didn't make a typo in any of the things
6178
# that should be the same for all vkwargs dict items:

src/mplfinance/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version_info = (0, 12, 3, 'alpha', 1)
1+
version_info = (0, 12, 3, 'alpha', 2)
22

33
_specifier_ = {'alpha': 'a', 'beta': 'b', 'candidate': 'rc', 'final': ''}
44

src/mplfinance/plotting.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
from mplfinance._arg_validators import _check_and_prepare_data, _mav_validator
2222
from mplfinance._arg_validators import _process_kwargs, _validate_vkwargs_dict
23+
from mplfinance._arg_validators import _kwarg_not_implemented, _bypass_kwarg_validation
2324

2425

2526
def with_rc_context(func):
@@ -72,7 +73,8 @@ def _valid_plot_kwargs():
7273
'Validator' : _mav_validator },
7374

7475
'study' : { 'Default' : None,
75-
'Validator' : lambda value: isinstance(value,dict) }, #{'studyname': {study parms}} example: {'TE':{'mav':20,'upper':2,'lower':2}}
76+
#'Validator' : lambda value: isinstance(value,dict) }, #{'studyname': {study parms}} example: {'TE':{'mav':20,'upper':2,'lower':2}}
77+
'Validator' : lambda value: _kwarg_not_implemented(value) },
7678

7779
'marketcolors': { 'Default' : None, # use 'style' for default, instead.
7880
'Validator' : lambda value: isinstance(value,dict) },
@@ -475,7 +477,7 @@ def _valid_addplot_kwargs():
475477
'Validator' : lambda value: value in ['main','lower'] },
476478

477479
'marker' : { 'Default' : 'o',
478-
'Validator' : lambda value: not isinstance(value,bool) },
480+
'Validator' : lambda value: _bypass_kwarg_validation(value) },
479481

480482
'markersize' : { 'Default' : 18,
481483
'Validator' : lambda value: isinstance(value,(int,float)) },

0 commit comments

Comments
 (0)