-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: Fix strange behavior of infinite-step-size/underflow-case in arange #10263
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
eric-wieser
merged 17 commits into
numpy:master
from
Licht-T:fix-strange-infinite-step-arange
Jun 4, 2018
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
671a224
BUG: Fix strange behavior of infinite step size in arange
Licht-T 825c681
TST: Add tests for np.arange with inf step
Licht-T 4af6233
Merge remote-tracking branch 'original/master' into fix-strange-infin…
Licht-T 2607ad7
Fix build error on Windows
Licht-T 123da27
Fix unnecessary calculation
Licht-T e2cc3e6
Use npy_signbit
Licht-T d4d2758
Add commnt
Licht-T 2827c66
Use int as bool, not intp
Licht-T 0b60753
Dereference the leaked PyObject
Licht-T 41cd4e1
Add zero PyObject pointer null-check
Licht-T 12d020c
Change the order of pointer initialization
Licht-T c5f589d
TST: Add tests for np.arange with underflow cases
Licht-T abc1686
Merge branch 'master' into fix-strange-infinite-step-arange
Licht-T 514c8ec
Remove the assigning a double value to a integer variable
Licht-T d68afb3
Add `PyObject_RichCompareBool` success check
Licht-T 2740bc9
STY: Fix whitespace
eric-wieser 04a85b4
STY: Fix whitespace
eric-wieser 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
Use npy_signbit
- Loading branch information
commit e2cc3e63b98e710eb3d13ae0e9eeba80baec7090
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 |
---|---|---|
|
@@ -28,7 +28,6 @@ | |
#include "templ_common.h" /* for npy_mul_with_overflow_intp */ | ||
#include "alloc.h" | ||
#include <assert.h> | ||
#include <math.h> | ||
|
||
#include "get_attr_string.h" | ||
|
||
|
@@ -2976,7 +2975,7 @@ PyArray_Arange(double start, double stop, double step, int type_num) | |
tmp_len = delta/step; | ||
|
||
if (tmp_len == 0.0 && delta != 0.0) { | ||
if (signbit(tmp_len)) { | ||
if (npy_signbit(tmp_len)) { | ||
length = -1.0; | ||
} | ||
else { | ||
|
@@ -3108,7 +3107,7 @@ _calc_length(PyObject *start, PyObject *stop, PyObject *step, PyObject **next, i | |
} | ||
|
||
if (val_is_zero && next_is_nonzero) { | ||
if (signbit(value)) { | ||
if (npy_signbit(value)) { | ||
len = -1.0; | ||
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. I think this should be |
||
} | ||
else { | ||
|
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.
This needs a comment explaining why it is a special case
Isn't this only satisfied if
step
isinf
anyway?Uh oh!
There was an error while loading. Please reload this page.
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.
@eric-wieser This also considers some underflow cases. eg. in master branch,