浏览代码

Changes RpnExpr.mutate argument order

Yann Weber 1年前
父节点
当前提交
684bb12614
共有 2 个文件被更改,包括 5 次插入5 次删除
  1. 4
    4
      python_rpnexpr.c
  2. 1
    1
      tests/tests_rpn_mutate.py

+ 4
- 4
python_rpnexpr.c 查看文件

@@ -40,7 +40,7 @@ static PyMethodDef RPNExpr_methods[] = {
40 40
 			"Evaluate an expression"),
41 41
 	PYRPN_method("mutate", rpnexpr_mutate,
42 42
 			METH_VARARGS | METH_KEYWORDS,
43
-			"self, params=None, n_mutations=1",
43
+			"self, n_mutations=1, params=None",
44 44
 			"Mutate an expression"),
45 45
 	PYRPN_method("reset_stack", rpnexpr_reset_stack,
46 46
 			METH_NOARGS,
@@ -548,15 +548,15 @@ PyObject* rpnexpr_mutate(PyObject* slf, PyObject *args, PyObject *kwds)
548 548
 {
549 549
 	PyRPNExpr_t *self = (PyRPNExpr_t*)slf;
550 550
 
551
-	char *str_args = "|OI:RPNIterExpr.mutate";
552
-	char *names[] = {"params", "n_mutations", NULL};
551
+	char *str_args = "|IO:RPNIterExpr.mutate";
552
+	char *names[] = {"n_mutations", "params", NULL};
553 553
 
554 554
 	PyObject *py_params = NULL;
555 555
 	unsigned int n_mutations = 1;
556 556
 	rpn_mutation_params_t params;
557 557
 
558 558
 	if(!PyArg_ParseTupleAndKeywords(args, kwds, str_args, names,
559
-				&py_params, &n_mutations))
559
+				&n_mutations, &py_params))
560 560
 	{
561 561
 		return NULL;
562 562
 	}

+ 1
- 1
tests/tests_rpn_mutate.py 查看文件

@@ -85,7 +85,7 @@ class TestRpnExprMutation(unittest.TestCase):
85 85
         expt_len = int(expt_len*n_mut)
86 86
 
87 87
         expr = pyrpn.RPNExpr("", 3)
88
-        expr.mutate(params, n_mutations=n_mut)
88
+        expr.mutate(n_mut, params)
89 89
         msg = "Expected a len of %d ( [%d..%d] with %.1f%% error) but got %d"
90 90
         self.assertTrue(abs(len(expr) - expt_len) <= n_mut*percent_error,
91 91
                 msg=msg % (expt_len,

正在加载...
取消
保存