PyDecisionGraph 0.3.2.post1__cp315-cp315-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- decision_graph/__infra__.pxd +1 -0
- decision_graph/__init__.pxd +1 -0
- decision_graph/__init__.py +39 -0
- decision_graph/decision_tree/__init__.pxd +2 -0
- decision_graph/decision_tree/__init__.py +85 -0
- decision_graph/decision_tree/bake/__infra__.pxd +502 -0
- decision_graph/decision_tree/bake/__init__.pxd +502 -0
- decision_graph/decision_tree/bake/__init__.py +29 -0
- decision_graph/decision_tree/bake/c_action.cp315-win_amd64.pyd +0 -0
- decision_graph/decision_tree/bake/c_action.h +324 -0
- decision_graph/decision_tree/bake/c_action.pxd +54 -0
- decision_graph/decision_tree/bake/c_action.pyi +126 -0
- decision_graph/decision_tree/bake/c_action.pyx +65 -0
- decision_graph/decision_tree/bake/c_allocator_protocol.cp315-win_amd64.pyd +0 -0
- decision_graph/decision_tree/bake/c_allocator_protocol.pxd +24 -0
- decision_graph/decision_tree/bake/c_allocator_protocol.pyi +61 -0
- decision_graph/decision_tree/bake/c_allocator_protocol.pyx +109 -0
- decision_graph/decision_tree/bake/c_bake.cp315-win_amd64.pyd +0 -0
- decision_graph/decision_tree/bake/c_bake.h +629 -0
- decision_graph/decision_tree/bake/c_bake.pxd +52 -0
- decision_graph/decision_tree/bake/c_bake.pyi +151 -0
- decision_graph/decision_tree/bake/c_bake.pyx +142 -0
- decision_graph/decision_tree/bake/c_collections.cp315-win_amd64.pyd +0 -0
- decision_graph/decision_tree/bake/c_collections.h +692 -0
- decision_graph/decision_tree/bake/c_collections.pxd +52 -0
- decision_graph/decision_tree/bake/c_collections.pyi +193 -0
- decision_graph/decision_tree/bake/c_collections.pyx +161 -0
- decision_graph/decision_tree/bake/c_const.cp315-win_amd64.pyd +0 -0
- decision_graph/decision_tree/bake/c_const.h +395 -0
- decision_graph/decision_tree/bake/c_const.pxd +56 -0
- decision_graph/decision_tree/bake/c_const.pyi +305 -0
- decision_graph/decision_tree/bake/c_const.pyx +278 -0
- decision_graph/decision_tree/bake/c_edge.cp315-win_amd64.pyd +0 -0
- decision_graph/decision_tree/bake/c_edge.h +511 -0
- decision_graph/decision_tree/bake/c_edge.pxd +117 -0
- decision_graph/decision_tree/bake/c_edge.pyi +192 -0
- decision_graph/decision_tree/bake/c_edge.pyx +270 -0
- decision_graph/decision_tree/bake/c_eval.h +848 -0
- decision_graph/decision_tree/bake/c_eval.pxd +40 -0
- decision_graph/decision_tree/bake/c_expr.cp315-win_amd64.pyd +0 -0
- decision_graph/decision_tree/bake/c_expr.h +1900 -0
- decision_graph/decision_tree/bake/c_expr.pxd +129 -0
- decision_graph/decision_tree/bake/c_expr.pyi +280 -0
- decision_graph/decision_tree/bake/c_expr.pyx +272 -0
- decision_graph/decision_tree/bake/c_hierarchy.cp315-win_amd64.pyd +0 -0
- decision_graph/decision_tree/bake/c_hierarchy.h +731 -0
- decision_graph/decision_tree/bake/c_hierarchy.pxd +71 -0
- decision_graph/decision_tree/bake/c_hierarchy.pyi +409 -0
- decision_graph/decision_tree/bake/c_hierarchy.pyx +277 -0
- decision_graph/decision_tree/bake/c_logic_group.cp315-win_amd64.pyd +0 -0
- decision_graph/decision_tree/bake/c_logic_group.h +1226 -0
- decision_graph/decision_tree/bake/c_logic_group.pxd +162 -0
- decision_graph/decision_tree/bake/c_logic_group.pyi +264 -0
- decision_graph/decision_tree/bake/c_logic_group.pyx +308 -0
- decision_graph/decision_tree/bake/c_node.cp315-win_amd64.pyd +0 -0
- decision_graph/decision_tree/bake/c_node.h +2660 -0
- decision_graph/decision_tree/bake/c_node.pxd +381 -0
- decision_graph/decision_tree/bake/c_node.pyi +438 -0
- decision_graph/decision_tree/bake/c_node.pyx +639 -0
- decision_graph/decision_tree/bake/c_reconstruct.cp315-win_amd64.pyd +0 -0
- decision_graph/decision_tree/bake/c_reconstruct.pxd +63 -0
- decision_graph/decision_tree/bake/c_reconstruct.pyi +60 -0
- decision_graph/decision_tree/bake/c_reconstruct.pyx +252 -0
- decision_graph/decision_tree/bake/c_var.cp315-win_amd64.pyd +0 -0
- decision_graph/decision_tree/bake/c_var.h +2054 -0
- decision_graph/decision_tree/bake/c_var.pxd +205 -0
- decision_graph/decision_tree/bake/c_var.pyi +271 -0
- decision_graph/decision_tree/bake/c_var.pyx +228 -0
- decision_graph/decision_tree/capi/__infra__.pxd +33 -0
- decision_graph/decision_tree/capi/__init__.pxd +33 -0
- decision_graph/decision_tree/capi/__init__.py +57 -0
- decision_graph/decision_tree/capi/c_abc.cp315-win_amd64.pyd +0 -0
- decision_graph/decision_tree/capi/c_abc.pxd +246 -0
- decision_graph/decision_tree/capi/c_abc.pyi +770 -0
- decision_graph/decision_tree/capi/c_abc.pyx +1532 -0
- decision_graph/decision_tree/capi/c_collection.cp315-win_amd64.pyd +0 -0
- decision_graph/decision_tree/capi/c_collection.pxd +22 -0
- decision_graph/decision_tree/capi/c_collection.pyi +245 -0
- decision_graph/decision_tree/capi/c_collection.pyx +138 -0
- decision_graph/decision_tree/capi/c_node.cp315-win_amd64.pyd +0 -0
- decision_graph/decision_tree/capi/c_node.pxd +95 -0
- decision_graph/decision_tree/capi/c_node.pyi +492 -0
- decision_graph/decision_tree/capi/c_node.pyx +551 -0
- decision_graph/decision_tree/exc.py +189 -0
- decision_graph/decision_tree/native/__init__.py +57 -0
- decision_graph/decision_tree/native/abc.py +1167 -0
- decision_graph/decision_tree/native/collection.py +134 -0
- decision_graph/decision_tree/native/node.py +521 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_action.c +16320 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_action.h +324 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_allocator_protocol.c +12473 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_bake.c +16485 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_bake.h +629 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_collections.c +17381 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_collections.h +692 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_const.c +20815 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_const.h +395 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_edge.c +20696 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_edge.h +511 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_eval.h +848 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_expr.c +22065 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_expr.h +1900 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_hierarchy.c +23267 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_hierarchy.h +731 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_logic_group.c +22434 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_logic_group.h +1226 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_node.c +28385 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_node.h +2660 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_reconstruct.c +15955 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_var.c +16881 -0
- decision_graph/includes/decision_graph/decision_tree/bake/c_var.h +2054 -0
- decision_graph/includes/decision_graph/decision_tree/capi/c_abc.c +59196 -0
- decision_graph/includes/decision_graph/decision_tree/capi/c_collection.c +19967 -0
- decision_graph/includes/decision_graph/decision_tree/capi/c_node.c +39229 -0
- decision_graph/logic_group/__init__.py +25 -0
- decision_graph/logic_group/base.py +100 -0
- decision_graph/logic_group/pending_request.py +384 -0
- decision_graph/webui/__init__.py +24 -0
- decision_graph/webui/bake/__init__.py +65 -0
- decision_graph/webui/bake/app.py +488 -0
- decision_graph/webui/bake/static/d3.v7.min.js +2 -0
- decision_graph/webui/bake/static/script.js +1440 -0
- decision_graph/webui/bake/static/style.css +920 -0
- decision_graph/webui/bake/templates/index.html +183 -0
- decision_graph/webui/bake/templates/offline.html +184 -0
- decision_graph/webui/capi/__init__.py +54 -0
- decision_graph/webui/capi/app.py +366 -0
- decision_graph/webui/capi/main.py +53 -0
- decision_graph/webui/capi/static/d3.v7.min.js +2 -0
- decision_graph/webui/capi/static/script.js +1026 -0
- decision_graph/webui/capi/static/style.css +656 -0
- decision_graph/webui/capi/templates/index.html +93 -0
- decision_graph/webui/capi/templates/offline.html +94 -0
- decision_graph/webui/native/__init__.py +54 -0
- decision_graph/webui/native/app.py +366 -0
- decision_graph/webui/native/main.py +53 -0
- decision_graph/webui/native/static/d3.v7.min.js +2 -0
- decision_graph/webui/native/static/script.js +1026 -0
- decision_graph/webui/native/static/style.css +656 -0
- decision_graph/webui/native/templates/index.html +93 -0
- decision_graph/webui/native/templates/offline.html +94 -0
- pydecisiongraph-0.3.2.post1.dist-info/METADATA +136 -0
- pydecisiongraph-0.3.2.post1.dist-info/RECORD +148 -0
- pydecisiongraph-0.3.2.post1.dist-info/WHEEL +5 -0
- pydecisiongraph-0.3.2.post1.dist-info/licenses/LICENSE +373 -0
- pydecisiongraph-0.3.2.post1.dist-info/top_level.txt +2 -0
- tests/bake_c_evaluator.cp315-win_amd64.pyd +0 -0
- tests/bake_eval_probe.cp315-win_amd64.pyd +0 -0
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
import enum
|
|
2
|
+
from collections.abc import Callable
|
|
3
|
+
from typing import Any, final, Generic, TypeVar
|
|
4
|
+
|
|
5
|
+
from .c_abc import LogicNode, LogicGroup, NodeEdgeCondition, BreakpointNode
|
|
6
|
+
from ..exc import NO_DEFAULT
|
|
7
|
+
|
|
8
|
+
UNARY_OP_FUNC = Callable[[Any], Any]
|
|
9
|
+
BINARY_OP_FUNC = Callable[[Any, Any], Any]
|
|
10
|
+
T = TypeVar('T')
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class NodeEvalPath(list[LogicNode], Generic[T]):
|
|
14
|
+
def to_clipboard(self) -> str:
|
|
15
|
+
"""Copy the evaluation path to the system clipboard as text.
|
|
16
|
+
|
|
17
|
+
Generates a json representation of the evaluation path and copies it to the clipboard for easy sharing or logging.
|
|
18
|
+
``pyperclip`` module required.
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
The generated text representation of the evaluation path.
|
|
22
|
+
|
|
23
|
+
Raises:
|
|
24
|
+
PyperclipException: If copying to clipboard fails.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class RootLogicNode(LogicNode):
|
|
29
|
+
"""Entry point node for a decision graph.
|
|
30
|
+
|
|
31
|
+
This node acts as the root container for a single child node and
|
|
32
|
+
largely delegates evaluation and rendering to that child. It enforces
|
|
33
|
+
that at most one child may be appended.
|
|
34
|
+
|
|
35
|
+
Apart from a normal LogicNode, the RootLogicNode:
|
|
36
|
+
- contains only 1 child node, with NO_CONDITION.
|
|
37
|
+
- always returns True for `c_entry_check()`.
|
|
38
|
+
- automatically shelve and unshelve contexts entering/exiting.
|
|
39
|
+
- automatically triggers inspection mode on entering and restore to previous mode on exit.
|
|
40
|
+
|
|
41
|
+
With these features, the RootLogicNode is designed as the Root node of a decision tree.
|
|
42
|
+
|
|
43
|
+
Attributes:
|
|
44
|
+
inherit_contexts: Whether to inherit outer logic groups when entered.
|
|
45
|
+
eval_path: List of nodes evaluated during the last evaluation. In cython interface this is a reflected copy, In python interface this is the actual list.
|
|
46
|
+
"""
|
|
47
|
+
inherit_contexts: bool
|
|
48
|
+
eval_path: NodeEvalPath[LogicNode]
|
|
49
|
+
|
|
50
|
+
def __init__(self, name: str = 'Entry Point', inherit_contexts: bool = False, **kwargs) -> None:
|
|
51
|
+
"""Create a RootLogicNode.
|
|
52
|
+
|
|
53
|
+
The constructor automatically passes the kwargs to underlying base classes. If any kwargs are provided, it can mess up the normal initializing process. It is recommended to not provide any kwargs and leave as is.
|
|
54
|
+
|
|
55
|
+
Example:
|
|
56
|
+
|
|
57
|
+
>>> with RootLogicNode() as root:
|
|
58
|
+
... with LogicNode() as child:
|
|
59
|
+
... ...
|
|
60
|
+
... # There should not be a second node appended to root
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
name: Optional name for the root node.
|
|
64
|
+
**kwargs: Implementation-specific options.
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
@final
|
|
68
|
+
def __enter__(self) -> RootLogicNode:
|
|
69
|
+
"""Enter context manager for the root node, to build a new decision graph in a seperated context.
|
|
70
|
+
|
|
71
|
+
On entering:
|
|
72
|
+
0. The RootLogicNode itself will be appended to active node stack.
|
|
73
|
+
1. Then the LGM will be shelved to preserve outer contexts.
|
|
74
|
+
2. With ``inherit_contexts`` flags, the outer LogicGroup contexts will be inherited.
|
|
75
|
+
3. After shelfing, a fresh LGM will be provided, with only this RootLogicNode activated.
|
|
76
|
+
|
|
77
|
+
Then on exiting, the LGM will be restored to previous state.
|
|
78
|
+
|
|
79
|
+
The __enter__ method is not overridden actually, only the internal c hook function.
|
|
80
|
+
|
|
81
|
+
Returns:
|
|
82
|
+
The RootLogicNode instance.
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
def dry_run(self) -> None:
|
|
86
|
+
"""Perform a dry run evaluation of the decision tree without executing actions.
|
|
87
|
+
|
|
88
|
+
This method traverses the decision tree starting from the root node,
|
|
89
|
+
evaluating conditions and logging the evaluation path without
|
|
90
|
+
executing any actions associated with the nodes.
|
|
91
|
+
|
|
92
|
+
Raises:
|
|
93
|
+
ExpressEvaluationError: If an error occurs during evaluation.
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
def get_breakpoint(self) -> BreakpointNode | None:
|
|
97
|
+
"""Get dangling breakpoint node attached to the root, if any.
|
|
98
|
+
Returns:
|
|
99
|
+
BreakpointNode if exists, else None.
|
|
100
|
+
"""
|
|
101
|
+
|
|
102
|
+
def append(self, child: LogicNode, condition: NodeEdgeCondition = NO_DEFAULT) -> None:
|
|
103
|
+
"""Append a child node to the root.
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
child: The child logic node to append.
|
|
107
|
+
condition: Edge condition associated with the child (ignored for
|
|
108
|
+
the root; defaults to None).
|
|
109
|
+
|
|
110
|
+
Raises:
|
|
111
|
+
TooManyChildren: If a child is already attached to the root.
|
|
112
|
+
"""
|
|
113
|
+
|
|
114
|
+
def to_html(self, file_name: str | None = None, with_eval: bool = True) -> None:
|
|
115
|
+
"""Render the decision tree to an HTML file.
|
|
116
|
+
|
|
117
|
+
This method generates a standalone HTML file visualizing the
|
|
118
|
+
decision tree structure starting from this root node. If
|
|
119
|
+
``with_eval`` is True, the evaluation results are also included
|
|
120
|
+
in the rendering.
|
|
121
|
+
|
|
122
|
+
Args:
|
|
123
|
+
file_name: Output HTML file name; when omitted, the file is named
|
|
124
|
+
after the root's ``repr``.
|
|
125
|
+
with_eval: Whether to include evaluation results in the rendering.
|
|
126
|
+
"""
|
|
127
|
+
|
|
128
|
+
def show(self, **kwargs):
|
|
129
|
+
"""Render and display the decision tree in a interactive web page.
|
|
130
|
+
This method generates an interactive visualization of the decision
|
|
131
|
+
tree structure starting from this root node. Additional keyword
|
|
132
|
+
arguments are passed to the underlying rendering flask engine.
|
|
133
|
+
|
|
134
|
+
Arguments:
|
|
135
|
+
**kwargs: keyword arguments passed into ``decision_graph.webui.capi.show`` method.
|
|
136
|
+
"""
|
|
137
|
+
|
|
138
|
+
def watch(self, **kwargs):
|
|
139
|
+
"""Continuously monitor and update the decision tree visualization in a web page.
|
|
140
|
+
|
|
141
|
+
This method sets up a live monitoring session where the decision
|
|
142
|
+
tree structure and evaluation results are periodically refreshed
|
|
143
|
+
and displayed in an interactive web page.
|
|
144
|
+
|
|
145
|
+
Arguments:
|
|
146
|
+
**kwargs: keyword arguments passed into ``decision_graph.webui.capi.watch`` method.
|
|
147
|
+
"""
|
|
148
|
+
|
|
149
|
+
@property
|
|
150
|
+
def child(self) -> LogicNode:
|
|
151
|
+
"""Return the single child node attached to the root.
|
|
152
|
+
|
|
153
|
+
Raises:
|
|
154
|
+
TooFewChildren: If no child is attached to the root.
|
|
155
|
+
"""
|
|
156
|
+
...
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
class ContextLogicExpression(LogicNode):
|
|
160
|
+
"""Base class for expressions that evaluate against a logic group/context.
|
|
161
|
+
|
|
162
|
+
This class implements Python operator overloads so expressions can be
|
|
163
|
+
composed using normal Python syntax (e.g. a + b, a > b, a & b).
|
|
164
|
+
|
|
165
|
+
Attributes:
|
|
166
|
+
logic_group: The LogicGroup used as the evaluation context.
|
|
167
|
+
"""
|
|
168
|
+
|
|
169
|
+
logic_group: LogicGroup
|
|
170
|
+
repr: str
|
|
171
|
+
|
|
172
|
+
def __init__(self, *, logic_group: LogicGroup = None, **kwargs) -> None:
|
|
173
|
+
"""Create a context-aware expression.
|
|
174
|
+
|
|
175
|
+
If ``logic_group`` is omitted the current active logic group is used.
|
|
176
|
+
|
|
177
|
+
Args:
|
|
178
|
+
logic_group: Optional logic group or mapping providing contexts.
|
|
179
|
+
**kwargs: Implementation-specific keyword arguments.
|
|
180
|
+
"""
|
|
181
|
+
|
|
182
|
+
# Mapping / attribute access
|
|
183
|
+
def __getitem__(self, key: str) -> AttrExpression:
|
|
184
|
+
"""Return an attribute expression representing ``logic_group[key]``.
|
|
185
|
+
|
|
186
|
+
Args:
|
|
187
|
+
key: Attribute/key name.
|
|
188
|
+
|
|
189
|
+
Returns:
|
|
190
|
+
AttrExpression: Expression representing the attribute access.
|
|
191
|
+
"""
|
|
192
|
+
|
|
193
|
+
def __getattr__(self, key: str) -> AttrExpression:
|
|
194
|
+
"""Return an attribute expression representing ``logic_group.key``.
|
|
195
|
+
|
|
196
|
+
Args:
|
|
197
|
+
key: Attribute name.
|
|
198
|
+
|
|
199
|
+
Returns:
|
|
200
|
+
AttrExpression: Expression representing the attribute access.
|
|
201
|
+
"""
|
|
202
|
+
|
|
203
|
+
# Arithmetic operators produce MathExpression
|
|
204
|
+
def __add__(self, other: Any) -> MathExpression: ...
|
|
205
|
+
|
|
206
|
+
def __sub__(self, other: Any) -> MathExpression: ...
|
|
207
|
+
|
|
208
|
+
def __mul__(self, other: Any) -> MathExpression: ...
|
|
209
|
+
|
|
210
|
+
def __truediv__(self, other: Any) -> MathExpression: ...
|
|
211
|
+
|
|
212
|
+
def __floordiv__(self, other: Any) -> MathExpression: ...
|
|
213
|
+
|
|
214
|
+
def __pow__(self, other: Any) -> MathExpression: ...
|
|
215
|
+
|
|
216
|
+
def __neg__(self) -> MathExpression: ...
|
|
217
|
+
|
|
218
|
+
# Comparison operators produce ComparisonExpression
|
|
219
|
+
def __eq__(self, other: Any) -> ComparisonExpression: ...
|
|
220
|
+
|
|
221
|
+
def __ne__(self, other: Any) -> ComparisonExpression: ...
|
|
222
|
+
|
|
223
|
+
def __gt__(self, other: Any) -> ComparisonExpression: ...
|
|
224
|
+
|
|
225
|
+
def __ge__(self, other: Any) -> ComparisonExpression: ...
|
|
226
|
+
|
|
227
|
+
def __lt__(self, other: Any) -> ComparisonExpression: ...
|
|
228
|
+
|
|
229
|
+
def __le__(self, other: Any) -> ComparisonExpression: ...
|
|
230
|
+
|
|
231
|
+
# Logical operators produce LogicalExpression
|
|
232
|
+
def __and__(self, other: Any) -> LogicalExpression: ...
|
|
233
|
+
|
|
234
|
+
def __or__(self, other: Any) -> LogicalExpression: ...
|
|
235
|
+
|
|
236
|
+
def __invert__(self) -> LogicalExpression: ...
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
class AttrExpression(ContextLogicExpression):
|
|
240
|
+
"""Expression representing a single attribute from the logic context.
|
|
241
|
+
|
|
242
|
+
Attributes:
|
|
243
|
+
attr: The attribute name referred to by the expression.
|
|
244
|
+
"""
|
|
245
|
+
|
|
246
|
+
attr: str
|
|
247
|
+
|
|
248
|
+
def __init__(self, *, attr: str, repr: str = None, **kwargs) -> None:
|
|
249
|
+
"""Create an attribute expression.
|
|
250
|
+
|
|
251
|
+
The constructor automatically passes the kwargs to underlying base classes, if any.
|
|
252
|
+
See ``ContextLogicExpression`` and ``LogicNode`` for more details.
|
|
253
|
+
|
|
254
|
+
Args:
|
|
255
|
+
attr: Attribute name or list of nested attribute names.
|
|
256
|
+
repr: Optional textual representation override.
|
|
257
|
+
"""
|
|
258
|
+
|
|
259
|
+
def __getitem__(self, key: str) -> AttrNestedExpression: ...
|
|
260
|
+
|
|
261
|
+
def __getattr__(self, key: str) -> AttrNestedExpression: ...
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
class AttrNestedExpression(ContextLogicExpression):
|
|
265
|
+
"""Expression representing nested attribute access (a.b.c).
|
|
266
|
+
|
|
267
|
+
Attributes:
|
|
268
|
+
attrs: list of attribute path components in access order.
|
|
269
|
+
"""
|
|
270
|
+
|
|
271
|
+
attrs: list[str]
|
|
272
|
+
|
|
273
|
+
def __init__(self, *, attrs: list[str], repr: str = None, **kwargs) -> None:
|
|
274
|
+
"""Create a nested attribute expression.
|
|
275
|
+
|
|
276
|
+
The constructor automatically passes the kwargs to underlying base classes, if any.
|
|
277
|
+
See ``ContextLogicExpression`` and ``LogicNode`` for more details.
|
|
278
|
+
|
|
279
|
+
Args:
|
|
280
|
+
attrs: Sequence of attribute names describing the path.
|
|
281
|
+
"""
|
|
282
|
+
|
|
283
|
+
def __getitem__(self, key: str) -> AttrNestedExpression: ...
|
|
284
|
+
|
|
285
|
+
def __getattr__(self, key: str) -> AttrNestedExpression: ...
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
class GetterExpression(ContextLogicExpression):
|
|
289
|
+
"""Expression representing a single key/index access from the logic context.
|
|
290
|
+
|
|
291
|
+
Attributes:
|
|
292
|
+
key: The key/index referred to by the expression.
|
|
293
|
+
"""
|
|
294
|
+
|
|
295
|
+
key: Any
|
|
296
|
+
|
|
297
|
+
def __init__(self, *, key: Any, repr: str = None, **kwargs) -> None:
|
|
298
|
+
"""Create a getter expression.
|
|
299
|
+
|
|
300
|
+
The constructor automatically passes the kwargs to underlying base classes, if any.
|
|
301
|
+
See ``ContextLogicExpression`` and ``LogicNode`` for more details.
|
|
302
|
+
|
|
303
|
+
Args:
|
|
304
|
+
key: Key/index or list of nested keys/indexes.
|
|
305
|
+
repr: Optional textual representation override.
|
|
306
|
+
"""
|
|
307
|
+
|
|
308
|
+
def __getitem__(self, key: Any) -> GetterNestedExpression: ...
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
class GetterNestedExpression(ContextLogicExpression):
|
|
312
|
+
"""Expression representing nested key/index access (a[b][c]).
|
|
313
|
+
|
|
314
|
+
Attributes:
|
|
315
|
+
keys: list of keys/indexes in access order.
|
|
316
|
+
"""
|
|
317
|
+
|
|
318
|
+
keys: list[Any]
|
|
319
|
+
|
|
320
|
+
def __init__(self, *, keys: list[Any], repr: str = None, **kwargs) -> None:
|
|
321
|
+
"""Create a nested getter expression.
|
|
322
|
+
|
|
323
|
+
The constructor automatically passes the kwargs to underlying base classes, if any.
|
|
324
|
+
See ``ContextLogicExpression`` and ``LogicNode`` for more details.
|
|
325
|
+
|
|
326
|
+
Args:
|
|
327
|
+
keys: Sequence of keys/indexes describing the access path.
|
|
328
|
+
"""
|
|
329
|
+
|
|
330
|
+
def __getitem__(self, key: Any) -> GetterNestedExpression: ...
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
class MathExpressionOperator(enum.StrEnum):
|
|
334
|
+
"""A pseudo-enum class representing mathematical operators for MathExpression."""
|
|
335
|
+
|
|
336
|
+
add: MathExpressionOperator
|
|
337
|
+
sub: MathExpressionOperator
|
|
338
|
+
mul: MathExpressionOperator
|
|
339
|
+
truediv: MathExpressionOperator
|
|
340
|
+
floordiv: MathExpressionOperator
|
|
341
|
+
pow: MathExpressionOperator
|
|
342
|
+
neg: MathExpressionOperator
|
|
343
|
+
|
|
344
|
+
def to_func(self) -> UNARY_OP_FUNC | BINARY_OP_FUNC: ...
|
|
345
|
+
|
|
346
|
+
@classmethod
|
|
347
|
+
def from_str(cls, op_str: str) -> MathExpressionOperator: ...
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
class MathExpression(ContextLogicExpression):
|
|
351
|
+
"""Expression representing an arithmetic operation.
|
|
352
|
+
|
|
353
|
+
Attributes:
|
|
354
|
+
left: Left operand (expression or literal).
|
|
355
|
+
right: Right operand or sentinel when unary.
|
|
356
|
+
dtype: Resulting data type (defaults to float).
|
|
357
|
+
op_name: Internal operator name.
|
|
358
|
+
op_repr: Human-readable operator symbol or function name.
|
|
359
|
+
"""
|
|
360
|
+
|
|
361
|
+
left: Any
|
|
362
|
+
right: Any
|
|
363
|
+
op_name: str
|
|
364
|
+
op_repr: str
|
|
365
|
+
|
|
366
|
+
def __init__(
|
|
367
|
+
self,
|
|
368
|
+
*,
|
|
369
|
+
left: Any,
|
|
370
|
+
op: str | MathExpressionOperator | UNARY_OP_FUNC | BINARY_OP_FUNC,
|
|
371
|
+
right: Any = NO_DEFAULT,
|
|
372
|
+
**kwargs
|
|
373
|
+
) -> None:
|
|
374
|
+
"""Create a MathExpression.
|
|
375
|
+
|
|
376
|
+
The constructor automatically passes the kwargs to underlying base classes, if any.
|
|
377
|
+
- `repr` is automatically generated based on the operator and operands, unless overridden via kwargs.
|
|
378
|
+
- `dtype` defaults to float unless specified in kwargs.
|
|
379
|
+
|
|
380
|
+
Args:
|
|
381
|
+
left: Left operand, can be an expression or a literal.
|
|
382
|
+
op: Operator specifier (operator object, string, or callable).
|
|
383
|
+
right: Right operand or omitted for unary operators.
|
|
384
|
+
op_name: Optional operator name override.
|
|
385
|
+
op_repr: Optional operator symbol override.
|
|
386
|
+
"""
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
class ComparisonExpressionOperator(enum.StrEnum):
|
|
390
|
+
"""A pseudo-enum class representing comparison operators for ComparisonExpression."""
|
|
391
|
+
|
|
392
|
+
eq: ComparisonExpressionOperator
|
|
393
|
+
ne: ComparisonExpressionOperator
|
|
394
|
+
gt: ComparisonExpressionOperator
|
|
395
|
+
ge: ComparisonExpressionOperator
|
|
396
|
+
lt: ComparisonExpressionOperator
|
|
397
|
+
le: ComparisonExpressionOperator
|
|
398
|
+
|
|
399
|
+
def to_func(self) -> BINARY_OP_FUNC: ...
|
|
400
|
+
|
|
401
|
+
@classmethod
|
|
402
|
+
def from_str(cls, op_str: str) -> ComparisonExpressionOperator: ...
|
|
403
|
+
|
|
404
|
+
@property
|
|
405
|
+
def int_enum(self) -> int: ...
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
class ComparisonExpression(ContextLogicExpression):
|
|
409
|
+
"""Expression representing a comparison operation, returning only boolean result."""
|
|
410
|
+
|
|
411
|
+
left: Any
|
|
412
|
+
right: Any
|
|
413
|
+
op_name: str
|
|
414
|
+
op_repr: str
|
|
415
|
+
|
|
416
|
+
def __init__(
|
|
417
|
+
self,
|
|
418
|
+
*,
|
|
419
|
+
left: Any,
|
|
420
|
+
op: Any,
|
|
421
|
+
right: Any,
|
|
422
|
+
**kwargs
|
|
423
|
+
) -> None:
|
|
424
|
+
"""Create a ComparisonExpression.
|
|
425
|
+
|
|
426
|
+
The constructor automatically passes the kwargs to underlying base classes, if any.
|
|
427
|
+
- 'repr' is automatically generated based on the operator and operands, unless overridden via kwargs.
|
|
428
|
+
- 'dtype' defaults to bool unless specified in kwargs.
|
|
429
|
+
|
|
430
|
+
Args:
|
|
431
|
+
left: Left operand.
|
|
432
|
+
op: Operator specifier (operator object, string, or callable).
|
|
433
|
+
right: Right operand.
|
|
434
|
+
op_name: Optional operator name override.
|
|
435
|
+
op_repr: Optional operator symbol override.
|
|
436
|
+
"""
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
class LogicalExpressionOperator(enum.StrEnum):
|
|
440
|
+
"""Pseudo-enum class representing logical operators for LogicalExpression."""
|
|
441
|
+
|
|
442
|
+
and_: LogicalExpressionOperator
|
|
443
|
+
or_: LogicalExpressionOperator
|
|
444
|
+
not_: LogicalExpressionOperator
|
|
445
|
+
|
|
446
|
+
def to_func(self) -> UNARY_OP_FUNC | BINARY_OP_FUNC: ...
|
|
447
|
+
|
|
448
|
+
@classmethod
|
|
449
|
+
def from_str(cls, op_str: str) -> LogicalExpressionOperator: ...
|
|
450
|
+
|
|
451
|
+
@property
|
|
452
|
+
def int_enum(self) -> int: ...
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
class LogicalExpression(ContextLogicExpression):
|
|
456
|
+
"""Expression representing boolean logic operations.
|
|
457
|
+
|
|
458
|
+
Attributes:
|
|
459
|
+
left: Left operand (expression or literal).
|
|
460
|
+
right: Right operand or sentinel for unary operations.
|
|
461
|
+
dtype: Resulting data type (bool).
|
|
462
|
+
op_name: Name of the logical operator.
|
|
463
|
+
op_repr: Operator symbol or representation.
|
|
464
|
+
repr: Human-readable representation of the expression.
|
|
465
|
+
"""
|
|
466
|
+
|
|
467
|
+
left: Any
|
|
468
|
+
right: Any
|
|
469
|
+
op_name: str
|
|
470
|
+
op_repr: str
|
|
471
|
+
|
|
472
|
+
def __init__(
|
|
473
|
+
self,
|
|
474
|
+
*,
|
|
475
|
+
left: Any,
|
|
476
|
+
op: Any,
|
|
477
|
+
right: Any = NO_DEFAULT,
|
|
478
|
+
**kwargs
|
|
479
|
+
) -> None:
|
|
480
|
+
"""Create a LogicalExpression.
|
|
481
|
+
|
|
482
|
+
The constructor automatically passes the kwargs to underlying base classes, if any.
|
|
483
|
+
- 'repr' is automatically generated based on the operator and operands, unless overridden via kwargs.
|
|
484
|
+
- 'dtype' defaults to bool unless specified in kwargs.
|
|
485
|
+
|
|
486
|
+
Args:
|
|
487
|
+
left: Left operand.
|
|
488
|
+
op: Logical operator specifier (operator object, string, or callable).
|
|
489
|
+
right: Optional right operand for binary operators.
|
|
490
|
+
op_name: Optional operator name override.
|
|
491
|
+
op_repr: Optional operator symbol override.
|
|
492
|
+
"""
|