Skip to content

Commit

Permalink
add hacks to satisfy mypy due to apparent bugs in typing
Browse files Browse the repository at this point in the history
  • Loading branch information
rettigl committed Oct 14, 2023
1 parent c8cc54c commit 4f4ef93
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion sed/calibrator/energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1732,8 +1732,10 @@ def peakdetect1d(
if lookahead < 1:
raise ValueError("Lookahead must be '1' or above in value")

if not (np.isscalar(delta) and delta >= 0):
if not (np.isscalar(delta) and cast(int, delta) >= 0):
raise ValueError("delta must be a positive number")
# Hack because TypeGuard with numpy 1.22.4 seems broken
delta = cast(int, delta)

# maxima and minima candidates are temporarily stored in
# mx and mn respectively
Expand Down
4 changes: 3 additions & 1 deletion tests/test_binning.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""This file contains code that performs several tests for the sed.binning module
"""
from typing import Any
from typing import cast
from typing import List
from typing import Sequence
from typing import Tuple
Expand Down Expand Up @@ -394,7 +395,8 @@ def test_simplify_binning_arguments(
)

for i, bin_ in enumerate(bins__):
np.testing.assert_array_equal(bin_, bins_expected[i])
# TODO: Why does typing fail?
np.testing.assert_array_equal(cast(np.ndarray, bin_), bins_expected[i])
np.testing.assert_array_equal(axes__[i], axes_expected[i])
if ranges__ is not None:
np.testing.assert_array_equal(ranges__[i], ranges_expected[i])
Expand Down

0 comments on commit 4f4ef93

Please sign in to comment.