FIX: ndimage.zoom ticket #1122 #204

Closed
wants to merge 4 commits into
from

Conversation

Projects
None yet
3 participants
@jjhelmus
Contributor

jjhelmus commented May 7, 2012

Using patch submitted by russel fixed Ticket #1122. Added a unit test to catch error. With my numpy error setup the test still raises a RuntimeWarning because of the division by zero but passes.

@rgommers

This comment has been minimized.

Show comment
Hide comment
@rgommers

rgommers May 7, 2012

Member

If the divide by zero is supposed to happen (I haven't checked), you can suppress the warning with

old_err = np.seterr(divide="ignore")
try:
    # do thing that divides by 0
finally:
    np.seterr(**old_err)
Member

rgommers commented May 7, 2012

If the divide by zero is supposed to happen (I haven't checked), you can suppress the warning with

old_err = np.seterr(divide="ignore")
try:
    # do thing that divides by 0
finally:
    np.seterr(**old_err)
@rgommers

This comment has been minimized.

Show comment
Hide comment
@rgommers

rgommers Jun 4, 2012

Member

@stefanv : would you be able to have a look at this in the next couple of days (branching 0.11.x on Wed is the plan, but may be a few days later)?

Member

rgommers commented Jun 4, 2012

@stefanv : would you be able to have a look at this in the next couple of days (branching 0.11.x on Wed is the plan, but may be a few days later)?

@jjhelmus

This comment has been minimized.

Show comment
Hide comment
@jjhelmus

jjhelmus Jun 4, 2012

Contributor

The latest commit is a better fix for the problem (both inf and nan should be filtered from zoom). The unit test error is now ignored.

Contributor

jjhelmus commented Jun 4, 2012

The latest commit is a better fix for the problem (both inf and nan should be filtered from zoom). The unit test error is now ignored.

@stefanv

This comment has been minimized.

Show comment
Hide comment
@stefanv

stefanv Jun 5, 2012

Member

I think we're almost there, but what about:

import numpy as np
import scipy.ndimage as ndi

x = np.array([[1, 2]])
print ndi.zoom(x, (2, 1))
print ndi.zoom(x, (1, 2))

which yields

[[1 2]
 [1 2]]

[[0 0 0 0]]

(Last seems incorrect)

Member

stefanv commented Jun 5, 2012

I think we're almost there, but what about:

import numpy as np
import scipy.ndimage as ndi

x = np.array([[1, 2]])
print ndi.zoom(x, (2, 1))
print ndi.zoom(x, (1, 2))

which yields

[[1 2]
 [1 2]]

[[0 0 0 0]]

(Last seems incorrect)

@jjhelmus

This comment has been minimized.

Show comment
Hide comment
@jjhelmus

jjhelmus Jun 6, 2012

Contributor

With the latest commit I get

[[1 2]
 [1 2]]

[[1 1 2 2]]

Which with ints is the expected results.

Contributor

jjhelmus commented Jun 6, 2012

With the latest commit I get

[[1 2]
 [1 2]]

[[1 1 2 2]]

Which with ints is the expected results.

@stefanv

This comment has been minimized.

Show comment
Hide comment
@stefanv

stefanv Jun 6, 2012

Member

It might help if I apply the patch before testing :)

Let's add the test example above and merge.

Member

stefanv commented Jun 6, 2012

It might help if I apply the patch before testing :)

Let's add the test example above and merge.

@jjhelmus

This comment has been minimized.

Show comment
Hide comment
@jjhelmus

jjhelmus Jun 6, 2012

Contributor

Done!

Contributor

jjhelmus commented Jun 6, 2012

Done!

@rgommers

This comment has been minimized.

Show comment
Hide comment
@rgommers

rgommers Jun 9, 2012

Member

Merged as 07f84e3. Thanks Jonathan and Stefan.

Member

rgommers commented Jun 9, 2012

Merged as 07f84e3. Thanks Jonathan and Stefan.

@rgommers rgommers closed this Jun 9, 2012

@rgommers

This comment has been minimized.

Show comment
Hide comment
@rgommers

rgommers Jun 9, 2012

Member

@jjhelmus you may want to set up your editor such that it strips trailing whitespace automatically, there were some lines which had that problem.

Member

rgommers commented Jun 9, 2012

@jjhelmus you may want to set up your editor such that it strips trailing whitespace automatically, there were some lines which had that problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment