Declares a path_info key a node may read: its type and allowed values.
options is None means any value of dtype is accepted. Subclasses may
add fields and override is_valid for finer checks.
Source code in src/quast_decisiontree/core/path.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 | @dataclass(frozen=True)
class PathKey:
"""Declares a path_info key a node may read: its type and allowed values.
`options is None` means any value of `dtype` is accepted. Subclasses may
add fields and override `is_valid` for finer checks.
"""
dtype: type
options: list | None = None
def is_valid(self, value: object) -> bool:
if not isinstance(value, self.dtype):
return False
return self.options is None or value in self.options
def to_dict(self) -> dict:
return dict(
dtype=self.dtype.__name__,
options=self.options,
)
|
options
class-attribute
instance-attribute
__init__
__init__(dtype, options=None)
is_valid
Source code in src/quast_decisiontree/core/path.py
| def is_valid(self, value: object) -> bool:
if not isinstance(value, self.dtype):
return False
return self.options is None or value in self.options
|
to_dict
Source code in src/quast_decisiontree/core/path.py
| def to_dict(self) -> dict:
return dict(
dtype=self.dtype.__name__,
options=self.options,
)
|