alecxe alecxe - 1 year ago 131
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']

Answer Source

You could do:

permutations(elements).map(lambda x: x[:n])
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download