From b9aa815d06f619855cc842b5f0c27cc2f0370280 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Mon, 4 Mar 2019 11:03:34 -0800 Subject: [PATCH] models_test: bundle test methods under VariationModelTest class in preparation for adding more unit tests to VariationModel class. --- Tests/varLib/models_test.py | 200 ++++++++++++++++++------------------ 1 file changed, 101 insertions(+), 99 deletions(-) diff --git a/Tests/varLib/models_test.py b/Tests/varLib/models_test.py index 106a604ca..42c8dba42 100644 --- a/Tests/varLib/models_test.py +++ b/Tests/varLib/models_test.py @@ -36,103 +36,105 @@ def test_supportScalar(): assert supportScalar({'wght':2.5}, {'wght':(0,2,4)}) == 0.75 -@pytest.mark.parametrize( - "locations, axisOrder, sortedLocs, supports, deltaWeights", - [ - ( - [ - {'wght':100}, - {'wght':-100}, - {'wght':-180}, - {'wdth':+.3}, - {'wght':+120,'wdth':.3}, - {'wght':+120,'wdth':.2}, - {}, - {'wght':+180,'wdth':.3}, - {'wght':+180}, - ], - ["wght"], - [ - {}, - {'wght': -100}, - {'wght': -180}, - {'wght': 100}, - {'wght': 180}, - {'wdth': 0.3}, - {'wdth': 0.3, 'wght': 180}, - {'wdth': 0.3, 'wght': 120}, - {'wdth': 0.2, 'wght': 120} - ], - [ - {}, - {'wght': (-180, -100, 0)}, - {'wght': (-180, -180, -100)}, - {'wght': (0, 100, 180)}, - {'wght': (100, 180, 180)}, - {'wdth': (0, 0.3, 0.3)}, - {'wdth': (0, 0.3, 0.3), 'wght': (0, 180, 180)}, - {'wdth': (0, 0.3, 0.3), 'wght': (0, 120, 180)}, - {'wdth': (0, 0.2, 0.3), 'wght': (0, 120, 180)} - ], - [ - {}, - {0: 1.0}, - {0: 1.0}, - {0: 1.0}, - {0: 1.0}, - {0: 1.0}, - {0: 1.0, 4: 1.0, 5: 1.0}, - {0: 1.0, 3: 0.75, 4: 0.25, 5: 1.0, 6: 0.6666666666666666}, - {0: 1.0, - 3: 0.75, - 4: 0.25, - 5: 0.6666666666666667, - 6: 0.4444444444444445, - 7: 0.6666666666666667} - ] - ), - ( - [ - {}, - {'bar': 0.5}, - {'bar': 1.0}, - {'foo': 1.0}, - {'bar': 0.5, 'foo': 1.0}, - {'bar': 1.0, 'foo': 1.0}, - ], - None, - [ - {}, - {'bar': 0.5}, - {'bar': 1.0}, - {'foo': 1.0}, - {'bar': 0.5, 'foo': 1.0}, - {'bar': 1.0, 'foo': 1.0}, - ], - [ - {}, - {'bar': (0, 0.5, 1.0)}, - {'bar': (0.5, 1.0, 1.0)}, - {'foo': (0, 1.0, 1.0)}, - {'bar': (0, 0.5, 1.0), 'foo': (0, 1.0, 1.0)}, - {'bar': (0.5, 1.0, 1.0), 'foo': (0, 1.0, 1.0)}, - ], - [ - {}, - {0: 1.0}, - {0: 1.0}, - {0: 1.0}, - {0: 1.0, 1: 1.0, 3: 1.0}, - {0: 1.0, 2: 1.0, 3: 1.0}, - ], - ) - ] -) -def test_VariationModel( - locations, axisOrder, sortedLocs, supports, deltaWeights -): - model = VariationModel(locations, axisOrder=axisOrder) +class VariationModelTest(object): - assert model.locations == sortedLocs - assert model.supports == supports - assert model.deltaWeights == deltaWeights + @pytest.mark.parametrize( + "locations, axisOrder, sortedLocs, supports, deltaWeights", + [ + ( + [ + {'wght':100}, + {'wght':-100}, + {'wght':-180}, + {'wdth':+.3}, + {'wght':+120,'wdth':.3}, + {'wght':+120,'wdth':.2}, + {}, + {'wght':+180,'wdth':.3}, + {'wght':+180}, + ], + ["wght"], + [ + {}, + {'wght': -100}, + {'wght': -180}, + {'wght': 100}, + {'wght': 180}, + {'wdth': 0.3}, + {'wdth': 0.3, 'wght': 180}, + {'wdth': 0.3, 'wght': 120}, + {'wdth': 0.2, 'wght': 120} + ], + [ + {}, + {'wght': (-180, -100, 0)}, + {'wght': (-180, -180, -100)}, + {'wght': (0, 100, 180)}, + {'wght': (100, 180, 180)}, + {'wdth': (0, 0.3, 0.3)}, + {'wdth': (0, 0.3, 0.3), 'wght': (0, 180, 180)}, + {'wdth': (0, 0.3, 0.3), 'wght': (0, 120, 180)}, + {'wdth': (0, 0.2, 0.3), 'wght': (0, 120, 180)} + ], + [ + {}, + {0: 1.0}, + {0: 1.0}, + {0: 1.0}, + {0: 1.0}, + {0: 1.0}, + {0: 1.0, 4: 1.0, 5: 1.0}, + {0: 1.0, 3: 0.75, 4: 0.25, 5: 1.0, 6: 0.6666666666666666}, + {0: 1.0, + 3: 0.75, + 4: 0.25, + 5: 0.6666666666666667, + 6: 0.4444444444444445, + 7: 0.6666666666666667} + ] + ), + ( + [ + {}, + {'bar': 0.5}, + {'bar': 1.0}, + {'foo': 1.0}, + {'bar': 0.5, 'foo': 1.0}, + {'bar': 1.0, 'foo': 1.0}, + ], + None, + [ + {}, + {'bar': 0.5}, + {'bar': 1.0}, + {'foo': 1.0}, + {'bar': 0.5, 'foo': 1.0}, + {'bar': 1.0, 'foo': 1.0}, + ], + [ + {}, + {'bar': (0, 0.5, 1.0)}, + {'bar': (0.5, 1.0, 1.0)}, + {'foo': (0, 1.0, 1.0)}, + {'bar': (0, 0.5, 1.0), 'foo': (0, 1.0, 1.0)}, + {'bar': (0.5, 1.0, 1.0), 'foo': (0, 1.0, 1.0)}, + ], + [ + {}, + {0: 1.0}, + {0: 1.0}, + {0: 1.0}, + {0: 1.0, 1: 1.0, 3: 1.0}, + {0: 1.0, 2: 1.0, 3: 1.0}, + ], + ) + ] + ) + def test_init( + self, locations, axisOrder, sortedLocs, supports, deltaWeights + ): + model = VariationModel(locations, axisOrder=axisOrder) + + assert model.locations == sortedLocs + assert model.supports == supports + assert model.deltaWeights == deltaWeights