def updateVisualizationOfNormalizedWeights(): if self._relative_iteration_weights_box.isValid(): weights = MultipleDataAssimilation.parseWeights(relative_iteration_weights_model.getValue()) normalized_weights = MultipleDataAssimilation.normalizeWeights(weights) normalized_weights_model.setValue(", ".join("%.2f" % x for x in normalized_weights)) else: normalized_weights_model.setValue("The weights are invalid!")
def test_normalized_weights(self): weights = mda.normalizeWeights([1]) self.assertAlmostEqualList([1.0], weights) weights = mda.normalizeWeights([1, 1]) self.assertAlmostEqualList([1.414214, 1.414214], weights) weights = mda.normalizeWeights([1, 0, 1]) self.assertAlmostEqualList([1.414214, 1.414214], weights) weights = mda.normalizeWeights([1, 1, 1]) self.assertAlmostEqualList([1.732051, 1.732051, 1.732051], weights) weights = mda.normalizeWeights([8, 4, 2, 1]) self.assertAlmostEqualList([ 9.219544457292887, 4.6097722286464435, 2.3048861143232218, 1.1524430571616109 ], weights) weights = mda.normalizeWeights([ 9.219544457292887, 4.6097722286464435, 2.3048861143232218, 1.1524430571616109 ]) self.assertAlmostEqualList([ 9.219544457292887, 4.6097722286464435, 2.3048861143232218, 1.1524430571616109 ], weights)
def test_normalized_weights(self): weights = mda.normalizeWeights([1]) self.assertAlmostEqualList([1.0], weights) weights = mda.normalizeWeights([1, 1]) self.assertAlmostEqualList([1.414214, 1.414214], weights) weights = mda.normalizeWeights([1, 0, 1]) self.assertAlmostEqualList([1.414214, 1.414214], weights) weights = mda.normalizeWeights([1, 1, 1]) self.assertAlmostEqualList([1.732051, 1.732051, 1.732051], weights) weights = mda.normalizeWeights([8, 4, 2, 1]) self.assertAlmostEqualList([9.219544457292887, 4.6097722286464435, 2.3048861143232218, 1.1524430571616109], weights) weights = mda.normalizeWeights([9.219544457292887, 4.6097722286464435, 2.3048861143232218, 1.1524430571616109]) self.assertAlmostEqualList([9.219544457292887, 4.6097722286464435, 2.3048861143232218, 1.1524430571616109], weights)