PySMT 0.9.7.dev461__py2.py3-none-any.whl → 0.9.7.dev464__py2.py3-none-any.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.
pysmt/__init__.py CHANGED
@@ -19,7 +19,7 @@
19
19
  from typing import Tuple, Union
20
20
 
21
21
 
22
- VERSION: Union[Tuple[int, int, int], Tuple[int, int, int, str, int]] = (0, 9, 7, "dev", 461)
22
+ VERSION: Union[Tuple[int, int, int], Tuple[int, int, int, str, int]] = (0, 9, 7, "dev", 464)
23
23
 
24
24
  # Try to provide human-readable version of latest commit for dev versions
25
25
  # E.g. v0.5.1-4-g49a49f2-wip
@@ -16,6 +16,8 @@
16
16
  # limitations under the License.
17
17
  #
18
18
  from fractions import Fraction
19
+
20
+ from pysmt.constants import is_pysmt_integer, is_pysmt_fraction
19
21
  import warnings
20
22
 
21
23
  from pysmt.solvers.solver import Solver
@@ -371,8 +373,9 @@ class OptSearchInterval(OptComparationFunctions):
371
373
  model_value: Union[Fraction, int] = obj_value.bv_signed_value()
372
374
  else:
373
375
  v = obj_value.constant_value()
374
- assert isinstance(v, (int, Fraction))
375
- model_value = v
376
+ # backend-aware: v may be a gmpy2 mpz/mpq, not a python int/Fraction
377
+ assert is_pysmt_integer(v) or is_pysmt_fraction(v)
378
+ model_value = cast(Union[Fraction, int], v)
376
379
  if self._obj.is_minimization_goal():
377
380
  if self._upper is None or self._upper > model_value:
378
381
  self._upper = model_value
pysmt/optimization/z3.py CHANGED
@@ -18,7 +18,6 @@
18
18
 
19
19
  from __future__ import absolute_import
20
20
 
21
- from fractions import Fraction
22
21
  from warnings import warn
23
22
 
24
23
  from pysmt.decorators import clear_pending_pop
@@ -63,9 +62,10 @@ class Z3NativeOptimizer(Optimizer, Z3Solver):
63
62
  assert isinstance(goal, MaxSMTGoal)
64
63
  for soft, weight_exp in goal.soft:
65
64
  obj_soft = self.converter.convert(soft)
66
- w: Union[float, int, Fraction, str] = weight_exp.constant_value()
67
- if isinstance(w, Fraction):
68
- w = float(w)
65
+ # str() yields an exact rational numeral ("1/3", "8") for every
66
+ # backend (int/Fraction and gmpy2 mpz/mpq); z3 add_soft parses it,
67
+ # avoiding the precision loss of float() on fractional weights.
68
+ w = str(weight_exp.constant_value())
69
69
  h = self.z3.add_soft(obj_soft, w, "__pysmt_" + str(goal_id))
70
70
  else:
71
71
  term = goal.term()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PySMT
3
- Version: 0.9.7.dev461
3
+ Version: 0.9.7.dev464
4
4
  Summary: A solver-agnostic library for SMT Formulae manipulation and solving
5
5
  Home-page: http://www.pysmt.org
6
6
  Author: PySMT Team
@@ -1,4 +1,4 @@
1
- pysmt/__init__.py,sha256=1SGEofFHRCjIIaHxwnnUVpx8VGc6I0LMZN90e5E-Pxs,1701
1
+ pysmt/__init__.py,sha256=tdicdG-NykaNPElSNBSUVNz9TMOnVIJ9Ux9d-piT6JM,1701
2
2
  pysmt/__main__.py,sha256=rR-MV1QtLYqtVoJyY3m5B5Iz-lua0-5o6YSB0W4lKy8,1085
3
3
  pysmt/configuration.py,sha256=Iq_46QZ9z_jpBMk76euJWTqGEwHad2qyiEDPix5sXsA,4538
4
4
  pysmt/constants.py,sha256=pulb6NvROY_X8BePeyyX8T9MJLB79HZ_1FUYSlZ7Jfg,5769
@@ -38,10 +38,10 @@ pysmt/cmd/installers/z3.py,sha256=5wP6O-a602-y1cuEyr22bkdWnOWHx8bIaPQ24xDtxX8,13
38
38
  pysmt/optimization/__init__.py,sha256=JXBHtcb4Lv-Sb8whc9JuGbRH2EBLWwtLUh3PL9HhNE8,650
39
39
  pysmt/optimization/goal.py,sha256=b6--z8gi-vyDjYSVNYIy9fiYhLXz51EPv5jxP64H_oI,10128
40
40
  pysmt/optimization/msat.py,sha256=yj5-vqxQFJnK3zjVlYpxemZ2BWG-6IrCTDKvjl94xNY,937
41
- pysmt/optimization/optimizer.py,sha256=eupiSExagPbLFnJMtTEOeLDOCpP-voEV_l9KzZvoIxg,29420
41
+ pysmt/optimization/optimizer.py,sha256=nt7x9YCULbS5wVg2IPWV6ZKnZGRQjDk5yGPYiz7QdmY,29607
42
42
  pysmt/optimization/optimsat.py,sha256=hRqhPcssuUzXnTeEEv8taFcRI5nE7gU8drwDIC0NtFk,11040
43
43
  pysmt/optimization/yices.py,sha256=Ly48G5JpnOhJBkd25Vg21jGcCjLEeEQUrWsG2Xxl_KI,931
44
- pysmt/optimization/z3.py,sha256=qhSQ0wR487555yYW9vSvLaIMutKN05cczPPITK_O_u4,7270
44
+ pysmt/optimization/z3.py,sha256=Y_yEP2TpaVVA4czNGUv6p7wFknMsX3CT4BnvdFaxZLQ,7376
45
45
  pysmt/smtlib/__init__.py,sha256=JXBHtcb4Lv-Sb8whc9JuGbRH2EBLWwtLUh3PL9HhNE8,650
46
46
  pysmt/smtlib/annotations.py,sha256=UTl_nnBikMGKzdpW5N17yIpvx-_8HZmo8hxXIKsm7Wo,4596
47
47
  pysmt/smtlib/commands.py,sha256=hwWnXrzZxJmKtkIitHRtuin01WDUErT0VERR9h45t2A,2277
@@ -143,10 +143,10 @@ pysmt/walkers/dag.py,sha256=4CWSgoXm6nONhM-1znKRU4SBCb791OTS-M9QlQFhbs8,5751
143
143
  pysmt/walkers/generic.py,sha256=dmp47kJGtO6rhC2t07Mf_FsYN-lcy64LX-dZggNnWm4,5179
144
144
  pysmt/walkers/identitydag.py,sha256=EAxSneEW91Z8GphlkbMPsPdlac7_FDcVj-_6_aunU2s,10902
145
145
  pysmt/walkers/tree.py,sha256=8oyDSXZtUsCdExcrwG3hKuEgARHgdW6fvz0LZJwjp-k,2983
146
- pysmt-0.9.7.dev461.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
147
- pysmt-0.9.7.dev461.dist-info/licenses/NOTICE,sha256=Ns-Jsa6nbqZUiTEEAM6HqioSZIxQ2RCJzxoBlWQaUfc,601
148
- pysmt-0.9.7.dev461.dist-info/METADATA,sha256=Ec5wIiEr0YFjWydmtI3-BiX-bmpqOH4lmloOZ28ci_k,1774
149
- pysmt-0.9.7.dev461.dist-info/WHEEL,sha256=4YBfCYNH4wlLpv3pzq1hbEuIlXA4WJabKLFurZ7eTL0,109
150
- pysmt-0.9.7.dev461.dist-info/entry_points.txt,sha256=gDc1XM0xTJJMDGC_nXd0kfbX-Omjke9Dn9F3awMLYIU,57
151
- pysmt-0.9.7.dev461.dist-info/top_level.txt,sha256=NwHQbpTaZMEvjIUdC0bvvj-WUyULe-nt-opK3YQNRMk,6
152
- pysmt-0.9.7.dev461.dist-info/RECORD,,
146
+ pysmt-0.9.7.dev464.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
147
+ pysmt-0.9.7.dev464.dist-info/licenses/NOTICE,sha256=Ns-Jsa6nbqZUiTEEAM6HqioSZIxQ2RCJzxoBlWQaUfc,601
148
+ pysmt-0.9.7.dev464.dist-info/METADATA,sha256=hFb-E6tWMNml9h2lWP8v-Q0zhIjSxWWrFNONrjEIvWQ,1774
149
+ pysmt-0.9.7.dev464.dist-info/WHEEL,sha256=4YBfCYNH4wlLpv3pzq1hbEuIlXA4WJabKLFurZ7eTL0,109
150
+ pysmt-0.9.7.dev464.dist-info/entry_points.txt,sha256=gDc1XM0xTJJMDGC_nXd0kfbX-Omjke9Dn9F3awMLYIU,57
151
+ pysmt-0.9.7.dev464.dist-info/top_level.txt,sha256=NwHQbpTaZMEvjIUdC0bvvj-WUyULe-nt-opK3YQNRMk,6
152
+ pysmt-0.9.7.dev464.dist-info/RECORD,,