alecxe alecxe - 6 months ago 73
Python Question

Random sampling with Hypothesis

In Hypothesis, there is an corresponding

strategy to

In [1]: from hypothesis import find, strategies as st

In [2]: find(st.sampled_from(('ST', 'LT', 'TG', 'CT')), lambda x: True)
Out[2]: 'ST'

But, is there a way to have
-like strategy to produce subsequences of length N out of a sequence?

In [3]: import random

In [4]: random.sample(('ST', 'LT', 'TG', 'CT'), 2)
Out[4]: ['CT', 'TG']


You could do:

permutations(elements).map(lambda x: x[:n])