Skip to content

Commit

Permalink
linting, more explicit coverage, add release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
tybug committed Dec 22, 2024
1 parent fb24384 commit 2f69208
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RELEASE_TYPE: patch

This patch lays some groundwork for migrating our internal representation to the typed choice sequence (:issue:`3921`)
Original file line number Diff line number Diff line change
Expand Up @@ -204,21 +204,19 @@ def choice_to_index(choice, kwargs):
return 0
return int(choice)
elif isinstance(choice, bytes):
index = collection_index(
return collection_index(
list(choice),
min_size=kwargs["min_size"],
alphabet_size=2**8,
)
return index
elif isinstance(choice, str):
intervals = kwargs["intervals"]
index = collection_index(
return collection_index(
choice,
min_size=kwargs["min_size"],
alphabet_size=len(intervals),
to_order=intervals.index_from_char_in_shrink_order,
)
return index
elif isinstance(choice, float):
sign = int(sign_aware_lte(choice, -0.0))
return (sign << 64) | float_to_lex(abs(choice))
Expand Down
2 changes: 2 additions & 0 deletions hypothesis-python/tests/conjecture/test_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,8 @@ def test_choice_index_and_value_are_inverses(ir_type_and_kwargs):
("integer", integer_kw(max_value=5, shrink_towards=2), range(-10, 5 + 1)),
("integer", integer_kw(max_value=5), range(-10, 5 + 1)),
("integer", integer_kw(min_value=0, shrink_towards=1), range(10)),
("integer", integer_kw(-5, 5, shrink_towards=3), range(-5, 5 + 1)),
("integer", integer_kw(-5, 5, shrink_towards=-3), range(-5, 5 + 1)),
(
"float",
float_kw(1.0, next_up(next_up(1.0))),
Expand Down

0 comments on commit 2f69208

Please sign in to comment.