We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
False positive HypothesisDeprecationWarning
Just upgraded to Hypothesis 3.8.2, and I'm getting the following warning:

```
.venv/lib/python3.6/site-packages/hypothesis/strategies.py:416: HypothesisDeprecationWarning: Cannot sample from <enum 'AnEnum'>, not a sequence.  Hypothesis goes to some length to ensure that sampling an element from a collection (with `sampled_from` or `choices`) is replayable and can be minimised.  To replay a saved example, the sampled values must have the same iteration order on every run - ruling out sets, dicts, etc due to hash randomisation.  Most cases can simply use `sorted(values)`, but mixed types or special values such as math.nan require careful handling - and note that when simplifying an example, Hypothesis treats earlier values as simpler.
  elements = check_sample(elements)
```
It's a great warning but I think I'm getting a false positive:
```
from hypothesis import given
from hypothesis.strategies import sampled_from

from enum import Enum


class AnEnum(Enum):
    A = "A"
    B = "B"


@given(sampled_from(AnEnum))
def test_enum(e):
    print(e)
```
According to https://docs.python.org/3/library/enum.html, "Enumerations support iteration, in definition order", so this should be fine, right?

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/hypothesis/version.py`
Content:
```
1 # coding=utf-8
2 #
3 # This file is part of Hypothesis, which may be found at
4 # https://github.com/HypothesisWorks/hypothesis-python
5 #
6 # Most of this work is copyright (C) 2013-2017 David R. MacIver
7 # (david@drmaciver.com), but it contains contributions by others. See
8 # CONTRIBUTING.rst for a full list of people who may hold copyright, and
9 # consult the git log if you need to determine who owns an individual
10 # contribution.
11 #
12 # This Source Code Form is subject to the terms of the Mozilla Public License,
13 # v. 2.0. If a copy of the MPL was not distributed with this file, You can
14 # obtain one at http://mozilla.org/MPL/2.0/.
15 #
16 # END HEADER
17 
18 from __future__ import division, print_function, absolute_import
19 
20 __version_info__ = (3, 8, 3)
21 __version__ = '.'.join(map(str, __version_info__))
22
```

Path: `src/hypothesis/internal/conjecture/utils.py`
Content:
```
1 # coding=utf-8
2 #
3 # This file is part of Hypothesis, which may be found at
4 # https://github.com/HypothesisWorks/hypothesis-python
5 #
6 # Most of this work is copyright (C) 2013-2017 David R. MacIver
7 # (david@drmaciver.com), but it contains contributions by others. See
8 # CONTRIBUTING.rst for a full list of people who may hold copyright, and
9 # consult the git log if you need to determine who owns an individual
10 # contribution.
11 #
12 # This Source Code Form is subject to the terms of the Mozilla Public License,
13 # v. 2.0. If a copy of the MPL was not distributed with this file, You can
14 # obtain one at http://mozilla.org/MPL/2.0/.
15 #
16 # END HEADER
17 
18 from __future__ import division, print_function, absolute_import
19 
20 import math
21 from collections import Sequence
22 
23 from hypothesis._settings import note_deprecation
24 from hypothesis.internal.compat import hbytes, bit_length, int_to_bytes, \
25     int_from_bytes
26 
27 
28 def n_byte_unsigned(data, n):
29     return int_from_bytes(data.draw_bytes(n))
30 
31 
32 def saturate(n):
33     bits = bit_length(n)
34     k = 1
35     while k < bits:
36         n |= (n >> k)
37         k *= 2
38     return n
39 
40 
41 def integer_range(data, lower, upper, center=None, distribution=None):
42     assert lower <= upper
43     if lower == upper:
44         return int(lower)
45 
46     if center is None:
47         center = lower
48     center = min(max(center, lower), upper)
49     if distribution is None:
50         if lower < center < upper:
51             def distribution(random):
52                 if random.randint(0, 1):
53                     return random.randint(center, upper)
54                 else:
55                     return random.randint(lower, center)
56         else:
57             def distribution(random):
58                 return random.randint(lower, upper)
59 
60     gap = upper - lower
61     bits = bit_length(gap)
62     nbytes = bits // 8 + int(bits % 8 != 0)
63     mask = saturate(gap)
64 
65     def byte_distribution(random, n):
66         assert n == nbytes
67         v = distribution(random)
68         if v >= center:
69             probe = v - center
70         else:
71             probe = upper - v
72         return int_to_bytes(probe, n)
73 
74     probe = gap + 1
75 
76     while probe > gap:
77         probe = int_from_bytes(
78             data.draw_bytes(nbytes, byte_distribution)
79         ) & mask
80 
81     if center == upper:
82         result = upper - probe
83     elif center == lower:
84         result = lower + probe
85     else:
86         if center + probe <= upper:
87             result = center + probe
88         else:
89             result = upper - probe
90     assert lower <= result <= upper
91     return int(result)
92 
93 
94 def integer_range_with_distribution(data, lower, upper, nums):
95     return integer_range(
96         data, lower, upper, distribution=nums
97     )
98 
99 
100 def centered_integer_range(data, lower, upper, center):
101     return integer_range(
102         data, lower, upper, center=center
103     )
104 
105 
106 def check_sample(values):
107     if not isinstance(values, Sequence):
108         note_deprecation(
109             ('Cannot sample from %r, not a sequence.  ' % (values,)) +
110             'Hypothesis goes to some length to ensure that sampling an '
111             'element from a collection (with `sampled_from` or `choices`) is '
112             'replayable and can be minimised.  To replay a saved example, '
113             'the sampled values must have the same iteration order on every '
114             'run - ruling out sets, dicts, etc due to hash randomisation.  '
115             'Most cases can simply use `sorted(values)`, but mixed types or '
116             'special values such as math.nan require careful handling - and '
117             'note that when simplifying an example, Hypothesis treats '
118             'earlier values as simpler.')
119     return tuple(values)
120 
121 
122 def choice(data, values):
123     return values[integer_range(data, 0, len(values) - 1)]
124 
125 
126 def geometric(data, p):
127     denom = math.log1p(-p)
128     n_bytes = 8
129 
130     def distribution(random, n):
131         assert n == n_bytes
132         for _ in range(100):
133             try:
134                 return int_to_bytes(int(
135                     math.log1p(-random.random()) / denom), n)
136             # This is basically impossible to hit but is required for
137             # correctness
138             except OverflowError:  # pragma: no cover
139                 pass
140         # We got a one in a million chance 100 times in a row. Something is up.
141         assert False  # pragma: no cover
142     return int_from_bytes(data.draw_bytes(n_bytes, distribution))
143 
144 
145 def boolean(data):
146     return bool(n_byte_unsigned(data, 1) & 1)
147 
148 
149 def biased_coin(data, p):
150     def distribution(random, n):
151         assert n == 1
152         return hbytes([int(random.random() <= p)])
153     return bool(
154         data.draw_bytes(1, distribution)[0] & 1
155     )
156 
157 
158 def write(data, string):
159     assert isinstance(string, hbytes)
160 
161     def distribution(random, n):
162         assert n == len(string)
163         return string
164     x = data.draw_bytes(len(string), distribution)
165     if x != string:
166         data.mark_invalid()
167
```

Path: `docs/conf.py`
Content:
```
1 # coding=utf-8
2 #
3 # This file is part of Hypothesis, which may be found at
4 # https://github.com/HypothesisWorks/hypothesis-python
5 #
6 # Most of this work is copyright (C) 2013-2017 David R. MacIver
7 # (david@drmaciver.com), but it contains contributions by others. See
8 # CONTRIBUTING.rst for a full list of people who may hold copyright, and
9 # consult the git log if you need to determine who owns an individual
10 # contribution.
11 #
12 # This Source Code Form is subject to the terms of the Mozilla Public License,
13 # v. 2.0. If a copy of the MPL was not distributed with this file, You can
14 # obtain one at http://mozilla.org/MPL/2.0/.
15 #
16 # END HEADER
17 
18 # -*- coding: utf-8 -*-
19 
20 from __future__ import division, print_function, absolute_import
21 
22 # on_rtd is whether we are on readthedocs.org
23 import os
24 import sys
25 
26 from hypothesis import __version__
27 
28 on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
29 
30 sys.path.append(
31     os.path.join(os.path.dirname(__file__), '..', 'src')
32 )
33 
34 
35 autodoc_member_order = 'bysource'
36 
37 extensions = [
38     'sphinx.ext.autodoc',
39     'sphinx.ext.doctest',
40     'sphinx.ext.extlinks',
41     'sphinx.ext.viewcode',
42     'sphinx.ext.intersphinx',
43 ]
44 
45 templates_path = ['_templates']
46 
47 source_suffix = '.rst'
48 
49 # The master toctree document.
50 master_doc = 'index'
51 
52 # General information about the project.
53 project = u'Hypothesis'
54 copyright = u'2015, David R. MacIver'
55 author = u'David R. MacIver'
56 
57 version = __version__
58 release = __version__
59 
60 language = None
61 
62 exclude_patterns = ['_build']
63 
64 pygments_style = 'sphinx'
65 
66 todo_include_todos = False
67 
68 intersphinx_mapping = {
69     'python': ('http://docs.python.org/', None),
70 }
71 
72 autodoc_mock_imports = ['numpy']
73 
74 doctest_global_setup = '''
75 # Some standard imports
76 from hypothesis import *
77 from hypothesis.strategies import *
78 # Ensure that output (including from strategies) is deterministic
79 import random
80 random.seed(0)
81 '''
82 
83 # This config value must be a dictionary of external sites, mapping unique
84 # short alias names to a base URL and a prefix.
85 # See http://sphinx-doc.org/ext/extlinks.html
86 extlinks = {
87     'commit': ('https://github.com/HypothesisWorks/hypothesis-python/commit/%s', 'commit '),
88     'gh-file': ('https://github.com/HypothesisWorks/hypothesis-python/blob/master/%s', ''),
89     'gh-link': ('https://github.com/HypothesisWorks/hypothesis-python/%s', ''),
90     'issue': ('https://github.com/HypothesisWorks/hypothesis-python/issues/%s', 'issue #'),
91     'pull': ('https://github.com/HypothesisWorks/hypothesis-python/pulls/%s', 'pull request #'),
92 }
93 
94 # -- Options for HTML output ----------------------------------------------
95 
96 if not on_rtd:  # only import and set the theme if we're building docs locally
97     import sphinx_rtd_theme
98     html_theme = 'sphinx_rtd_theme'
99     html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
100 
101 html_static_path = ['_static']
102 
103 htmlhelp_basename = 'Hypothesisdoc'
104 
105 # -- Options for LaTeX output ---------------------------------------------
106 
107 latex_elements = {
108 }
109 
110 latex_documents = [
111     (master_doc, 'Hypothesis.tex', u'Hypothesis Documentation',
112      u'David R. MacIver', 'manual'),
113 ]
114 
115 man_pages = [
116     (master_doc, 'hypothesis', u'Hypothesis Documentation',
117      [author], 1)
118 ]
119 
120 texinfo_documents = [
121     (master_doc, 'Hypothesis', u'Hypothesis Documentation',
122      author, 'Hypothesis', 'One line description of project.',
123      'Miscellaneous'),
124 ]
125
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -22,6 +22,7 @@
 # on_rtd is whether we are on readthedocs.org
 import os
 import sys
+import datetime
 
 from hypothesis import __version__
 
@@ -51,7 +52,7 @@
 
 # General information about the project.
 project = u'Hypothesis'
-copyright = u'2015, David R. MacIver'
+copyright = u'2013-%s, David R. MacIver' % datetime.datetime.utcnow().year
 author = u'David R. MacIver'
 
 version = __version__
diff --git a/src/hypothesis/internal/conjecture/utils.py b/src/hypothesis/internal/conjecture/utils.py
--- a/src/hypothesis/internal/conjecture/utils.py
+++ b/src/hypothesis/internal/conjecture/utils.py
@@ -17,6 +17,7 @@
 
 from __future__ import division, print_function, absolute_import
 
+import enum
 import math
 from collections import Sequence
 
@@ -104,7 +105,7 @@
 
 
 def check_sample(values):
-    if not isinstance(values, Sequence):
+    if not isinstance(values, (Sequence, enum.EnumMeta)):
         note_deprecation(
             ('Cannot sample from %r, not a sequence.  ' % (values,)) +
             'Hypothesis goes to some length to ensure that sampling an '
diff --git a/src/hypothesis/version.py b/src/hypothesis/version.py
--- a/src/hypothesis/version.py
+++ b/src/hypothesis/version.py
@@ -17,5 +17,5 @@
 
 from __future__ import division, print_function, absolute_import
 
-__version_info__ = (3, 8, 3)
+__version_info__ = (3, 8, 4)
 __version__ = '.'.join(map(str, __version_info__))

{"golden_diff": "diff --git a/docs/conf.py b/docs/conf.py\n--- a/docs/conf.py\n+++ b/docs/conf.py\n@@ -22,6 +22,7 @@\n # on_rtd is whether we are on readthedocs.org\n import os\n import sys\n+import datetime\n \n from hypothesis import __version__\n \n@@ -51,7 +52,7 @@\n \n # General information about the project.\n project = u'Hypothesis'\n-copyright = u'2015, David R. MacIver'\n+copyright = u'2013-%s, David R. MacIver' % datetime.datetime.utcnow().year\n author = u'David R. MacIver'\n \n version = __version__\ndiff --git a/src/hypothesis/internal/conjecture/utils.py b/src/hypothesis/internal/conjecture/utils.py\n--- a/src/hypothesis/internal/conjecture/utils.py\n+++ b/src/hypothesis/internal/conjecture/utils.py\n@@ -17,6 +17,7 @@\n \n from __future__ import division, print_function, absolute_import\n \n+import enum\n import math\n from collections import Sequence\n \n@@ -104,7 +105,7 @@\n \n \n def check_sample(values):\n-    if not isinstance(values, Sequence):\n+    if not isinstance(values, (Sequence, enum.EnumMeta)):\n         note_deprecation(\n             ('Cannot sample from %r, not a sequence.  ' % (values,)) +\n             'Hypothesis goes to some length to ensure that sampling an '\ndiff --git a/src/hypothesis/version.py b/src/hypothesis/version.py\n--- a/src/hypothesis/version.py\n+++ b/src/hypothesis/version.py\n@@ -17,5 +17,5 @@\n \n from __future__ import division, print_function, absolute_import\n \n-__version_info__ = (3, 8, 3)\n+__version_info__ = (3, 8, 4)\n __version__ = '.'.join(map(str, __version_info__))\n", "issue": "False positive HypothesisDeprecationWarning\nJust upgraded to Hypothesis 3.8.2, and I'm getting the following warning:\r\n\r\n```\r\n.venv/lib/python3.6/site-packages/hypothesis/strategies.py:416: HypothesisDeprecationWarning: Cannot sample from <enum 'AnEnum'>, not a sequence.  Hypothesis goes to some length to ensure that sampling an element from a collection (with `sampled_from` or `choices`) is replayable and can be minimised.  To replay a saved example, the sampled values must have the same iteration order on every run - ruling out sets, dicts, etc due to hash randomisation.  Most cases can simply use `sorted(values)`, but mixed types or special values such as math.nan require careful handling - and note that when simplifying an example, Hypothesis treats earlier values as simpler.\r\n  elements = check_sample(elements)\r\n```\r\nIt's a great warning but I think I'm getting a false positive:\r\n```\r\nfrom hypothesis import given\r\nfrom hypothesis.strategies import sampled_from\r\n\r\nfrom enum import Enum\r\n\r\n\r\nclass AnEnum(Enum):\r\n    A = \"A\"\r\n    B = \"B\"\r\n\r\n\r\n@given(sampled_from(AnEnum))\r\ndef test_enum(e):\r\n    print(e)\r\n```\r\nAccording to https://docs.python.org/3/library/enum.html, \"Enumerations support iteration, in definition order\", so this should be fine, right?\n", "before_files": [{"content": "# coding=utf-8\n#\n# This file is part of Hypothesis, which may be found at\n# https://github.com/HypothesisWorks/hypothesis-python\n#\n# Most of this work is copyright (C) 2013-2017 David R. MacIver\n# (david@drmaciver.com), but it contains contributions by others. See\n# CONTRIBUTING.rst for a full list of people who may hold copyright, and\n# consult the git log if you need to determine who owns an individual\n# contribution.\n#\n# This Source Code Form is subject to the terms of the Mozilla Public License,\n# v. 2.0. If a copy of the MPL was not distributed with this file, You can\n# obtain one at http://mozilla.org/MPL/2.0/.\n#\n# END HEADER\n\nfrom __future__ import division, print_function, absolute_import\n\n__version_info__ = (3, 8, 3)\n__version__ = '.'.join(map(str, __version_info__))\n", "path": "src/hypothesis/version.py"}, {"content": "# coding=utf-8\n#\n# This file is part of Hypothesis, which may be found at\n# https://github.com/HypothesisWorks/hypothesis-python\n#\n# Most of this work is copyright (C) 2013-2017 David R. MacIver\n# (david@drmaciver.com), but it contains contributions by others. See\n# CONTRIBUTING.rst for a full list of people who may hold copyright, and\n# consult the git log if you need to determine who owns an individual\n# contribution.\n#\n# This Source Code Form is subject to the terms of the Mozilla Public License,\n# v. 2.0. If a copy of the MPL was not distributed with this file, You can\n# obtain one at http://mozilla.org/MPL/2.0/.\n#\n# END HEADER\n\nfrom __future__ import division, print_function, absolute_import\n\nimport math\nfrom collections import Sequence\n\nfrom hypothesis._settings import note_deprecation\nfrom hypothesis.internal.compat import hbytes, bit_length, int_to_bytes, \\\n    int_from_bytes\n\n\ndef n_byte_unsigned(data, n):\n    return int_from_bytes(data.draw_bytes(n))\n\n\ndef saturate(n):\n    bits = bit_length(n)\n    k = 1\n    while k < bits:\n        n |= (n >> k)\n        k *= 2\n    return n\n\n\ndef integer_range(data, lower, upper, center=None, distribution=None):\n    assert lower <= upper\n    if lower == upper:\n        return int(lower)\n\n    if center is None:\n        center = lower\n    center = min(max(center, lower), upper)\n    if distribution is None:\n        if lower < center < upper:\n            def distribution(random):\n                if random.randint(0, 1):\n                    return random.randint(center, upper)\n                else:\n                    return random.randint(lower, center)\n        else:\n            def distribution(random):\n                return random.randint(lower, upper)\n\n    gap = upper - lower\n    bits = bit_length(gap)\n    nbytes = bits // 8 + int(bits % 8 != 0)\n    mask = saturate(gap)\n\n    def byte_distribution(random, n):\n        assert n == nbytes\n        v = distribution(random)\n        if v >= center:\n            probe = v - center\n        else:\n            probe = upper - v\n        return int_to_bytes(probe, n)\n\n    probe = gap + 1\n\n    while probe > gap:\n        probe = int_from_bytes(\n            data.draw_bytes(nbytes, byte_distribution)\n        ) & mask\n\n    if center == upper:\n        result = upper - probe\n    elif center == lower:\n        result = lower + probe\n    else:\n        if center + probe <= upper:\n            result = center + probe\n        else:\n            result = upper - probe\n    assert lower <= result <= upper\n    return int(result)\n\n\ndef integer_range_with_distribution(data, lower, upper, nums):\n    return integer_range(\n        data, lower, upper, distribution=nums\n    )\n\n\ndef centered_integer_range(data, lower, upper, center):\n    return integer_range(\n        data, lower, upper, center=center\n    )\n\n\ndef check_sample(values):\n    if not isinstance(values, Sequence):\n        note_deprecation(\n            ('Cannot sample from %r, not a sequence.  ' % (values,)) +\n            'Hypothesis goes to some length to ensure that sampling an '\n            'element from a collection (with `sampled_from` or `choices`) is '\n            'replayable and can be minimised.  To replay a saved example, '\n            'the sampled values must have the same iteration order on every '\n            'run - ruling out sets, dicts, etc due to hash randomisation.  '\n            'Most cases can simply use `sorted(values)`, but mixed types or '\n            'special values such as math.nan require careful handling - and '\n            'note that when simplifying an example, Hypothesis treats '\n            'earlier values as simpler.')\n    return tuple(values)\n\n\ndef choice(data, values):\n    return values[integer_range(data, 0, len(values) - 1)]\n\n\ndef geometric(data, p):\n    denom = math.log1p(-p)\n    n_bytes = 8\n\n    def distribution(random, n):\n        assert n == n_bytes\n        for _ in range(100):\n            try:\n                return int_to_bytes(int(\n                    math.log1p(-random.random()) / denom), n)\n            # This is basically impossible to hit but is required for\n            # correctness\n            except OverflowError:  # pragma: no cover\n                pass\n        # We got a one in a million chance 100 times in a row. Something is up.\n        assert False  # pragma: no cover\n    return int_from_bytes(data.draw_bytes(n_bytes, distribution))\n\n\ndef boolean(data):\n    return bool(n_byte_unsigned(data, 1) & 1)\n\n\ndef biased_coin(data, p):\n    def distribution(random, n):\n        assert n == 1\n        return hbytes([int(random.random() <= p)])\n    return bool(\n        data.draw_bytes(1, distribution)[0] & 1\n    )\n\n\ndef write(data, string):\n    assert isinstance(string, hbytes)\n\n    def distribution(random, n):\n        assert n == len(string)\n        return string\n    x = data.draw_bytes(len(string), distribution)\n    if x != string:\n        data.mark_invalid()\n", "path": "src/hypothesis/internal/conjecture/utils.py"}, {"content": "# coding=utf-8\n#\n# This file is part of Hypothesis, which may be found at\n# https://github.com/HypothesisWorks/hypothesis-python\n#\n# Most of this work is copyright (C) 2013-2017 David R. MacIver\n# (david@drmaciver.com), but it contains contributions by others. See\n# CONTRIBUTING.rst for a full list of people who may hold copyright, and\n# consult the git log if you need to determine who owns an individual\n# contribution.\n#\n# This Source Code Form is subject to the terms of the Mozilla Public License,\n# v. 2.0. If a copy of the MPL was not distributed with this file, You can\n# obtain one at http://mozilla.org/MPL/2.0/.\n#\n# END HEADER\n\n# -*- coding: utf-8 -*-\n\nfrom __future__ import division, print_function, absolute_import\n\n# on_rtd is whether we are on readthedocs.org\nimport os\nimport sys\n\nfrom hypothesis import __version__\n\non_rtd = os.environ.get('READTHEDOCS', None) == 'True'\n\nsys.path.append(\n    os.path.join(os.path.dirname(__file__), '..', 'src')\n)\n\n\nautodoc_member_order = 'bysource'\n\nextensions = [\n    'sphinx.ext.autodoc',\n    'sphinx.ext.doctest',\n    'sphinx.ext.extlinks',\n    'sphinx.ext.viewcode',\n    'sphinx.ext.intersphinx',\n]\n\ntemplates_path = ['_templates']\n\nsource_suffix = '.rst'\n\n# The master toctree document.\nmaster_doc = 'index'\n\n# General information about the project.\nproject = u'Hypothesis'\ncopyright = u'2015, David R. MacIver'\nauthor = u'David R. MacIver'\n\nversion = __version__\nrelease = __version__\n\nlanguage = None\n\nexclude_patterns = ['_build']\n\npygments_style = 'sphinx'\n\ntodo_include_todos = False\n\nintersphinx_mapping = {\n    'python': ('http://docs.python.org/', None),\n}\n\nautodoc_mock_imports = ['numpy']\n\ndoctest_global_setup = '''\n# Some standard imports\nfrom hypothesis import *\nfrom hypothesis.strategies import *\n# Ensure that output (including from strategies) is deterministic\nimport random\nrandom.seed(0)\n'''\n\n# This config value must be a dictionary of external sites, mapping unique\n# short alias names to a base URL and a prefix.\n# See http://sphinx-doc.org/ext/extlinks.html\nextlinks = {\n    'commit': ('https://github.com/HypothesisWorks/hypothesis-python/commit/%s', 'commit '),\n    'gh-file': ('https://github.com/HypothesisWorks/hypothesis-python/blob/master/%s', ''),\n    'gh-link': ('https://github.com/HypothesisWorks/hypothesis-python/%s', ''),\n    'issue': ('https://github.com/HypothesisWorks/hypothesis-python/issues/%s', 'issue #'),\n    'pull': ('https://github.com/HypothesisWorks/hypothesis-python/pulls/%s', 'pull request #'),\n}\n\n# -- Options for HTML output ----------------------------------------------\n\nif not on_rtd:  # only import and set the theme if we're building docs locally\n    import sphinx_rtd_theme\n    html_theme = 'sphinx_rtd_theme'\n    html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]\n\nhtml_static_path = ['_static']\n\nhtmlhelp_basename = 'Hypothesisdoc'\n\n# -- Options for LaTeX output ---------------------------------------------\n\nlatex_elements = {\n}\n\nlatex_documents = [\n    (master_doc, 'Hypothesis.tex', u'Hypothesis Documentation',\n     u'David R. MacIver', 'manual'),\n]\n\nman_pages = [\n    (master_doc, 'hypothesis', u'Hypothesis Documentation',\n     [author], 1)\n]\n\ntexinfo_documents = [\n    (master_doc, 'Hypothesis', u'Hypothesis Documentation',\n     author, 'Hypothesis', 'One line description of project.',\n     'Miscellaneous'),\n]\n", "path": "docs/conf.py"}], "after_files": [{"content": "# coding=utf-8\n#\n# This file is part of Hypothesis, which may be found at\n# https://github.com/HypothesisWorks/hypothesis-python\n#\n# Most of this work is copyright (C) 2013-2017 David R. MacIver\n# (david@drmaciver.com), but it contains contributions by others. See\n# CONTRIBUTING.rst for a full list of people who may hold copyright, and\n# consult the git log if you need to determine who owns an individual\n# contribution.\n#\n# This Source Code Form is subject to the terms of the Mozilla Public License,\n# v. 2.0. If a copy of the MPL was not distributed with this file, You can\n# obtain one at http://mozilla.org/MPL/2.0/.\n#\n# END HEADER\n\nfrom __future__ import division, print_function, absolute_import\n\n__version_info__ = (3, 8, 4)\n__version__ = '.'.join(map(str, __version_info__))\n", "path": "src/hypothesis/version.py"}, {"content": "# coding=utf-8\n#\n# This file is part of Hypothesis, which may be found at\n# https://github.com/HypothesisWorks/hypothesis-python\n#\n# Most of this work is copyright (C) 2013-2017 David R. MacIver\n# (david@drmaciver.com), but it contains contributions by others. See\n# CONTRIBUTING.rst for a full list of people who may hold copyright, and\n# consult the git log if you need to determine who owns an individual\n# contribution.\n#\n# This Source Code Form is subject to the terms of the Mozilla Public License,\n# v. 2.0. If a copy of the MPL was not distributed with this file, You can\n# obtain one at http://mozilla.org/MPL/2.0/.\n#\n# END HEADER\n\nfrom __future__ import division, print_function, absolute_import\n\nimport enum\nimport math\nfrom collections import Sequence\n\nfrom hypothesis._settings import note_deprecation\nfrom hypothesis.internal.compat import hbytes, bit_length, int_to_bytes, \\\n    int_from_bytes\n\n\ndef n_byte_unsigned(data, n):\n    return int_from_bytes(data.draw_bytes(n))\n\n\ndef saturate(n):\n    bits = bit_length(n)\n    k = 1\n    while k < bits:\n        n |= (n >> k)\n        k *= 2\n    return n\n\n\ndef integer_range(data, lower, upper, center=None, distribution=None):\n    assert lower <= upper\n    if lower == upper:\n        return int(lower)\n\n    if center is None:\n        center = lower\n    center = min(max(center, lower), upper)\n    if distribution is None:\n        if lower < center < upper:\n            def distribution(random):\n                if random.randint(0, 1):\n                    return random.randint(center, upper)\n                else:\n                    return random.randint(lower, center)\n        else:\n            def distribution(random):\n                return random.randint(lower, upper)\n\n    gap = upper - lower\n    bits = bit_length(gap)\n    nbytes = bits // 8 + int(bits % 8 != 0)\n    mask = saturate(gap)\n\n    def byte_distribution(random, n):\n        assert n == nbytes\n        v = distribution(random)\n        if v >= center:\n            probe = v - center\n        else:\n            probe = upper - v\n        return int_to_bytes(probe, n)\n\n    probe = gap + 1\n\n    while probe > gap:\n        probe = int_from_bytes(\n            data.draw_bytes(nbytes, byte_distribution)\n        ) & mask\n\n    if center == upper:\n        result = upper - probe\n    elif center == lower:\n        result = lower + probe\n    else:\n        if center + probe <= upper:\n            result = center + probe\n        else:\n            result = upper - probe\n    assert lower <= result <= upper\n    return int(result)\n\n\ndef integer_range_with_distribution(data, lower, upper, nums):\n    return integer_range(\n        data, lower, upper, distribution=nums\n    )\n\n\ndef centered_integer_range(data, lower, upper, center):\n    return integer_range(\n        data, lower, upper, center=center\n    )\n\n\ndef check_sample(values):\n    if not isinstance(values, (Sequence, enum.EnumMeta)):\n        note_deprecation(\n            ('Cannot sample from %r, not a sequence.  ' % (values,)) +\n            'Hypothesis goes to some length to ensure that sampling an '\n            'element from a collection (with `sampled_from` or `choices`) is '\n            'replayable and can be minimised.  To replay a saved example, '\n            'the sampled values must have the same iteration order on every '\n            'run - ruling out sets, dicts, etc due to hash randomisation.  '\n            'Most cases can simply use `sorted(values)`, but mixed types or '\n            'special values such as math.nan require careful handling - and '\n            'note that when simplifying an example, Hypothesis treats '\n            'earlier values as simpler.')\n    return tuple(values)\n\n\ndef choice(data, values):\n    return values[integer_range(data, 0, len(values) - 1)]\n\n\ndef geometric(data, p):\n    denom = math.log1p(-p)\n    n_bytes = 8\n\n    def distribution(random, n):\n        assert n == n_bytes\n        for _ in range(100):\n            try:\n                return int_to_bytes(int(\n                    math.log1p(-random.random()) / denom), n)\n            # This is basically impossible to hit but is required for\n            # correctness\n            except OverflowError:  # pragma: no cover\n                pass\n        # We got a one in a million chance 100 times in a row. Something is up.\n        assert False  # pragma: no cover\n    return int_from_bytes(data.draw_bytes(n_bytes, distribution))\n\n\ndef boolean(data):\n    return bool(n_byte_unsigned(data, 1) & 1)\n\n\ndef biased_coin(data, p):\n    def distribution(random, n):\n        assert n == 1\n        return hbytes([int(random.random() <= p)])\n    return bool(\n        data.draw_bytes(1, distribution)[0] & 1\n    )\n\n\ndef write(data, string):\n    assert isinstance(string, hbytes)\n\n    def distribution(random, n):\n        assert n == len(string)\n        return string\n    x = data.draw_bytes(len(string), distribution)\n    if x != string:\n        data.mark_invalid()\n", "path": "src/hypothesis/internal/conjecture/utils.py"}, {"content": "# coding=utf-8\n#\n# This file is part of Hypothesis, which may be found at\n# https://github.com/HypothesisWorks/hypothesis-python\n#\n# Most of this work is copyright (C) 2013-2017 David R. MacIver\n# (david@drmaciver.com), but it contains contributions by others. See\n# CONTRIBUTING.rst for a full list of people who may hold copyright, and\n# consult the git log if you need to determine who owns an individual\n# contribution.\n#\n# This Source Code Form is subject to the terms of the Mozilla Public License,\n# v. 2.0. If a copy of the MPL was not distributed with this file, You can\n# obtain one at http://mozilla.org/MPL/2.0/.\n#\n# END HEADER\n\n# -*- coding: utf-8 -*-\n\nfrom __future__ import division, print_function, absolute_import\n\n# on_rtd is whether we are on readthedocs.org\nimport os\nimport sys\nimport datetime\n\nfrom hypothesis import __version__\n\non_rtd = os.environ.get('READTHEDOCS', None) == 'True'\n\nsys.path.append(\n    os.path.join(os.path.dirname(__file__), '..', 'src')\n)\n\n\nautodoc_member_order = 'bysource'\n\nextensions = [\n    'sphinx.ext.autodoc',\n    'sphinx.ext.doctest',\n    'sphinx.ext.extlinks',\n    'sphinx.ext.viewcode',\n    'sphinx.ext.intersphinx',\n]\n\ntemplates_path = ['_templates']\n\nsource_suffix = '.rst'\n\n# The master toctree document.\nmaster_doc = 'index'\n\n# General information about the project.\nproject = u'Hypothesis'\ncopyright = u'2013-%s, David R. MacIver' % datetime.datetime.utcnow().year\nauthor = u'David R. MacIver'\n\nversion = __version__\nrelease = __version__\n\nlanguage = None\n\nexclude_patterns = ['_build']\n\npygments_style = 'sphinx'\n\ntodo_include_todos = False\n\nintersphinx_mapping = {\n    'python': ('http://docs.python.org/', None),\n}\n\nautodoc_mock_imports = ['numpy']\n\ndoctest_global_setup = '''\n# Some standard imports\nfrom hypothesis import *\nfrom hypothesis.strategies import *\n# Ensure that output (including from strategies) is deterministic\nimport random\nrandom.seed(0)\n'''\n\n# This config value must be a dictionary of external sites, mapping unique\n# short alias names to a base URL and a prefix.\n# See http://sphinx-doc.org/ext/extlinks.html\nextlinks = {\n    'commit': ('https://github.com/HypothesisWorks/hypothesis-python/commit/%s', 'commit '),\n    'gh-file': ('https://github.com/HypothesisWorks/hypothesis-python/blob/master/%s', ''),\n    'gh-link': ('https://github.com/HypothesisWorks/hypothesis-python/%s', ''),\n    'issue': ('https://github.com/HypothesisWorks/hypothesis-python/issues/%s', 'issue #'),\n    'pull': ('https://github.com/HypothesisWorks/hypothesis-python/pulls/%s', 'pull request #'),\n}\n\n# -- Options for HTML output ----------------------------------------------\n\nif not on_rtd:  # only import and set the theme if we're building docs locally\n    import sphinx_rtd_theme\n    html_theme = 'sphinx_rtd_theme'\n    html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]\n\nhtml_static_path = ['_static']\n\nhtmlhelp_basename = 'Hypothesisdoc'\n\n# -- Options for LaTeX output ---------------------------------------------\n\nlatex_elements = {\n}\n\nlatex_documents = [\n    (master_doc, 'Hypothesis.tex', u'Hypothesis Documentation',\n     u'David R. MacIver', 'manual'),\n]\n\nman_pages = [\n    (master_doc, 'hypothesis', u'Hypothesis Documentation',\n     [author], 1)\n]\n\ntexinfo_documents = [\n    (master_doc, 'Hypothesis', u'Hypothesis Documentation',\n     author, 'Hypothesis', 'One line description of project.',\n     'Miscellaneous'),\n]\n", "path": "docs/conf.py"}]}