compiled-knowledge 4.0.0a9__cp312-cp312-win_amd64.whl → 4.0.0a10__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.
- ck/circuit/circuit.c +38860 -0
- ck/circuit/circuit.cp312-win_amd64.pyd +0 -0
- ck/circuit/circuit.pyx +9 -3
- ck/circuit_compiler/cython_vm_compiler/_compiler.c +17373 -0
- ck/circuit_compiler/cython_vm_compiler/_compiler.cp312-win_amd64.pyd +0 -0
- ck/pgm.py +78 -37
- ck/pgm_circuit/pgm_circuit.py +13 -9
- ck/pgm_circuit/program_with_slotmap.py +6 -4
- ck/pgm_compiler/ace/ace.py +48 -4
- ck/pgm_compiler/factor_elimination.py +6 -4
- ck/pgm_compiler/recursive_conditioning.py +8 -3
- ck/pgm_compiler/support/circuit_table/circuit_table.c +16042 -0
- ck/pgm_compiler/support/circuit_table/circuit_table.cp312-win_amd64.pyd +0 -0
- ck/pgm_compiler/support/clusters.py +1 -1
- ck/pgm_compiler/variable_elimination.py +3 -3
- ck/probability/empirical_probability_space.py +3 -0
- ck/probability/pgm_probability_space.py +32 -0
- ck/probability/probability_space.py +66 -12
- ck/sampling/sampler_support.py +1 -1
- ck/sampling/uniform_sampler.py +10 -4
- ck/sampling/wmc_direct_sampler.py +4 -2
- ck/sampling/wmc_gibbs_sampler.py +6 -0
- ck/sampling/wmc_metropolis_sampler.py +7 -1
- ck/sampling/wmc_rejection_sampler.py +2 -0
- ck/utils/iter_extras.py +9 -6
- {compiled_knowledge-4.0.0a9.dist-info → compiled_knowledge-4.0.0a10.dist-info}/METADATA +1 -1
- {compiled_knowledge-4.0.0a9.dist-info → compiled_knowledge-4.0.0a10.dist-info}/RECORD +30 -26
- {compiled_knowledge-4.0.0a9.dist-info → compiled_knowledge-4.0.0a10.dist-info}/WHEEL +0 -0
- {compiled_knowledge-4.0.0a9.dist-info → compiled_knowledge-4.0.0a10.dist-info}/licenses/LICENSE.txt +0 -0
- {compiled_knowledge-4.0.0a9.dist-info → compiled_knowledge-4.0.0a10.dist-info}/top_level.txt +0 -0
|
Binary file
|
|
@@ -9,7 +9,7 @@ from ck.pgm import PGM
|
|
|
9
9
|
|
|
10
10
|
# A VEObjective is a variable elimination objective function.
|
|
11
11
|
# An objective function is a function from a random variable index (int)
|
|
12
|
-
# to an
|
|
12
|
+
# to an objective value (float or int). This is used to select
|
|
13
13
|
# a random variable to eliminate in `ve_greedy_min`.
|
|
14
14
|
VEObjective = Callable[[int], int | float]
|
|
15
15
|
|
|
@@ -69,13 +69,13 @@ def compile_pgm(
|
|
|
69
69
|
tables_with_rv.append(product(x, y))
|
|
70
70
|
next_tables.append(sum_out(tables_with_rv[0], (rv_idx,)))
|
|
71
71
|
cur_tables = next_tables
|
|
72
|
-
|
|
72
|
+
|
|
73
|
+
# All rvs are now eliminated - all tables should have a single top.
|
|
73
74
|
tops: List[CircuitNode] = [
|
|
74
75
|
table.top()
|
|
75
76
|
for table in cur_tables
|
|
76
|
-
if len(table) > 0
|
|
77
77
|
]
|
|
78
|
-
top = factor_tables.circuit.
|
|
78
|
+
top: CircuitNode = factor_tables.circuit.optimised_mul(tops)
|
|
79
79
|
top.circuit.remove_unreachable_op_nodes(top)
|
|
80
80
|
|
|
81
81
|
return PGMCircuit(
|
|
@@ -7,6 +7,9 @@ from ck.probability.probability_space import ProbabilitySpace, Condition, check_
|
|
|
7
7
|
class EmpiricalProbabilitySpace(ProbabilitySpace):
|
|
8
8
|
def __init__(self, rvs: Sequence[RandomVariable], samples: Iterable[Instance]):
|
|
9
9
|
"""
|
|
10
|
+
Enable probabilistic queries over a sample from a sample space.
|
|
11
|
+
Note that this is not necessarily an efficient approach to calculating probabilities and statistics.
|
|
12
|
+
|
|
10
13
|
Assumes:
|
|
11
14
|
len(sample) == len(rvs), for each sample in samples.
|
|
12
15
|
0 <= sample[i] < len(rvs[i]), for each sample in samples, for i in range(len(rvs)).
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from typing import Sequence, Iterable, Tuple, Dict, List
|
|
2
|
+
|
|
3
|
+
from ck.pgm import RandomVariable, Indicator, Instance, PGM
|
|
4
|
+
from ck.probability.probability_space import ProbabilitySpace, Condition, check_condition
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class PGMProbabilitySpace(ProbabilitySpace):
|
|
8
|
+
def __init__(self, pgm: PGM):
|
|
9
|
+
"""
|
|
10
|
+
Enable probabilistic queries directly on a PGM.
|
|
11
|
+
Note that this is not necessarily an efficient approach to calculating probabilities and statistics.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
pgm: The PGM to query.
|
|
15
|
+
"""
|
|
16
|
+
self._pgm = pgm
|
|
17
|
+
self._z = None
|
|
18
|
+
|
|
19
|
+
@property
|
|
20
|
+
def rvs(self) -> Sequence[RandomVariable]:
|
|
21
|
+
return self._pgm.rvs
|
|
22
|
+
|
|
23
|
+
def wmc(self, *condition: Condition) -> float:
|
|
24
|
+
condition: Tuple[Indicator, ...] = check_condition(condition)
|
|
25
|
+
return self._pgm.value_product_indicators(*condition)
|
|
26
|
+
|
|
27
|
+
@property
|
|
28
|
+
def z(self) -> float:
|
|
29
|
+
if self._z is None:
|
|
30
|
+
self._z = self._pgm.value_product_indicators()
|
|
31
|
+
return self._z
|
|
32
|
+
|
|
@@ -3,6 +3,7 @@ An abstract class for object providing probabilities.
|
|
|
3
3
|
"""
|
|
4
4
|
import math
|
|
5
5
|
from abc import ABC, abstractmethod
|
|
6
|
+
from itertools import chain
|
|
6
7
|
from typing import Sequence, Tuple, Iterable, Callable
|
|
7
8
|
|
|
8
9
|
import numpy as np
|
|
@@ -75,15 +76,38 @@ class ProbabilitySpace(ABC):
|
|
|
75
76
|
the probability of the given indicators, conditioned on the given conditions.
|
|
76
77
|
"""
|
|
77
78
|
condition: Tuple[Indicator, ...] = check_condition(condition)
|
|
79
|
+
|
|
78
80
|
if len(condition) == 0:
|
|
79
81
|
z = self.z
|
|
82
|
+
if z <= 0:
|
|
83
|
+
return np.nan
|
|
80
84
|
else:
|
|
81
85
|
z = self.wmc(*condition)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
if z <= 0:
|
|
87
|
+
return np.nan
|
|
88
|
+
|
|
89
|
+
# Combine the indicators with the condition
|
|
90
|
+
# If a variable is mentioned in both the indicators and condition, then
|
|
91
|
+
# we need to take the intersection, and check for contradictions.
|
|
92
|
+
# If a variable is mentioned in the condition but not indicators, then
|
|
93
|
+
# the rv condition needs to be added to the indicators.
|
|
94
|
+
indicator_groups: MapSet[int, Indicator] = _group_indicators(indicators)
|
|
95
|
+
condition_groups: MapSet[int, Indicator] = _group_indicators(condition)
|
|
96
|
+
|
|
97
|
+
for rv_idx, indicators in condition_groups.items():
|
|
98
|
+
indicator_group = indicator_groups.get(rv_idx)
|
|
99
|
+
if indicator_group is None:
|
|
100
|
+
indicator_groups.add_all(rv_idx, indicators)
|
|
101
|
+
else:
|
|
102
|
+
indicator_group.intersection_update(indicators)
|
|
103
|
+
if len(indicator_group) == 0:
|
|
104
|
+
# A contradiction between the indicators and conditions
|
|
105
|
+
return 0.0
|
|
106
|
+
|
|
107
|
+
# Collect all the indicators from the updated indicator_groups
|
|
108
|
+
indicators = chain(*indicator_groups.values())
|
|
109
|
+
|
|
110
|
+
return self.wmc(*indicators) / z
|
|
87
111
|
|
|
88
112
|
def marginal_distribution(self, *rvs: RandomVariable, condition: Condition = ()) -> NDArrayNumeric:
|
|
89
113
|
"""
|
|
@@ -160,9 +184,7 @@ class ProbabilitySpace(ABC):
|
|
|
160
184
|
assert len(rv_indexes) == len(rvs), 'duplicated random variables not allowed'
|
|
161
185
|
|
|
162
186
|
# Group conditioning indicators by random variable.
|
|
163
|
-
conditions_by_rvs =
|
|
164
|
-
for ind in condition:
|
|
165
|
-
conditions_by_rvs.get_set(ind.rv_idx).add(ind.state_idx)
|
|
187
|
+
conditions_by_rvs = _group_states(condition)
|
|
166
188
|
|
|
167
189
|
# See if any MAP random variable is also conditioned.
|
|
168
190
|
# Reduce the state space of any conditioned MAP rv.
|
|
@@ -195,12 +217,12 @@ class ProbabilitySpace(ABC):
|
|
|
195
217
|
# Loop over the state space of the 'loop' rvs
|
|
196
218
|
best_probability = float('-inf')
|
|
197
219
|
best_states = None
|
|
198
|
-
|
|
199
|
-
for
|
|
200
|
-
probability = self.wmc(*(
|
|
220
|
+
indicators: Tuple[Indicator, ...]
|
|
221
|
+
for indicators in _combos(loop_rvs):
|
|
222
|
+
probability = self.wmc(*(indicators + new_conditions))
|
|
201
223
|
if probability > best_probability:
|
|
202
224
|
best_probability = probability
|
|
203
|
-
best_states = tuple(ind.state_idx for ind in
|
|
225
|
+
best_states = tuple(ind.state_idx for ind in indicators)
|
|
204
226
|
condition_probability = self.wmc(*condition)
|
|
205
227
|
return best_probability / condition_probability, best_states
|
|
206
228
|
|
|
@@ -551,6 +573,38 @@ def dtype_for_state_indexes(rvs: Iterable[RandomVariable]) -> DTypeStates:
|
|
|
551
573
|
return dtype_for_number_of_states(max((len(rv) for rv in rvs), default=0))
|
|
552
574
|
|
|
553
575
|
|
|
576
|
+
def _group_indicators(indicators: Iterable[Indicator]) -> MapSet[int, Indicator]:
|
|
577
|
+
"""
|
|
578
|
+
Group the given indicators by rv_idx.
|
|
579
|
+
|
|
580
|
+
Args:
|
|
581
|
+
indicators: the indicators to group.
|
|
582
|
+
|
|
583
|
+
Returns:
|
|
584
|
+
A mapping from rv_idx to set of indicators.
|
|
585
|
+
"""
|
|
586
|
+
groups: MapSet[int, Indicator] = MapSet()
|
|
587
|
+
for indicator in indicators:
|
|
588
|
+
groups.add(indicator.rv_idx, indicator)
|
|
589
|
+
return groups
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
def _group_states(indicators: Iterable[Indicator]) -> MapSet[int, int]:
|
|
593
|
+
"""
|
|
594
|
+
Group the given indicator states by rv_idx.
|
|
595
|
+
|
|
596
|
+
Args:
|
|
597
|
+
indicators: the indicators to group.
|
|
598
|
+
|
|
599
|
+
Returns:
|
|
600
|
+
A mapping from rv_idx to set of state indexes.
|
|
601
|
+
"""
|
|
602
|
+
groups: MapSet[int, int] = MapSet()
|
|
603
|
+
for indicator in indicators:
|
|
604
|
+
groups.add(indicator.rv_idx, indicator.state_idx)
|
|
605
|
+
return groups
|
|
606
|
+
|
|
607
|
+
|
|
554
608
|
def _normalise_marginal(distribution: NDArrayFloat64) -> None:
|
|
555
609
|
"""
|
|
556
610
|
Update the values in the given distribution to
|
ck/sampling/sampler_support.py
CHANGED
|
@@ -13,7 +13,7 @@ from ck.utils.random_extras import Random
|
|
|
13
13
|
# Type of a yield function. Support for a sampler.
|
|
14
14
|
# A yield function may be used to implement a sampler's iterator, thus
|
|
15
15
|
# it provides an Instance or single state index.
|
|
16
|
-
YieldF = Callable[[NDArrayStates],
|
|
16
|
+
YieldF = Callable[[NDArrayStates], int] | Callable[[NDArrayStates], Instance]
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
@dataclass
|
ck/sampling/uniform_sampler.py
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
from typing import Set, List, Iterator, Optional, Sequence
|
|
2
1
|
import random
|
|
2
|
+
from typing import Set, List, Iterator, Optional, Sequence
|
|
3
3
|
|
|
4
4
|
import numpy as np
|
|
5
5
|
|
|
6
6
|
from ck.pgm import Instance, RandomVariable, Indicator
|
|
7
7
|
from ck.probability.probability_space import dtype_for_state_indexes, Condition, check_condition
|
|
8
|
-
from .sampler import Sampler
|
|
9
|
-
from .sampler_support import YieldF
|
|
10
8
|
from ck.utils.map_set import MapSet
|
|
11
9
|
from ck.utils.np_extras import DType
|
|
12
10
|
from ck.utils.random_extras import Random
|
|
11
|
+
from .sampler import Sampler
|
|
12
|
+
from .sampler_support import YieldF
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class UniformSampler(Sampler):
|
|
@@ -39,11 +39,15 @@ class UniformSampler(Sampler):
|
|
|
39
39
|
conditioned_rvs.add(ind.rv_idx, ind.state_idx)
|
|
40
40
|
|
|
41
41
|
def get_possible_states(_rv: RandomVariable) -> List[int]:
|
|
42
|
+
"""
|
|
43
|
+
Get the allowable states for a given random variable, given
|
|
44
|
+
conditions in `conditioned_rvs`.
|
|
45
|
+
"""
|
|
42
46
|
condition_states: Optional[Set[int]] = conditioned_rvs.get(_rv.idx)
|
|
43
47
|
if condition_states is None:
|
|
44
48
|
return list(range(len(_rv)))
|
|
45
49
|
else:
|
|
46
|
-
return
|
|
50
|
+
return list(condition_states)
|
|
47
51
|
|
|
48
52
|
possible_states: List[List[int]] = [
|
|
49
53
|
get_possible_states(rv)
|
|
@@ -63,4 +67,6 @@ class UniformSampler(Sampler):
|
|
|
63
67
|
for i, l in enumerate(possible_states):
|
|
64
68
|
state_idx = rand.randrange(0, len(l))
|
|
65
69
|
state[i] = l[state_idx]
|
|
70
|
+
# We know the yield function will always provide either ints or Instances
|
|
71
|
+
# noinspection PyTypeChecker
|
|
66
72
|
yield yield_f(state)
|
|
@@ -8,7 +8,7 @@ from ck.program.program_buffer import ProgramBuffer
|
|
|
8
8
|
from ck.program.raw_program import RawProgram
|
|
9
9
|
from ck.sampling.sampler import Sampler
|
|
10
10
|
from ck.sampling.sampler_support import SampleRV, YieldF, SamplerInfo
|
|
11
|
-
from ck.utils.np_extras import NDArrayNumeric
|
|
11
|
+
from ck.utils.np_extras import NDArrayNumeric, NDArrayStates
|
|
12
12
|
from ck.utils.random_extras import Random
|
|
13
13
|
|
|
14
14
|
|
|
@@ -52,7 +52,7 @@ class WMCDirectSampler(Sampler):
|
|
|
52
52
|
return program_buffer.compute().item()
|
|
53
53
|
|
|
54
54
|
# Set up working memory buffers
|
|
55
|
-
states = np.zeros(len(sample_rvs), dtype=self._state_dtype)
|
|
55
|
+
states: NDArrayStates = np.zeros(len(sample_rvs), dtype=self._state_dtype)
|
|
56
56
|
buff_slots = np.zeros(self._max_number_of_states, dtype=np.uintp)
|
|
57
57
|
buff_states = np.zeros(self._max_number_of_states, dtype=self._state_dtype)
|
|
58
58
|
|
|
@@ -153,6 +153,8 @@ class WMCDirectSampler(Sampler):
|
|
|
153
153
|
slots[slot] = 1
|
|
154
154
|
states[sample_rv.index] = state
|
|
155
155
|
|
|
156
|
+
# We know the yield function will always provide either ints or Instances
|
|
157
|
+
# noinspection PyTypeChecker
|
|
156
158
|
yield yield_f(states)
|
|
157
159
|
|
|
158
160
|
# Reset the one slots for the next iteration.
|
ck/sampling/wmc_gibbs_sampler.py
CHANGED
|
@@ -65,12 +65,16 @@ class WMCGibbsSampler(Sampler):
|
|
|
65
65
|
if skip == 0:
|
|
66
66
|
while True:
|
|
67
67
|
self._next_sample_gibbs(sample_rvs, slots_1, program_buffer, prs, state, rand)
|
|
68
|
+
# We know the yield function will always provide either ints or Instances
|
|
69
|
+
# noinspection PyTypeChecker
|
|
68
70
|
yield yield_f(state)
|
|
69
71
|
else:
|
|
70
72
|
while True:
|
|
71
73
|
for _ in range(skip):
|
|
72
74
|
self._next_sample_gibbs(sample_rvs, slots_1, program_buffer, prs, state, rand)
|
|
73
75
|
self._next_sample_gibbs(sample_rvs, slots_1, program_buffer, prs, state, rand)
|
|
76
|
+
# We know the yield function will always provide either ints or Instances
|
|
77
|
+
# noinspection PyTypeChecker
|
|
74
78
|
yield yield_f(state)
|
|
75
79
|
|
|
76
80
|
else:
|
|
@@ -79,6 +83,8 @@ class WMCGibbsSampler(Sampler):
|
|
|
79
83
|
for _ in range(skip):
|
|
80
84
|
self._next_sample_gibbs(sample_rvs, slots_1, program_buffer, prs, state, rand)
|
|
81
85
|
self._next_sample_gibbs(sample_rvs, slots_1, program_buffer, prs, state, rand)
|
|
86
|
+
# We know the yield function will always provide either ints or Instances
|
|
87
|
+
# noinspection PyTypeChecker
|
|
82
88
|
yield yield_f(state)
|
|
83
89
|
if rand.random() < pr_restart:
|
|
84
90
|
# Set an initial system state
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Collection, Iterator,
|
|
1
|
+
from typing import Collection, Iterator, Sequence
|
|
2
2
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
|
|
@@ -78,12 +78,16 @@ class WMCMetropolisSampler(Sampler):
|
|
|
78
78
|
if skip == 0:
|
|
79
79
|
while True:
|
|
80
80
|
w = self._next_sample_metropolis(possibles, program_buffer, state, w, rand)
|
|
81
|
+
# We know the yield function will always provide either ints or Instances
|
|
82
|
+
# noinspection PyTypeChecker
|
|
81
83
|
yield yield_f(state)
|
|
82
84
|
else:
|
|
83
85
|
while True:
|
|
84
86
|
for _ in range(skip):
|
|
85
87
|
w = self._next_sample_metropolis(possibles, program_buffer, state, w, rand)
|
|
86
88
|
w = self._next_sample_metropolis(possibles, program_buffer, state, w, rand)
|
|
89
|
+
# We know the yield function will always provide either ints or Instances
|
|
90
|
+
# noinspection PyTypeChecker
|
|
87
91
|
yield yield_f(state)
|
|
88
92
|
|
|
89
93
|
else:
|
|
@@ -92,6 +96,8 @@ class WMCMetropolisSampler(Sampler):
|
|
|
92
96
|
for _ in range(skip):
|
|
93
97
|
w = self._next_sample_metropolis(possibles, program_buffer, state, w, rand)
|
|
94
98
|
w = self._next_sample_metropolis(possibles, program_buffer, state, w, rand)
|
|
99
|
+
# We know the yield function will always provide either ints or Instances
|
|
100
|
+
# noinspection PyTypeChecker
|
|
95
101
|
yield yield_f(state)
|
|
96
102
|
|
|
97
103
|
if rand.random() < pr_restart:
|
|
@@ -91,6 +91,8 @@ class WMCRejectionSampler(Sampler):
|
|
|
91
91
|
w: float = wmc()
|
|
92
92
|
|
|
93
93
|
if rand.random() * self._w_max < w:
|
|
94
|
+
# We know the yield function will always provide either ints or Instances
|
|
95
|
+
# noinspection PyTypeChecker
|
|
94
96
|
yield yield_f(state)
|
|
95
97
|
|
|
96
98
|
# Update w_not_seen and w_high to adapt w_max.
|
ck/utils/iter_extras.py
CHANGED
|
@@ -4,19 +4,19 @@ A module with extra iteration functions.
|
|
|
4
4
|
from functools import reduce as _reduce
|
|
5
5
|
from itertools import combinations, chain
|
|
6
6
|
from operator import mul as _mul
|
|
7
|
-
from typing import Iterable, Tuple,
|
|
7
|
+
from typing import Iterable, Tuple, Sequence, TypeVar
|
|
8
8
|
|
|
9
9
|
_T = TypeVar('_T')
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
def flatten(iterables: Iterable[Iterable[_T]]) ->
|
|
12
|
+
def flatten(iterables: Iterable[Iterable[_T]]) -> Iterable[_T]:
|
|
13
13
|
"""
|
|
14
14
|
Iterate over the elements of an iterable of iterables.
|
|
15
15
|
"""
|
|
16
16
|
return (elem for iterable in iterables for elem in iterable)
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
def deep_flatten(iterables: Iterable) ->
|
|
19
|
+
def deep_flatten(iterables: Iterable) -> Iterable:
|
|
20
20
|
"""
|
|
21
21
|
Iterate over the flattening of nested iterables.
|
|
22
22
|
"""
|
|
@@ -28,7 +28,7 @@ def deep_flatten(iterables: Iterable) -> Iterator:
|
|
|
28
28
|
yield el
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
def combos(list_of_lists: Sequence[Sequence[_T]], flip=False) ->
|
|
31
|
+
def combos(list_of_lists: Sequence[Sequence[_T]], flip=False) -> Iterable[Tuple[_T, ...]]:
|
|
32
32
|
"""
|
|
33
33
|
Iterate over all combinations of taking one element from each of the lists.
|
|
34
34
|
|
|
@@ -66,7 +66,7 @@ def combos(list_of_lists: Sequence[Sequence[_T]], flip=False) -> Iterator[Tuple[
|
|
|
66
66
|
return
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
def combos_ranges(list_of_lens: Sequence[int], flip=False) ->
|
|
69
|
+
def combos_ranges(list_of_lens: Sequence[int], flip=False) -> Iterable[Tuple[int, ...]]:
|
|
70
70
|
"""
|
|
71
71
|
Equivalent to combos([range(l) for l in list_of_lens], flip).
|
|
72
72
|
|
|
@@ -106,7 +106,7 @@ def pairs(elements: Iterable[_T]) -> Iterable[Tuple[_T, _T]]:
|
|
|
106
106
|
return combinations(elements, 2)
|
|
107
107
|
|
|
108
108
|
|
|
109
|
-
def sequential_pairs(elements: Sequence[_T]) ->
|
|
109
|
+
def sequential_pairs(elements: Sequence[_T]) -> Iterable[Tuple[_T, _T]]:
|
|
110
110
|
"""
|
|
111
111
|
Iterate over sequential pairs in the given list of elements.
|
|
112
112
|
"""
|
|
@@ -135,6 +135,9 @@ def unzip(xs: Iterable[Tuple[_T]]) -> Tuple[Iterable[_T]]:
|
|
|
135
135
|
Inverse function of zip.
|
|
136
136
|
|
|
137
137
|
E.g., a, b, c = unzip(zip(a, b, c))
|
|
138
|
+
|
|
139
|
+
Note that the Python type of `a`, `b`, and `c` may not be preserved, only
|
|
140
|
+
the contents, order and length are guaranteed.
|
|
138
141
|
"""
|
|
139
142
|
return zip(*xs)
|
|
140
143
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
ck/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
ck/pgm.py,sha256=
|
|
2
|
+
ck/pgm.py,sha256=PcuoqQyymMvbmUWb62hIe4cly2k28EuF0R4yM-KYBvI,124358
|
|
3
3
|
ck/circuit/__init__.py,sha256=tozFNNVzsgQDwFrtGzrgcFS4XTszhgyFmbMGfV5pimc,212
|
|
4
|
-
ck/circuit/circuit.
|
|
5
|
-
ck/circuit/circuit.
|
|
4
|
+
ck/circuit/circuit.c,sha256=nPXdIXZHyMC25nQ58iPtIpBnUNRwtOtrCxjp8-fv4Yw,1772565
|
|
5
|
+
ck/circuit/circuit.cp312-win_amd64.pyd,sha256=ni89eTKbJVWmXEcMY_YkLDSuIJr3zw53DIq6bwZCfdk,252416
|
|
6
|
+
ck/circuit/circuit.pyx,sha256=H5OIVZS7Ft5K3b-1KPna815JHfwhvoQPQBcvJq3IZCY,27854
|
|
6
7
|
ck/circuit/circuit_node.pyx,sha256=8RuEC1ngYxnsGryzQ1lOEPc4ewTxvKwc56sOxWLB9zs,4103
|
|
7
8
|
ck/circuit/circuit_py.py,sha256=Y4g3vf3l1_3zS1g52b5Fi9F-4DupiZTeF8yiYiKz6Vc,27507
|
|
8
9
|
ck/circuit/tmp_const.py,sha256=dG9FuGfoAG5qjYG1rNwekqKiea_KmVfxHMTOgCPbBiQ,2372
|
|
@@ -13,7 +14,8 @@ ck/circuit_compiler/llvm_compiler.py,sha256=ejeNPkO5Og2FyjjyA5JAexxUl1f8IJ6mwU5N
|
|
|
13
14
|
ck/circuit_compiler/llvm_vm_compiler.py,sha256=I46_XV5FrClDKO06zIjn8T3ME5XQ9RYJ_1aAE8e_YzM,21873
|
|
14
15
|
ck/circuit_compiler/named_circuit_compilers.py,sha256=Fsk2HANYhw25uxAdOo5-7aSnVZxlPgsaPz9wO_1YdRg,2400
|
|
15
16
|
ck/circuit_compiler/cython_vm_compiler/__init__.py,sha256=pEAwTleuZgdYhTAQMea2f9YsFK54eoNbZSbrWkW8aeE,49
|
|
16
|
-
ck/circuit_compiler/cython_vm_compiler/_compiler.
|
|
17
|
+
ck/circuit_compiler/cython_vm_compiler/_compiler.c,sha256=xpYybtj-aRcMJV1oKkB-p0kciZVW3gLRd0OJBfDg3sc,757006
|
|
18
|
+
ck/circuit_compiler/cython_vm_compiler/_compiler.cp312-win_amd64.pyd,sha256=S3nPwu09dARS8GrKmr_KtA-EHH5MD0ioAnyZ-cqf0q4,92160
|
|
17
19
|
ck/circuit_compiler/cython_vm_compiler/_compiler.pyx,sha256=hHuNo99TbodNpWgQwQ8qzW1cTwGXZj5SW0tKAo9u6cw,7718
|
|
18
20
|
ck/circuit_compiler/cython_vm_compiler/cython_vm_compiler.py,sha256=yUkBNr5HnoVXyWjJdXHp8lyAXFiIDYapvMvHtzKuhI8,3140
|
|
19
21
|
ck/circuit_compiler/support/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -64,33 +66,35 @@ ck/in_out/render_pomegranate.py,sha256=gGvXyX9vOoilGIIL3rsMB07gERMU-12XPsttfSb4x
|
|
|
64
66
|
ck/pgm_circuit/__init__.py,sha256=B0CCjNMnPzrd0YiOEFdK4JzmRCvFIGJi3RJQ5Vg6fqA,37
|
|
65
67
|
ck/pgm_circuit/marginals_program.py,sha256=DUvSND3ozQuBCZcmIsgwZ4w_IWCVV7O31Pm4PJ7ZDok,14786
|
|
66
68
|
ck/pgm_circuit/mpe_program.py,sha256=IjHPZv2xKXZGp_FR1QFJgJpMhLKdajLgV33R4DEbn4o,10231
|
|
67
|
-
ck/pgm_circuit/pgm_circuit.py,sha256=
|
|
68
|
-
ck/pgm_circuit/program_with_slotmap.py,sha256=
|
|
69
|
+
ck/pgm_circuit/pgm_circuit.py,sha256=3vKOh2gFGyB_PhfQgviCQGXv1t4dbawBL89sjm4-SPA,3287
|
|
70
|
+
ck/pgm_circuit/program_with_slotmap.py,sha256=boS8Y1X60F-_pTM3wFyC4oP9jc-5zDc8Iv4vn7JUJWM,8959
|
|
69
71
|
ck/pgm_circuit/slot_map.py,sha256=T4nBweoiivEdBDhYZ6GWpOXqSusRbp3vrSbCTyP1qpI,857
|
|
70
72
|
ck/pgm_circuit/target_marginals_program.py,sha256=x4YQM-hUQRo2OLxodKJVOAKxqNlxmiDl9nGbbknypkY,3768
|
|
71
73
|
ck/pgm_circuit/wmc_program.py,sha256=WtABU74FOCCJuKRCoDL4CyZ4CJXFmt9RSxiNNHsOhRY,12699
|
|
72
74
|
ck/pgm_circuit/support/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
73
75
|
ck/pgm_circuit/support/compile_circuit.py,sha256=RuYzDCRpfXZcY96sSW8v7x6ev9ScQ4IZkVqMdJUoMp8,3484
|
|
74
76
|
ck/pgm_compiler/__init__.py,sha256=XCK1AWBBB9UYi6kbFnxMFzBL9a25EWfHnz_yn3ZKYuM,112
|
|
75
|
-
ck/pgm_compiler/factor_elimination.py,sha256=
|
|
77
|
+
ck/pgm_compiler/factor_elimination.py,sha256=iZe7Y-YIm0P9I-h4jLomUS49QiEedAbWQ1btU5JRBLg,13244
|
|
76
78
|
ck/pgm_compiler/named_pgm_compilers.py,sha256=zqRR8gER4zhl_RjXPHy8U0j5G-bQhYQZuG9hWptAHms,3720
|
|
77
79
|
ck/pgm_compiler/pgm_compiler.py,sha256=F44PtlwqMG0FS6KzOYKZuyZT6olWAVtBH-QXZPzz4O8,616
|
|
78
|
-
ck/pgm_compiler/recursive_conditioning.py,sha256=
|
|
79
|
-
ck/pgm_compiler/variable_elimination.py,sha256=
|
|
80
|
+
ck/pgm_compiler/recursive_conditioning.py,sha256=dlLAKdV7KUf7hHRVIndBsMC1bGUvrOCXeOY0vGs6yHE,7935
|
|
81
|
+
ck/pgm_compiler/variable_elimination.py,sha256=wNNntrng2OGSsnGHWr8cLHsMHDQgJodQxhu6h7RMung,3459
|
|
80
82
|
ck/pgm_compiler/ace/__init__.py,sha256=BkZXAF32Pk8QU7jhkuKvHqtsFasPjf8gxiZbyrGDDbQ,82
|
|
81
|
-
ck/pgm_compiler/ace/ace.py,sha256=
|
|
83
|
+
ck/pgm_compiler/ace/ace.py,sha256=SpOX8s0PsNP0I9X5_TagHo5Gh4kZYxciKuEQbuvpyE4,10131
|
|
82
84
|
ck/pgm_compiler/support/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
83
|
-
ck/pgm_compiler/support/clusters.py,sha256=
|
|
85
|
+
ck/pgm_compiler/support/clusters.py,sha256=96Up5XUgERh-t6KzSIOF2gtP5T4Ul83JK_aPtIR72Ic,20821
|
|
84
86
|
ck/pgm_compiler/support/factor_tables.py,sha256=LAZbWtDVyTpxps7C4d3q38uUVkNnzRBO8JpYl9Qly-c,15081
|
|
85
87
|
ck/pgm_compiler/support/join_tree.py,sha256=tRHev655cwRsOSyLK9HYwfX8EEkubmlg1fw748Kztb4,10418
|
|
86
88
|
ck/pgm_compiler/support/named_compiler_maker.py,sha256=tQ79JOI8MknAziUiFhFGV9n4y6PPKrnbq3-quMmnrwY,974
|
|
87
89
|
ck/pgm_compiler/support/circuit_table/__init__.py,sha256=eWMP5ywgd51RJexKkhcpKJb_8iEluL0C4_hyOpzlAvQ,167
|
|
88
|
-
ck/pgm_compiler/support/circuit_table/circuit_table.
|
|
90
|
+
ck/pgm_compiler/support/circuit_table/circuit_table.c,sha256=aO3bq3V-FwbmJDzWVYwigOFeQUC6gFz-nAq091XQp2E,702527
|
|
91
|
+
ck/pgm_compiler/support/circuit_table/circuit_table.cp312-win_amd64.pyd,sha256=TPzAAETE8QIjRp6yReo9YlNczibIBFQ6mu7KlTzUeXE,94720
|
|
89
92
|
ck/pgm_compiler/support/circuit_table/circuit_table.pyx,sha256=jhzstay-3EUgu0CIbWKd0eNDNToX1tmm9IQxk0ZgpYM,11904
|
|
90
93
|
ck/pgm_compiler/support/circuit_table/circuit_table_py.py,sha256=1WFCxgBFu4oaYRCdk_1uXeufFQu6PqMOsYIQ_SkXDS4,10156
|
|
91
94
|
ck/probability/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
92
|
-
ck/probability/empirical_probability_space.py,sha256=
|
|
93
|
-
ck/probability/
|
|
95
|
+
ck/probability/empirical_probability_space.py,sha256=HoLxmigzlWFWQlcZQwDOYk-mjgf6RW1IPE-l0t8vMPw,1950
|
|
96
|
+
ck/probability/pgm_probability_space.py,sha256=vK-drx145PWW2aYB8HttQcvhvqPfxVl72bPcFO8jw8M,1034
|
|
97
|
+
ck/probability/probability_space.py,sha256=itv3dNEpSTLhKg6JCNhe7Iy6n9MKWqeKO4RxKR9kKF0,25882
|
|
94
98
|
ck/program/__init__.py,sha256=Ss9-0eqsGxCGloD6liH-0iqBG5Q3vPRF4XCw2hkDJ0M,110
|
|
95
99
|
ck/program/program.py,sha256=ONeKhhMtgkaMtcgC-DDRUqId9ATgqnFD0ovt1t2nqrM,3773
|
|
96
100
|
ck/program/program_buffer.py,sha256=1fiUcT7sqyr4vu8jXzK3ZsrgURFhWMdm6hr2BeS9ONA,5665
|
|
@@ -99,14 +103,14 @@ ck/sampling/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
99
103
|
ck/sampling/forward_sampler.py,sha256=pTtpaH_ONH67G4P-aJ1p8YZSaXr4TTD6pj3ZEI2y7KM,8348
|
|
100
104
|
ck/sampling/marginals_direct_sampler.py,sha256=p1jDr1stG2Hjay3D8hILezW-5YZTX1p3odUcJDAI-OQ,4466
|
|
101
105
|
ck/sampling/sampler.py,sha256=qhfguy8rnVQBVVXhJylvh-8Kq7rfHW62a3DEtv9v7Xc,2306
|
|
102
|
-
ck/sampling/sampler_support.py,sha256=
|
|
103
|
-
ck/sampling/uniform_sampler.py,sha256=
|
|
104
|
-
ck/sampling/wmc_direct_sampler.py,sha256=
|
|
105
|
-
ck/sampling/wmc_gibbs_sampler.py,sha256=
|
|
106
|
-
ck/sampling/wmc_metropolis_sampler.py,sha256=
|
|
107
|
-
ck/sampling/wmc_rejection_sampler.py,sha256=
|
|
106
|
+
ck/sampling/sampler_support.py,sha256=beFJ993yXyvy5y2T7tJmK638ESp3qvErFWoM3BEwD5E,9742
|
|
107
|
+
ck/sampling/uniform_sampler.py,sha256=NCN1T77v4g4hsdNgIsZDxHBndfj4AghLSk8WKQt_2a0,2586
|
|
108
|
+
ck/sampling/wmc_direct_sampler.py,sha256=7qiz-bRlQ59ZBJmg0bEG0y63pXTVXNVx4d410BGhnJg,7265
|
|
109
|
+
ck/sampling/wmc_gibbs_sampler.py,sha256=GMKVW2AVtsWtP6vxE3Y2dy-dKr7GoO_vLEA9eC304fo,6567
|
|
110
|
+
ck/sampling/wmc_metropolis_sampler.py,sha256=PRv7wtPZz7BcwN8iArsykVwqgY77v5km7rXcawFAUPQ,6470
|
|
111
|
+
ck/sampling/wmc_rejection_sampler.py,sha256=cd0VONZf-oa491RRKfwT2LakQs0o_slgPCes8AOvSNc,4897
|
|
108
112
|
ck/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
109
|
-
ck/utils/iter_extras.py,sha256=
|
|
113
|
+
ck/utils/iter_extras.py,sha256=DDml5Jprmun2RovJxkwXx1uJkWacYhZEnX1ARSX2TB4,4310
|
|
110
114
|
ck/utils/map_list.py,sha256=T2OpjI7eDgC4geCtW_FsEr6ryiePOnKZwfDahB63zfA,3847
|
|
111
115
|
ck/utils/map_set.py,sha256=BLu9BO3FCtzZlZ9MfP9STtIdQ4Me8-QKdwB7o15y7f8,3809
|
|
112
116
|
ck/utils/np_extras.py,sha256=J5KIQJX3C79ltAfKKYc0B0HI43iyuUQxLI9HZ9FiORI,1734
|
|
@@ -161,8 +165,8 @@ ck_demos/utils/compare.py,sha256=eC1rJXuWQhEfq4yQlXggn2O_sk-xAVEn6PpVuIaZJoo,344
|
|
|
161
165
|
ck_demos/utils/convert_network.py,sha256=TSKj8q7L7J5rhrvwjaDkdYZ0Sg8vV5FRL_vCanX1CQw,1363
|
|
162
166
|
ck_demos/utils/sample_model.py,sha256=in-Nlv-iuNIu6y9fDuMyo7nzgimBuTAnCWcpnVqvqDQ,8839
|
|
163
167
|
ck_demos/utils/stop_watch.py,sha256=VzXHRWx0V8vPSD-bLgLlEYkCkR2FA0-KmM_pfKx-Pxo,13205
|
|
164
|
-
compiled_knowledge-4.0.
|
|
165
|
-
compiled_knowledge-4.0.
|
|
166
|
-
compiled_knowledge-4.0.
|
|
167
|
-
compiled_knowledge-4.0.
|
|
168
|
-
compiled_knowledge-4.0.
|
|
168
|
+
compiled_knowledge-4.0.0a10.dist-info/licenses/LICENSE.txt,sha256=uMYx7tmroEKNASizbCOwPveMQsD5UErLDC1_SANmNn8,1089
|
|
169
|
+
compiled_knowledge-4.0.0a10.dist-info/METADATA,sha256=olz_v2tXOkTcuQGPYBnSiaDyGS_N7sja-guy1p2onDE,1689
|
|
170
|
+
compiled_knowledge-4.0.0a10.dist-info/WHEEL,sha256=b7PoVIxzH_MOHKjftqMzQiGKfdHRlRFepVBVPg0y3vc,101
|
|
171
|
+
compiled_knowledge-4.0.0a10.dist-info/top_level.txt,sha256=Cf8DAfd2vcnLiA7HlxoduOzV0Q-8surE3kzX8P9qdks,12
|
|
172
|
+
compiled_knowledge-4.0.0a10.dist-info/RECORD,,
|
|
File without changes
|
{compiled_knowledge-4.0.0a9.dist-info → compiled_knowledge-4.0.0a10.dist-info}/licenses/LICENSE.txt
RENAMED
|
File without changes
|
{compiled_knowledge-4.0.0a9.dist-info → compiled_knowledge-4.0.0a10.dist-info}/top_level.txt
RENAMED
|
File without changes
|