8000 BUG: Fix strange behavior of infinite-step-size/underflow-case in arange by Licht-T · Pull Request #10263 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

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
merged 17 commits into from
Jun 4, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove the assigning a double value to a integer variable
  • Loading branch information
Licht-T committed May 2, 2018
commit 514c8eca9fdd0048ef395a9051812bb35416a48d
8 changes: 4 additions & 4 deletions numpy/core/src/multiarray/ctors.c
Original file line number Diff line number Diff line change
Expand Up @@ -3008,10 +3008,10 @@ PyArray_Arange(double start, double stop, double step, int type_num)
/* Underflow and divide-by-inf check */
if (tmp_len == 0.0 && delta != 0.0) {
Copy link
Member

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 is inf anyway?

Copy link
Contributor Author
@Licht-T Licht-T Dec 24, 2017

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,

>>> m = np.float32(3.40282347E+38)
>>> e = np.float32(1.401298E-45)
>>> m
3.4028235e+38
>>> e
1.4012985e-45
>>> e/m
0.0
>>> np.arange(np.float32(0), e, m)
array([], dtype=float64)

if (npy_signbit(tmp_len)) {
length = -1.0;
length = 0;
}
else {
length = 1.0;
length = 1;
}
}
else {
Expand Down Expand Up @@ -3149,10 +3149,10 @@ _calc_length(PyObject *start, PyObject *stop, PyObject *step, PyObject **next, i
/* Underflow and divide-by-inf check */
if (val_is_zero && next_is_nonzero) {
if (npy_signbit(value)) {
len = -1.0;
len = 0;
}
else {
len = 1.0;
len = 1;
}
}
else {
Expand Down
0