PyDecisionGraph 0.3.2.post1__cp315-cp315t-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.
Files changed (148) hide show
  1. decision_graph/__infra__.pxd +1 -0
  2. decision_graph/__init__.pxd +1 -0
  3. decision_graph/__init__.py +39 -0
  4. decision_graph/decision_tree/__init__.pxd +2 -0
  5. decision_graph/decision_tree/__init__.py +85 -0
  6. decision_graph/decision_tree/bake/__infra__.pxd +502 -0
  7. decision_graph/decision_tree/bake/__init__.pxd +502 -0
  8. decision_graph/decision_tree/bake/__init__.py +29 -0
  9. decision_graph/decision_tree/bake/c_action.cp315t-win_amd64.pyd +0 -0
  10. decision_graph/decision_tree/bake/c_action.h +324 -0
  11. decision_graph/decision_tree/bake/c_action.pxd +54 -0
  12. decision_graph/decision_tree/bake/c_action.pyi +126 -0
  13. decision_graph/decision_tree/bake/c_action.pyx +65 -0
  14. decision_graph/decision_tree/bake/c_allocator_protocol.cp315t-win_amd64.pyd +0 -0
  15. decision_graph/decision_tree/bake/c_allocator_protocol.pxd +24 -0
  16. decision_graph/decision_tree/bake/c_allocator_protocol.pyi +61 -0
  17. decision_graph/decision_tree/bake/c_allocator_protocol.pyx +109 -0
  18. decision_graph/decision_tree/bake/c_bake.cp315t-win_amd64.pyd +0 -0
  19. decision_graph/decision_tree/bake/c_bake.h +629 -0
  20. decision_graph/decision_tree/bake/c_bake.pxd +52 -0
  21. decision_graph/decision_tree/bake/c_bake.pyi +151 -0
  22. decision_graph/decision_tree/bake/c_bake.pyx +142 -0
  23. decision_graph/decision_tree/bake/c_collections.cp315t-win_amd64.pyd +0 -0
  24. decision_graph/decision_tree/bake/c_collections.h +692 -0
  25. decision_graph/decision_tree/bake/c_collections.pxd +52 -0
  26. decision_graph/decision_tree/bake/c_collections.pyi +193 -0
  27. decision_graph/decision_tree/bake/c_collections.pyx +161 -0
  28. decision_graph/decision_tree/bake/c_const.cp315t-win_amd64.pyd +0 -0
  29. decision_graph/decision_tree/bake/c_const.h +395 -0
  30. decision_graph/decision_tree/bake/c_const.pxd +56 -0
  31. decision_graph/decision_tree/bake/c_const.pyi +305 -0
  32. decision_graph/decision_tree/bake/c_const.pyx +278 -0
  33. decision_graph/decision_tree/bake/c_edge.cp315t-win_amd64.pyd +0 -0
  34. decision_graph/decision_tree/bake/c_edge.h +511 -0
  35. decision_graph/decision_tree/bake/c_edge.pxd +117 -0
  36. decision_graph/decision_tree/bake/c_edge.pyi +192 -0
  37. decision_graph/decision_tree/bake/c_edge.pyx +270 -0
  38. decision_graph/decision_tree/bake/c_eval.h +848 -0
  39. decision_graph/decision_tree/bake/c_eval.pxd +40 -0
  40. decision_graph/decision_tree/bake/c_expr.cp315t-win_amd64.pyd +0 -0
  41. decision_graph/decision_tree/bake/c_expr.h +1900 -0
  42. decision_graph/decision_tree/bake/c_expr.pxd +129 -0
  43. decision_graph/decision_tree/bake/c_expr.pyi +280 -0
  44. decision_graph/decision_tree/bake/c_expr.pyx +272 -0
  45. decision_graph/decision_tree/bake/c_hierarchy.cp315t-win_amd64.pyd +0 -0
  46. decision_graph/decision_tree/bake/c_hierarchy.h +731 -0
  47. decision_graph/decision_tree/bake/c_hierarchy.pxd +71 -0
  48. decision_graph/decision_tree/bake/c_hierarchy.pyi +409 -0
  49. decision_graph/decision_tree/bake/c_hierarchy.pyx +277 -0
  50. decision_graph/decision_tree/bake/c_logic_group.cp315t-win_amd64.pyd +0 -0
  51. decision_graph/decision_tree/bake/c_logic_group.h +1226 -0
  52. decision_graph/decision_tree/bake/c_logic_group.pxd +162 -0
  53. decision_graph/decision_tree/bake/c_logic_group.pyi +264 -0
  54. decision_graph/decision_tree/bake/c_logic_group.pyx +308 -0
  55. decision_graph/decision_tree/bake/c_node.cp315t-win_amd64.pyd +0 -0
  56. decision_graph/decision_tree/bake/c_node.h +2660 -0
  57. decision_graph/decision_tree/bake/c_node.pxd +381 -0
  58. decision_graph/decision_tree/bake/c_node.pyi +438 -0
  59. decision_graph/decision_tree/bake/c_node.pyx +639 -0
  60. decision_graph/decision_tree/bake/c_reconstruct.cp315t-win_amd64.pyd +0 -0
  61. decision_graph/decision_tree/bake/c_reconstruct.pxd +63 -0
  62. decision_graph/decision_tree/bake/c_reconstruct.pyi +60 -0
  63. decision_graph/decision_tree/bake/c_reconstruct.pyx +252 -0
  64. decision_graph/decision_tree/bake/c_var.cp315t-win_amd64.pyd +0 -0
  65. decision_graph/decision_tree/bake/c_var.h +2054 -0
  66. decision_graph/decision_tree/bake/c_var.pxd +205 -0
  67. decision_graph/decision_tree/bake/c_var.pyi +271 -0
  68. decision_graph/decision_tree/bake/c_var.pyx +228 -0
  69. decision_graph/decision_tree/capi/__infra__.pxd +33 -0
  70. decision_graph/decision_tree/capi/__init__.pxd +33 -0
  71. decision_graph/decision_tree/capi/__init__.py +57 -0
  72. decision_graph/decision_tree/capi/c_abc.cp315t-win_amd64.pyd +0 -0
  73. decision_graph/decision_tree/capi/c_abc.pxd +246 -0
  74. decision_graph/decision_tree/capi/c_abc.pyi +770 -0
  75. decision_graph/decision_tree/capi/c_abc.pyx +1532 -0
  76. decision_graph/decision_tree/capi/c_collection.cp315t-win_amd64.pyd +0 -0
  77. decision_graph/decision_tree/capi/c_collection.pxd +22 -0
  78. decision_graph/decision_tree/capi/c_collection.pyi +245 -0
  79. decision_graph/decision_tree/capi/c_collection.pyx +138 -0
  80. decision_graph/decision_tree/capi/c_node.cp315t-win_amd64.pyd +0 -0
  81. decision_graph/decision_tree/capi/c_node.pxd +95 -0
  82. decision_graph/decision_tree/capi/c_node.pyi +492 -0
  83. decision_graph/decision_tree/capi/c_node.pyx +551 -0
  84. decision_graph/decision_tree/exc.py +189 -0
  85. decision_graph/decision_tree/native/__init__.py +57 -0
  86. decision_graph/decision_tree/native/abc.py +1167 -0
  87. decision_graph/decision_tree/native/collection.py +134 -0
  88. decision_graph/decision_tree/native/node.py +521 -0
  89. decision_graph/includes/decision_graph/decision_tree/bake/c_action.c +16320 -0
  90. decision_graph/includes/decision_graph/decision_tree/bake/c_action.h +324 -0
  91. decision_graph/includes/decision_graph/decision_tree/bake/c_allocator_protocol.c +12473 -0
  92. decision_graph/includes/decision_graph/decision_tree/bake/c_bake.c +16485 -0
  93. decision_graph/includes/decision_graph/decision_tree/bake/c_bake.h +629 -0
  94. decision_graph/includes/decision_graph/decision_tree/bake/c_collections.c +17381 -0
  95. decision_graph/includes/decision_graph/decision_tree/bake/c_collections.h +692 -0
  96. decision_graph/includes/decision_graph/decision_tree/bake/c_const.c +20815 -0
  97. decision_graph/includes/decision_graph/decision_tree/bake/c_const.h +395 -0
  98. decision_graph/includes/decision_graph/decision_tree/bake/c_edge.c +20696 -0
  99. decision_graph/includes/decision_graph/decision_tree/bake/c_edge.h +511 -0
  100. decision_graph/includes/decision_graph/decision_tree/bake/c_eval.h +848 -0
  101. decision_graph/includes/decision_graph/decision_tree/bake/c_expr.c +22065 -0
  102. decision_graph/includes/decision_graph/decision_tree/bake/c_expr.h +1900 -0
  103. decision_graph/includes/decision_graph/decision_tree/bake/c_hierarchy.c +23267 -0
  104. decision_graph/includes/decision_graph/decision_tree/bake/c_hierarchy.h +731 -0
  105. decision_graph/includes/decision_graph/decision_tree/bake/c_logic_group.c +22434 -0
  106. decision_graph/includes/decision_graph/decision_tree/bake/c_logic_group.h +1226 -0
  107. decision_graph/includes/decision_graph/decision_tree/bake/c_node.c +28385 -0
  108. decision_graph/includes/decision_graph/decision_tree/bake/c_node.h +2660 -0
  109. decision_graph/includes/decision_graph/decision_tree/bake/c_reconstruct.c +15955 -0
  110. decision_graph/includes/decision_graph/decision_tree/bake/c_var.c +16881 -0
  111. decision_graph/includes/decision_graph/decision_tree/bake/c_var.h +2054 -0
  112. decision_graph/includes/decision_graph/decision_tree/capi/c_abc.c +59196 -0
  113. decision_graph/includes/decision_graph/decision_tree/capi/c_collection.c +19967 -0
  114. decision_graph/includes/decision_graph/decision_tree/capi/c_node.c +39229 -0
  115. decision_graph/logic_group/__init__.py +25 -0
  116. decision_graph/logic_group/base.py +100 -0
  117. decision_graph/logic_group/pending_request.py +384 -0
  118. decision_graph/webui/__init__.py +24 -0
  119. decision_graph/webui/bake/__init__.py +65 -0
  120. decision_graph/webui/bake/app.py +488 -0
  121. decision_graph/webui/bake/static/d3.v7.min.js +2 -0
  122. decision_graph/webui/bake/static/script.js +1440 -0
  123. decision_graph/webui/bake/static/style.css +920 -0
  124. decision_graph/webui/bake/templates/index.html +183 -0
  125. decision_graph/webui/bake/templates/offline.html +184 -0
  126. decision_graph/webui/capi/__init__.py +54 -0
  127. decision_graph/webui/capi/app.py +366 -0
  128. decision_graph/webui/capi/main.py +53 -0
  129. decision_graph/webui/capi/static/d3.v7.min.js +2 -0
  130. decision_graph/webui/capi/static/script.js +1026 -0
  131. decision_graph/webui/capi/static/style.css +656 -0
  132. decision_graph/webui/capi/templates/index.html +93 -0
  133. decision_graph/webui/capi/templates/offline.html +94 -0
  134. decision_graph/webui/native/__init__.py +54 -0
  135. decision_graph/webui/native/app.py +366 -0
  136. decision_graph/webui/native/main.py +53 -0
  137. decision_graph/webui/native/static/d3.v7.min.js +2 -0
  138. decision_graph/webui/native/static/script.js +1026 -0
  139. decision_graph/webui/native/static/style.css +656 -0
  140. decision_graph/webui/native/templates/index.html +93 -0
  141. decision_graph/webui/native/templates/offline.html +94 -0
  142. pydecisiongraph-0.3.2.post1.dist-info/METADATA +136 -0
  143. pydecisiongraph-0.3.2.post1.dist-info/RECORD +148 -0
  144. pydecisiongraph-0.3.2.post1.dist-info/WHEEL +5 -0
  145. pydecisiongraph-0.3.2.post1.dist-info/licenses/LICENSE +373 -0
  146. pydecisiongraph-0.3.2.post1.dist-info/top_level.txt +2 -0
  147. tests/bake_c_evaluator.cp315t-win_amd64.pyd +0 -0
  148. tests/bake_eval_probe.cp315t-win_amd64.pyd +0 -0
@@ -0,0 +1,205 @@
1
+ from libc.stdint cimport uint64_t
2
+ from libc.stdio cimport FILE
3
+ from libcpp cimport bool as c_bool
4
+
5
+ from cbase.allocator_protocol cimport allocator_protocol
6
+
7
+
8
+ cdef extern from "decision_graph/decision_tree/bake/c_var.h":
9
+ const c_bool DCG_VAR_HAS_SESSION_TIME
10
+ const int DCG_VAR_STRING_MAXLEN
11
+ const c_bool DCG_VIGILANT
12
+
13
+ ctypedef enum dcg_ret_code:
14
+ DCG_OK
15
+ DCG_ERR_INVALID_ARG
16
+ DCG_ERR_INVALID_BUF
17
+ DCG_ERR_OOM
18
+ DCG_ERR_NOT_FOUND
19
+ DCG_ERR_FULL
20
+ DCG_ERR_BAD_CAST
21
+ DCG_ERR_FORMAT
22
+ DCG_ERR_TYPE
23
+ DCG_ERR_CYCLE
24
+ DCG_ERR_BUSY
25
+ DCG_ERR_DUPLICATE
26
+ DCG_ERR_EDGE
27
+ DCG_ERR_UNRESOLVED
28
+ DCG_ERR_RANGE
29
+ DCG_ERR_HOOK
30
+ DCG_ERR_NO_MATCH
31
+ DCG_ERR_MATH
32
+ DCG_ERR_UNBOUND
33
+
34
+ ctypedef enum dcg_var_numeric:
35
+ VAR_NUMERIC_NONE
36
+ VAR_NUMERIC_INT
37
+ VAR_NUMERIC_DOUBLE
38
+
39
+ ctypedef enum dcg_var_type_mask:
40
+ VAR_TYPE_BASE_MASK
41
+ VAR_TYPE_REF_MASK
42
+ VAR_TYPE_REF_SHIFT
43
+ VAR_TYPE_REF_LEVEL1
44
+ VAR_TYPE_REF_LEVEL2
45
+
46
+ ctypedef enum dcg_var_type:
47
+ VAR_TYPE_RAW_PTR
48
+ VAR_TYPE_STRING
49
+ VAR_TYPE_BOOL
50
+ VAR_TYPE_DOUBLE
51
+ VAR_TYPE_INT
52
+ VAR_TYPE_OFFSET
53
+ VAR_TYPE_TIME
54
+ VAR_TYPE_DATE
55
+ VAR_TYPE_DATETIME
56
+ VAR_TYPE_D_VECTOR
57
+ VAR_TYPE_D_MATRIX
58
+ VAR_TYPE_NODE
59
+ VAR_TYPE_RESERVED
60
+
61
+ VAR_TYPE_RAW_PTR_REF
62
+ VAR_TYPE_STRING_REF
63
+ VAR_TYPE_BOOL_REF
64
+ VAR_TYPE_DOUBLE_REF
65
+ VAR_TYPE_INT_REF
66
+ VAR_TYPE_OFFSET_REF
67
+ VAR_TYPE_TIME_REF
68
+ VAR_TYPE_DATE_REF
69
+ VAR_TYPE_DATETIME_REF
70
+ VAR_TYPE_D_VECTOR_REF
71
+ VAR_TYPE_D_MATRIX_REF
72
+ VAR_TYPE_NODE_REF
73
+ VAR_TYPE_INFERRED
74
+
75
+ VAR_TYPE_RAW_PTR_REF_REF
76
+ VAR_TYPE_STRING_REF_REF
77
+ VAR_TYPE_BOOL_REF_REF
78
+ VAR_TYPE_DOUBLE_REF_REF
79
+ VAR_TYPE_INT_REF_REF
80
+ VAR_TYPE_OFFSET_REF_REF
81
+ VAR_TYPE_TIME_REF_REF
82
+ VAR_TYPE_DATE_REF_REF
83
+ VAR_TYPE_DATETIME_REF_REF
84
+ VAR_TYPE_D_VECTOR_REF_REF
85
+ VAR_TYPE_D_MATRIX_REF_REF
86
+ VAR_TYPE_NODE_REF_REF
87
+
88
+ ctypedef struct dcg_d_vector_t:
89
+ double* data
90
+ size_t n
91
+
92
+ ctypedef struct dcg_d_matrix_t:
93
+ double* data
94
+ size_t n_rows
95
+ size_t n_cols
96
+ c_bool row_major
97
+
98
+ ctypedef union dcg_var_variant:
99
+ void* as_ptr
100
+ const char* as_string
101
+ c_bool as_bool
102
+ double as_double
103
+ ssize_t as_int
104
+ ssize_t as_offset
105
+ uint64_t as_bits
106
+ dcg_d_vector_t* as_dvector
107
+ dcg_d_matrix_t* as_dmatrix
108
+ const void* as_ref
109
+ void* as_node
110
+
111
+ ctypedef struct dcg_var_t:
112
+ dcg_var_type dtype
113
+ dcg_var_variant value
114
+
115
+ dcg_d_vector_t* c_dcg_d_vector_new(size_t n, allocator_protocol* allocator) noexcept nogil
116
+ dcg_d_vector_t* c_dcg_d_vector_new_child(size_t n, allocator_protocol* allocator, const void* parent) noexcept nogil
117
+ void c_dcg_d_vector_free(dcg_d_vector_t* vector) noexcept nogil
118
+ double* c_dcg_d_vector_data(const dcg_d_vector_t* vector) noexcept nogil
119
+ size_t c_dcg_d_vector_size(const dcg_d_vector_t* vector) noexcept nogil
120
+ double c_dcg_d_vector_at(const dcg_d_vector_t* vector, size_t index) noexcept nogil
121
+ int c_dcg_d_vector_set(dcg_d_vector_t* vector, size_t index, double value) noexcept nogil
122
+
123
+ dcg_d_matrix_t* c_dcg_d_matrix_new(size_t n_rows, size_t n_cols, c_bool row_major, allocator_protocol* allocator) noexcept nogil
124
+ dcg_d_matrix_t* c_dcg_d_matrix_new_child(size_t n_rows, size_t n_cols, c_bool row_major, allocator_protocol* allocator, const void* parent) noexcept nogil
125
+ void c_dcg_d_matrix_free(dcg_d_matrix_t* matrix) noexcept nogil
126
+ double* c_dcg_d_matrix_data(const dcg_d_matrix_t* matrix) noexcept nogil
127
+ size_t c_dcg_d_matrix_rows(const dcg_d_matrix_t* matrix) noexcept nogil
128
+ size_t c_dcg_d_matrix_cols(const dcg_d_matrix_t* matrix) noexcept nogil
129
+ double c_dcg_d_matrix_at(const dcg_d_matrix_t* matrix, size_t row, size_t col) noexcept nogil
130
+ int c_dcg_d_matrix_set(dcg_d_matrix_t* matrix, size_t row, size_t col, double value) noexcept nogil
131
+
132
+ dcg_var_t* c_dcg_var_new(allocator_protocol* allocator) noexcept nogil
133
+ dcg_var_t* c_dcg_var_new_bool(c_bool value, allocator_protocol* allocator) noexcept nogil
134
+ dcg_var_t* c_dcg_var_new_double(double value, allocator_protocol* allocator) noexcept nogil
135
+ dcg_var_t* c_dcg_var_new_int(ssize_t value, allocator_protocol* allocator) noexcept nogil
136
+ dcg_var_t* c_dcg_var_new_offset(ssize_t value, allocator_protocol* allocator) noexcept nogil
137
+ dcg_var_t* c_dcg_var_new_string(const char* value, allocator_protocol* allocator) noexcept nogil
138
+ dcg_var_t* c_dcg_var_new_ptr(void* value, allocator_protocol* allocator) noexcept nogil
139
+ dcg_var_t* c_dcg_var_new_dvector(size_t n, allocator_protocol* allocator) noexcept nogil
140
+ dcg_var_t* c_dcg_var_new_dmatrix(size_t n_rows, size_t n_cols, c_bool row_major, allocator_protocol* allocator) noexcept nogil
141
+ dcg_var_t* c_dcg_var_new_ref(const dcg_var_t* src, allocator_protocol* allocator) noexcept nogil
142
+ void c_dcg_var_free(dcg_var_t* var) noexcept nogil
143
+ void c_dcg_var_dealloc(dcg_var_t* var) noexcept nogil
144
+
145
+ int c_dcg_var_init(dcg_var_t* var) noexcept nogil
146
+ int c_dcg_var_init_reserved(dcg_var_t* var) noexcept nogil
147
+ int c_dcg_var_init_bool(dcg_var_t* var, c_bool value) noexcept nogil
148
+ int c_dcg_var_init_double(dcg_var_t* var, double value) noexcept nogil
149
+ int c_dcg_var_init_int(dcg_var_t* var, ssize_t value) noexcept nogil
150
+ int c_dcg_var_init_offset(dcg_var_t* var, ssize_t value) noexcept nogil
151
+ int c_dcg_var_init_string(dcg_var_t* var, const char* value) noexcept nogil
152
+ int c_dcg_var_init_ref_raw(dcg_var_t* var, dcg_var_type dtype, const void* ref) noexcept nogil
153
+ int c_dcg_var_init_ref(dcg_var_t* var, const dcg_var_t* src) noexcept nogil
154
+ int c_dcg_var_init_ptr(dcg_var_t* var, void* value) noexcept nogil
155
+ int c_dcg_var_init_node(dcg_var_t* var, const dcg_node* node) noexcept nogil
156
+ int c_dcg_var_init_dvector(dcg_var_t* var, double* value, size_t n, c_bool copy, allocator_protocol* allocator) noexcept nogil
157
+ int c_dcg_var_init_dmatrix(dcg_var_t* var, double* value, size_t n_rows, size_t n_cols, c_bool row_major, c_bool copy, allocator_protocol* allocator) noexcept nogil
158
+
159
+ int c_dcg_var_ref_level(dcg_var_type dtype) noexcept nogil
160
+ c_bool c_dcg_var_is_ref(dcg_var_type dtype) noexcept nogil
161
+ dcg_var_type c_dcg_var_ref_base(dcg_var_type dtype) noexcept nogil
162
+
163
+ const char* c_dcg_ret_code_name(dcg_ret_code code) noexcept nogil
164
+ const char* c_dcg_var_type_name(dcg_var_type dtype) noexcept nogil
165
+ c_bool c_dcg_var_is_numeric(const dcg_var_t* var) noexcept nogil
166
+ dcg_var_numeric c_dcg_var_numeric_of(const dcg_var_t* var) noexcept nogil
167
+ c_bool c_dcg_var_is_container(const dcg_var_t* var) noexcept nogil
168
+ c_bool c_dcg_var_is_null(const dcg_var_t* var) noexcept nogil
169
+ c_bool c_dcg_var_is_truthy(const dcg_var_t* var) noexcept nogil
170
+ c_bool c_dcg_var_equals(const dcg_var_t* lhs, const dcg_var_t* rhs) noexcept nogil
171
+
172
+ void c_dcg_var_vigilant_abort(const char* getter, dcg_var_type dtype, const char* what) noexcept nogil
173
+ const void* c_dcg_var_ref_slot(const dcg_var_t* var, const char* getter) noexcept nogil
174
+ c_bool c_dcg_var_as_bool(const dcg_var_t* var) noexcept nogil
175
+ double c_dcg_var_as_double(const dcg_var_t* var) noexcept nogil
176
+ ssize_t c_dcg_var_as_int(const dcg_var_t* var) noexcept nogil
177
+ ssize_t c_dcg_var_as_offset(const dcg_var_t* var) noexcept nogil
178
+ const char* c_dcg_var_as_string(const dcg_var_t* var) noexcept nogil
179
+ const void* c_dcg_var_as_ref(const dcg_var_t* var) noexcept nogil
180
+ void* c_dcg_var_as_ptr(const dcg_var_t* var) noexcept nogil
181
+ const dcg_node* c_dcg_var_as_node(const dcg_var_t* var) noexcept nogil
182
+ dcg_d_vector_t* c_dcg_var_as_dvector(const dcg_var_t* var) noexcept nogil
183
+ dcg_d_matrix_t* c_dcg_var_as_dmatrix(const dcg_var_t* var) noexcept nogil
184
+ int c_dcg_var_cast(dcg_var_t* out, const dcg_var_t* var, dcg_var_type dtype) noexcept nogil
185
+ void c_dcg_var_snapshot(dcg_var_t* snapshot, const dcg_var_t* slot) noexcept nogil
186
+
187
+ int c_dcg_var_format(const dcg_var_t* var, char* out, size_t cap) noexcept nogil
188
+ int c_dcg_var_print(const dcg_var_t* var, FILE* stream) noexcept nogil
189
+
190
+
191
+ cdef extern from "decision_graph/decision_tree/bake/c_node.h":
192
+ ctypedef struct dcg_node:
193
+ pass
194
+
195
+
196
+ cdef class VarView:
197
+ cdef const dcg_var_t* header
198
+
199
+ @staticmethod
200
+ cdef inline VarView c_from_header(const dcg_var_t* var)
201
+
202
+
203
+ cdef void c_dcg_var_pypack(dcg_var_t* out, object value) except *
204
+
205
+ cdef object c_dcg_var_pyunpack(const dcg_var_t* var)
@@ -0,0 +1,271 @@
1
+ """The value layer: tagged values, containers, references, casts and output.
2
+
3
+ The unit of data that flows through a graph is a ``dcg_var_t``: a *tag* and a
4
+ *payload*. The tag is what an evaluator dispatches on, the payload is read
5
+ through the member the tag names, and everything else in this module is a reader
6
+ over the two - which is what ``VarView`` below is the Python window into.
7
+
8
+ Nothing else here is a Python object: the constructors, the initialisers, the
9
+ containers, the references, the casts and the output helpers are all ``cdef``
10
+ (``c_dcg_var_*``), plus the ``cdef extern`` declarations of the C header. A
11
+ caller reaches a value through the wrapper it belongs to - a node's ``out``, a
12
+ store's slot, a condition's payload - and reads it through ``VarView``.
13
+
14
+ The two Cython-level bridges are not module attributes either:
15
+ ``c_dcg_var_pypack`` and ``c_dcg_var_pyunpack`` translate between a
16
+ ``dcg_var_t`` and a Python object, and are cimported by the modules that need
17
+ them (``c_const``, ``c_collections``).
18
+ """
19
+
20
+ from enum import IntEnum
21
+
22
+
23
+ class VarType(IntEnum):
24
+ """The tag of a value: what it is, and whether it is a reference.
25
+
26
+ The members are the C enumerators by value, so a tag crosses the boundary as
27
+ itself and no translation table exists to fall out of step. The reference
28
+ ones are named as the C ones are - ``double_ref`` refers to a double,
29
+ ``double_ref_ref`` to a reference to one, one name per rung - and
30
+ ``inferred`` is a reference to a slot whose type is not known yet.
31
+
32
+ Attributes:
33
+ node: A node, held as its own address. It is what an action leaf's slot
34
+ carries - the node IS the value it stands for - and what unpacks back
35
+ into that node's wrapper.
36
+ reserved: A slot holding nothing yet: an entry whose value has not
37
+ arrived. ``is_null`` is true for one, and reading it refuses.
38
+ inferred: A reference to a ``reserved`` slot - "the type is the slot's to
39
+ say". It is what a read of a not-yet-filled store entry is born as.
40
+ """
41
+
42
+ raw_ptr: VarType
43
+ string: VarType
44
+ bool: VarType
45
+ double: VarType
46
+ int: VarType
47
+ offset: VarType
48
+ time: VarType
49
+ date: VarType
50
+ datetime: VarType
51
+ d_vector: VarType
52
+ d_matrix: VarType
53
+ reserved: VarType
54
+ node: VarType
55
+ raw_ptr_ref: VarType
56
+ string_ref: VarType
57
+ bool_ref: VarType
58
+ double_ref: VarType
59
+ int_ref: VarType
60
+ offset_ref: VarType
61
+ time_ref: VarType
62
+ date_ref: VarType
63
+ datetime_ref: VarType
64
+ d_vector_ref: VarType
65
+ d_matrix_ref: VarType
66
+ node_ref: VarType
67
+ inferred: VarType
68
+ raw_ptr_ref_ref: VarType
69
+ string_ref_ref: VarType
70
+ bool_ref_ref: VarType
71
+ double_ref_ref: VarType
72
+ int_ref_ref: VarType
73
+ offset_ref_ref: VarType
74
+ time_ref_ref: VarType
75
+ date_ref_ref: VarType
76
+ datetime_ref_ref: VarType
77
+ d_vector_ref_ref: VarType
78
+ d_matrix_ref_ref: VarType
79
+ node_ref_ref: VarType
80
+
81
+
82
+ class VarNumeric(IntEnum):
83
+ """How a value reads as a number - the shape of the answer, not the value.
84
+
85
+ A value that is not a number at all is ``none``, which is what the numeric
86
+ operators refuse. The two that ARE numbers are what decides the type of an
87
+ arithmetic result: an operation with a double in it is a double, and one
88
+ without is whole.
89
+ """
90
+
91
+ none: VarNumeric
92
+ int: VarNumeric
93
+ double: VarNumeric
94
+
95
+
96
+ class VarView:
97
+ """A read-only window onto a ``dcg_var_t``: the value layer's Python face.
98
+
99
+ A view is an ADDRESS, not a copy: it holds the slot it was taken over, and
100
+ every read answers for what that slot holds at the moment of the read. A
101
+ view owns nothing and frees nothing, so it must not outlive the value it
102
+ looks at - which the layer guarantees by handing one out only from a wrapper
103
+ that keeps that value alive (``LogicNode.out``).
104
+
105
+ It cannot write, and that is not a promise this docstring is making: the
106
+ view holds the value **const**, and every reader it exposes takes a const
107
+ pointer, so a write through a view does not compile. Reading a value that
108
+ another part of the layer is changing is what a view is for - it reports what
109
+ the slot holds now, never a snapshot taken when it was made.
110
+
111
+ The value type itself, which this class documents because it is its subject:
112
+
113
+ **The tag.** ``dcg_var_type`` names what the payload is - a raw pointer, a
114
+ string, a bool, a double, an int, an offset, a session time, date or
115
+ datetime, a contiguous double vector, or a matrix - and a tag with reference
116
+ bits set names a REFERENCE instead. The level in those bits is how many hops
117
+ the reference takes, and ``dtype & VAR_TYPE_BASE_MASK`` still names what sits
118
+ at the END of the walk: a reference to a double is a ``double_ref``, a
119
+ reference to that is a ``double_ref_ref``, and one more rung adds one more
120
+ star. A ``reserved`` slot is one that holds nothing yet - an entry created
121
+ before its value - and a reference to one is ``inferred``: the type is the
122
+ slot's to say, and a reader asks the slot.
123
+
124
+ **The payload.** One union, read through the member the tag calls for. A
125
+ container tag carries a pointer to a shape struct the value OWNS (allocated
126
+ as a child block, so one free releases the value and its container), a string
127
+ may be owned or borrowed, and a reference carries the address of the slot it
128
+ refers to and nothing else.
129
+
130
+ **References.** A reference owns nothing: the slot belongs to whoever set it
131
+ up, must outlive the reference, and must keep the shape the level assumes.
132
+ Reading through one is what the readers do - they follow the hops and read
133
+ what the tag says is at the end - so nothing in a payload is ever read as a
134
+ value header to find the way.
135
+
136
+ Attributes:
137
+ _header: The C value this view reads through.
138
+ """
139
+
140
+ def __init__(self, address: int) -> None:
141
+ """View the value at an address.
142
+
143
+ Args:
144
+ address: Address of a ``dcg_var_t``. The layer hands these out
145
+ itself (``LogicNode.out``); nothing here checks that the address
146
+ is a value, and the view keeps nothing alive.
147
+ """
148
+ ...
149
+
150
+ def __repr__(self) -> str:
151
+ """The view's own text: its class and the value's display text."""
152
+ ...
153
+
154
+ def format(self) -> str:
155
+ """The value as display text, as the C layer renders it.
156
+
157
+ Returns:
158
+ The text: a string quoted, a double with ``%g``, a pointer as an
159
+ address, a bool as true/false, a container as its shape.
160
+
161
+ Raises:
162
+ RuntimeError: When the view is uninitialised, or the C layer fails.
163
+ """
164
+ ...
165
+
166
+ @property
167
+ def address(self) -> int:
168
+ """The value's address - the slot this view reads through."""
169
+ ...
170
+
171
+ @property
172
+ def dtype(self) -> VarType:
173
+ """The value's tag."""
174
+ ...
175
+
176
+ @property
177
+ def type_name(self) -> str:
178
+ """The tag's stable name: ``'double'``, ``'double_ref'``, ``'inferred'``."""
179
+ ...
180
+
181
+ @property
182
+ def is_null(self) -> bool:
183
+ """Whether the value is absent: no payload of any type.
184
+
185
+ A live reference whose slot holds NULL is absent, like a NULL string or a
186
+ vector with no buffer, and so is a reserved slot. A reference that points
187
+ at nothing is not absent but broken: reading through it refuses.
188
+ """
189
+ ...
190
+
191
+ @property
192
+ def is_ref(self) -> bool:
193
+ """Whether the tag names a reference rather than a plain value."""
194
+ ...
195
+
196
+ @property
197
+ def ref_level(self) -> int:
198
+ """How many hops the tag refers through: 0, 1, 2, ... as far as it nests."""
199
+ ...
200
+
201
+ @property
202
+ def ref_base(self) -> VarType:
203
+ """The tag at the end of the walk - for a plain value, the tag itself."""
204
+ ...
205
+
206
+ @property
207
+ def numeric(self) -> VarNumeric:
208
+ """How the value reads as a number.
209
+
210
+ The question the arithmetic operators ask about an operand before they
211
+ apply themselves, and the answer that decides the type of what they
212
+ produce. A reference answers for what it refers to.
213
+ """
214
+ ...
215
+
216
+ @property
217
+ def value(self) -> bool | int | float | str | None:
218
+ """The value as a Python object, read by its own tag.
219
+
220
+ A reference is read through, as every reader reads one. None comes back
221
+ for a value that stands for nothing - unset, empty, or a tag with no
222
+ Python counterpart (a container, a session time).
223
+ """
224
+ ...
225
+
226
+ @property
227
+ def as_bool(self) -> bool:
228
+ """The value's truth, following Python's rules for its tag.
229
+
230
+ Never refuses: every tag has a truth value, so this is the one reader
231
+ that can always answer.
232
+ """
233
+ ...
234
+
235
+ @property
236
+ def as_int(self) -> int:
237
+ """The value as an integer, coercing: doubles truncate toward zero.
238
+
239
+ A non-numeric tag has no answer to give, and the layer's vigilant mode
240
+ reports the mistake where it is made rather than returning a 0 that
241
+ reads like a value.
242
+ """
243
+ ...
244
+
245
+ @property
246
+ def as_double(self) -> float:
247
+ """The value as a double, coercing from the numeric tags.
248
+
249
+ As with ``as_int``: a tag that is not a number is reported, not coerced.
250
+ """
251
+ ...
252
+
253
+ @property
254
+ def as_string(self) -> str | None:
255
+ """The text a string-shaped tag holds, or None when that text is NULL.
256
+
257
+ A tag that is not string-shaped is refused rather than answered
258
+ (vigilant mode names the reader and the tag on stderr and aborts), so a
259
+ caller asks ``type_name`` or ``is_null`` first.
260
+ """
261
+ ...
262
+
263
+ @property
264
+ def as_ptr(self) -> int:
265
+ """The pointer a pointer-shaped tag holds, as an address."""
266
+ ...
267
+
268
+ @property
269
+ def as_ref(self) -> int:
270
+ """The address a reference tag holds - the slot, one star per rung."""
271
+ ...