PySDD 1.0.4__tar.gz → 1.0.6__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.
Files changed (86) hide show
  1. {pysdd-1.0.4 → pysdd-1.0.6}/PKG-INFO +3 -2
  2. {pysdd-1.0.4 → pysdd-1.0.6}/PySDD.egg-info/PKG-INFO +3 -2
  3. {pysdd-1.0.4 → pysdd-1.0.6}/pyproject.toml +2 -1
  4. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/sdd.pyx +4 -1
  5. {pysdd-1.0.4 → pysdd-1.0.6}/tests/test_minimize.py +16 -0
  6. {pysdd-1.0.4 → pysdd-1.0.6}/tests/test_nnf.py +13 -18
  7. {pysdd-1.0.4 → pysdd-1.0.6}/LICENSE +0 -0
  8. {pysdd-1.0.4 → pysdd-1.0.6}/PySDD.egg-info/SOURCES.txt +0 -0
  9. {pysdd-1.0.4 → pysdd-1.0.6}/PySDD.egg-info/dependency_links.txt +0 -0
  10. {pysdd-1.0.4 → pysdd-1.0.6}/PySDD.egg-info/entry_points.txt +0 -0
  11. {pysdd-1.0.4 → pysdd-1.0.6}/PySDD.egg-info/requires.txt +0 -0
  12. {pysdd-1.0.4 → pysdd-1.0.6}/PySDD.egg-info/top_level.txt +0 -0
  13. {pysdd-1.0.4 → pysdd-1.0.6}/README.rst +0 -0
  14. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/__init__.py +0 -0
  15. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/__main__.py +0 -0
  16. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/cli.py +0 -0
  17. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/iterator.py +0 -0
  18. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/basic/computed.c +0 -0
  19. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/basic/count_and_size.c +0 -0
  20. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/basic/gc.c +0 -0
  21. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/basic/hash.c +0 -0
  22. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/basic/memory.c +0 -0
  23. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/basic/multiply.c +0 -0
  24. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/basic/nodes.c +0 -0
  25. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/basic/partitions.c +0 -0
  26. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/basic/references.c +0 -0
  27. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/basic/replace.c +0 -0
  28. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/basic/shadows.c +0 -0
  29. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/basic/sort.c +0 -0
  30. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/manager/copy.c +0 -0
  31. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/manager/interface.c +0 -0
  32. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/manager/manager.c +0 -0
  33. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/manager/stats.c +0 -0
  34. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/manager/variables.c +0 -0
  35. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/sdds/apply.c +0 -0
  36. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/sdds/bits.c +0 -0
  37. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/sdds/cardinality.c +0 -0
  38. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/sdds/condition.c +0 -0
  39. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/sdds/copy.c +0 -0
  40. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/sdds/count.c +0 -0
  41. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/sdds/essential_vars.c +0 -0
  42. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/sdds/exists.c +0 -0
  43. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/sdds/exists_multiple.c +0 -0
  44. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/sdds/exists_multiple_static.c +0 -0
  45. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/sdds/forall.c +0 -0
  46. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/sdds/io.c +0 -0
  47. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/sdds/model_count.c +0 -0
  48. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/sdds/rename_vars.c +0 -0
  49. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/sdds/size.c +0 -0
  50. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/sdds/wmc.c +0 -0
  51. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/util.c +0 -0
  52. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/verify.c +0 -0
  53. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/version.c +0 -0
  54. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/vtree_fragments/construction.c +0 -0
  55. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/vtree_fragments/moves.c +0 -0
  56. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/vtree_fragments/operations.c +0 -0
  57. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/vtree_operations/cartesian_product.c +0 -0
  58. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/vtree_operations/dissect.c +0 -0
  59. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/vtree_operations/limits.c +0 -0
  60. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/vtree_operations/op_left_rotate.c +0 -0
  61. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/vtree_operations/op_right_rotate.c +0 -0
  62. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/vtree_operations/op_swap.c +0 -0
  63. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/vtree_operations/rollback.c +0 -0
  64. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/vtree_operations/split.c +0 -0
  65. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/vtree_search/auto.c +0 -0
  66. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/vtree_search/search.c +0 -0
  67. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/vtree_search/state.c +0 -0
  68. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/vtrees/compare.c +0 -0
  69. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/vtrees/edit.c +0 -0
  70. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/vtrees/io.c +0 -0
  71. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/vtrees/maps.c +0 -0
  72. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/vtrees/moves.c +0 -0
  73. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/vtrees/static.c +0 -0
  74. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/libsdd-2.0/src/vtrees/vtree.c +0 -0
  75. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/sdd-2.0/src/fnf/compiler.c +0 -0
  76. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/sdd-2.0/src/fnf/fnf.c +0 -0
  77. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/sdd-2.0/src/fnf/io.c +0 -0
  78. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/lib/sdd-2.0/src/fnf/utils.c +0 -0
  79. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/util.py +0 -0
  80. {pysdd-1.0.4 → pysdd-1.0.6}/pysdd/wmcstochastic.py +0 -0
  81. {pysdd-1.0.4 → pysdd-1.0.6}/setup.cfg +0 -0
  82. {pysdd-1.0.4 → pysdd-1.0.6}/tests/test_iterator.py +0 -0
  83. {pysdd-1.0.4 → pysdd-1.0.6}/tests/test_psdd.py +0 -0
  84. {pysdd-1.0.4 → pysdd-1.0.6}/tests/test_util.py +0 -0
  85. {pysdd-1.0.4 → pysdd-1.0.6}/tests/test_vtree.py +0 -0
  86. {pysdd-1.0.4 → pysdd-1.0.6}/tests/test_wmcstochastic.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: PySDD
3
- Version: 1.0.4
3
+ Version: 1.0.6
4
4
  Summary: Sentential Decision Diagrams
5
5
  Author: Arthur Choi
6
6
  Author-email: Wannes Meert <wannes.meert@cs.kuleuven.be>, Robin Manhaeve <robin.manhaeve@kuleuven.be>
@@ -33,6 +33,7 @@ Provides-Extra: tests
33
33
  Requires-Dist: pytest; extra == "tests"
34
34
  Provides-Extra: notebooks
35
35
  Requires-Dist: numpy; extra == "notebooks"
36
+ Dynamic: license-file
36
37
 
37
38
  =====
38
39
  PySDD
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: PySDD
3
- Version: 1.0.4
3
+ Version: 1.0.6
4
4
  Summary: Sentential Decision Diagrams
5
5
  Author: Arthur Choi
6
6
  Author-email: Wannes Meert <wannes.meert@cs.kuleuven.be>, Robin Manhaeve <robin.manhaeve@kuleuven.be>
@@ -33,6 +33,7 @@ Provides-Extra: tests
33
33
  Requires-Dist: pytest; extra == "tests"
34
34
  Provides-Extra: notebooks
35
35
  Requires-Dist: numpy; extra == "notebooks"
36
+ Dynamic: license-file
36
37
 
37
38
  =====
38
39
  PySDD
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "PySDD"
7
- version = "1.0.4"
7
+ version = "1.0.6"
8
8
  description = "Sentential Decision Diagrams"
9
9
  authors = [
10
10
  { name = "Wannes Meert", email = "wannes.meert@cs.kuleuven.be" },
@@ -116,6 +116,7 @@ include-dirs = [
116
116
  environment = {CFLAGS="-O3 -DNDEBUG" }
117
117
  test-requires = "pytest"
118
118
  test-command = "pytest {project}/tests"
119
+ skip = "pp*"
119
120
 
120
121
  [tool.cibuildwheel.windows]
121
122
  environment = {CL = "/O2 /DNDEBUG"}
@@ -53,6 +53,7 @@ cdef class SddNode:
53
53
  wrapper._sddnode = node
54
54
  if wrapper.garbage_collected():
55
55
  return None
56
+ wrapper.ref()
56
57
  if sddapi_c.sdd_node_is_literal(node):
57
58
  wrapper._name = sddapi_c.sdd_node_literal(node)
58
59
  elif sddapi_c.sdd_node_is_true(node):
@@ -63,6 +64,9 @@ cdef class SddNode:
63
64
  wrapper._name = "Decision"
64
65
  return wrapper
65
66
 
67
+ def __del__(self):
68
+ # clean up _sddnode ref
69
+ self.deref()
66
70
 
67
71
  @property
68
72
  def id(self):
@@ -306,7 +310,6 @@ cdef class SddNode:
306
310
 
307
311
  Returns the node.
308
312
  """
309
- # TODO: Should we ref every Python SDDNode object on creation and deref on Python GC?
310
313
  sddapi_c.sdd_ref(self._sddnode, self._manager._sddmanager)
311
314
 
312
315
  def deref(self):
@@ -74,6 +74,22 @@ def test_min2():
74
74
  # with (directory / "sdd2_before_b.gv").open("w") as out:
75
75
  # print(sdd_to_dot(sdd), file=out)
76
76
 
77
+ def test_refcount():
78
+ sdd = SddManager(var_count=2)
79
+ a, b = sdd.vars
80
+ f = a | b
81
+ assert f.ref_count() == 1
82
+ f.ref()
83
+ assert f.ref_count() == 2
84
+ f.deref()
85
+ assert f.ref_count() == 1
86
+ # equivalent formula will
87
+ # ref same formula object
88
+ f2 = b | a
89
+ assert f2.ref_count() == 2
90
+ assert f.ref_count() == 2
91
+ del f2
92
+ assert f.ref_count() == 1
77
93
 
78
94
  if __name__ == "__main__":
79
95
  logger.setLevel(logging.DEBUG)
@@ -1,12 +1,10 @@
1
1
  from pysdd.util import nnf_file_wmc, sdd_file_wmc, psdd_file_wmc
2
- from pysdd.sdd import Fnf, Vtree, SddManager
3
2
  from pysdd import cli
4
3
  import sys
5
4
  import os
6
5
  import math
7
6
  import logging
8
7
  from pathlib import Path
9
- import filecmp
10
8
 
11
9
 
12
10
  logger = logging.getLogger("pysdd")
@@ -14,6 +12,13 @@ directory = None
14
12
  counter = 0
15
13
  here = Path(__file__).parent
16
14
 
15
+ def file_contents_equal(path1, path2):
16
+ with open(path1) as f1:
17
+ lines1 = [l.strip() for l in f1.readlines()]
18
+ with open(path2) as f2:
19
+ lines2 = [l.strip() for l in f2.readlines()]
20
+ return lines1 == lines2
21
+
17
22
 
18
23
  def test_nnf1():
19
24
  weights = {
@@ -33,16 +38,6 @@ def test_nnf2():
33
38
  assert wmc == 0.75
34
39
 
35
40
 
36
- # def test_dnf1():
37
- # dnf_filename = str(here / "rsrc" / "test.cnf.nnf")
38
- # fnf = Fnf.from_dnf_file(bytes(dnf_filename, encoding='utf8'))
39
- # # weights = read_weights(dnf_filename)
40
- # vtree = Vtree(var_count=fnf.var_count)
41
- # manager = SddManager.from_vtree(vtree)
42
- # node = manager.fnf_to_sdd(fnf)
43
- # print(node)
44
-
45
-
46
41
  def test_sdd1():
47
42
  weights = {
48
43
  +3: 0.5, +2: 0.5, +1: 1,
@@ -70,13 +65,12 @@ def test_psdd1():
70
65
 
71
66
 
72
67
  def test_dimacs1():
73
- """This test fails on Windows because of a mismatch between 64b and 32b data types."""
74
68
  fn_dimacs = here / "rsrc" / "dimacs1.txt"
75
69
  fn_vtree = here / "rsrc" / "dimacs1.vtree"
76
70
  fn_vtree_sol = here / "rsrc" / "dimacs1_solution.vtree"
77
71
  fn_sdd = here / "rsrc" / "dimacs1.sdd"
78
72
  cli.main(["-c", str(fn_dimacs), "-W", str(fn_vtree), "-R", str(fn_sdd)])
79
- assert filecmp.cmp(fn_vtree, fn_vtree_sol)
73
+ assert file_contents_equal(fn_vtree, fn_vtree_sol)
80
74
  with fn_vtree.open("r") as fp:
81
75
  print(fp.read())
82
76
 
@@ -87,8 +81,9 @@ if __name__ == "__main__":
87
81
  logger.addHandler(sh)
88
82
  directory = Path(os.environ.get('TESTDIR', Path(__file__).parent))
89
83
  print(f"Saving files to {directory}")
90
- # test_nnf1()
91
- # test_sdd2()
92
- # test_psdd1()
93
- # test_dnf1()
84
+ test_nnf1()
85
+ test_nnf2()
86
+ test_sdd1()
87
+ test_sdd2()
88
+ test_psdd1()
94
89
  test_dimacs1()
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
File without changes
File without changes
File without changes
File without changes
File without changes