Navigation Menu

Skip to content
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

Reenable shading tests for numpy 1.9.1 and later #3755

Merged
merged 2 commits into from Nov 5, 2014

Conversation

jenshnielsen
Copy link
Member

This fixes #3598 now the numpy 1.9.1 is released which changes the default gradient on the edge back to first order and fixes an issue with sharing of masks for masked arrays calculated from other masked arrays.

The non masked test passed for all versions of numpy different from 1.9.0. To get the tests passing with 1.9.0 the arrays are modified to cut out the edges which is the only differences.

The masked test is different for all versions due to the long standing mask bug. The numpy 1.9.1 version is the most correct so I chose to raise a knowfailure for all older versions.

See attached illustration (the corners where previously masked but are now calculated correctly) :

numpy19shadebug

@jenshnielsen
Copy link
Member Author

This is somewhat urgent since on of the tests is failing on master with a knowfailure test did not fail using numpy 1.9.1 which Travis might soon pickup.

@tacaswell
Copy link
Member

Not sure what to make of the failing test passing on 2.6/np 1.6

@tacaswell tacaswell added this to the v1.5.x milestone Nov 4, 2014
@jenshnielsen
Copy link
Member Author

I reenabled the test on 1.6 and that is fine.
I ran the gradient on various different numpy versions and that confirms it 1.6 behaves like 1.9.1

numpy 1.6

z before

[[-10.0 -6.0 -1.0 1.0 1.0 -1.0 -6.0 -10.0]
 [-6.0 1.0 5.0 7.0 7.0 5.0 1.0 -6.0]
 [-1.0 5.0 9.0 10.0 10.0 9.0 5.0 -1.0]
 [1.0 7.0 10.0 -- -- 10.0 7.0 1.0]
 [1.0 7.0 10.0 -- -- 10.0 7.0 1.0]
 [-1.0 5.0 9.0 10.0 10.0 9.0 5.0 -1.0]
 [-6.0 1.0 5.0 7.0 7.0 5.0 1.0 -6.0]
 [-10.0 -6.0 -1.0 1.0 1.0 -1.0 -6.0 -10.0]]

z after

[[-10.0 -6.0 -1.0 1.0 1.0 -1.0 -6.0 -10.0]
 [-6.0 1.0 5.0 7.0 7.0 5.0 1.0 -6.0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.0]
 [3.0 3.0 2.0 -- -- 2.0 3.0 3.0]
 [1.0 1.0 0.0 -- -- 0.0 1.0 1.0]
 [-1.0 -1.0 -0.0 -- -- -0.0 -1.0 -1.0]
 [-3.0 -3.0 -2.0 -- -- -2.0 -3.0 -3.0]
 [-4.0 -6.0 -5.0 -4.0 -4.0 -5.0 -6.0 -4.0]
 [-4.0 -7.0 -7.0 -6.0 -6.0 -7.0 -7.0 -4.0]]

as a result of running

import numpy as np
y, x = np.mgrid[-1.2:1.2:8j, -1.2:1.2:8j]
z = 10 * np.cos(x**2 + y**2)

z_mask = np.ma.masked_greater(z, 9.9)


print('z before\n')
print(np.round(z_mask))
print('\nz after\n')
dy, dx = np.gradient(z_mask)
print(np.round(z_mask))
print('\ndx\n')
print(np.round(dx))
print('\ndy\n')
print(np.round(dy))

tacaswell added a commit that referenced this pull request Nov 5, 2014
TST : Reenable shading tests for numpy 1.9.1 and later
@tacaswell tacaswell merged commit a8e028d into matplotlib:master Nov 5, 2014
@tacaswell
Copy link
Member

Thanks for being on top of these numpy issues.

@jenshnielsen jenshnielsen deleted the numpy_191_fixes branch November 5, 2014 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test_light_source_shading_default and test_light_source_masked_shading fails with numpy 1.9
2 participants