Created
April 8, 2016 10:45
-
-
Save rhizoome/7700aa41ca6529e0a8fd72a6a8c68436 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RES_COUNT = 35 | |
| range_intagers_st = st.integers(min_value=0, max_value=RES_COUNT) | |
| @st.composite | |
| def provide_require_st(draw, filter_=True): | |
| commands = draw(range_intagers_st) | |
| provides = draw( | |
| st.lists( | |
| st.lists(range_intagers_st), | |
| min_size = commands, | |
| max_size = commands | |
| ) | |
| ) | |
| is_func = draw( | |
| st.lists( | |
| st.booleans(), | |
| min_size = commands, | |
| max_size = commands | |
| ) | |
| ) | |
| provides_set = set() | |
| for command in provides: | |
| provides_set.update(command) | |
| requires = [] | |
| if provides_set: | |
| for command in provides: | |
| if command: | |
| max_prov = max(command) | |
| else: | |
| max_prov = 0 | |
| if filter_: | |
| provides_filter = [x for x in provides_set if x > max_prov] | |
| else: | |
| provides_filter = provides_set | |
| if provides_filter: | |
| sample = st.sampled_from(provides_filter) | |
| requires.append(draw(st.lists(sample))) | |
| else: | |
| requires.append([]) | |
| else: | |
| requires = [[]] * commands | |
| return (provides, requires, is_func) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment