Skip to content

Commit 9ecb3ff

Browse files
authored
Merge branch 'master' into fix/446-guard-free-basemap-import
2 parents 3efa999 + 515ed4f commit 9ecb3ff

5 files changed

Lines changed: 21 additions & 1 deletion

File tree

malariagen_data/anoph/frq_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def plot_frequencies_heatmap(
227227
**kwargs,
228228
) -> plotly_params.figure:
229229
# Check len of input.
230-
if max_len and len(df) > max_len:
230+
if max_len is not None and len(df) > max_len:
231231
raise ValueError(
232232
dedent(
233233
f"""

malariagen_data/anoph/g123.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,9 @@ def _garud_g123(gt):
629629
# convert to array of sorted frequencies
630630
f = np.sort(np.fromiter(frq_counter.values(), dtype=float))[::-1]
631631

632+
if f.size == 0:
633+
return np.nan
634+
632635
# compute G123
633636
g123 = np.sum(f[:3]) ** 2 + np.sum(f[3:] ** 2)
634637

malariagen_data/anoph/h12.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,9 @@ def _garud_h12(ht):
848848
# Convert to array of sorted frequencies.
849849
f = np.sort(np.fromiter(frq_counter.values(), dtype=float))[::-1]
850850

851+
if f.size == 0:
852+
return np.nan
853+
851854
# Compute H12.
852855
h12 = np.sum(f[:2]) ** 2 + np.sum(f[2:] ** 2)
853856

tests/anoph/test_g123.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,10 @@ def test_g123_calibration(fixture, api: AnophelesG123Analysis):
265265
# Run plotting function.
266266
fig = api.plot_g123_calibration(**g123_params, show=False)
267267
assert isinstance(fig, bokeh.models.Plot)
268+
269+
270+
def test_garud_g123_empty_window():
271+
import numpy as np
272+
from malariagen_data.anoph.g123 import _garud_g123
273+
274+
assert np.isnan(_garud_g123(np.empty((0, 0), dtype=int)))

tests/anoph/test_h12.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,10 @@ def test_h12_gwss_multi_with_analysis(fixture, api: AnophelesH12Analysis):
328328
params["min_cohort_size"] = n2 + 1
329329
with pytest.raises(ValueError):
330330
api.plot_h12_gwss_multi_panel(**params)
331+
332+
333+
def test_garud_h12_empty_window():
334+
import numpy as np
335+
from malariagen_data.anoph.h12 import _garud_h12
336+
337+
assert np.isnan(_garud_h12(np.empty((0, 0), dtype=int)))

0 commit comments

Comments
 (0)