Browse Source

Intermediate changes

robot-piglet 9 months ago
parent
commit
01f2411bab

+ 1 - 1
contrib/python/hypothesis/py3/.dist-info/METADATA

@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: hypothesis
-Version: 6.102.1
+Version: 6.102.4
 Summary: A library for property-based testing
 Home-page: https://hypothesis.works
 Author: David R. MacIver and Zac Hatfield-Dodds

+ 3 - 2
contrib/python/hypothesis/py3/hypothesis/internal/conjecture/choicetree.py

@@ -12,7 +12,7 @@ from collections import defaultdict
 from random import Random
 from typing import Callable, Dict, Iterable, List, Optional, Sequence
 
-from hypothesis.internal.conjecture.junkdrawer import LazySequenceCopy, pop_random
+from hypothesis.internal.conjecture.junkdrawer import LazySequenceCopy
 
 
 def prefix_selection_order(
@@ -41,7 +41,8 @@ def random_selection_order(random: Random) -> Callable[[int, int], Iterable[int]
     def selection_order(depth: int, n: int) -> Iterable[int]:
         pending = LazySequenceCopy(range(n))
         while pending:
-            yield pop_random(random, pending)
+            i = random.randrange(0, len(pending))
+            yield pending.pop(i)
 
     return selection_order
 

+ 15 - 4
contrib/python/hypothesis/py3/hypothesis/internal/conjecture/datatree.py

@@ -755,7 +755,14 @@ class DataTree:
                     attempts = 0
                     while True:
                         if attempts <= 10:
-                            (v, buf) = self._draw(ir_type, kwargs, random=random)
+                            try:
+                                (v, buf) = self._draw(ir_type, kwargs, random=random)
+                            except StopTest:  # pragma: no cover
+                                # it is possible that drawing from a fresh data can
+                                # overrun BUFFER_SIZE, due to eg unlucky rejection sampling
+                                # of integer probes. Retry these cases.
+                                attempts += 1
+                                continue
                         else:
                             (v, buf) = self._draw_from_cache(
                                 ir_type, kwargs, key=id(current_node), random=random
@@ -781,9 +788,13 @@ class DataTree:
                 attempts = 0
                 while True:
                     if attempts <= 10:
-                        (v, buf) = self._draw(
-                            branch.ir_type, branch.kwargs, random=random
-                        )
+                        try:
+                            (v, buf) = self._draw(
+                                branch.ir_type, branch.kwargs, random=random
+                            )
+                        except StopTest:  # pragma: no cover
+                            attempts += 1
+                            continue
                     else:
                         (v, buf) = self._draw_from_cache(
                             branch.ir_type, branch.kwargs, key=id(branch), random=random

+ 39 - 20
contrib/python/hypothesis/py3/hypothesis/internal/conjecture/junkdrawer.py

@@ -31,6 +31,8 @@ from typing import (
     overload,
 )
 
+from sortedcontainers import SortedList
+
 from hypothesis.errors import HypothesisWarning
 
 ARRAY_CODES = ["B", "H", "I", "L", "Q", "O"]
@@ -199,27 +201,36 @@ class LazySequenceCopy:
     in O(1) time. The full list API is not supported yet but there's no reason
     in principle it couldn't be."""
 
-    __mask: Optional[Dict[int, int]]
-
     def __init__(self, values: Sequence[int]):
         self.__values = values
         self.__len = len(values)
-        self.__mask = None
+        self.__mask: Optional[Dict[int, int]] = None
+        self.__popped_indices: Optional[SortedList] = None
 
     def __len__(self) -> int:
-        return self.__len
+        if self.__popped_indices is None:
+            return self.__len
+        return self.__len - len(self.__popped_indices)
 
-    def pop(self) -> int:
+    def pop(self, i: int = -1) -> int:
         if len(self) == 0:
             raise IndexError("Cannot pop from empty list")
-        result = self[-1]
-        self.__len -= 1
+        i = self.__underlying_index(i)
+
+        v = None
         if self.__mask is not None:
-            self.__mask.pop(self.__len, None)
-        return result
+            v = self.__mask.pop(i, None)
+        if v is None:
+            v = self.__values[i]
+
+        if self.__popped_indices is None:
+            self.__popped_indices = SortedList()
+        self.__popped_indices.add(i)
+        return v
 
     def __getitem__(self, i: int) -> int:
-        i = self.__check_index(i)
+        i = self.__underlying_index(i)
+
         default = self.__values[i]
         if self.__mask is None:
             return default
@@ -227,18 +238,34 @@ class LazySequenceCopy:
             return self.__mask.get(i, default)
 
     def __setitem__(self, i: int, v: int) -> None:
-        i = self.__check_index(i)
+        i = self.__underlying_index(i)
         if self.__mask is None:
             self.__mask = {}
         self.__mask[i] = v
 
-    def __check_index(self, i: int) -> int:
+    def __underlying_index(self, i: int) -> int:
         n = len(self)
         if i < -n or i >= n:
             raise IndexError(f"Index {i} out of range [0, {n})")
         if i < 0:
             i += n
         assert 0 <= i < n
+
+        if self.__popped_indices is not None:
+            # given an index i in the popped representation of the list, compute
+            # its corresponding index in the underlying list. given
+            #   l = [1, 4, 2, 10, 188]
+            #   l.pop(3)
+            #   l.pop(1)
+            #   assert l == [1, 2, 188]
+            #
+            # we want l[i] == self.__values[f(i)], where f is this function.
+            assert len(self.__popped_indices) <= len(self.__values)
+
+            for idx in self.__popped_indices:
+                if idx > i:
+                    break
+                i += 1
         return i
 
 
@@ -345,14 +372,6 @@ def find_integer(f: Callable[[int], bool]) -> int:
     return lo
 
 
-def pop_random(random: Random, seq: LazySequenceCopy) -> int:
-    """Remove and return a random element of seq. This runs in O(1) but leaves
-    the sequence in an arbitrary order."""
-    i = random.randrange(0, len(seq))
-    swap(seq, i, len(seq) - 1)
-    return seq.pop()
-
-
 class NotFound(Exception):
     pass
 

+ 1 - 2
contrib/python/hypothesis/py3/hypothesis/internal/conjecture/pareto.py

@@ -179,8 +179,7 @@ class ParetoFront:
             failures = 0
             while i + 1 < len(front) and failures < 10:
                 j = self.__random.randrange(i + 1, len(front))
-                swap(front, j, len(front) - 1)
-                candidate = front.pop()
+                candidate = front.pop(j)
                 dom = dominance(data, candidate)
                 assert dom != DominanceRelation.RIGHT_DOMINATES
                 if dom == DominanceRelation.LEFT_DOMINATES:

+ 2 - 6
contrib/python/hypothesis/py3/hypothesis/strategies/_internal/collections.py

@@ -287,12 +287,8 @@ class UniqueSampledListStrategy(UniqueListStrategy):
         remaining = LazySequenceCopy(self.element_strategy.elements)
 
         while remaining and should_draw.more():
-            i = len(remaining) - 1
-            j = data.draw_integer(0, i)
-            if j != i:
-                remaining[i], remaining[j] = remaining[j], remaining[i]
-            value = self.element_strategy._transform(remaining.pop())
-
+            j = data.draw_integer(0, len(remaining) - 1)
+            value = self.element_strategy._transform(remaining.pop(j))
             if value is not filter_not_satisfied and all(
                 key(value) not in seen for key, seen in zip(self.keys, seen_sets)
             ):

+ 1 - 1
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, 102, 1)
+__version_info__ = (6, 102, 4)
 __version__ = ".".join(map(str, __version_info__))

+ 1 - 1
contrib/python/hypothesis/py3/ya.make

@@ -2,7 +2,7 @@
 
 PY3_LIBRARY()
 
-VERSION(6.102.1)
+VERSION(6.102.4)
 
 LICENSE(MPL-2.0)
 

+ 9 - 1
contrib/python/zope.interface/py3/.dist-info/METADATA

@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: zope.interface
-Version: 6.3
+Version: 6.4
 Summary: Interfaces for Python
 Home-page: https://github.com/zopefoundation/zope.interface
 Author: Zope Foundation and Contributors
@@ -75,6 +75,14 @@ For detailed documentation, please see https://zopeinterface.readthedocs.io/en/l
  Changes
 =========
 
+6.4 (2024-05-15)
+================
+
+- Adjust for incompatible changes in Python 3.13b1.
+  (`#292 <https://github.com/zopefoundation/zope.interface/issues/292>`)
+
+- Build windows wheels on GHA.
+
 6.3 (2024-04-12)
 ================
 

+ 1 - 1
contrib/python/zope.interface/py3/ya.make

@@ -2,7 +2,7 @@
 
 PY3_LIBRARY()
 
-VERSION(6.3)
+VERSION(6.4)
 
 LICENSE(ZPL-2.1)
 

Some files were not shown because too many files changed in this diff