MCPcopy Create free account
hub / github.com/Open-Quant/openquant / _solve_linear_system

Function _solve_linear_system

python/openquant/feature_diagnostics.py:140–164  ·  view source on GitHub ↗
(a: list[list[float]], b: list[float])

Source from the content-addressed store, hash-verified

138 )
139 return [(i, i) for i in range(n_rows)]
140 ends = []
141 for value in event_end_indices:
142 if isinstance(value, (bool, np.bool_)):
143 raise ValueError("event_end_indices must contain exact non-boolean integers")
144 try:
145 ends.append(index(value))
146 except TypeError as exc:
147 raise ValueError("event_end_indices must contain exact non-boolean integers") from exc
148 if len(ends) != n_rows:
149 raise ValueError(f"event_end_indices/X length mismatch: {len(ends)} vs {n_rows}")
150 intervals: list[tuple[int, int]] = []
151 for i, end in enumerate(ends):
152 if end < i:
153 raise ValueError("event_end_indices must satisfy end >= start index")
154 intervals.append((i, min(end, n_rows - 1)))
155 return intervals
156
157
158def _purged_kfold_splits(
159 intervals: Sequence[tuple[int, int]],
160 n_splits: int,
161 pct_embargo: float,
162) -> list[tuple[list[int], list[int]]]:
163 n = len(intervals)
164 if n_splits < 2:
165 raise ValueError("n_splits must be >= 2")
166 if n_splits > n:
167 raise ValueError("n_splits cannot exceed sample count")

Callers 1

Calls 1

maxFunction · 0.85

Tested by

no test coverage detected