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_weights(self): weights = mda.parseWeights("2, 2, 2, 2") print(weights) self.assertAlmostEqualList([2, 2, 2, 2], weights) weights = mda.parseWeights("1, 2, 3, ") self.assertAlmostEqualList([1, 2, 3], weights) weights = mda.parseWeights("1, 0, 1") self.assertAlmostEqualList([1, 1], weights) weights = mda.parseWeights("1.414213562373095, 1.414213562373095") self.assertAlmostEqualList([1.414213562373095, 1.414213562373095], weights) with self.assertRaises(ValueError): mda.parseWeights("2, error, 2, 2")