Skip to content

Commit

Permalink
Merge pull request #1963 from Zac-HD/fix-dtype-flakiness
Browse files Browse the repository at this point in the history
Work around weird behavior of np.dtype
  • Loading branch information
Zac-HD committed May 7, 2019
2 parents ad1ccc9 + 68e396d commit 7eec4da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
RELEASE_TYPE: patch

This patch fixes the very rare :issue:`1798` in
:func:`~hypothesis.extra.numpy.array_dtypes`,
which caused an internal error in our tests.
6 changes: 2 additions & 4 deletions hypothesis-python/src/hypothesis/extra/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from hypothesis import Verbosity
from hypothesis._settings import note_deprecation
from hypothesis.errors import InvalidArgument
from hypothesis.internal.compat import hrange, integer_types, text_type
from hypothesis.internal.compat import hrange, integer_types
from hypothesis.internal.coverage import check_function
from hypothesis.internal.reflection import proxies
from hypothesis.internal.validation import check_type, check_valid_interval
Expand Down Expand Up @@ -636,9 +636,7 @@ def array_dtypes(
"""Return a strategy for generating array (compound) dtypes, with members
drawn from the given subtype strategy."""
order_check("size", 0, min_size, max_size)
native_strings = st.text() # type: SearchStrategy[Any]
if text_type is not str: # pragma: no cover
native_strings = st.binary()
native_strings = st.from_type(str).filter(bool) # See issue #1798 re: filter!
elements = st.tuples(native_strings, subtype_strategy)
if allow_subarrays:
elements |= st.tuples(
Expand Down

0 comments on commit 7eec4da

Please sign in to comment.