compiled-knowledge 4.0.0a16__cp312-cp312-win_amd64.whl → 4.0.0a17__cp312-cp312-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.

Potentially problematic release.


This version of compiled-knowledge might be problematic. Click here for more details.

Files changed (29) hide show
  1. ck/circuit/__init__.py +2 -2
  2. ck/circuit/_circuit_cy.cp312-win_amd64.pyd +0 -0
  3. ck/circuit/{circuit.pyx → _circuit_cy.pyx} +65 -57
  4. ck/circuit/{circuit_py.py → _circuit_py.py} +14 -6
  5. ck/circuit_compiler/cython_vm_compiler/_compiler.c +1603 -2030
  6. ck/circuit_compiler/cython_vm_compiler/_compiler.cp312-win_amd64.pyd +0 -0
  7. ck/circuit_compiler/cython_vm_compiler/_compiler.pyx +85 -58
  8. ck/circuit_compiler/named_circuit_compilers.py +1 -1
  9. ck/pgm_compiler/factor_elimination.py +23 -13
  10. ck/pgm_compiler/support/circuit_table/__init__.py +2 -2
  11. ck/pgm_compiler/support/circuit_table/_circuit_table_cy.cp312-win_amd64.pyd +0 -0
  12. ck/pgm_compiler/support/circuit_table/{circuit_table.pyx → _circuit_table_cy.pyx} +9 -9
  13. ck/pgm_compiler/support/circuit_table/{circuit_table_py.py → _circuit_table_py.py} +5 -5
  14. ck/pgm_compiler/support/clusters.py +16 -4
  15. ck/pgm_compiler/support/factor_tables.py +1 -1
  16. ck/pgm_compiler/support/join_tree.py +67 -10
  17. ck/pgm_compiler/variable_elimination.py +2 -0
  18. ck_demos/pgm_compiler/demo_compiler_dump.py +10 -0
  19. ck_demos/pgm_compiler/time_fe_compiler.py +93 -0
  20. {compiled_knowledge-4.0.0a16.dist-info → compiled_knowledge-4.0.0a17.dist-info}/METADATA +1 -1
  21. {compiled_knowledge-4.0.0a16.dist-info → compiled_knowledge-4.0.0a17.dist-info}/RECORD +24 -26
  22. ck/circuit/circuit.c +0 -38861
  23. ck/circuit/circuit.cp312-win_amd64.pyd +0 -0
  24. ck/circuit/circuit_node.pyx +0 -138
  25. ck/pgm_compiler/support/circuit_table/circuit_table.c +0 -16042
  26. ck/pgm_compiler/support/circuit_table/circuit_table.cp312-win_amd64.pyd +0 -0
  27. {compiled_knowledge-4.0.0a16.dist-info → compiled_knowledge-4.0.0a17.dist-info}/WHEEL +0 -0
  28. {compiled_knowledge-4.0.0a16.dist-info → compiled_knowledge-4.0.0a17.dist-info}/licenses/LICENSE.txt +0 -0
  29. {compiled_knowledge-4.0.0a16.dist-info → compiled_knowledge-4.0.0a17.dist-info}/top_level.txt +0 -0
Binary file
@@ -1,138 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from typing import Optional, Tuple
4
-
5
- # Python Type for values of ConstNode objects
6
- ConstValue = float | int | bool
7
-
8
- cdef class CircuitNode:
9
- """
10
- A node in an arithmetic circuit.
11
- Each node is either an op, var, or const node.
12
-
13
- Each op node is either a mul, add or sub node. Each op
14
- node has zero or more arguments. Each argument is another node.
15
-
16
- Every var node has an index, `idx`, which is an integer counting from zero, and denotes
17
- its creation order.
18
-
19
- A var node may be temporarily set to be a constant node, which may
20
- be useful for optimising a compiled circuit.
21
- """
22
- cdef public object circuit
23
-
24
- def __init__(self, circuit):
25
- self.circuit = circuit
26
-
27
- cpdef int is_zero(self) except*:
28
- return False
29
-
30
- cpdef int is_one(self) except*:
31
- return False
32
-
33
- def __add__(self, other: CircuitNode | ConstValue):
34
- return self.circuit.add(self, other)
35
-
36
- def __mul__(self, other: CircuitNode | ConstValue):
37
- return self.circuit.mul(self, other)
38
-
39
-
40
- cdef class ConstNode(CircuitNode):
41
- cdef public object value
42
-
43
- """
44
- A node in a circuit representing a constant value.
45
- """
46
- def __init__(self, circuit, value: ConstValue):
47
- super().__init__(circuit)
48
- self.value: ConstValue = value
49
-
50
- cpdef int is_zero(self) except*:
51
- # noinspection PyProtectedMember
52
- return self is self.circuit.zero
53
-
54
- cpdef int is_one(self) except*:
55
- # noinspection PyProtectedMember
56
- return self is self.circuit.one
57
-
58
- def __str__(self) -> str:
59
- return 'const(' + str(self.value) + ')'
60
-
61
- def __lt__(self, other) -> bool:
62
- if isinstance(other, ConstNode):
63
- return self.value < other.value
64
- else:
65
- return False
66
-
67
- cdef class VarNode(CircuitNode):
68
- """
69
- A node in a circuit representing an input variable.
70
- """
71
- cdef public int idx
72
- cdef object _const
73
-
74
- def __init__(self, circuit, idx: int):
75
- super().__init__(circuit)
76
- self.idx = idx
77
- self._const = None
78
-
79
- cpdef int is_zero(self) except*:
80
- return self._const is not None and self._const.is_zero()
81
-
82
- cpdef int is_one(self) except*:
83
- return self._const is not None and self._const.is_one()
84
-
85
- cpdef int is_const(self) except*:
86
- return self._const is not None
87
-
88
- @property
89
- def const(self) -> Optional[ConstNode]:
90
- return self._const
91
-
92
- @const.setter
93
- def const(self, value: ConstValue | ConstNode | None) -> None:
94
- if value is None:
95
- self._const = None
96
- else:
97
- self._const = self.circuit.const(value)
98
-
99
- def __lt__(self, other) -> bool:
100
- if isinstance(other, VarNode):
101
- return self.idx < other.idx
102
- else:
103
- return False
104
-
105
- def __str__(self) -> str:
106
- if self._const is None:
107
- return 'var[' + str(self.idx) + ']'
108
- else:
109
- return 'var[' + str(self.idx) + '] = ' + str(self._const.value)
110
-
111
- cdef class OpNode(CircuitNode):
112
- """
113
- A node in a circuit representing an arithmetic operation.
114
- """
115
- cdef public tuple[object, ...] args
116
- cdef public str symbol
117
-
118
- def __init__(self, object circuit, symbol: str, tuple[object, ...] args: Tuple[CircuitNode]):
119
- super().__init__(circuit)
120
- self.args = tuple(args)
121
- self.symbol = str(symbol)
122
-
123
- def __str__(self) -> str:
124
- return self.symbol + '\\' + str(len(self.args))
125
-
126
- cdef class MulNode(OpNode):
127
- """
128
- A node in a circuit representing a multiplication operation.
129
- """
130
- def __init__(self, object circuit, tuple[object, ...] args: Tuple[CircuitNode, ...]):
131
- super().__init__(circuit, 'mul', args)
132
-
133
- cdef class AddNode(OpNode):
134
- """
135
- A node in a circuit representing an addition operation.
136
- """
137
- def __init__(self, circuit, tuple[object, ...] args: Tuple[CircuitNode, ...]):
138
- super().__init__(circuit, 'add', args)