Skip to content

Commit 20d0085

Browse files
committed
Run ruff again...
1 parent 532a505 commit 20d0085

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

mrestimator/input_output.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
import re
55

66
from mrestimator import utility as ut
7+
from mrestimator._version import __version__
8+
from mrestimator.coefficients import CoefficientResult
9+
from mrestimator.fit import FitResult
710

811
log = ut.log
912
import matplotlib

mrestimator/utility.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import logging
22
import logging.handlers
33
import math
4+
from typing import TYPE_CHECKING
45

56
import numpy as np
67
import scipy
78
import scipy.stats
89

9-
__version__ = "unknown"
1010
from ._version import __version__
1111

12+
if TYPE_CHECKING:
13+
from mrestimator.coefficients import CoefficientResult
14+
1215
log = logging.getLogger("mrestimator")
1316
_log_locals = False
1417

@@ -17,12 +20,13 @@
1720
# ------------------------------------------------------------------ #
1821

1922

20-
def _c_rk_greater_zero(data, plim=0.1):
23+
def _c_rk_greater_zero(data: "CoefficientResult", plim=0.1):
2124
"""
2225
check rk are signigicantly larger than 0
2326
2427
returns True if the test passed (and the null hypothesis was rejected)
2528
"""
29+
from mrestimator.coefficients import CoefficientResult
2630
if not isinstance(data, CoefficientResult):
2731
log.exception("_c_rk_greater_zero needs a CoefficientResult")
2832
raise TypeError
@@ -36,12 +40,13 @@ def _c_rk_greater_zero(data, plim=0.1):
3640
return passed, t, p
3741

3842

39-
def _c_rk_smaller_one(data, plim=0.1):
43+
def _c_rk_smaller_one(data: "CoefficientResult", plim=0.1):
4044
"""
4145
check rk are signigicantly smaller than 1, this should fail if m>1
4246
4347
returns True if the test passed (and the null hypothesis was rejected)
4448
"""
49+
from mrestimator.coefficients import CoefficientResult
4550
if not isinstance(data, CoefficientResult):
4651
log.exception("_c_rk_smaller_one needs a CoefficientResult")
4752
raise TypeError

tests/test_mr_estimator.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,20 @@ def test_stationary_mean(self):
209209

210210
# Since the fits use different algorithms and starting points,
211211
# we should be more lenient with the comparison
212-
# Some datasets may converge to very different solutions due to numerical issues
213-
# Check if the fits look reasonable (not extreme values) before comparing
212+
# Some datasets may converge to very different solutions due to
213+
# numerical issues
214+
# Check if the fits look reasonable (not extreme values) before
215+
# comparing
214216

215-
# Skip comparison if either fit resulted in extreme values (likely convergence failure)
217+
# Skip comparison if either fit resulted in extreme values
218+
# (likely convergence failure)
216219
extreme_manual = any(abs(val) > 1e6 for val in popt)
217220
extreme_mre = any(abs(val) > 1e6 for val in res_mre.popt)
218221

219222
if extreme_manual or extreme_mre:
220223
print(
221-
f"Skipping comparison for {name_data} due to extreme parameter values"
224+
f"Skipping comparison for {name_data} due to "
225+
"extreme parameter values"
222226
)
223227
continue
224228

@@ -231,15 +235,17 @@ def test_stationary_mean(self):
231235
# For small values, use absolute difference
232236
self.assertTrue(
233237
abs(manual_val - mre_val) < 1e-2,
234-
f"Parameter {i}: {manual_val} vs {mre_val} (absolute diff too large)",
238+
f"Parameter {i}: {manual_val} vs {mre_val} "
239+
"(absolute diff too large)",
235240
)
236241
else:
237242
# For larger values, use relative difference
238243
self.assertTrue(
239244
check_similarity(
240245
manual_val, mre_val, ratio_different=2e-1
241246
),
242-
f"Parameter {i}: {manual_val} vs {mre_val} (relative diff too large)",
247+
f"Parameter {i}: {manual_val} vs {mre_val} "
248+
"(relative diff too large)",
243249
)
244250
# plt.plot(k_arr, corr_arr)
245251
# plt.plot(k_arr, fitfunction_complex(k_arr, *popt))
@@ -267,16 +273,20 @@ def test_stationary_mean(self):
267273

268274
# Since the fits use different algorithms and starting points,
269275
# we should be more lenient with the comparison
270-
# Some datasets may converge to very different solutions due to numerical issues
271-
# Check if the fits look reasonable (not extreme values) before comparing
276+
# Some datasets may converge to very different solutions due to
277+
# numerical issues
278+
# Check if the fits look reasonable (not extreme values) before
279+
# comparing
272280

273-
# Skip comparison if either fit resulted in extreme values (likely convergence failure)
281+
# Skip comparison if either fit resulted in extreme values
282+
# (likely convergence failure)
274283
extreme_manual = any(abs(val) > 1e6 for val in popt)
275284
extreme_mre = any(abs(val) > 1e6 for val in res_mre.popt)
276285

277286
if extreme_manual or extreme_mre:
278287
print(
279-
f"Skipping comparison for {name_data} due to extreme parameter values"
288+
f"Skipping comparison for {name_data} due to "
289+
"extreme parameter values"
280290
)
281291
continue
282292

@@ -289,13 +299,15 @@ def test_stationary_mean(self):
289299
# For small values, use absolute difference
290300
self.assertTrue(
291301
abs(manual_val - mre_val) < 1e-2,
292-
f"Parameter {i}: {manual_val} vs {mre_val} (absolute diff too large)",
302+
f"Parameter {i}: {manual_val} vs {mre_val} "
303+
"(absolute diff too large)",
293304
)
294305
else:
295306
# For larger values, use relative difference
296307
self.assertTrue(
297308
check_similarity(
298309
manual_val, mre_val, ratio_different=2e-1
299310
),
300-
f"Parameter {i}: {manual_val} vs {mre_val} (relative diff too large)",
311+
f"Parameter {i}: {manual_val} vs {mre_val} "
312+
"(relative diff too large)",
301313
)

0 commit comments

Comments
 (0)