iita-python 1.4__tar.gz → 1.4.2__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: iita_python
3
- Version: 1.4
3
+ Version: 1.4.2
4
4
  Summary: IITA algorithm in python
5
5
  Author-email: Aliaksei Badnarchuk <alexejbodnarchuk@gmail.com>
6
6
  Requires-Python: >=3.9
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '1.4'
22
- __version_tuple__ = version_tuple = (1, 4)
21
+ __version__ = version = '1.4.2'
22
+ __version_tuple__ = version_tuple = (1, 4, 2)
23
23
 
24
- __commit_id__ = commit_id = 'g8439da544'
24
+ __commit_id__ = commit_id = 'g07488e250'
@@ -21,8 +21,38 @@ class QuasiOrder:
21
21
  edge_list.append([i+buff, j+buff])
22
22
 
23
23
  return edge_list
24
+
25
+ def get_knowledge_space(self):
26
+ """
27
+ Returns the knowledge space described by the quasiorder as a numpy matrix\n
28
+ In the output matrix, the rows represent the elements of the knowledge space,
29
+ and the columns represent the items. An entry is 1 if the item is in the knowledge state, and 0 otherwise.
30
+ """
31
+
32
+ n = self.full_matrix.shape[0]
33
+
34
+ bits = 1 << np.arange(n, dtype=object)
35
+ predecessors = np.array([int(np.packbits(self.full_matrix[:, j], bitorder='little')[0]) | (1 << j) for j in range(n)])
36
+
37
+ knowledge_space_set = {0}
38
+ queue = [0]
39
+
40
+ while queue:
41
+ current = queue.pop()
42
+
43
+ absent = (current & bits) == 0
44
+ candidates = (current | predecessors)[absent]
45
+
46
+ for new_set in candidates:
47
+ if new_set not in knowledge_space_set:
48
+ knowledge_space_set.add(new_set)
49
+ queue.append(new_set)
50
+
51
+ masks = np.array(sorted(knowledge_space_set), dtype=object)
52
+ knowledge_space_matrix = ((masks[:, None] & bits) != 0).astype(np.int_)
53
+ return knowledge_space_matrix
24
54
 
25
- def ind_gen(counterexamples: pd.DataFrame, n: int) -> list[QuasiOrder]:
55
+ def ind_gen(counterexamples: pd.DataFrame) -> list[QuasiOrder]:
26
56
  """
27
57
  Inductively generates quasiorders from counterexample count DataFrame\n
28
58
  """
@@ -53,6 +83,7 @@ def ind_gen(counterexamples: pd.DataFrame, n: int) -> list[QuasiOrder]:
53
83
  queue = np.concat([group, long_queue], axis=0)
54
84
  queue = np.array(sorted(queue.tolist()), dtype=np.int_)
55
85
  allow = np.ones((len(queue)))
86
+ long_queue = np.empty((0, 2), dtype=np.int_)
56
87
 
57
88
  for a, b in queue:
58
89
  new_qo[a][b] = 1
@@ -69,7 +100,7 @@ def ind_gen(counterexamples: pd.DataFrame, n: int) -> list[QuasiOrder]:
69
100
 
70
101
  if (allow.sum() == len(allow)): break
71
102
 
72
- long_queue = queue[np.logical_not(allow)].copy()
103
+ long_queue = np.concat((long_queue, queue[np.logical_not(allow)].copy()), axis=0)
73
104
  queue = queue[allow.astype(np.bool)].copy()
74
105
  allow = allow[allow.astype(np.bool)].copy()
75
106
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: iita_python
3
- Version: 1.4
3
+ Version: 1.4.2
4
4
  Summary: IITA algorithm in python
5
5
  Author-email: Aliaksei Badnarchuk <alexejbodnarchuk@gmail.com>
6
6
  Requires-Python: >=3.9
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes