Skip to content

Commit 025e059

Browse files
author
Matthew Townson
authored
Merge pull request #54 from andrewpaulreeves/master
Fix Gaussian 2d bug when numpy array given as centre point coordinates
2 parents 3b6ae03 + 32ceb84 commit 025e059

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

aotools/functions/_functions.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ def gaussian2d(size, width, amplitude=1., cent=None):
1010
size (tuple, float): Dimensions of Array to place gaussian (y, x)
1111
width (tuple, float): Width of distribution.
1212
Accepts tuple for x and y values in order (y, x).
13-
amplitude (float): Amplitude of guassian distribution
14-
cent (tuple): Centre of distribution on grid in order (y, x).
13+
amplitude (float, optional): Amplitude of guassian distribution. default is 1.
14+
cent (tuple, optional): Centre of distribution on grid in order (y, x). Default is middle
1515
'''
1616

1717
try:
@@ -25,8 +25,9 @@ def gaussian2d(size, width, amplitude=1., cent=None):
2525
xWidth = float(width[1])
2626
except (TypeError, IndexError):
2727
xWidth = yWidth = float(width)
28-
29-
if not cent:
28+
29+
# If a centre point not given, centre is centre of array
30+
if cent is None:
3031
xCent = xSize/2.
3132
yCent = ySize/2.
3233
else:

test/test_functions.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ def test_gaussian2d():
77
assert gaussian.shape == (10, 10)
88

99

10+
def test_gaussian2d_array_centre_point():
11+
gaussian = functions.gaussian2d((10, 8), (3, 2), 10., numpy.asarray((4, 3)))
12+
assert gaussian.shape == (10, 8)
13+
14+
1015
def test_gaussian2d_2d():
1116
gaussian = functions.gaussian2d((10, 8), (3, 2), 10., (4, 3))
12-
print(gaussian.shape)
1317
assert gaussian.shape == (10, 8)

0 commit comments

Comments
 (0)