def _values_mask(data: np.ndarray, col: int) -> \ Tuple[np.ndarray, np.ndarray]: try: values = data[:, col] except IndexError: values = np.array([], dtype=object) return values, isnastr(values)
def _cont_column(data: np.ndarray, col: int, offset=0, **_) -> _ColumnProperties: orig_vals, namask = _TableBuilder._values_mask(data, col) values = np.empty(data.shape[0], dtype=float) try: np.copyto(values, orig_vals, casting="unsafe", where=~namask) values[namask] = np.nan except ValueError: row = 0 for row, num in enumerate(orig_vals): if not isnastr(num): try: float(num) except ValueError: break raise ValueError(f'Non-continuous value in (1-based) ' f'line {row + offset + 1}, column {col + 1}') return _ColumnProperties(values=values, coltype=ContinuousVariable, orig_values=orig_vals)