implement split shuffle
This commit is contained in:
@@ -5,7 +5,7 @@ from src.models import KeypadSize
|
||||
|
||||
@pytest.fixture()
|
||||
def user_keypad():
|
||||
return UserKeypad.create(keypad_size=KeypadSize(props_per_key=7, numb_of_keys=10))
|
||||
return UserKeypad.create(keypad_size=KeypadSize(props_per_key=8, numb_of_keys=8))
|
||||
|
||||
|
||||
def test_dispersion(user_keypad):
|
||||
@@ -17,19 +17,19 @@ def test_dispersion(user_keypad):
|
||||
assert (adj_graph.isdisjoint(post_dispersion_graph[prop]))
|
||||
|
||||
|
||||
#def test_shuffle_props(user_keypad):
|
||||
# """there's no easy way to test this. At some point we'll have to run this code thousands of time to see if we get
|
||||
# expected statistical outcomes like:
|
||||
# - every property gets to every key with a uniform distribution
|
||||
# - every property is adjacent to every other property with uniform distribution
|
||||
# - the order in which the cipher move from key to key is random (i.e. the distance traveled is uniform)
|
||||
# """
|
||||
# pre_shuffle_keypad = user_keypad.keypad
|
||||
# user_keypad.partial_keypad_shuffle()
|
||||
# post_shuffle_keypad = user_keypad.keypad
|
||||
# assert (not all(
|
||||
# post_shuffle_keypad[idx] == pre_shuffle_keypad[idx] for idx in range(len(post_shuffle_keypad))
|
||||
# ))
|
||||
# assert (not all(
|
||||
# post_shuffle_keypad[idx] != pre_shuffle_keypad[idx] for idx in range(len(post_shuffle_keypad))
|
||||
# ))
|
||||
def test_shuffle_props(user_keypad):
|
||||
"""there's no easy way to test this. At some point we'll have to run this code thousands of time to see if we get
|
||||
expected statistical outcomes like:
|
||||
- every property gets to every key with a uniform distribution
|
||||
- every property is adjacent to every other property with uniform distribution
|
||||
- the order in which the cipher move from key to key is random (i.e. the distance traveled is uniform)
|
||||
"""
|
||||
pre_shuffle_keypad = user_keypad.keypad.copy()
|
||||
user_keypad.split_shuffle()
|
||||
post_shuffle_keypad = user_keypad.keypad.copy()
|
||||
assert (not all(
|
||||
post_shuffle_keypad[idx] == pre_shuffle_keypad[idx] for idx in range(len(post_shuffle_keypad))
|
||||
))
|
||||
assert (not all(
|
||||
post_shuffle_keypad[idx] != pre_shuffle_keypad[idx] for idx in range(len(post_shuffle_keypad))
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user