nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: pyro-ppl/numpyro
Pull request #1774 (2024-04-04 18:57:24)

Fix ensemble mcmc multiple run
Due to misordering of the code in `ensemble.init`, ensemble mcmc would raise an error when running more than once after initialization.  




fehiepsi: Could you merge the master branch to make test pass?

Patch:
diff --git a/numpyro/infer/ensemble.py b/numpyro/infer/ensemble.py
index 7b0e1e5e..33e3f50b 100644
--- a/numpyro/infer/ensemble.py
+++ b/numpyro/infer/ensemble.py
@@ -154,15 +154,8 @@ class EnsembleSampler(MCMCKernel, ABC):
             "EnsembleSampler only supports chain_method='vectorized' with num_chains > 1.\n"
             "If you want to run chains in parallel, please raise a github issue."
         )
-
         assert rng_key.shape[0] % 2 == 0, "Number of chains must be even."
-
         self._num_chains = rng_key.shape[0]
-
-        if self._potential_fn and init_params is None:
-            raise ValueError(
-                "Valid value of `init_params` must be provided with `potential_fn`."
-            )
         if init_params is not None:
             assert all(
                 [
@@ -178,6 +171,11 @@ class EnsembleSampler(MCMCKernel, ABC):
             rng_key_init_model, model_args, model_kwargs, init_params
         )
 
+        if self._potential_fn and init_params is None:
+            raise ValueError(
+                "Valid value of `init_params` must be provided with `potential_fn`."
+            )
+
         self._num_warmup = num_warmup
 
         return EnsembleSamplerState(


Test patch:
diff --git a/test/infer/test_ensemble_mcmc.py b/test/infer/test_ensemble_mcmc.py
index 02c065aa..a49e6a63 100644
--- a/test/infer/test_ensemble_mcmc.py
+++ b/test/infer/test_ensemble_mcmc.py
@@ -79,3 +79,20 @@ def test_out_shape_smoke(kernel_cls):
 def test_invalid_moves(kernel_cls):
     with pytest.raises(AssertionError, match="Each move"):
         kernel_cls(model, moves={"invalid": 1.0})
+
+
+@pytest.mark.parametrize("kernel_cls", [AIES, ESS])
+def test_multirun(kernel_cls):
+    n_chains = 10
+    kernel = kernel_cls(model)
+
+    mcmc = MCMC(
+        kernel,
+        num_warmup=10,
+        num_samples=10,
+        progress_bar=False,
+        num_chains=n_chains,
+        chain_method="vectorized",
+    )
+    mcmc.run(random.PRNGKey(2), labels)
+    mcmc.run(random.PRNGKey(3), labels)
Repository: pyro-ppl/numpyro
Pull request #1822 (2024-06-24 22:17:42)

Less than eq constaint
I noticed in #1729 and #1793, contributor has contributed greater than equals to constraint. I think less than equals to should also be there.

fehiepsi: Thanks, @Qazalbash!

Patch:
diff --git a/numpyro/distributions/constraints.py b/numpyro/distributions/constraints.py
index 4d9445db..56075078 100644
--- a/numpyro/distributions/constraints.py
+++ b/numpyro/distributions/constraints.py
@@ -415,6 +415,16 @@ class _LessThan(Constraint):
         return jnp.array_equal(self.upper_bound, other.upper_bound)
 
 
+class _LessThanEq(_LessThan):
+    def __call__(self, x):
+        return x <= self.upper_bound
+
+    def __eq__(self, other):
+        if not isinstance(other, _LessThanEq):
+            return False
+        return jnp.array_equal(self.upper_bound, other.upper_bound)
+
+
 class _IntegerInterval(Constraint):
     is_discrete = True
 
@@ -768,6 +778,7 @@ dependent = _Dependent()
 greater_than = _GreaterThan
 greater_than_eq = _GreaterThanEq
 less_than = _LessThan
+less_than_eq = _LessThanEq
 independent = _IndependentConstraint
 integer_interval = _IntegerInterval
 integer_greater_than = _IntegerGreaterThan
diff --git a/numpyro/distributions/transforms.py b/numpyro/distributions/transforms.py
index b7d984b5..564c628d 100644
--- a/numpyro/distributions/transforms.py
+++ b/numpyro/distributions/transforms.py
@@ -1529,6 +1529,7 @@ def _transform_to_greater_than(constraint):
 
 
 @biject_to.register(constraints.less_than)
+@biject_to.register(constraints.less_than_eq)
 def _transform_to_less_than(constraint):
     return ComposeTransform(
         [


Test patch:
diff --git a/test/test_constraints.py b/test/test_constraints.py
index e413da21..bfb459bd 100644
--- a/test/test_constraints.py
+++ b/test/test_constraints.py
@@ -52,6 +52,7 @@ PARAMETRIZED_CONSTRAINTS = {
     "greater_than": T(constraints.greater_than, (_a(0.0),), dict()),
     "greater_than_eq": T(constraints.greater_than_eq, (_a(0.0),), dict()),
     "less_than": T(constraints.less_than, (_a(-1.0),), dict()),
+    "less_than_eq": T(constraints.less_than_eq, (_a(-1.0),), dict()),
     "independent": T(
         constraints.independent,
         (constraints.greater_than(jnp.zeros((2,))),),
diff --git a/test/test_transforms.py b/test/test_transforms.py
index e3ada6fd..8f68eaf6 100644
--- a/test/test_transforms.py
+++ b/test/test_transforms.py
@@ -366,6 +366,7 @@ def test_batched_recursive_linear_transform():
         (constraints.interval(8, 13), (17,)),
         (constraints.l1_ball, (4,)),
         (constraints.less_than(-1), ()),
+        (constraints.less_than_eq(-1), ()),
         (constraints.lower_cholesky, (15,)),
         (constraints.open_interval(3, 4), ()),
         (constraints.ordered_vector, (5,)),
Repository: pyro-ppl/numpyro
Pull request #1856 (2024-08-26 03:17:24)

Raise error when using CircularReparam at observed site
Fixes https://github.com/pyro-ppl/numpyro/issues/1846


Patch:
diff --git a/numpyro/infer/reparam.py b/numpyro/infer/reparam.py
index 60be9fa7..f191100c 100644
--- a/numpyro/infer/reparam.py
+++ b/numpyro/infer/reparam.py
@@ -338,6 +338,7 @@ class CircularReparam(Reparam):
         if isinstance(support, constraints.independent):
             support = fn.support.base_constraint
         assert support is constraints.circular
+        assert obs is None, "CircularReparam does not support observe statements"
 
         # Draw parameter-free noise.
         new_fn = dist.ImproperUniform(constraints.real, fn.batch_shape, fn.event_shape)


Test patch:
diff --git a/test/infer/test_reparam.py b/test/infer/test_reparam.py
index f1d72f74..e734f3c9 100644
--- a/test/infer/test_reparam.py
+++ b/test/infer/test_reparam.py
@@ -378,6 +378,16 @@ def test_circular(shape):
     assert_allclose(actual_probe, expected_probe, atol=0.1)
 
 
+def test_circular_reparam_no_observe():
+    def model():
+        numpyro.sample("x", dist.VonMises(0, 1), obs=0.5)
+
+    with numpyro.handlers.seed(rng_seed=0):
+        with numpyro.handlers.reparam(config={"x": CircularReparam()}):
+            with pytest.raises(AssertionError, match="not support observe"):
+                model()
+
+
 _unconstrain_reparam = numpyro.infer.util._unconstrain_reparam
Repository: pyro-ppl/numpyro
Pull request #1895 (2024-10-23 15:58:48)

Correct event dimensions for `ReshapeTransform`.
This PR fixes the event dimensions of the `ReshapeTransform` such that `ReshapeTransform((12, 13), (3, 4, 13))` correctly transforms from three to two event dimensions.

```python
>>> from numpyro.distributions.transforms import ReshapeTransform
>>> t = ReshapeTransform((12, 13), (3, 4, 13))
>>> t.domain.event_dim
3
>>> t.codomain.event_dim
2
```

This PR depends on #1894 because `AutoBatched*` guides requires correct handling of event dimensions by `ComposeTransform`.

fehiepsi: @tillahoffmann There is a merge conflict. Thanks for fixing the issue!
tillahoffmann: Thanks for the fast review. Merge conflicts are resolved.

Patch:
diff --git a/numpyro/distributions/transforms.py b/numpyro/distributions/transforms.py
index 05ae19ef..a1aee001 100644
--- a/numpyro/distributions/transforms.py
+++ b/numpyro/distributions/transforms.py
@@ -1209,10 +1209,6 @@ class ReshapeTransform(Transform):
     :param inverse_shape: Shape of the sample for the inverse transform.
     """
 
-    domain = constraints.real
-    codomain = constraints.real
-    sign = 1
-
     def __init__(self, forward_shape, inverse_shape) -> None:
         forward_size = math.prod(forward_shape)
         inverse_size = math.prod(inverse_shape)
@@ -1224,6 +1220,14 @@ class ReshapeTransform(Transform):
         self._forward_shape = forward_shape
         self._inverse_shape = inverse_shape
 
+    @property
+    def domain(self) -> constraints.Constraint:
+        return constraints.independent(constraints.real, len(self._inverse_shape))
+
+    @property
+    def codomain(self) -> constraints.Constraint:
+        return constraints.independent(constraints.real, len(self._forward_shape))
+
     def forward_shape(self, shape):
         return _get_target_shape(shape, self._forward_shape, self._inverse_shape)
 


Test patch:
diff --git a/test/test_transforms.py b/test/test_transforms.py
index 9d8c6594..beff83b8 100644
--- a/test/test_transforms.py
+++ b/test/test_transforms.py
@@ -404,9 +404,27 @@ def test_biject_to(constraint, shape):
     [
         CorrCholeskyTransform(),
         CorrCholeskyTransform().inv,
+        ReshapeTransform((3, 4), (12,)),
+        ReshapeTransform((12,), (3, 4)),
     ],
 )
 def test_compose_domain_codomain(transform):
     composed = ComposeTransform([transform])
     assert transform.domain.event_dim == composed.domain.event_dim
     assert transform.codomain.event_dim == composed.codomain.event_dim
+
+
+def test_compose_sequence_domain_codomain():
+    parts = [
+        CorrCholeskyTransform(),  # 1 to 2
+        ReshapeTransform((3, 4, 12), (12, 12)),  # 2 to 3
+        AffineTransform(0, 1),  # 3 to 3
+        ReshapeTransform((12, 12), (144,)),  # 3 to 1
+    ]
+    x = jnp.zeros(66)
+    for i, event_dim in enumerate([2, 3, 3]):
+        composed = ComposeTransform(parts[: i + 1])
+        y = composed(x)
+        assert y.ndim == event_dim
+        assert composed.codomain.event_dim == event_dim
+        assert composed.domain.event_dim == 1
Repository: pyro-ppl/numpyro
Pull request #1973 (2025-02-06 19:09:04)

Fix promote_batch_shape logic to take batch shapes of all parameters
Fixes https://github.com/pyro-ppl/numpyro/issues/1971


Patch:
diff --git a/numpyro/distributions/batch_util.py b/numpyro/distributions/batch_util.py
index 23512733..de0ad382 100644
--- a/numpyro/distributions/batch_util.py
+++ b/numpyro/distributions/batch_util.py
@@ -504,12 +504,16 @@ def promote_batch_shape(d: Distribution):
 
 @promote_batch_shape.register
 def _default_promote_batch_shape(d: Distribution):
-    attr_name = list(d.arg_constraints.keys())[0]
-    attr_event_dim = d.arg_constraints[attr_name].event_dim
-    attr = getattr(d, attr_name)
-    resolved_batch_shape = attr.shape[
-        : max(0, attr.ndim - d.event_dim - attr_event_dim)
-    ]
+    attr_batch_shapes = [d.batch_shape]
+    for attr_name, constraint in d.arg_constraints.items():
+        try:
+            attr_event_dim = constraint.event_dim
+        except NotImplementedError:
+            continue
+        attr = getattr(d, attr_name)
+        attr_batch_ndim = max(0, jnp.ndim(attr) - attr_event_dim)
+        attr_batch_shapes.append(jnp.shape(attr)[:attr_batch_ndim])
+    resolved_batch_shape = jnp.broadcast_shapes(*attr_batch_shapes)
     new_self = copy.deepcopy(d)
     new_self._batch_shape = resolved_batch_shape
     return new_self


Test patch:
diff --git a/test/contrib/test_control_flow.py b/test/contrib/test_control_flow.py
index 21cb1a89..7ec829ec 100644
--- a/test/contrib/test_control_flow.py
+++ b/test/contrib/test_control_flow.py
@@ -272,3 +272,19 @@ def test_scan_svi():
 
     xhat = results.params["x_auto_loc"]
     assert_allclose(xhat, tr["x"]["value"], rtol=0.1, atol=0.2)
+
+
+def test_scan_mvn():
+    def model():
+        def transition(c, a):
+            with numpyro.plate("foo", 5):
+                c2 = numpyro.sample(
+                    "val", dist.MultivariateNormal(c + a, scale_tril=jnp.eye(2))
+                )
+            return c2, c2
+
+        scan(transition, jnp.zeros((5, 2)), jnp.ones((4, 5, 2)))
+
+    with numpyro.handlers.seed(rng_seed=0), numpyro.handlers.trace() as tr:
+        model()
+    assert tr["val"]["fn"].batch_shape == (4, 5)
Repository: spf13/cobra
Pull request #70 (2015-03-16 19:49:55)

Add mergePersistentFlags in strip flags since we now look at the flag set.
@jlowdermilk @spf13 @smarterclayton ptal.

Thanks!
--brendan

smarterclayton: Test case? :)
brendandburns: Test cases added.

ptal.

Thanks!
--brendan

Patch:
diff --git a/command.go b/command.go
index 82368e2..7285d10 100644
--- a/command.go
+++ b/command.go
@@ -275,6 +275,7 @@ func stripFlags(args []string, c *Command) []string {
 	if len(args) < 1 {
 		return args
 	}
+	c.mergePersistentFlags()
 
 	commands := []string{}
 


Test patch:
diff --git a/command_test.go b/command_test.go
index ae66522..308f7fd 100644
--- a/command_test.go
+++ b/command_test.go
@@ -5,6 +5,8 @@ import (
 	"testing"
 )
 
+// TODO Test persistent flags on subcommands.  This requires testing the full execute function.
+
 func TestStripFlags(t *testing.T) {
 	tests := []struct {
 		input  []string
@@ -54,6 +56,14 @@ func TestStripFlags(t *testing.T) {
 			[]string{"-c", "bar", "-i", "foo", "blah"},
 			[]string{"bar", "blah"},
 		},
+		{
+			[]string{"--persist", "bar"},
+			[]string{"bar"},
+		},
+		{
+			[]string{"-p", "bar"},
+			[]string{"bar"},
+		},
 	}
 
 	cmdPrint := &Command{
@@ -68,6 +78,7 @@ func TestStripFlags(t *testing.T) {
 	var flagi int
 	var flagstr string
 	var flagbool bool
+	cmdPrint.PersistentFlags().BoolVarP(&flagbool, "persist", "p", false, "help for persistent one")
 	cmdPrint.Flags().IntVarP(&flagi, "int", "i", 345, "help message for flag int")
 	cmdPrint.Flags().StringVarP(&flagstr, "bar", "b", "bar", "help message for flag string")
 	cmdPrint.Flags().BoolVarP(&flagbool, "cat", "c", false, "help message for flag bool")
Repository: spf13/cobra
Pull request #83 (2015-04-03 05:23:01)

Fix redundant error for unknown root commands
When an unknown command is called on a non-runnable root, the error message stated twice, in slightly different ways:

```
~/code/src/github.com/adammck/cobra-test$ ./cobra-test whatever
Error: unknown command "whatever"
Run 'help' for usage.

cobra-test: invalid command [`whatever`]
Run 'cobra-test help' for usage
```

Neither of these are especially clear, so I merged them. The result is:

```
~/code/src/github.com/adammck/cobra-test$ ./cobra-test whatever
Error: unknown command "whatever"                        
Run 'cobra-test help' for usage
```

I believe this solves #29, and obsoletes #34.


Patch:
diff --git a/command.go b/command.go
index a7d9088..5e882d0 100644
--- a/command.go
+++ b/command.go
@@ -378,7 +378,7 @@ func (c *Command) Find(arrs []string) (*Command, []string, error) {
 	// if commander returned and the first argument (if it exists) doesn't
 	// match the command name, return nil & error
 	if commandFound.Name() == c.Name() && len(arrs[0]) > 0 && commandFound.Name() != arrs[0] {
-		return nil, a, fmt.Errorf("unknown command %q\nRun 'help' for usage.\n", a[0])
+		return nil, a, fmt.Errorf("unknown command %q", a[0])
 	}
 
 	return commandFound, a, nil
@@ -539,10 +539,10 @@ func (c *Command) Execute() (err error) {
 	if err != nil {
 		if err == flag.ErrHelp {
 			c.Help()
+
 		} else {
 			c.Println("Error:", err.Error())
-			c.Printf("%v: invalid command %#q\n", c.Root().Name(), os.Args[1:])
-			c.Printf("Run '%v help' for usage\n", c.Root().Name())
+			c.Printf("Run '%v help' for usage.\n", c.Root().Name())
 		}
 	}
 


Test patch:
diff --git a/cobra_test.go b/cobra_test.go
index 120bc5c..68e55ef 100644
--- a/cobra_test.go
+++ b/cobra_test.go
@@ -554,6 +554,15 @@ func TestRootNoCommandHelp(t *testing.T) {
 	}
 }
 
+func TestRootUnknownCommand(t *testing.T) {
+	r := noRRSetupTest("bogus")
+	s := "Error: unknown command \"bogus\"\nRun 'cobra-test help' for usage.\n"
+
+	if r.Output != s {
+		t.Errorf("Unexpected response.\nExpecting to be:\n %q\nGot:\n %q\n", s, r.Output)
+	}
+}
+
 func TestFlagsBeforeCommand(t *testing.T) {
 	// short without space
 	x := fullSetupTest("-i10 echo")
Repository: spf13/cobra
Pull request #105 (2015-05-04 20:03:46)

make filename extension handling a bash function
We were trying to call a bash function with bash stuff like @ () from a
variable.  Stop that.  Just call a function with an arg from a variable
instead of trying to pass around the bash.

Should fix https://github.com/spf13/cobra/pull/103


Patch:
diff --git a/bash_completions.go b/bash_completions.go
index 592a5d5..735d2f5 100644
--- a/bash_completions.go
+++ b/bash_completions.go
@@ -93,6 +93,13 @@ __handle_reply()
     fi
 }
 
+# The arguments should be in the form "ext1|ext2|extn"
+__handle_filename_extension_flag()
+{
+    local ext="$1"
+    _filedir "@(${ext})"
+}
+
 __handle_flag()
 {
     __debug "${FUNCNAME}: c is $c words[c] is ${words[c]}"
@@ -213,7 +220,7 @@ func writeFlagHandler(name string, annotations map[string][]string, out *bytes.B
 			fmt.Fprintf(out, "    flags_with_completion+=(%q)\n", name)
 
 			ext := strings.Join(value, "|")
-			ext = "_filedir '@(" + ext + ")'"
+			ext = "__handle_filename_extension_flag " + ext
 			fmt.Fprintf(out, "    flags_completion+=(%q)\n", ext)
 		}
 	}
diff --git a/bash_completions.md b/bash_completions.md
index f6707ff..e1a5d56 100644
--- a/bash_completions.md
+++ b/bash_completions.md
@@ -123,18 +123,15 @@ and you'll get something like
 In this example we use --filename= and expect to get a json or yaml file as the argument. To make this easier we annotate the --filename flag with valid filename extensions.
 
 ```go
-	annotations := []string{"json", "yaml", "yml"}
+	annotations := make([]string, 3)
+	annotations[0] = "json"
+	annotations[1] = "yaml"
+	annotations[2] = "yml"
+
 	annotation := make(map[string][]string)
 	annotation[cobra.BashCompFilenameExt] = annotations
 
-	flag := &pflag.Flag{
-		Name:        "filename",
-		Shorthand:   "f",
-		Usage:       usage,
-		Value:       value,
-		DefValue:    value.String(),
-		Annotations: annotation,
-	}
+	flag := &pflag.Flag{"filename", "f", usage, value, value.String(), false, annotation}
 	cmd.Flags().AddFlag(flag)
 ```
 


Test patch:
diff --git a/bash_completions_test.go b/bash_completions_test.go
index 4b7d06c..ee632cf 100644
--- a/bash_completions_test.go
+++ b/bash_completions_test.go
@@ -76,7 +76,7 @@ func TestBashCompletions(t *testing.T) {
 	// check for required nouns
 	check(t, str, `must_have_one_noun+=("pods")`)
 	// check for filename extention flags
-	check(t, str, `flags_completion+=("_filedir '@(json|yaml|yml)'")`)
+	check(t, str, `flags_completion+=("__handle_filename_extension_flag json|yaml|yml")`)
 
 	checkOmit(t, str, cmdDeprecated.Name())
 }
Repository: spf13/cobra
Pull request #116 (2015-06-22 09:04:06)

Correctly print the unknown command name
by now, if someone calls: `program --validflag unknowncommand` the
output will be:

```
Error: unknown command "--validflag"
Run 'program help' for usage.
```

This patch strips out flags so the unknown command is printed:

```
Error: unknown command "unknowncommand"
Run 'program help' for usage.
```


Patch:
diff --git a/command.go b/command.go
index 3831c33..8375aa5 100644
--- a/command.go
+++ b/command.go
@@ -424,7 +424,7 @@ func (c *Command) Find(args []string) (*Command, []string, error) {
 
 	// If we matched on the root, but we asked for a subcommand, return an error
 	if commandFound.Name() == c.Name() && len(stripFlags(args, c)) > 0 && commandFound.Name() != args[0] {
-		return nil, a, fmt.Errorf("unknown command %q", a[0])
+		return nil, a, fmt.Errorf("unknown command %q", stripFlags(args, c)[0])
 	}
 
 	return commandFound, a, nil


Test patch:
diff --git a/cobra_test.go b/cobra_test.go
index 9848d21..7e64907 100644
--- a/cobra_test.go
+++ b/cobra_test.go
@@ -755,6 +755,11 @@ func TestRootUnknownCommand(t *testing.T) {
 	if r.Output != s {
 		t.Errorf("Unexpected response.\nExpecting to be:\n %q\nGot:\n %q\n", s, r.Output)
 	}
+
+	r = noRRSetupTest("--strtwo=a bogus")
+	if r.Output != s {
+		t.Errorf("Unexpected response.\nExpecting to be:\n %q\nGot:\n %q\n", s, r.Output)
+	}
 }
 
 func TestFlagsBeforeCommand(t *testing.T) {
Repository: spf13/cobra
Pull request #119 (2015-06-22 21:29:08)

Correctly print the unknown command name
by now, if someone calls: program --validflag unknowncommand the
output will be:

```
Error: unknown command "--validflag"
Run 'program help' for usage.
```
This patch strips out flags so the unknown command is printed:
```
Error: unknown command "unknowncommand"
Run 'program help' for usage.
```

Reported-by: Simone Gotti in https://github.com/spf13/cobra/pull/116

This also fixes a problem with the original code where if you had a
root command and a grand child with the same name, the parser would
break and would not run the grandchild. The code was special casing if
the immediate child had the same name, but didn't handle grand-children

sgotti: @eparis LGTM. I was doing something similar in another patch as I noticed the same problem (but wanted to keep the two patches separated for clearness). 

eparis: @sgotti that's fair. I'll merge your patch and rebase mine on top. I'm going to push a new PR with a whole slew of changes you might want to check out. Really cleans up a bunch.

Patch:
diff --git a/command.go b/command.go
index 8375aa5..141cfab 100644
--- a/command.go
+++ b/command.go
@@ -423,8 +423,9 @@ func (c *Command) Find(args []string) (*Command, []string, error) {
 	commandFound, a := innerfind(c, args)
 
 	// If we matched on the root, but we asked for a subcommand, return an error
-	if commandFound.Name() == c.Name() && len(stripFlags(args, c)) > 0 && commandFound.Name() != args[0] {
-		return nil, a, fmt.Errorf("unknown command %q", stripFlags(args, c)[0])
+	argsWOflags := stripFlags(a, commandFound)
+	if commandFound == c && len(argsWOflags) > 0 {
+		return nil, a, fmt.Errorf("unknown command %q", argsWOflags[0])
 	}
 
 	return commandFound, a, nil


Test patch:
diff --git a/cobra_test.go b/cobra_test.go
index 7e64907..f181a07 100644
--- a/cobra_test.go
+++ b/cobra_test.go
@@ -378,6 +378,24 @@ func TestChildSameName(t *testing.T) {
 	}
 }
 
+func TestGrandChildSameName(t *testing.T) {
+	c := initializeWithSameName()
+	cmdTimes.AddCommand(cmdPrint)
+	c.AddCommand(cmdTimes)
+	c.SetArgs(strings.Split("times print one two", " "))
+	c.Execute()
+
+	if te != nil || tt != nil {
+		t.Error("Wrong command called")
+	}
+	if tp == nil {
+		t.Error("Wrong command called")
+	}
+	if strings.Join(tp, " ") != "one two" {
+		t.Error("Command didn't parse correctly")
+	}
+}
+
 func TestFlagLong(t *testing.T) {
 	noRRSetupTest("echo --intone=13 something here")