(
self,
info,
preload=False,
first_samps=(0,),
last_samps=None,
filenames=None,
raw_extras=(None,),
orig_format="double",
dtype=np.float64,
buffer_size_sec=1.0,
orig_units=None,
*,
verbose=None,
)
| 186 | |
| 187 | @verbose |
| 188 | def __init__( |
| 189 | self, |
| 190 | info, |
| 191 | preload=False, |
| 192 | first_samps=(0,), |
| 193 | last_samps=None, |
| 194 | filenames=None, |
| 195 | raw_extras=(None,), |
| 196 | orig_format="double", |
| 197 | dtype=np.float64, |
| 198 | buffer_size_sec=1.0, |
| 199 | orig_units=None, |
| 200 | *, |
| 201 | verbose=None, |
| 202 | ): |
| 203 | # wait until the end to preload data, but triage here |
| 204 | if isinstance(preload, np.ndarray): |
| 205 | # some functions (e.g., filtering) only work w/64-bit data |
| 206 | if preload.dtype not in (np.float64, np.complex128): |
| 207 | raise RuntimeError( |
| 208 | f"datatype must be float64 or complex128, not {preload.dtype}" |
| 209 | ) |
| 210 | if preload.dtype != dtype: |
| 211 | raise ValueError("preload and dtype must match") |
| 212 | self._data = preload |
| 213 | self.preload = True |
| 214 | assert len(first_samps) == 1 |
| 215 | last_samps = [first_samps[0] + self._data.shape[1] - 1] |
| 216 | load_from_disk = False |
| 217 | else: |
| 218 | if last_samps is None: |
| 219 | raise ValueError( |
| 220 | "last_samps must be given unless preload is an ndarray" |
| 221 | ) |
| 222 | if not preload: |
| 223 | self.preload = False |
| 224 | load_from_disk = False |
| 225 | else: |
| 226 | load_from_disk = True |
| 227 | self._last_samps = np.array(last_samps) |
| 228 | self._first_samps = np.array(first_samps) |
| 229 | orig_ch_names = info["ch_names"] |
| 230 | with info._unlock(check_after=True): |
| 231 | # be permissive of old code |
| 232 | if isinstance(info["meas_date"], tuple): |
| 233 | info["meas_date"] = _stamp_to_dt(info["meas_date"]) |
| 234 | self.info = info |
| 235 | self.buffer_size_sec = float(buffer_size_sec) |
| 236 | cals = np.empty(info["nchan"]) |
| 237 | for k in range(info["nchan"]): |
| 238 | cals[k] = info["chs"][k]["range"] * info["chs"][k]["cal"] |
| 239 | bad = np.where(cals == 0)[0] |
| 240 | if len(bad) > 0: |
| 241 | raise ValueError( |
| 242 | f"Bad cals for channels {dict((ii, self.ch_names[ii]) for ii in bad)}" |
| 243 | ) |
| 244 | self._cals = cals |
| 245 | if raw_extras is None: |
nothing calls this directly
no test coverage detected