def test_design_matrix_with_continuous_iv(): matrix = np.array( [ [-1, -1], [1, -1], [-1, 1], [1, 1], [0, 0], [0, 0], [0, 0], [0, 0], [-1.41421356, 0], [1.41421356, 0], [0, -1.41421356], [0, 1.41421356], [0, 0], [0, 0], [0, 0], [0, 0], ] ) # pyDOE.ccdesign(2) iv_names = ["a", "b"] iv_values = [None, None] d = Design(zip(iv_names, iv_values), design_matrix=matrix) d.first_pass() for _ in range(3): yield check_design_matrix, d.get_order(), iv_names, iv_values, matrix
def test_different_bad_design_matrix(): iv_names = ('a', 'b', 'c') iv_values = [[1, 2], [1, 2, 3], [1, 2]] matrix = np.array([[-1., -1., 1.], [1., -1., -1.], [-1., 1., -1.], [1., 1., 1.]]) # pyDOE.fracfact('a b ab') d = Design(ivs=zip(iv_names, iv_values), design_matrix=matrix) with pytest.raises(ValueError): d.first_pass()
def test_factorial(): iv_names = ('a', 'b') iv_values = [[1, 2, 3], [1, 2]] conditions = [ {'a': 1, 'b': 1}, {'a': 1, 'b': 2}, {'a': 2, 'b': 1}, {'a': 2, 'b': 2}, {'a': 3, 'b': 1}, {'a': 3, 'b': 2}, ] assert list(Design.full_cross(iv_names, iv_values)) == conditions d = Design(zip(iv_names, iv_values)) d.first_pass() for _ in range(3): yield check_sequences, d.get_order(), conditions iv_names = ('a', 'b', 'c') iv_values = [[1, 2], [1, 2], [1, 2]] conditions = [ {'a': 1, 'b': 1, 'c': 1}, {'a': 1, 'b': 1, 'c': 2}, {'a': 1, 'b': 2, 'c': 1}, {'a': 1, 'b': 2, 'c': 2}, {'a': 2, 'b': 1, 'c': 1}, {'a': 2, 'b': 1, 'c': 2}, {'a': 2, 'b': 2, 'c': 1}, {'a': 2, 'b': 2, 'c': 2}, ] assert list(Design.full_cross(iv_names, iv_values)) == conditions d = Design(zip(iv_names, iv_values)) d.first_pass() for _ in range(3): yield check_sequences, d.get_order(), conditions
def test_factorial(): iv_names = ("a", "b") iv_values = [[1, 2, 3], [1, 2]] conditions = [ {"a": 1, "b": 1}, {"a": 1, "b": 2}, {"a": 2, "b": 1}, {"a": 2, "b": 2}, {"a": 3, "b": 1}, {"a": 3, "b": 2}, ] assert list(Design.full_cross(iv_names, iv_values)) == conditions d = Design(zip(iv_names, iv_values)) d.first_pass() for _ in range(3): yield check_sequences, d.get_order(), conditions iv_names = ("a", "b", "c") iv_values = [[1, 2], [1, 2], [1, 2]] conditions = [ {"a": 1, "b": 1, "c": 1}, {"a": 1, "b": 1, "c": 2}, {"a": 1, "b": 2, "c": 1}, {"a": 1, "b": 2, "c": 2}, {"a": 2, "b": 1, "c": 1}, {"a": 2, "b": 1, "c": 2}, {"a": 2, "b": 2, "c": 1}, {"a": 2, "b": 2, "c": 2}, ] assert list(Design.full_cross(iv_names, iv_values)) == conditions d = Design(zip(iv_names, iv_values)) d.first_pass() for _ in range(3): yield check_sequences, d.get_order(), conditions
def test_design_matrix(): iv_names = ('a', 'b', 'c') iv_values = [[1, 2], [1, 2], [1, 2]] conditions = [ { 'a': 1, 'b': 1, 'c': 2 }, { 'a': 1, 'b': 2, 'c': 1 }, { 'a': 2, 'b': 1, 'c': 1 }, { 'a': 2, 'b': 2, 'c': 2 }, ] matrix = np.array([[-1., -1., 1.], [1., -1., -1.], [-1., 1., -1.], [1., 1., 1.]]) # pyDOE.fracfact('a b ab') d = Design(ivs=zip(iv_names, iv_values), design_matrix=matrix) d.first_pass() for _ in range(3): yield check_sequences, d.get_order(), conditions yield check_design_matrix, d.get_order(), iv_names, iv_values, matrix
def test_design_matrix_with_continuous_iv(): matrix = np.array([[-1, -1], [1, -1], [-1, 1], [1, 1], [0, 0], [0, 0], [0, 0], [0, 0], [-1.41421356, 0], [1.41421356, 0], [0, -1.41421356], [0, 1.41421356], [0, 0], [0, 0], [0, 0], [0, 0]]) # pyDOE.ccdesign(2) iv_names = ['a', 'b'] iv_values = [None, None] d = Design(zip(iv_names, iv_values), design_matrix=matrix) d.first_pass() for _ in range(3): yield check_design_matrix, d.get_order(), iv_names, iv_values, matrix
def test_design_matrix(): iv_names = ('a', 'b', 'c') iv_values = [[1, 2], [1, 2], [1, 2]] conditions = [ {'a': 1, 'b': 1, 'c': 2}, {'a': 1, 'b': 2, 'c': 1}, {'a': 2, 'b': 1, 'c': 1}, {'a': 2, 'b': 2, 'c': 2}, ] matrix = np.array([[-1., -1., 1.], [1., -1., -1.], [-1., 1., -1.], [1., 1., 1.]]) # pyDOE.fracfact('a b ab') d = Design(ivs=zip(iv_names, iv_values), design_matrix=matrix) d.first_pass() for _ in range(3): yield check_sequences, d.get_order(), conditions yield check_design_matrix, d.get_order(), iv_names, iv_values, matrix
def test_design_matrix(): iv_names = ("a", "b", "c") iv_values = [[1, 2], [1, 2], [1, 2]] conditions = [ {"a": 1, "b": 1, "c": 2}, {"a": 1, "b": 2, "c": 1}, {"a": 2, "b": 1, "c": 1}, {"a": 2, "b": 2, "c": 2}, ] matrix = np.array( [[-1.0, -1.0, 1.0], [1.0, -1.0, -1.0], [-1.0, 1.0, -1.0], [1.0, 1.0, 1.0]] ) # pyDOE.fracfact('a b ab') d = Design(ivs=zip(iv_names, iv_values), design_matrix=matrix) d.first_pass() for _ in range(3): yield check_sequences, d.get_order(), conditions yield check_design_matrix, d.get_order(), iv_names, iv_values, matrix
def test_bad_design_matrix(): with pytest.raises(TypeError): design = Design(ivs=[('a', [1]), ('b', [1])], design_matrix=np.ones((3, 3))) design.first_pass()
def test_factorial(): iv_names = ('a', 'b') iv_values = [[1, 2, 3], [1, 2]] conditions = [ { 'a': 1, 'b': 1 }, { 'a': 1, 'b': 2 }, { 'a': 2, 'b': 1 }, { 'a': 2, 'b': 2 }, { 'a': 3, 'b': 1 }, { 'a': 3, 'b': 2 }, ] assert list(Design.full_cross(iv_names, iv_values)) == conditions d = Design(zip(iv_names, iv_values)) d.first_pass() for _ in range(3): yield check_sequences, d.get_order(), conditions iv_names = ('a', 'b', 'c') iv_values = [[1, 2], [1, 2], [1, 2]] conditions = [ { 'a': 1, 'b': 1, 'c': 1 }, { 'a': 1, 'b': 1, 'c': 2 }, { 'a': 1, 'b': 2, 'c': 1 }, { 'a': 1, 'b': 2, 'c': 2 }, { 'a': 2, 'b': 1, 'c': 1 }, { 'a': 2, 'b': 1, 'c': 2 }, { 'a': 2, 'b': 2, 'c': 1 }, { 'a': 2, 'b': 2, 'c': 2 }, ] assert list(Design.full_cross(iv_names, iv_values)) == conditions d = Design(zip(iv_names, iv_values)) d.first_pass() for _ in range(3): yield check_sequences, d.get_order(), conditions