pyfunctionhood 0.3.0__tar.gz → 0.3.1__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.
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/.gitignore +2 -1
- pyfunctionhood-0.3.1/MANIFEST.in +3 -0
- {pyfunctionhood-0.3.0/src/pyfunctionhood.egg-info → pyfunctionhood-0.3.1}/PKG-INFO +11 -9
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/README.md +10 -8
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/src/pyfunctionhood/main.py +92 -34
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1/src/pyfunctionhood.egg-info}/PKG-INFO +11 -9
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/src/pyfunctionhood.egg-info/SOURCES.txt +1 -0
- pyfunctionhood-0.3.1/src/pyfunctionhood.egg-info/scm_file_list.json +109 -0
- pyfunctionhood-0.3.1/src/pyfunctionhood.egg-info/scm_version.json +8 -0
- pyfunctionhood-0.3.0/src/pyfunctionhood.egg-info/scm_file_list.json +0 -20
- pyfunctionhood-0.3.0/src/pyfunctionhood.egg-info/scm_version.json +0 -8
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/.github/workflows/python-publish.yml +0 -0
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/LICENSE +0 -0
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/img/pyfunctionhood.png +0 -0
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/pyproject.toml +0 -0
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/requirements.txt +0 -0
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/setup.cfg +0 -0
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/src/pyfunctionhood/__init__.py +0 -0
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/src/pyfunctionhood/clause.py +0 -0
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/src/pyfunctionhood/function.py +0 -0
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/src/pyfunctionhood/hassediagram.py +0 -0
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/src/pyfunctionhood/powerset.py +0 -0
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/src/pyfunctionhood.egg-info/dependency_links.txt +0 -0
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/src/pyfunctionhood.egg-info/entry_points.txt +0 -0
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/src/pyfunctionhood.egg-info/requires.txt +0 -0
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/src/pyfunctionhood.egg-info/top_level.txt +0 -0
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/tests/test_check_rules.py +0 -0
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/tests/test_check_sign_changes.py +0 -0
- {pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/tests/test_rule_categorization.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyfunctionhood
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Local computation of immediate neighbours of a given monotone non-degenerate Boolean function
|
|
5
5
|
Author-email: "Pedro T. Monteiro" <Pedro.Tiago.Monteiro@tecnico.ulisboa.pt>
|
|
6
6
|
License: AGPL-3.0
|
|
@@ -45,11 +45,11 @@ Given a reference monotone Boolean function, this library can be used in three d
|
|
|
45
45
|
Usage - command line
|
|
46
46
|
--------------------
|
|
47
47
|
```
|
|
48
|
-
Usage example: python main.py <type> <dimension> <function> [<
|
|
48
|
+
Usage example: python main.py <type> <dimension> <function> [<signature>]
|
|
49
49
|
<type>: [p]arents or [c]hildren
|
|
50
50
|
<dimension>: 4
|
|
51
51
|
<function>: "{{1,2,3},{1,3,4},{2,3,4}}"
|
|
52
|
-
<
|
|
52
|
+
<signature>: optional target signature, e.g. "1011" (bit i: 1 = positive, 0 = negative variable i)
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
**Parents**
|
|
@@ -76,12 +76,12 @@ R1 {{1,2,3},{2,3,4}}
|
|
|
76
76
|
|
|
77
77
|
**Sign changes**
|
|
78
78
|
|
|
79
|
-
Commands accept an optional trailing `<
|
|
79
|
+
Commands accept an optional trailing `<signature>` argument: the target signature, a bitstring of the same length as `<dimension>`, where bit `i` is `1` if variable/regulator `i` is positive and `0` if it is negative. The function is given in the all-positive signature (all 1's). When a signature with some `0` is provided, the closest parents/children in that signature are computed instead of the default fixed-topology rules:
|
|
80
80
|
```
|
|
81
|
-
python main.py p 4 "{{1,2,3},{1,3,4},{2,3,4}}"
|
|
82
|
-
python main.py c 4 "{{1,2,3},{1,3,4},{2,3,4}}"
|
|
81
|
+
python main.py p 4 "{{1,2,3},{1,3,4},{2,3,4}}" 1011
|
|
82
|
+
python main.py c 4 "{{1,2,3},{1,3,4},{2,3,4}}" 1011
|
|
83
83
|
```
|
|
84
|
-
When omitted (or all
|
|
84
|
+
When omitted (or all 1's), the behaviour is unchanged from above, i.e. fixed-topology. In the output, `~i` denotes the negated variable `i`: for instance, `python main.py p 3 "{{1,2},{3}}" 101` yields `R1 {{1},{~2},{3}}`.
|
|
85
85
|
|
|
86
86
|
---
|
|
87
87
|
|
|
@@ -94,7 +94,7 @@ There is also a graphical interface using Tkinter where the user can define the
|
|
|
94
94
|
|
|
95
95
|
The interface has a button to automatically write the Infimum function of the chosen dimension, and another for the Supremum function.
|
|
96
96
|
|
|
97
|
-
A **
|
|
97
|
+
A **Signature** text box is also available to optionally specify the target signature, a bitstring of the same length as the dimension, where bit `i` is `1` if variable/regulator `i` is positive and `0` if it is negative. It is set to all 1's (the default, i.e. the fixed-topology behaviour) and goes back to all 1's whenever the dimension changes. Hovering over it shows a short explanation.
|
|
98
98
|
|
|
99
99
|
The user has two buttons to generate the immediate neighbouring functions: **Generate Parents** to generate the list of parent functions, and **Generate Children** to generate the list of children functions.
|
|
100
100
|
|
|
@@ -144,6 +144,8 @@ changed_signs = bitarray('0100')
|
|
|
144
144
|
s1, s2, s3 = hd.get_f_parents_with_sign_changes(f, changed_signs)
|
|
145
145
|
```
|
|
146
146
|
|
|
147
|
+
This is the complement of the `<signature>` used by the command line and the GUI: `changed_signs = ~bitarray(signature)`.
|
|
148
|
+
|
|
147
149
|
---
|
|
148
150
|
|
|
149
151
|
Testing
|
|
@@ -165,7 +167,7 @@ This runs 22 tests covering:
|
|
|
165
167
|
License
|
|
166
168
|
-------
|
|
167
169
|
|
|
168
|
-
This code is available under
|
|
170
|
+
This code is available under the GNU Affero General Public License v3.0 (AGPL-3.0). See the `LICENSE` file.
|
|
169
171
|
|
|
170
172
|
Cite
|
|
171
173
|
----
|
|
@@ -19,11 +19,11 @@ Given a reference monotone Boolean function, this library can be used in three d
|
|
|
19
19
|
Usage - command line
|
|
20
20
|
--------------------
|
|
21
21
|
```
|
|
22
|
-
Usage example: python main.py <type> <dimension> <function> [<
|
|
22
|
+
Usage example: python main.py <type> <dimension> <function> [<signature>]
|
|
23
23
|
<type>: [p]arents or [c]hildren
|
|
24
24
|
<dimension>: 4
|
|
25
25
|
<function>: "{{1,2,3},{1,3,4},{2,3,4}}"
|
|
26
|
-
<
|
|
26
|
+
<signature>: optional target signature, e.g. "1011" (bit i: 1 = positive, 0 = negative variable i)
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
**Parents**
|
|
@@ -50,12 +50,12 @@ R1 {{1,2,3},{2,3,4}}
|
|
|
50
50
|
|
|
51
51
|
**Sign changes**
|
|
52
52
|
|
|
53
|
-
Commands accept an optional trailing `<
|
|
53
|
+
Commands accept an optional trailing `<signature>` argument: the target signature, a bitstring of the same length as `<dimension>`, where bit `i` is `1` if variable/regulator `i` is positive and `0` if it is negative. The function is given in the all-positive signature (all 1's). When a signature with some `0` is provided, the closest parents/children in that signature are computed instead of the default fixed-topology rules:
|
|
54
54
|
```
|
|
55
|
-
python main.py p 4 "{{1,2,3},{1,3,4},{2,3,4}}"
|
|
56
|
-
python main.py c 4 "{{1,2,3},{1,3,4},{2,3,4}}"
|
|
55
|
+
python main.py p 4 "{{1,2,3},{1,3,4},{2,3,4}}" 1011
|
|
56
|
+
python main.py c 4 "{{1,2,3},{1,3,4},{2,3,4}}" 1011
|
|
57
57
|
```
|
|
58
|
-
When omitted (or all
|
|
58
|
+
When omitted (or all 1's), the behaviour is unchanged from above, i.e. fixed-topology. In the output, `~i` denotes the negated variable `i`: for instance, `python main.py p 3 "{{1,2},{3}}" 101` yields `R1 {{1},{~2},{3}}`.
|
|
59
59
|
|
|
60
60
|
---
|
|
61
61
|
|
|
@@ -68,7 +68,7 @@ There is also a graphical interface using Tkinter where the user can define the
|
|
|
68
68
|
|
|
69
69
|
The interface has a button to automatically write the Infimum function of the chosen dimension, and another for the Supremum function.
|
|
70
70
|
|
|
71
|
-
A **
|
|
71
|
+
A **Signature** text box is also available to optionally specify the target signature, a bitstring of the same length as the dimension, where bit `i` is `1` if variable/regulator `i` is positive and `0` if it is negative. It is set to all 1's (the default, i.e. the fixed-topology behaviour) and goes back to all 1's whenever the dimension changes. Hovering over it shows a short explanation.
|
|
72
72
|
|
|
73
73
|
The user has two buttons to generate the immediate neighbouring functions: **Generate Parents** to generate the list of parent functions, and **Generate Children** to generate the list of children functions.
|
|
74
74
|
|
|
@@ -118,6 +118,8 @@ changed_signs = bitarray('0100')
|
|
|
118
118
|
s1, s2, s3 = hd.get_f_parents_with_sign_changes(f, changed_signs)
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
+
This is the complement of the `<signature>` used by the command line and the GUI: `changed_signs = ~bitarray(signature)`.
|
|
122
|
+
|
|
121
123
|
---
|
|
122
124
|
|
|
123
125
|
Testing
|
|
@@ -139,7 +141,7 @@ This runs 22 tests covering:
|
|
|
139
141
|
License
|
|
140
142
|
-------
|
|
141
143
|
|
|
142
|
-
This code is available under
|
|
144
|
+
This code is available under the GNU Affero General Public License v3.0 (AGPL-3.0). See the `LICENSE` file.
|
|
143
145
|
|
|
144
146
|
Cite
|
|
145
147
|
----
|
|
@@ -3,6 +3,26 @@ import sys
|
|
|
3
3
|
from bitarray import bitarray
|
|
4
4
|
from .hassediagram import HasseDiagram
|
|
5
5
|
from .function import Function
|
|
6
|
+
import re
|
|
7
|
+
|
|
8
|
+
def signature_to_changed_signs(signature, ndim):
|
|
9
|
+
""" Converts a target signature (a string of ndim bits, 1 = positive and 0 = negative regulator,
|
|
10
|
+
relative to the all-positive reference) into the bitarray of changed signs expected by the
|
|
11
|
+
get_f_*_with_sign_changes methods. Returns None if no sign changes (empty or all 1's).
|
|
12
|
+
Raises ValueError if the signature is invalid. """
|
|
13
|
+
signature = signature.strip()
|
|
14
|
+
if not signature:
|
|
15
|
+
return None
|
|
16
|
+
if len(signature) != ndim or any(c not in ('0', '1') for c in signature):
|
|
17
|
+
raise ValueError('signature must be a string of ' + str(ndim) + ' bits (0/1)!')
|
|
18
|
+
changed_signs = ~bitarray(signature)
|
|
19
|
+
return changed_signs if changed_signs.count() else None
|
|
20
|
+
|
|
21
|
+
def format_function(f, changed_signs=None):
|
|
22
|
+
""" String of function f, writing variable i as ~i whenever its sign changed. """
|
|
23
|
+
if changed_signs is None:
|
|
24
|
+
return str(f)
|
|
25
|
+
return re.sub(r'\d+', lambda m: ('~' if changed_signs[int(m.group(0)) - 1] else '') + m.group(0), str(f))
|
|
6
26
|
|
|
7
27
|
def GUI_mode():
|
|
8
28
|
try:
|
|
@@ -12,15 +32,33 @@ def GUI_mode():
|
|
|
12
32
|
print("Please install tkinter or run in command line mode.")
|
|
13
33
|
sys.exit(1)
|
|
14
34
|
|
|
35
|
+
class ToolTip:
|
|
36
|
+
"""Small tooltip shown while the mouse is over a widget."""
|
|
37
|
+
def __init__(self, widget, text):
|
|
38
|
+
self.widget, self.text, self.tip = widget, text, None
|
|
39
|
+
widget.bind('<Enter>', self.show)
|
|
40
|
+
widget.bind('<Leave>', self.hide)
|
|
41
|
+
widget.bind('<ButtonPress>', self.hide)
|
|
42
|
+
|
|
43
|
+
def show(self, event=None):
|
|
44
|
+
if self.tip is not None:
|
|
45
|
+
return
|
|
46
|
+
x = self.widget.winfo_rootx() + 20
|
|
47
|
+
y = self.widget.winfo_rooty() + self.widget.winfo_height() + 4
|
|
48
|
+
self.tip = tk.Toplevel(self.widget)
|
|
49
|
+
self.tip.wm_overrideredirect(True)
|
|
50
|
+
self.tip.wm_geometry('+%d+%d' % (x, y))
|
|
51
|
+
tk.Label(self.tip, text=self.text, justify='left', background='#ffffe0',
|
|
52
|
+
relief='solid', borderwidth=1, padx=6, pady=4).pack()
|
|
53
|
+
|
|
54
|
+
def hide(self, event=None):
|
|
55
|
+
if self.tip is not None:
|
|
56
|
+
self.tip.destroy()
|
|
57
|
+
self.tip = None
|
|
58
|
+
|
|
15
59
|
def get_changed_signs(idim):
|
|
16
|
-
""" Returns None if no sign changed, otherwise the
|
|
17
|
-
|
|
18
|
-
if not strSigns:
|
|
19
|
-
return None
|
|
20
|
-
if len(strSigns) != idim or any(c not in ('0', '1') for c in strSigns):
|
|
21
|
-
raise ValueError('changed signs must be a string of ' + str(idim) + ' bits (0/1)!')
|
|
22
|
-
changed_signs = bitarray(strSigns)
|
|
23
|
-
return changed_signs if changed_signs.count() else None
|
|
60
|
+
""" Returns None if no sign changed, otherwise the bitarray of changed signs. """
|
|
61
|
+
return signature_to_changed_signs(varSignature.get(), idim)
|
|
24
62
|
|
|
25
63
|
def get_parents():
|
|
26
64
|
try:
|
|
@@ -32,9 +70,9 @@ def GUI_mode():
|
|
|
32
70
|
s1Parents, s2Parents, s3Parents = hd.get_f_parents(f)
|
|
33
71
|
else:
|
|
34
72
|
s1Parents, s2Parents, s3Parents = hd.get_f_parents_with_sign_changes(f, changed_signs)
|
|
35
|
-
lParents = ['R1 ' +
|
|
36
|
-
+ ['R2 ' +
|
|
37
|
-
+ ['R3 ' +
|
|
73
|
+
lParents = ['R1 ' + format_function(f, changed_signs) for f in s1Parents]\
|
|
74
|
+
+ ['R2 ' + format_function(f, changed_signs) for f in s2Parents]\
|
|
75
|
+
+ ['R3 ' + format_function(f, changed_signs) for f in s3Parents]
|
|
38
76
|
output = '** Parents(f) ***\n' + '\n'.join(lParents)
|
|
39
77
|
except ValueError as e:
|
|
40
78
|
output = "ERROR! " + str(e)
|
|
@@ -51,9 +89,9 @@ def GUI_mode():
|
|
|
51
89
|
s1Children, s2Children, s3Children = hd.get_f_children(f)
|
|
52
90
|
else:
|
|
53
91
|
s1Children, s2Children, s3Children = hd.get_f_children_with_sign_changes(f, changed_signs)
|
|
54
|
-
lChildren = ['R1 ' +
|
|
55
|
-
+ ['R2 ' +
|
|
56
|
-
+ ['R3 ' +
|
|
92
|
+
lChildren = ['R1 ' + format_function(f, changed_signs) for f in s1Children]\
|
|
93
|
+
+ ['R2 ' + format_function(f, changed_signs) for f in s2Children]\
|
|
94
|
+
+ ['R3 ' + format_function(f, changed_signs) for f in s3Children]
|
|
57
95
|
output = '** Children(f) ***\n' + '\n'.join(lChildren)
|
|
58
96
|
except ValueError as e:
|
|
59
97
|
output = "ERROR! " + str(e)
|
|
@@ -63,7 +101,7 @@ def GUI_mode():
|
|
|
63
101
|
def default_values():
|
|
64
102
|
varFunction.set('{{1,2,3},{1,3,4},{2,3,4}}')
|
|
65
103
|
varDimension.set(4)
|
|
66
|
-
|
|
104
|
+
varSignature.set('1' * 4)
|
|
67
105
|
outputText.delete(1.0, "end") # Clear previous output
|
|
68
106
|
outputText.insert(1.0, '')
|
|
69
107
|
|
|
@@ -116,11 +154,32 @@ def GUI_mode():
|
|
|
116
154
|
entryFunction.grid(row=row, column=1, columnspan=2)
|
|
117
155
|
|
|
118
156
|
row += 1
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
157
|
+
labelSignature = tk.Label(root, text="Signature")
|
|
158
|
+
labelSignature.grid(row=row, column=0, sticky='w')
|
|
159
|
+
varSignature = tk.StringVar(value='1' * varDimension.get()) # all 1's: no sign change
|
|
160
|
+
entrySignature = tk.Entry(root, textvariable=varSignature, width=48)
|
|
161
|
+
entrySignature.grid(row=row, column=1, columnspan=2)
|
|
162
|
+
|
|
163
|
+
def reset_signature(*args):
|
|
164
|
+
""" Whenever the dimension changes, the signature goes back to all 1's. """
|
|
165
|
+
try:
|
|
166
|
+
varSignature.set('1' * int(varDimension.get()))
|
|
167
|
+
except (ValueError, tk.TclError): # dimension field empty or not (yet) a number
|
|
168
|
+
pass
|
|
169
|
+
varDimension.trace_add('write', reset_signature)
|
|
170
|
+
|
|
171
|
+
signatureHelp = ("Target signature: one bit per variable, 1 = positive and 0 = negative regulator.\n"
|
|
172
|
+
"All 1's (the default): no sign change. Set a bit to 0 to flip that variable.\n"
|
|
173
|
+
"\n"
|
|
174
|
+
"For instance, with 3 variables:\n"
|
|
175
|
+
" 101 -> variable 2 is negative\n"
|
|
176
|
+
" 110 -> variable 3 is negative\n"
|
|
177
|
+
"\n"
|
|
178
|
+
"The function is given in the all-positive signature. In the output,\n"
|
|
179
|
+
"~i denotes the negated variable i. The signature is reset to all 1's\n"
|
|
180
|
+
"when the dimension changes.")
|
|
181
|
+
ToolTip(labelSignature, signatureHelp)
|
|
182
|
+
ToolTip(entrySignature, signatureHelp)
|
|
124
183
|
|
|
125
184
|
row += 1
|
|
126
185
|
bottomFrame = tk.Frame(root, padx=5, pady=5)
|
|
@@ -165,11 +224,12 @@ def GUI_mode():
|
|
|
165
224
|
def usage():
|
|
166
225
|
print('\nFor graphical mode, run without arguments: python', sys.argv[0])
|
|
167
226
|
print('\nFor command line mode, use the following arguments:')
|
|
168
|
-
print('Usage example:', sys.argv[0], '<type>', '<dimension>', '<function>', '[<
|
|
227
|
+
print('Usage example:', sys.argv[0], '<type>', '<dimension>', '<function>', '[<signature>]')
|
|
169
228
|
print(' <type>: [p]arents or [c]hildren')
|
|
170
229
|
print(' <dimension>: 4')
|
|
171
230
|
print(' <function>: "{{1,2,3},{1,3,4},{2,3,4}}"')
|
|
172
|
-
print(' <
|
|
231
|
+
print(' <signature>: optional target signature, e.g. "1011" (bit i: 1 = positive, 0 = negative variable i;')
|
|
232
|
+
print(' all 1\'s or omitted: no sign change). In the output, ~i denotes the negated variable i')
|
|
173
233
|
sys.exit(1)
|
|
174
234
|
|
|
175
235
|
def command_line_mode():
|
|
@@ -186,31 +246,29 @@ def command_line_mode():
|
|
|
186
246
|
|
|
187
247
|
changed_signs = None
|
|
188
248
|
if len(sys.argv) == 5:
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
249
|
+
try:
|
|
250
|
+
changed_signs = signature_to_changed_signs(sys.argv[4], ndim)
|
|
251
|
+
except ValueError:
|
|
252
|
+
print('ERROR: invalid <signature>')
|
|
192
253
|
usage()
|
|
193
|
-
changed_signs = bitarray(strSigns)
|
|
194
|
-
if changed_signs.count() == 0:
|
|
195
|
-
changed_signs = None
|
|
196
254
|
|
|
197
255
|
if sys.argv[1] in ('p','parents'):
|
|
198
256
|
if changed_signs is None:
|
|
199
257
|
s1Parents, s2Parents, s3Parents = hd.get_f_parents(f)
|
|
200
258
|
else:
|
|
201
259
|
s1Parents, s2Parents, s3Parents = hd.get_f_parents_with_sign_changes(f, changed_signs)
|
|
202
|
-
lParents = ['R1 ' +
|
|
203
|
-
+ ['R2 ' +
|
|
204
|
-
+ ['R3 ' +
|
|
260
|
+
lParents = ['R1 ' + format_function(f, changed_signs) for f in s1Parents]\
|
|
261
|
+
+ ['R2 ' + format_function(f, changed_signs) for f in s2Parents]\
|
|
262
|
+
+ ['R3 ' + format_function(f, changed_signs) for f in s3Parents]
|
|
205
263
|
print('\n'.join(lParents))
|
|
206
264
|
else:
|
|
207
265
|
if changed_signs is None:
|
|
208
266
|
s1Children, s2Children, s3Children = hd.get_f_children(f)
|
|
209
267
|
else:
|
|
210
268
|
s1Children, s2Children, s3Children = hd.get_f_children_with_sign_changes(f, changed_signs)
|
|
211
|
-
lChildren = ['R1 ' +
|
|
212
|
-
+ ['R2 ' +
|
|
213
|
-
+ ['R3 ' +
|
|
269
|
+
lChildren = ['R1 ' + format_function(f, changed_signs) for f in s1Children]\
|
|
270
|
+
+ ['R2 ' + format_function(f, changed_signs) for f in s2Children]\
|
|
271
|
+
+ ['R3 ' + format_function(f, changed_signs) for f in s3Children]
|
|
214
272
|
print('\n'.join(lChildren))
|
|
215
273
|
|
|
216
274
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyfunctionhood
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Local computation of immediate neighbours of a given monotone non-degenerate Boolean function
|
|
5
5
|
Author-email: "Pedro T. Monteiro" <Pedro.Tiago.Monteiro@tecnico.ulisboa.pt>
|
|
6
6
|
License: AGPL-3.0
|
|
@@ -45,11 +45,11 @@ Given a reference monotone Boolean function, this library can be used in three d
|
|
|
45
45
|
Usage - command line
|
|
46
46
|
--------------------
|
|
47
47
|
```
|
|
48
|
-
Usage example: python main.py <type> <dimension> <function> [<
|
|
48
|
+
Usage example: python main.py <type> <dimension> <function> [<signature>]
|
|
49
49
|
<type>: [p]arents or [c]hildren
|
|
50
50
|
<dimension>: 4
|
|
51
51
|
<function>: "{{1,2,3},{1,3,4},{2,3,4}}"
|
|
52
|
-
<
|
|
52
|
+
<signature>: optional target signature, e.g. "1011" (bit i: 1 = positive, 0 = negative variable i)
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
**Parents**
|
|
@@ -76,12 +76,12 @@ R1 {{1,2,3},{2,3,4}}
|
|
|
76
76
|
|
|
77
77
|
**Sign changes**
|
|
78
78
|
|
|
79
|
-
Commands accept an optional trailing `<
|
|
79
|
+
Commands accept an optional trailing `<signature>` argument: the target signature, a bitstring of the same length as `<dimension>`, where bit `i` is `1` if variable/regulator `i` is positive and `0` if it is negative. The function is given in the all-positive signature (all 1's). When a signature with some `0` is provided, the closest parents/children in that signature are computed instead of the default fixed-topology rules:
|
|
80
80
|
```
|
|
81
|
-
python main.py p 4 "{{1,2,3},{1,3,4},{2,3,4}}"
|
|
82
|
-
python main.py c 4 "{{1,2,3},{1,3,4},{2,3,4}}"
|
|
81
|
+
python main.py p 4 "{{1,2,3},{1,3,4},{2,3,4}}" 1011
|
|
82
|
+
python main.py c 4 "{{1,2,3},{1,3,4},{2,3,4}}" 1011
|
|
83
83
|
```
|
|
84
|
-
When omitted (or all
|
|
84
|
+
When omitted (or all 1's), the behaviour is unchanged from above, i.e. fixed-topology. In the output, `~i` denotes the negated variable `i`: for instance, `python main.py p 3 "{{1,2},{3}}" 101` yields `R1 {{1},{~2},{3}}`.
|
|
85
85
|
|
|
86
86
|
---
|
|
87
87
|
|
|
@@ -94,7 +94,7 @@ There is also a graphical interface using Tkinter where the user can define the
|
|
|
94
94
|
|
|
95
95
|
The interface has a button to automatically write the Infimum function of the chosen dimension, and another for the Supremum function.
|
|
96
96
|
|
|
97
|
-
A **
|
|
97
|
+
A **Signature** text box is also available to optionally specify the target signature, a bitstring of the same length as the dimension, where bit `i` is `1` if variable/regulator `i` is positive and `0` if it is negative. It is set to all 1's (the default, i.e. the fixed-topology behaviour) and goes back to all 1's whenever the dimension changes. Hovering over it shows a short explanation.
|
|
98
98
|
|
|
99
99
|
The user has two buttons to generate the immediate neighbouring functions: **Generate Parents** to generate the list of parent functions, and **Generate Children** to generate the list of children functions.
|
|
100
100
|
|
|
@@ -144,6 +144,8 @@ changed_signs = bitarray('0100')
|
|
|
144
144
|
s1, s2, s3 = hd.get_f_parents_with_sign_changes(f, changed_signs)
|
|
145
145
|
```
|
|
146
146
|
|
|
147
|
+
This is the complement of the `<signature>` used by the command line and the GUI: `changed_signs = ~bitarray(signature)`.
|
|
148
|
+
|
|
147
149
|
---
|
|
148
150
|
|
|
149
151
|
Testing
|
|
@@ -165,7 +167,7 @@ This runs 22 tests covering:
|
|
|
165
167
|
License
|
|
166
168
|
-------
|
|
167
169
|
|
|
168
|
-
This code is available under
|
|
170
|
+
This code is available under the GNU Affero General Public License v3.0 (AGPL-3.0). See the `LICENSE` file.
|
|
169
171
|
|
|
170
172
|
Cite
|
|
171
173
|
----
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files": [
|
|
3
|
+
".github/workflows/python-publish.yml",
|
|
4
|
+
".gitignore",
|
|
5
|
+
"LICENSE",
|
|
6
|
+
"MANIFEST.in",
|
|
7
|
+
"README.md",
|
|
8
|
+
"experiments/README.md",
|
|
9
|
+
"experiments/fig_sc_cost.py",
|
|
10
|
+
"experiments/fig_sc_neighbourhood.py",
|
|
11
|
+
"experiments/requirements.txt",
|
|
12
|
+
"experiments/results/n2_k0_s10_r10_b10.txt",
|
|
13
|
+
"experiments/results/n2_k1_s10_r10_b10.txt",
|
|
14
|
+
"experiments/results/n2_k2_s10_r10_b10.txt",
|
|
15
|
+
"experiments/results/n3_k0_s10_r10_b10.txt",
|
|
16
|
+
"experiments/results/n3_k1_s10_r10_b10.txt",
|
|
17
|
+
"experiments/results/n3_k2_s10_r10_b10.txt",
|
|
18
|
+
"experiments/results/n3_k3_s10_r10_b10.txt",
|
|
19
|
+
"experiments/results/n4_k0_s10_r10_b10.txt",
|
|
20
|
+
"experiments/results/n4_k1_s10_r10_b10.txt",
|
|
21
|
+
"experiments/results/n4_k2_s10_r10_b10.txt",
|
|
22
|
+
"experiments/results/n4_k3_s10_r10_b10.txt",
|
|
23
|
+
"experiments/results/n4_k4_s10_r10_b10.txt",
|
|
24
|
+
"experiments/results/n5_k0_s10_r10_b10.txt",
|
|
25
|
+
"experiments/results/n5_k1_s10_r10_b10.txt",
|
|
26
|
+
"experiments/results/n5_k2_s10_r10_b10.txt",
|
|
27
|
+
"experiments/results/n5_k3_s10_r10_b10.txt",
|
|
28
|
+
"experiments/results/n5_k4_s10_r10_b10.txt",
|
|
29
|
+
"experiments/results/n5_k5_s10_r10_b10.txt",
|
|
30
|
+
"experiments/results/n6_k0_s10_r10_b10.txt",
|
|
31
|
+
"experiments/results/n6_k1_s10_r10_b10.txt",
|
|
32
|
+
"experiments/results/n6_k2_s10_r10_b10.txt",
|
|
33
|
+
"experiments/results/n6_k3_s10_r10_b10.txt",
|
|
34
|
+
"experiments/results/n6_k4_s10_r10_b10.txt",
|
|
35
|
+
"experiments/results/n6_k5_s10_r10_b10.txt",
|
|
36
|
+
"experiments/results/n6_k6_s10_r10_b10.txt",
|
|
37
|
+
"experiments/results/n7_k0_s10_r10_b10.txt",
|
|
38
|
+
"experiments/results/n7_k1_s10_r10_b10.txt",
|
|
39
|
+
"experiments/results/n7_k2_s10_r10_b10.txt",
|
|
40
|
+
"experiments/results/n7_k3_s10_r10_b10.txt",
|
|
41
|
+
"experiments/results/n7_k4_s10_r10_b10.txt",
|
|
42
|
+
"experiments/results/n7_k5_s10_r10_b10.txt",
|
|
43
|
+
"experiments/results/n7_k6_s10_r10_b10.txt",
|
|
44
|
+
"experiments/results/n7_k7_s10_r10_b10.txt",
|
|
45
|
+
"experiments/results/n8_k0_s10_r10_b10.txt",
|
|
46
|
+
"experiments/results/n8_k1_s10_r10_b10.txt",
|
|
47
|
+
"experiments/results/n8_k2_s10_r10_b10.txt",
|
|
48
|
+
"experiments/results/n8_k3_s10_r10_b10.txt",
|
|
49
|
+
"experiments/results/n8_k4_s10_r10_b10.txt",
|
|
50
|
+
"experiments/results/n8_k5_s10_r10_b10.txt",
|
|
51
|
+
"experiments/results/n8_k6_s10_r10_b10.txt",
|
|
52
|
+
"experiments/results/n8_k7_s10_r10_b10.txt",
|
|
53
|
+
"experiments/results/n8_k8_s10_r10_b10.txt",
|
|
54
|
+
"experiments/results/neigh_n2_k0_s100.txt",
|
|
55
|
+
"experiments/results/neigh_n2_k1_s100.txt",
|
|
56
|
+
"experiments/results/neigh_n2_k2_s100.txt",
|
|
57
|
+
"experiments/results/neigh_n3_k0_s100.txt",
|
|
58
|
+
"experiments/results/neigh_n3_k1_s100.txt",
|
|
59
|
+
"experiments/results/neigh_n3_k2_s100.txt",
|
|
60
|
+
"experiments/results/neigh_n3_k3_s100.txt",
|
|
61
|
+
"experiments/results/neigh_n4_k0_s100.txt",
|
|
62
|
+
"experiments/results/neigh_n4_k1_s100.txt",
|
|
63
|
+
"experiments/results/neigh_n4_k2_s100.txt",
|
|
64
|
+
"experiments/results/neigh_n4_k3_s100.txt",
|
|
65
|
+
"experiments/results/neigh_n4_k4_s100.txt",
|
|
66
|
+
"experiments/results/neigh_n5_k0_s100.txt",
|
|
67
|
+
"experiments/results/neigh_n5_k1_s100.txt",
|
|
68
|
+
"experiments/results/neigh_n5_k2_s100.txt",
|
|
69
|
+
"experiments/results/neigh_n5_k3_s100.txt",
|
|
70
|
+
"experiments/results/neigh_n5_k4_s100.txt",
|
|
71
|
+
"experiments/results/neigh_n5_k5_s100.txt",
|
|
72
|
+
"experiments/results/neigh_n6_k0_s100.txt",
|
|
73
|
+
"experiments/results/neigh_n6_k1_s100.txt",
|
|
74
|
+
"experiments/results/neigh_n6_k2_s100.txt",
|
|
75
|
+
"experiments/results/neigh_n6_k3_s100.txt",
|
|
76
|
+
"experiments/results/neigh_n6_k4_s100.txt",
|
|
77
|
+
"experiments/results/neigh_n6_k5_s100.txt",
|
|
78
|
+
"experiments/results/neigh_n6_k6_s100.txt",
|
|
79
|
+
"experiments/results/neigh_n7_k0_s40.txt",
|
|
80
|
+
"experiments/results/neigh_n7_k1_s40.txt",
|
|
81
|
+
"experiments/results/neigh_n7_k2_s40.txt",
|
|
82
|
+
"experiments/results/neigh_n7_k3_s40.txt",
|
|
83
|
+
"experiments/results/neigh_n7_k4_s40.txt",
|
|
84
|
+
"experiments/results/neigh_n7_k5_s40.txt",
|
|
85
|
+
"experiments/results/neigh_n7_k6_s40.txt",
|
|
86
|
+
"experiments/results/neigh_n7_k7_s40.txt",
|
|
87
|
+
"experiments/results/neigh_n8_k0_s20.txt",
|
|
88
|
+
"experiments/results/neigh_n8_k1_s20.txt",
|
|
89
|
+
"experiments/results/neigh_n8_k2_s20.txt",
|
|
90
|
+
"experiments/results/neigh_n8_k3_s20.txt",
|
|
91
|
+
"experiments/results/neigh_n8_k4_s20.txt",
|
|
92
|
+
"experiments/results/neigh_n8_k5_s20.txt",
|
|
93
|
+
"experiments/results/neigh_n8_k6_s20.txt",
|
|
94
|
+
"experiments/results/neigh_n8_k7_s20.txt",
|
|
95
|
+
"experiments/results/neigh_n8_k8_s20.txt",
|
|
96
|
+
"img/pyfunctionhood.png",
|
|
97
|
+
"pyproject.toml",
|
|
98
|
+
"requirements.txt",
|
|
99
|
+
"src/pyfunctionhood/__init__.py",
|
|
100
|
+
"src/pyfunctionhood/clause.py",
|
|
101
|
+
"src/pyfunctionhood/function.py",
|
|
102
|
+
"src/pyfunctionhood/hassediagram.py",
|
|
103
|
+
"src/pyfunctionhood/main.py",
|
|
104
|
+
"src/pyfunctionhood/powerset.py",
|
|
105
|
+
"tests/test_check_rules.py",
|
|
106
|
+
"tests/test_check_sign_changes.py",
|
|
107
|
+
"tests/test_rule_categorization.py"
|
|
108
|
+
]
|
|
109
|
+
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"files": [
|
|
3
|
-
".github/workflows/python-publish.yml",
|
|
4
|
-
".gitignore",
|
|
5
|
-
"LICENSE",
|
|
6
|
-
"README.md",
|
|
7
|
-
"img/pyfunctionhood.png",
|
|
8
|
-
"pyproject.toml",
|
|
9
|
-
"requirements.txt",
|
|
10
|
-
"src/pyfunctionhood/__init__.py",
|
|
11
|
-
"src/pyfunctionhood/clause.py",
|
|
12
|
-
"src/pyfunctionhood/function.py",
|
|
13
|
-
"src/pyfunctionhood/hassediagram.py",
|
|
14
|
-
"src/pyfunctionhood/main.py",
|
|
15
|
-
"src/pyfunctionhood/powerset.py",
|
|
16
|
-
"tests/test_check_rules.py",
|
|
17
|
-
"tests/test_check_sign_changes.py",
|
|
18
|
-
"tests/test_rule_categorization.py"
|
|
19
|
-
]
|
|
20
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pyfunctionhood-0.3.0 → pyfunctionhood-0.3.1}/src/pyfunctionhood.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|