-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
converted assert into exception #3060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
873e91d
converted assert into exception
montefra b297f41
Exception type modified according to @pelson comment
montefra 187f584
removed assert in `draw_artist` and `redraw_in_frame`
montefra 34c6a5f
most asserts modified to ValueError
montefra 0c1f9f7
All asserts substituted by ValueError
montefra 4cfa781
method name explicitly written in the message
montefra aba9d99
Most asserts changed to ValueErrors. Two changed to warning
montefra 8fbb652
c* files done
montefra 5a45046
assert removed
montefra 33fdabe
Asserts removed. Side effect: function to check that the inputs have …
montefra 67bdfea
Asserts removed throughout the files m*
montefra 531004c
Asserts removed throughout the files r*
montefra eaca138
SyntaxError from Travis corrected
montefra 9e4b911
assert removed from files s*
montefra d12fbb8
asserts removed from t* file. test and tri directories ignored
montefra 7f80628
asserts removed from [u-z]* files
montefra 4fc36c6
the only assert in a python public function removed
montefra 617b622
Bug introduced while getting rid of the asserts fixed
montefra 2cbb326
typo fixed (broke building documentation)
montefra 20966e9
pep8 fixed. plot_day_summary2 removed (retained by error when rebasing)
montefra 96c733e
PEP8 fixed
montefra 140210f
PEP8 fixed - image.py
montefra a2abc7b
PEP 8 fixed - mlab.py
montefra 25cec22
PEP 8 fixed - patches.py
montefra 06aedf7
PEP8 fixed - path.py
montefra 77da3b6
PEP8 fixed - sankey.py
montefra 95ae2cd
PEP8 fixed - spines.py, table.py
montefra b167c0c
test adapted to code change (AssertionError -> ValueError)
montefra f9792a9
fixed according to #3060 comment
montefra 850178e
Two bugs in assert -> exception transformation fixed
montefra c0ebd4f
Typo fixed
montefra 6b6d2de
Bug in assert -> exception transformation fixed
montefra 088542e
Typo fixed
montefra 41bf6b5
Modified according to @tacaswell comments
montefra 7ea5c1a
fixed pep8 Travis failure
montefra d6c3c32
python2.6 string formatting. style more uniform
montefra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
pep8 fixed. plot_day_summary2 removed (retained by error when rebasing)
- Loading branch information
commit 20966e93bc8b54d722c65fb45024f04c53ef3dc0
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -736,7 +736,7 @@ def candlestick_ohlc(ax, quotes, width=0.2, colorup='k', colordown='r', | |
|
||
|
||
def _candlestick(ax, quotes, width=0.2, colorup='k', colordown='r', | ||
alpha=1.0, ochl=True): | ||
alpha=1.0, ochl=True): | ||
|
||
""" | ||
Plot the time, open, high, low, close as a vertical line ranging | ||
|
@@ -817,7 +817,7 @@ def _candlestick(ax, quotes, width=0.2, colorup='k', colordown='r', | |
|
||
|
||
def _check_input(opens, closes, highs, lows, miss=-1): | ||
"""Checks that *opens*, *highs*, *lows* and *closes* have the same length. | ||
"""Checks that *opens*, *highs*, *lows* and *closes* have the same length. | ||
NOTE: this code assumes if any value open, high, low, close is | ||
missing (*-1*) they all are missing | ||
|
||
|
@@ -833,86 +833,48 @@ def _check_input(opens, closes, highs, lows, miss=-1): | |
sequence of low values | ||
closes : sequence | ||
sequence of closing values | ||
miss: | ||
miss : int | ||
identifier of the missing data | ||
|
||
Raises | ||
------ | ||
ValueError | ||
if the input sequences don't have the same length | ||
""" | ||
|
||
def _missing(sequence, miss=-1): | ||
"""Returns the index in *sequence* of the missing data, identified by | ||
*miss* | ||
|
||
Parameters | ||
---------- | ||
sequence: | ||
sequence : | ||
sequence to evaluate | ||
miss: | ||
miss : | ||
identifier of the missing data | ||
|
||
Returns | ||
------- | ||
where_miss: numpy.ndarray | ||
indices of the missing data | ||
""" | ||
return np.where(np.array(sequence)==miss)[0] | ||
return np.where(np.array(sequence) == miss)[0] | ||
|
||
same_length = (len(opens) == len(highs)) and (len(opens) == len(lows)) and\ | ||
(len(opens) == len(closes)) | ||
_missopens = _missing(opens) | ||
same_missing = (_missopens == _missing(highs)).all() and (_missopens ==\ | ||
same_missing = (_missopens == _missing(highs)).all() and (_missopens == | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you put the line break after one of the |
||
_missing(lows)).all() and (_missopens == _missing(closes)).all() | ||
|
||
if not (same_length and same_missing): | ||
msg = """ | ||
*opens*, *highs*, *lows* and *closes* must have the same length. | ||
*opens*, *highs*, *lows* and *closes* must have the same length. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is going to result in a message with tabs and new lines. I think this is better done as
|
||
NOTE: this code assumes if any value open, high, low, close is | ||
missing (*-1*) they all must be missing | ||
""" | ||
raise ValueError(msg) | ||
|
||
|
||
def plot_day_summary2(ax, opens, closes, highs, lows, ticksize=4, | ||
colorup='k', colordown='r', | ||
): | ||
"""Represent the time, open, close, high, low, as a vertical line | ||
ranging from low to high. The left tick is the open and the right | ||
tick is the close. | ||
|
||
|
||
This function has been deprecated in 1.4 in favor of | ||
`plot_day_summary2_ochl`, which maintains the original argument | ||
order, or `plot_day_summary2_ohlc`, which uses the | ||
open-high-low-close order. This function will be removed in 1.5 | ||
|
||
|
||
Parameters | ||
---------- | ||
ax : `Axes` | ||
an Axes instance to plot to | ||
opens : sequence | ||
sequence of opening values | ||
closes : sequence | ||
sequence of closing values | ||
highs : sequence | ||
sequence of high values | ||
lows : sequence | ||
sequence of low values | ||
ticksize : int | ||
size of open and close ticks in points | ||
colorup : color | ||
the color of the lines where close >= open | ||
colordown : color | ||
the color of the lines where close < open | ||
|
||
Returns | ||
------- | ||
ret : list | ||
a list of lines added to the axes | ||
""" | ||
|
||
warnings.warn(_warn_str.format(fun='plot_day_summary2'), mplDeprecation) | ||
return plot_day_summary2_ohlc(ax, opens, highs, lows, closes, ticksize, | ||
colorup, colordown) | ||
|
||
|
||
def plot_day_summary2_ochl(ax, opens, closes, highs, lows, ticksize=4, | ||
colorup='k', colordown='r', | ||
): | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't need the
\
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that
len(opens) == len(highs) == len(lows) == len(closes)
will also work here (python puts in the implicitand
s).