Coverage for C: \ Users \ peaco \ OneDrive \ Documents \ GitHub \ mt_metadata \ mt_metadata \ features \ weights \ base.py: 100%
15 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-10 00:11 -0800
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-10 00:11 -0800
1# =====================================================
2# Imports
3# =====================================================
4from typing import Annotated
6from pydantic import Field
8from mt_metadata.base import MetadataBase
9from mt_metadata.common.enumerations import StrEnumerationBase
12# =====================================================
13class WeightTypeEnum(StrEnumerationBase):
14 monotonic = "monotonic"
15 learned = "learned"
16 spatial = "spatial"
17 custom = "custom"
20class Base(MetadataBase):
21 weight_type: Annotated[
22 WeightTypeEnum,
23 Field(
24 default=WeightTypeEnum.monotonic,
25 description="Type of weighting kernel (e.g., monotonic, learned, spatial).",
26 alias=None,
27 json_schema_extra={
28 "units": None,
29 "required": True,
30 "examples": ["monotonic"],
31 },
32 ),
33 ]
35 description: Annotated[
36 str | None,
37 Field(
38 default=None,
39 description="Human-readable description of what this kernel is for.",
40 alias=None,
41 json_schema_extra={
42 "units": None,
43 "required": False,
44 "examples": [
45 "This kernel smoothly transitions between 0 and 1 in a monotonic way"
46 ],
47 },
48 ),
49 ]
51 active: Annotated[
52 bool | None,
53 Field(
54 default=None,
55 description="If false, this kernel will be skipped during weighting.",
56 alias=None,
57 json_schema_extra={
58 "units": None,
59 "required": False,
60 "examples": ["false"],
61 },
62 ),
63 ]
65 def evaluate(self, values):
66 """
67 Evaluate the kernel on the input feature values.
69 Parameters
70 ----------
71 values : np.ndarray or float
72 The feature values to apply the weight kernel to.
74 Returns
75 -------
76 weights : np.ndarray or float
77 The resulting weight(s).
78 """
79 raise NotImplementedError("BaseWeightKernel cannot be evaluated directly.")