(x: Sequence[Sequence[float]])
| 19 | |
| 20 | |
| 21 | def _as_matrix(x: Sequence[Sequence[float]]) -> list[list[float]]: |
| 22 | rows = [list(map(float, r)) for r in x] |
| 23 | if not rows: |
| 24 | raise ValueError("X cannot be empty") |
| 25 | width = len(rows[0]) |
| 26 | if width == 0: |
| 27 | raise ValueError("X must contain at least one feature") |
| 28 | if any(len(r) != width for r in rows): |
| 29 | raise ValueError("X must be rectangular") |
| 30 | return rows |
| 31 | |
| 32 | |
| 33 | def _as_vector(y: Sequence[float], n_rows: int) -> list[float]: |
no outgoing calls
no test coverage detected