-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathparams.py
More file actions
46 lines (36 loc) · 1.28 KB
/
params.py
File metadata and controls
46 lines (36 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from dataclasses import dataclass
from datetime import datetime
from os import PathLike
from pathlib import Path
from typing import Iterable, Optional, Type, Union
import numpy as np
from harp.data.model import Model
datapath = Path(__file__).parent
@dataclass
class DataFileParam:
path: Union[str, PathLike]
expected_rows: int
expected_cols: Optional[Iterable[str]] = None
expected_address: Optional[int] = None
expected_dtype: Optional[np.dtype] = None
expected_length: Optional[int] = None
expected_error: Optional[Type[BaseException]] = None
repeat_data: Optional[int] = None
epoch: Optional[datetime] = None
keep_type: bool = False
def __post_init__(self):
self.path = datapath / self.path
@dataclass
class DeviceSchemaParam:
path: Union[str, PathLike]
expected_whoAmI: int
expected_device: Optional[int] = None
expected_registers: Optional[Iterable[str]] = None
expected_error: Optional[Type[BaseException]] = None
def __post_init__(self):
self.path = datapath / self.path
def assert_schema(self, device: Model):
assert device.whoAmI == self.expected_whoAmI
if self.expected_registers:
for register in self.expected_registers:
assert register in device.registers