Skip to content

Commit 33aeedc

Browse files
committed
make binary weights checker more strict
1 parent 36966c0 commit 33aeedc

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

hera_filters/dspec.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ def _are_wgts_binary(wgts):
117117
Returns:
118118
Value of True if wgts contains only 1's and 0's
119119
"""
120-
binary_total = np.sum(np.isclose(wgts, 0) + np.isclose(wgts, 1))
121-
return binary_total == np.prod(wgts.shape)
120+
return np.all((wgts == 0) | (wgts == 1))
122121

123122
def place_data_on_uniform_grid(x, data, weights, xtol=1e-3):
124123
"""If possible, place data on a uniformly spaced grid.

hera_filters/tests/test_dspec.py

+4
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ def test_are_wgts_binary():
7878
wgts = np.random.uniform(0, 1, size=100)
7979
assert not dspec._are_wgts_binary(wgts)
8080

81+
# Binary weights array plus some small number should return False
82+
wgts = np.random.choice([0, 1], size=100) + 1e-12
83+
assert not dspec._are_wgts_binary(wgts)
84+
8185
def test_delay_filter_2D():
8286
NCHAN = 128
8387
NTIMES = 10

0 commit comments

Comments
 (0)