aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/hypothesis
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-04-04 07:45:46 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-04-04 07:53:28 +0300
commit51958dfd22674e02052c8a292ab70fc2d52a07fc (patch)
tree42d2b859c555e9045203791ed3f60fa16e1b267e /contrib/python/hypothesis
parent7e62114667a5059c6b6a617d4cd9076928818478 (diff)
downloadydb-51958dfd22674e02052c8a292ab70fc2d52a07fc.tar.gz
Intermediate changes
Diffstat (limited to 'contrib/python/hypothesis')
-rw-r--r--contrib/python/hypothesis/py3/.dist-info/METADATA2
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py48
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py4
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/version.py2
-rw-r--r--contrib/python/hypothesis/py3/ya.make2
5 files changed, 47 insertions, 11 deletions
diff --git a/contrib/python/hypothesis/py3/.dist-info/METADATA b/contrib/python/hypothesis/py3/.dist-info/METADATA
index c61fb5cb38..e7444c3052 100644
--- a/contrib/python/hypothesis/py3/.dist-info/METADATA
+++ b/contrib/python/hypothesis/py3/.dist-info/METADATA
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: hypothesis
-Version: 6.99.9
+Version: 6.99.11
Summary: A library for property-based testing
Home-page: https://hypothesis.works
Author: David R. MacIver and Zac Hatfield-Dodds
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py
index c35b533ecb..3f15a974ef 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py
@@ -56,6 +56,7 @@ from hypothesis.internal.floats import (
SIGNALING_NAN,
SMALLEST_SUBNORMAL,
float_to_int,
+ int_to_float,
make_float_clamper,
next_down,
next_up,
@@ -998,13 +999,29 @@ class IRNode:
return self.value == shrink_towards
if self.ir_type == "float":
- # floats shrink "like integers" (for now, anyway), except shrink_towards
- # is not configurable and is always 0.
+ min_value = self.kwargs["min_value"]
+ max_value = self.kwargs["max_value"]
shrink_towards = 0
- shrink_towards = max(self.kwargs["min_value"], shrink_towards)
- shrink_towards = min(self.kwargs["max_value"], shrink_towards)
- return ir_value_equal("float", self.value, shrink_towards)
+ if min_value == -math.inf and max_value == math.inf:
+ return ir_value_equal("float", self.value, shrink_towards)
+
+ if (
+ not math.isinf(min_value)
+ and not math.isinf(max_value)
+ and math.ceil(min_value) <= math.floor(max_value)
+ ):
+ # the interval contains an integer. the simplest integer is the
+ # one closest to shrink_towards
+ shrink_towards = max(math.ceil(min_value), shrink_towards)
+ shrink_towards = min(math.floor(max_value), shrink_towards)
+ return ir_value_equal("float", self.value, shrink_towards)
+
+ # the real answer here is "the value in [min_value, max_value] with
+ # the lowest denominator when represented as a fraction".
+ # It would be good to compute this correctly in the future, but it's
+ # also not incorrect to be conservative here.
+ return False
if self.ir_type == "boolean":
return self.value is False
if self.ir_type == "string":
@@ -1481,6 +1498,27 @@ class HypothesisProvider(PrimitiveProvider):
result = clamped
else:
result = nasty_floats[i - 1]
+ # nan values generated via int_to_float break list membership:
+ #
+ # >>> n = 18444492273895866368
+ # >>> assert math.isnan(int_to_float(n))
+ # >>> assert int_to_float(n) not in [int_to_float(n)]
+ #
+ # because int_to_float nans are not equal in the sense of either
+ # `a == b` or `a is b`.
+ #
+ # This can lead to flaky errors when collections require unique
+ # floats. I think what is happening is that in some places we
+ # provide math.nan, and in others we provide
+ # int_to_float(float_to_int(math.nan)), and which one gets used
+ # is not deterministic across test iterations.
+ #
+ # As a (temporary?) fix, we'll *always* generate nan values which
+ # are not equal in the identity sense.
+ #
+ # see also https://github.com/HypothesisWorks/hypothesis/issues/3926.
+ if math.isnan(result):
+ result = int_to_float(float_to_int(result))
self._draw_float(forced=result, fake_forced=fake_forced)
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py
index ce232c67f1..ae28fcd741 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py
@@ -1194,7 +1194,6 @@ class Shrinker:
block,
lambda b: self.try_shrinking_blocks(targets, b),
random=self.random,
- full=False,
)
@defines_shrink_pass()
@@ -1217,7 +1216,7 @@ class Shrinker:
node = chooser.choose(
self.nodes,
- lambda node: node.ir_type == "float" and not node.was_forced
+ lambda node: node.ir_type == "float" and not node.trivial
# avoid shrinking integer-valued floats. In our current ordering, these
# are already simpler than all other floats, so it's better to shrink
# them in other passes.
@@ -1364,7 +1363,6 @@ class Shrinker:
self.shrink_target.buffer[u:v],
lambda b: self.try_shrinking_blocks((i,), b),
random=self.random,
- full=False,
)
if self.shrink_target is not initial:
diff --git a/contrib/python/hypothesis/py3/hypothesis/version.py b/contrib/python/hypothesis/py3/hypothesis/version.py
index 670380b619..5525778600 100644
--- a/contrib/python/hypothesis/py3/hypothesis/version.py
+++ b/contrib/python/hypothesis/py3/hypothesis/version.py
@@ -8,5 +8,5 @@
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at https://mozilla.org/MPL/2.0/.
-__version_info__ = (6, 99, 9)
+__version_info__ = (6, 99, 11)
__version__ = ".".join(map(str, __version_info__))
diff --git a/contrib/python/hypothesis/py3/ya.make b/contrib/python/hypothesis/py3/ya.make
index f6d2f61d06..19c7255bfd 100644
--- a/contrib/python/hypothesis/py3/ya.make
+++ b/contrib/python/hypothesis/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(6.99.9)
+VERSION(6.99.11)
LICENSE(MPL-2.0)