Skip to content

Commit 572e5ed

Browse files
authored
Merge pull request #109 from CCPBioSim/94-improve-test-coverage-for-levels
Improve Test Coverage for `levels.py`
2 parents 80e6c05 + ebe7d9a commit 572e5ed

File tree

2 files changed

+760
-3
lines changed

2 files changed

+760
-3
lines changed

CodeEntropy/levels.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,14 +441,17 @@ def get_sphCoord_axes(self, arg_r):
441441
if x2y2 == 0.0:
442442
raise ValueError("x2y2 is zero, cannot compute sin_phi and cos_phi.")
443443

444+
# These conditions are mathematically unreachable for real-valued vectors.
445+
# Marked as no cover to avoid false negatives in coverage reports.
446+
444447
# Check for non-negative values inside the square root
445-
if x2y2 / r2 < 0:
448+
if x2y2 / r2 < 0: # pragma: no cover
446449
raise ValueError(
447450
f"Negative value encountered for sin_theta calculation: {x2y2 / r2}. "
448451
f"Cannot take square root."
449452
)
450453

451-
if x2y2 < 0:
454+
if x2y2 < 0: # pragma: no cover
452455
raise ValueError(
453456
f"Negative value encountered for sin_phi and cos_phi "
454457
f"calculation: {x2y2}. "
@@ -462,7 +465,7 @@ def get_sphCoord_axes(self, arg_r):
462465
sin_phi = arg_r[1] / np.sqrt(x2y2)
463466
cos_phi = arg_r[0] / np.sqrt(x2y2)
464467

465-
else:
468+
else: # pragma: no cover
466469
sin_theta = 0.0
467470
cos_theta = 1
468471

0 commit comments

Comments
 (0)