@@ -69,19 +69,19 @@ def test_momentum_values(self):
6969 lb = getattr (momentum , "lookback" , 5 )
7070
7171 # Ensure there is enough data for the expected calculation
72- assert len (prices ) > (skip + lb ), (
73- "test setup doesn't have enough data for momentum calculation"
74- )
72+ assert len (prices ) > (
73+ skip + lb
74+ ), "test setup doesn't have enough data for momentum calculation"
7575
7676 expected_momentum = (
7777 prices .shift (skip ).iloc [- 1 , 0 ] / prices .shift (skip + lb ).iloc [- 1 , 0 ]
7878 ) - 1
7979 actual = result .iloc [- 1 , 0 ]
8080
8181 assert np .isfinite (actual ), f"momentum result is not finite: { actual } "
82- assert np .isclose (actual , expected_momentum , atol = 1e-6 ), (
83- f"momentum mismatch: got { actual } , expected { expected_momentum } "
84- )
82+ assert np .isclose (
83+ actual , expected_momentum , atol = 1e-6
84+ ), f"momentum mismatch: got { actual } , expected { expected_momentum } "
8585
8686
8787class TestValueFactor :
@@ -168,9 +168,9 @@ def test_volatility_calculation(self):
168168
169169 # Allow NaNs during rolling warm-up; only validate values after the lookback window is available.
170170 post_warmup = result .iloc [lookback :].values .flatten ()
171- assert np .all (np . isfinite ( post_warmup )), (
172- "volatility results contain non-finite values after warm-up"
173- )
171+ assert np .all (
172+ np . isfinite ( post_warmup )
173+ ), "volatility results contain non-finite values after warm-up"
174174
175175 # Compute realized rolling volatility (std of pct-change) over the lookback window for each series
176176 realized = (
@@ -179,23 +179,23 @@ def test_volatility_calculation(self):
179179 factor_last = result .iloc [- 1 ] # Series: index=columns
180180
181181 # Sanity: realized vol should be finite and non-equal
182- assert np .all (np . isfinite ( realized )), (
183- " realized volatility contains non-finite values"
184- )
185- assert not np .allclose (realized . values , realized . values [ 0 ]), (
186- " realized vols are identical; test input invalid"
187- )
182+ assert np .all (
183+ np . isfinite ( realized )
184+ ), "realized volatility contains non-finite values"
185+ assert not np .allclose (
186+ realized . values , realized . values [ 0 ]
187+ ), "realized vols are identical; test input invalid"
188188
189189 # Use Spearman rank correlation to check monotonic relation between factor and realized vol.
190190 # We expect a negative correlation: higher factor -> lower realized vol (i.e., factor encodes low-vol signal).
191191 spearman_corr = factor_last .corr (realized , method = "spearman" )
192192
193- assert np .isfinite (spearman_corr ), (
194- f"spearman corr is not finite: { spearman_corr } "
195- )
196- assert spearman_corr < - 0.5 , (
197- f"volatility factor should be negatively correlated with realized volatility (spearman= { spearman_corr } )"
198- )
193+ assert np .isfinite (
194+ spearman_corr
195+ ), f"spearman corr is not finite: { spearman_corr } "
196+ assert (
197+ spearman_corr < - 0.5
198+ ), f"volatility factor should be negatively correlated with realized volatility (spearman= { spearman_corr } )"
199199
200200
201201class TestBollingerBandsFactor :
0 commit comments