def __init__(self, operators, operands):
     self.operators = operators
     self.operands = operands
     self.n1 = len(operators.keys())  # 不同的 操作符 数量
     self.n2 = len(operands.keys())  # 不同的 操作数 数量
     self.N1 = list(accumulate(list(operators.values())))[-1]  # 操作数 总数
     self.N2 = list(accumulate(list(operands.values())))[-1]  # 操作数 总数
     print "operators:"
     print operators
Esempio n. 2
0
 def test_custom_function(self):
     """Test accumulate with a custom function"""
     self.assertEqual(
         list(mi.accumulate((1, 2, 3, 2, 1), func=max)), [1, 2, 3, 3, 3]
     )
Esempio n. 3
0
 def test_bogus_function(self):
     """Test accumulate with an invalid function"""
     with self.assertRaises(TypeError):
         list(mi.accumulate([1, 2, 3], func=lambda x: x))
Esempio n. 4
0
 def test_default(self):
     """Test accumulate with the default function (addition)"""
     self.assertEqual(list(mi.accumulate([1, 2, 3])), [1, 3, 6])
Esempio n. 5
0
 def test_empty(self):
     """Test that an empty input returns an empty output"""
     self.assertEqual(list(mi.accumulate([])), [])
 def test_custom_function(self):
     """Test accumulate with a custom function"""
     self.assertEqual(list(mi.accumulate((1, 2, 3, 2, 1), func=max)),
                      [1, 2, 3, 3, 3])
 def test_bogus_function(self):
     """Test accumulate with an invalid function"""
     with self.assertRaises(TypeError):
         list(mi.accumulate([1, 2, 3], func=lambda x: x))
 def test_default(self):
     """Test accumulate with the default function (addition)"""
     self.assertEqual(list(mi.accumulate([1, 2, 3])), [1, 3, 6])
 def test_empty(self):
     """Test that an empty input returns an empty output"""
     self.assertEqual(list(mi.accumulate([])), [])