Last active
December 15, 2015 08:59
-
-
Save satomacoto/5235171 to your computer and use it in GitHub Desktop.
Test parameters
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
#!/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
''' | |
try some parameters. | |
$ python params_test.py | |
[0, -1] | |
False | |
[0, 0] | |
False | |
[0, 1] | |
False | |
[1, -1] | |
True | |
[1, 0] | |
False | |
[1, 1] | |
True | |
''' | |
import itertools | |
# [0,1,2] to func(x) = x | |
# [0,1,2,3] to func(x) = x-1 | |
func_list = [lambda x: x, lambda x: x-1] # functions | |
params_lists = [range(2), range(3)] # parameters | |
for params_list in itertools.product(*params_lists): | |
print [func(params) for func, params in zip(func_list, params_list)] | |
print all(func(params) for func, params in zip(funcs_list, params_list)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment