[SciPy-user] Array selection help
josef.pktd at gmail.com
josef.pktd at gmail.com
Wed Feb 11 13:46:14 EST 2009
sorry, cut and paste error, the test function used globals, correction below.
You can speed up a little bit more using itertools.izip instead of
zip. (labelmeanfilter 0.377629000334)
Josef
def test_labelmeanfilter(arr1, arr2):
arr3b = labelmeanfilter(arr1, arr2)
labelsunique = np.unique(arr1)
labelmeans = ndimage.mean(arr2, labels=arr1, index=labelsunique)
labmeandict = dict(zip(labelsunique,labelmeans))
for orig,means in zip(arr1,arr3b):
assert_array_equal(means, labmeandict[orig], repr(orig))
More information about the SciPy-User
mailing list