Skip to content

Commit 2d9a548

Browse files
committed
Mirror R's tryCatch fallback around NNS.dep in regression dependence
R Regression.R wraps the NNS.dep call in tryCatch with a 0.1 fallback before averaging with the copula measure; the port only guarded the copula half. Wrap the nns_dep call the same way so the order=NULL dependence chain is a literal transcription of the R block. Verified against live R NNS 13.1 on nine datasets spanning n<100 and n>=100: NNS.dep and NNS.copula components bit-identical, composed dependence within 1 ulp, and every resolved dep.reduced.order equal (order=NULL and integer overrides). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BPbZvtDw4h2XJo9w5hw57h
1 parent 2a68bec commit 2d9a548

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/nns/regression.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,12 @@ def _as_point_est(point_est: NDArray[np.float64] | float | None) -> NDArray[np.f
10711071

10721072

10731073
def _regression_dependence(x: NDArray[np.float64], y: NDArray[np.float64]) -> float:
1074-
dep = nns_dep(x, y, asym=True)["Dependence"]
1074+
# Mirrors R Regression.R's tryCatch chain: NNS.dep error -> 0.1, copula
1075+
# error -> keep the NNS.dep component, NA -> 0.1.
1076+
try:
1077+
dep = nns_dep(x, y, asym=True)["Dependence"]
1078+
except (ValueError, FloatingPointError, ZeroDivisionError):
1079+
dep = 0.1
10751080
try:
10761081
scaled = np.column_stack(
10771082
(

0 commit comments

Comments
 (0)