Skip to content

Commit

Permalink
Merge pull request #1128 from hugovk/noise
Browse files Browse the repository at this point in the history
Fix ImagingEffectNoise
  • Loading branch information
wiredfool committed Mar 9, 2015
2 parents 001772c + 9bd38bf commit 4566a4d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions Tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ def test_effect_mandelbrot_bad_arguments(self):
ValueError,
lambda: Image.effect_mandelbrot(size, extent, quality))

@unittest.skipUnless(sys.platform.startswith('win32'),
"Stalls on Travis CI, passes on Windows")
def test_effect_noise(self):
# Arrange
size = (100, 100)
Expand All @@ -180,8 +178,8 @@ def test_effect_noise(self):

# Assert
self.assertEqual(im.size, (100, 100))
self.assertEqual(im.getpixel((0, 0)), 60)
self.assertEqual(im.getpixel((0, 1)), 28)
self.assertEqual(im.mode, "L")
self.assertNotEqual(im.getpixel((0, 0)), im.getpixel((0, 1)))

def test_effect_spread(self):
# Arrange
Expand Down
4 changes: 2 additions & 2 deletions libImaging/Effects.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ ImagingEffectNoise(int xsize, int ysize, float sigma)
/* after numerical recipes */
double v1, v2, radius, factor;
do {
v1 = rand()*(2.0/32767.0) - 1.0;
v2 = rand()*(2.0/32767.0) - 1.0;
v1 = rand()*(2.0/RAND_MAX) - 1.0;
v2 = rand()*(2.0/RAND_MAX) - 1.0;
radius= v1*v1 + v2*v2;
} while (radius >= 1.0);
factor = sqrt(-2.0*log(radius)/radius);
Expand Down

0 comments on commit 4566a4d

Please sign in to comment.