def on_ok(self): w1 = self.get_widget('ncol') w2 = self.get_widget('nexp') col_dict = {} for i,f in enumerate(self.parentApp.data): col_dict = {**col_dict, **{'d{0}c{1}'.format(i+1, j+1) : f[col] for j, col in enumerate(f)}} vals = math_parser.evaluate(w2.value, col_dict) self.parentApp.data[self.parentApp.current_dataset-1][w1.value] = vals self.parentApp.getForm(self.return_id).ncols += 1 self.parentApp.getForm(self.return_id).draw_columns() self.parentApp.switchForm(self.return_id)
def test_1(self): self.assertEqual(math_parser.evaluate("foo+bar", self.variables), 9)
def testSingleVariable(self): self.assertEqual(math_parser.evaluate("foo", self.variables), 4)
def test_2(self): self.assertEqual(math_parser.evaluate("a*b+c", self.variables), 5)
def test_1(self): self.assertEqual(math_parser.evaluate("a+b*c", self.variables), 7)
def test_6(self): self.assertEqual(math_parser.evaluate("foo+(bar*c*a)+((b*c))", self.variables), 704)
def test_4(self): self.assertEqual(math_parser.evaluate("foo+(bar*c*a)+b", self.variables), 506)
def test_2(self): self.assertEqual(math_parser.evaluate("foo+(bar*c)", self.variables), 504)