Coverage for tests/test_fsd.py: 100%
31 statements
« prev ^ index » next coverage.py v7.15.3, created at 2026-09-03 17:23 +1200
« prev ^ index » next coverage.py v7.15.3, created at 2026-09-03 17:23 +1200
1import typing
3from hypothesis import given, strategies as st
4import numpy as np
6from crispatt._fsd import MonoFSD, RampFSD
8if typing.TYPE_CHECKING:
9 from crispatt._fsd import _FSDHandler
11pancake_size_strategy = st.floats(
12 min_value=0.1,
13 max_value=100.0,
14 allow_nan=False,
15)
16n_floes_st = st.integers(1, 20)
19def mono_average(handler: MonoFSD):
20 assert handler.average_length == handler.length
23def ramp_average(handler):
24 assert handler.average_length == (handler.length_left + handler.length_right) / 2
27@given(length=pancake_size_strategy)
28def test_mono(length: float):
29 handler = MonoFSD(length)
30 assert handler.length == length
31 mono_average(handler)
32 n_floes(handler)
35@given(lengths=st.tuples(pancake_size_strategy, pancake_size_strategy))
36def test_ramp(lengths: tuple[float, float]):
37 length_left, length_right = lengths
38 handler = RampFSD(length_left, length_right)
39 assert handler.length_left == length_left
40 assert handler.length_right == length_right
41 ramp_average(handler)
42 n_floes(handler)
45@given(n_floes=n_floes_st)
46def n_floes(handler: "_FSDHandler", n_floes: int):
47 lengths = handler.compute_lengths(n_floes)
48 assert isinstance(lengths, np.ndarray)
49 assert lengths.ndim == 1
50 assert lengths.size == n_floes + 1
51 assert np.isposinf(lengths[-1])