internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: pyro-ppl/numpyro

Issue:
mnist loader should not scale the label
Scaling the label as in [this line](https://github.com/pyro-ppl/numpyro/blob/db2913b61b1d82fcad6662eb4d25ce5808f46d00/numpyro/examples/datasets.py#L167) seems wrong to me.


Discussion:

Resolving patch:
diff --git a/numpyro/examples/datasets.py b/numpyro/examples/datasets.py
--- a/numpyro/examples/datasets.py
+++ b/numpyro/examples/datasets.py
@@ -164,7 +164,7 @@ def _load_mnist():
     def read_label(file):
         with gzip.open(file, "rb") as f:
             f.read(8)
-            data = np.frombuffer(f.read(), dtype=np.int8) / np.float32(255.0)
+            data = np.frombuffer(f.read(), dtype=np.int8)
             return data
 
     def read_img(file):


Test patch:
Repository: pyro-ppl/numpyro

Issue:
Error when importing numpyro-0.13.1
UPDATE: Bumping JAX to the latest version seems to fix the problem

jax version = 0.4.14

Reproducible example in google colab: https://colab.research.google.com/drive/1R444hZjVV0KDaaksTE6Gf72DaH8rUqZt?usp=sharing

```
[/usr/local/lib/python3.10/dist-packages/numpyro/__init__.py](https://localhost:8080/#) in <module>
      4 import logging
      5 
----> 6 from numpyro import compat, diagnostics, distributions, handlers, infer, ops, optim
      7 from numpyro.distributions.distribution import enable_validation, validation_enabled
      8 from numpyro.infer.inspect import render_model

[/usr/local/lib/python3.10/dist-packages/numpyro/infer/__init__.py](https://localhost:8080/#) in <module>
      3 
      4 from numpyro.infer.barker import BarkerMH
----> 5 from numpyro.infer.elbo import (
      6     ELBO,
      7     RenyiELBO,

[/usr/local/lib/python3.10/dist-packages/numpyro/infer/elbo.py](https://localhost:8080/#) in <module>
     23     log_density,
     24 )
---> 25 from numpyro.ops.provenance import eval_provenance
     26 from numpyro.util import _validate_model, check_model_guide_match, find_stack_level
     27 

[/usr/local/lib/python3.10/dist-packages/numpyro/ops/provenance.py](https://localhost:8080/#) in <module>
      6 import jax.core as core
      7 from jax.experimental.pjit import pjit_p
----> 8 import jax.extend.linear_util as lu
      9 from jax.interpreters.partial_eval import trace_to_jaxpr_dynamic
     10 from jax.interpreters.pxla import xla_pmap_p

ModuleNotFoundError: No module named 'jax.extend.linear_util'
```


Discussion:

Resolving patch:
diff --git a/numpyro/ops/provenance.py b/numpyro/ops/provenance.py
--- a/numpyro/ops/provenance.py
+++ b/numpyro/ops/provenance.py
@@ -5,7 +5,11 @@
 from jax.api_util import flatten_fun, shaped_abstractify
 import jax.core as core
 from jax.experimental.pjit import pjit_p
-import jax.extend.linear_util as lu
+
+try:
+    import jax.extend.linear_util as lu
+except ImportError:
+    import jax.linear_util as lu
 from jax.interpreters.partial_eval import trace_to_jaxpr_dynamic
 from jax.interpreters.pxla import xla_pmap_p
 import jax.numpy as jnp


Test patch:
diff --git a/test/ops/test_provenance.py b/test/ops/test_provenance.py
--- a/test/ops/test_provenance.py
+++ b/test/ops/test_provenance.py
@@ -8,7 +8,11 @@
 import jax
 from jax.api_util import flatten_fun_nokwargs
 import jax.core as core
-import jax.extend.linear_util as lu
+
+try:
+    import jax.extend.linear_util as lu
+except ImportError:
+    import jax.linear_util as lu
 import jax.numpy as jnp
 
 from numpyro.ops.provenance import eval_provenance
Repository: pyro-ppl/numpyro

Issue:
Typo in docs
In the LKJ distribution, there is a code snippet with example [here](https://num.pyro.ai/en/stable/distributions.html#numpyro.distributions.continuous.LKJ)

In this example, the following line:
`# we can also use a faster formula `cov_mat = jnp.outer(theta, theta) * corr_mat``

Should be changed to
`# we can also use a faster formula `cov_mat = jnp.outer(sigma, sigma) * corr_mat``


Discussion:
Thanks, could you submit the fix?

Resolving patch:
diff --git a/numpyro/distributions/continuous.py b/numpyro/distributions/continuous.py
--- a/numpyro/distributions/continuous.py
+++ b/numpyro/distributions/continuous.py
@@ -882,7 +882,7 @@ def model(y):  # y has dimension N x d
             concentration = jnp.ones(1)  # Implies a uniform distribution over correlation matrices
             corr_mat = numpyro.sample("corr_mat", dist.LKJ(d, concentration))
             sigma = jnp.sqrt(theta)
-            # we can also use a faster formula `cov_mat = jnp.outer(theta, theta) * corr_mat`
+            # we can also use a faster formula `cov_mat = jnp.outer(sigma, sigma) * corr_mat`
             cov_mat = jnp.matmul(jnp.matmul(jnp.diag(sigma), corr_mat), jnp.diag(sigma))
 
             # Vector of expectations


Test patch:
Repository: pyro-ppl/numpyro

Issue:
Specify python version for pip
Can the python version be specified for pip in the setup.py?  Specifically using the method here:
- https://stackoverflow.com/questions/45778790/specifying-the-minimum-python-version-required-for-a-module-in-pip

i.e. `python_requires` so that it's picked up by pip

Currently, the update of this to drop 3.9 support broke a build of mine on a python 3.8 image.  I can get around this by pegging it to 0.12.1, but if python_requires is added, I believe pip will do this dependency resolution automatically.


Discussion:
Thanks for the ping! Do you want to make a PR for it?

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -86,6 +86,7 @@
         "tpu": f"jax[tpu]{_jax_version_constraints}",
         "cuda": f"jax[cuda]{_jax_version_constraints}",
     },
+    python_requires=">=3.9",
     long_description=long_description,
     long_description_content_type="text/markdown",
     keywords="probabilistic machine learning bayesian statistics",


Test patch:
Repository: pyro-ppl/numpyro

Issue:
random_flax_module broken
First and foremost **thanks** for the great work on `numpyro`!

**The utility function `random_flax_module()` from the `numpyro.contrib.module` seems to be broken.** As a minimal reproducible example for the error I take the example given in the docstring of the function ([https://github.com/pyro-ppl/numpyro/blob/master/numpyro/contrib/module.py#L285](https://github.com/pyro-ppl/numpyro/blob/master/numpyro/contrib/module.py#L285)) itself. The example with imports is given below:
```
import flax
import numpyro.distributions as dist
from numpyro.contrib.module import random_flax_module
random_flax_module(
    "net",
    flax.linen.Dense(features=1),
    prior={"bias": dist.Cauchy(), "kernel": dist.Normal()},
    input_shape=(4,)
)
```

This leads directly to `ValueError: First argument passed to an init function should be a `jax.PRNGKey` or a dictionary mapping strings to `jax.PRNGKey`.` 

Hope I just missed something obvious as the function would be very handy!


Discussion:
Good catch! the error means that this is run outside of numpyro context, in particular the seed handler. We should raise better errors here.
Thanks for the quick reply! Could you please shortly elaborate on how to fix the issue in general i.e. how to specify the context in a generic way that does not interfere with any downstream sampling tasks? Thanks in advance :) 
To seed a program, you can put it under a handler
```
with handlers.seed(rng_seed=0):
    # random_flax_module...
```
That's what I thought, just wanted to make sure I don't overlook any subtlety :) Thanks again! 

Resolving patch:
diff --git a/numpyro/primitives.py b/numpyro/primitives.py
--- a/numpyro/primitives.py
+++ b/numpyro/primitives.py
@@ -622,6 +622,10 @@ def prng_key():
     :return: a PRNG key of shape (2,) and dtype unit32.
     """
     if not _PYRO_STACK:
+        warnings.warn(
+            "Cannot generate JAX PRNG key outside of `seed` handler.",
+            stacklevel=find_stack_level(),
+        )
         return
 
     initial_msg = {


Test patch:
diff --git a/test/test_handlers.py b/test/test_handlers.py
--- a/test/test_handlers.py
+++ b/test/test_handlers.py
@@ -778,7 +778,8 @@ def guide():
 
 
 def test_prng_key():
-    assert numpyro.prng_key() is None
+    with pytest.warns(Warning, match="outside of `seed`"):
+        assert numpyro.prng_key() is None
 
     with handlers.seed(rng_seed=0):
         rng_key = numpyro.prng_key()
Repository: nipy/nipype

Issue:
ApplyXFM does not set default value of required flag
from @davidgutman

Just noticed this, after scratching my head for a bit....  by default
it seems the ApplyXfm doesn't bass the applyxfm.inputs.apply_xfm=True
parameter... in which case it is rerunning the registration ...

I couldn't figure out why my transformation was working oddly and
realized it's because that flag wasn't being passed, and I
inadvertently assumed that that was the default behavior of ApplyXfm
(i.e. to apply an XFM)....

Not sure if this should be changed or not as the default behavior that
can be overridden (in which case.. you'd probably just want to use
fsl.FLIRT() anyway)..

More of a semantics thing I guess..

ApplyXfm
Code: http://github.com/nipy/nipype/blob/master/nipype/interfaces/fsl/preprocess.py#L495

Wraps command flirt

Currently just a light wrapper around FLIRT, with no modifications

ApplyXfm is used to apply an existing tranform to an image

Examples

> > > import nipype.interfaces.fsl as fsl
> > > from nipype.testing import example_data
> > > applyxfm = fsl.ApplyXfm()
> > > applyxfm.inputs.in_file = example_data('structural.nii')
> > > applyxfm.inputs.in_matrix_file = example_data('trans.mat')
> > > applyxfm.inputs.out_file = 'newfile.nii'
> > > applyxfm.inputs.reference = example_data('mni.nii')
> > > applyxfm.inputs.apply_xfm = True
> > > result = applyxfm.run()
> > > Inputs:

[Mandatory]
in_file: (an existing file name)
        input file
reference: (an existing file name)
        reference file

[Optional]
angle_rep: ('quaternion' or 'euler')
        representation of rotation angles
apply_xfm: (a boolean)
        apply transformation supplied by in_matrix_file
## 

David A Gutman, M.D. Ph.D.



Discussion:
Hey,

I just started building my own preproc-pipeline and just found out about this and wanted to post this issue. It took me a lot of time and frustration to figure out today. I do love the software so keep up the good work.

:)


Resolving patch:
diff --git a/nipype/interfaces/fsl/preprocess.py b/nipype/interfaces/fsl/preprocess.py
--- a/nipype/interfaces/fsl/preprocess.py
+++ b/nipype/interfaces/fsl/preprocess.py
@@ -522,6 +522,10 @@ def _gen_filename(self, name):
         else:
             return None
 
+class ApplyXfmInputSpec(FLIRTInputSpec):
+    apply_xfm = traits.Bool(True, argstr='-applyxfm', requires=['in_matrix_file'],
+                     desc='apply transformation supplied by in_matrix_file', usedefault=True)
+
 
 class ApplyXfm(FLIRT):
     """Currently just a light wrapper around FLIRT,
@@ -544,7 +548,7 @@ class ApplyXfm(FLIRT):
     >>> result = applyxfm.run() # doctest: +SKIP
 
     """
-    pass
+    input_spec = ApplyXfmInputSpec
 
 
 class MCFLIRTInputSpec(FSLCommandInputSpec):


Test patch:
Repository: nipy/nipype

Issue:
Missing mask1 and mask2 arguments in doc example for Similarity
The mandatory arguments mask1 and mask2 are missing from the example here:

http://nipy.sourceforge.net/nipype/interfaces/generated/nipype.interfaces.nipy.utils.html



Discussion:

Resolving patch:
diff --git a/nipype/interfaces/nipy/utils.py b/nipype/interfaces/nipy/utils.py
--- a/nipype/interfaces/nipy/utils.py
+++ b/nipype/interfaces/nipy/utils.py
@@ -1,3 +1,11 @@
+"""
+    Change directory to provide relative paths for doctests
+    >>> import os
+    >>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
+    >>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
+    >>> os.chdir(datadir)
+
+"""
 import warnings
 
 import nibabel as nb
@@ -50,6 +58,8 @@ class Similarity(BaseInterface):
     >>> similarity = Similarity()
     >>> similarity.inputs.volume1 = 'rc1s1.nii'
     >>> similarity.inputs.volume2 = 'rc1s2.nii'
+    >>> similarity.inputs.mask1 = 'mask.nii'
+    >>> similarity.inputs.mask2 = 'mask.nii'
     >>> similarity.inputs.metric = 'cr'
     >>> res = similarity.run() # doctest: +SKIP
     """


Test patch:
Repository: nipy/nipype

Issue:
Fixed AttributeError in Refit
Before these changes I was getting this:

131113-10:53:15,735 workflow INFO:
     Running: 3drefit -deoblique /tmp/tmp0nwzz7/func_preproc/func_deoblique/rest_calc.nii.gz...

.../lib/python2.7/site-packages/nipype/interfaces/afni/preprocess.py", line 200, in _list_outputs
    self.outputs["out_file"] = os.path.abspath(self.inputs.in_file)
AttributeError: 'Refit' object has no attribute 'outputs'
Interface Refit failed to run.

The changes allow the workflow to complete successfully. Let me know your thoughts.



Discussion:
But line 200 of /interfaces/afni/preprocess.py 
outputs["out_file"] = os.path.abspath(self.inputs.in_file)
not
self.outputs["out_file"] = os.path.abspath(self.inputs.in_file)

https://github.com/nipy/nipype/blob/master/nipype/interfaces/afni/preprocess.py#L199

Maybe you did not check out properly or had some left over changes?

I'm not sure what you mean - I added the "self.outputs" change so that it would work with the output dict initialization that happens within the class but outside of the class function _list_outputs.

It runs with this change, does it crash for you?


Resolving patch:
diff --git a/nipype/interfaces/afni/preprocess.py b/nipype/interfaces/afni/preprocess.py
--- a/nipype/interfaces/afni/preprocess.py
+++ b/nipype/interfaces/afni/preprocess.py
@@ -195,7 +195,7 @@ class Refit(CommandLine):
     output_spec = AFNICommandOutputSpec
 
     def _list_outputs(self):
-        outputs = super(Refit, self)._list_outputs()
+        outputs = self.output_spec().get()
         outputs["out_file"] = os.path.abspath(self.inputs.in_file)
         return outputs
 


Test patch:
Repository: nipy/nipype

Issue:
LSF plugin does not apply workflow bsub_args
The LSF plugin does not respect a `bsub_args` set on the workflow, e.g.:

``` python
metaflow.run(
    plugin="LSF",
    plugin_args={"bsub_args": "-q xl_jobs"}
)
```

does not add the "-q xl_jobs" to the command as `self._bsub_args` in [lsf.py line 65](https://github.com/nipy/nipype/blob/master/nipype/pipeline/plugins/lsf.py#L65) is never set in `__init__`. Only `self._qsub_args` is set in [SGELikeBatchManagerBase line 465](https://github.com/nipy/nipype/blob/master/nipype/pipeline/plugins/base.py#L465) (the super class).

I will provide a simple pull request to fix this.



Discussion:

Resolving patch:
diff --git a/nipype/pipeline/plugins/lsf.py b/nipype/pipeline/plugins/lsf.py
--- a/nipype/pipeline/plugins/lsf.py
+++ b/nipype/pipeline/plugins/lsf.py
@@ -36,6 +36,8 @@ def __init__(self, **kwargs):
                 self._retry_timeout = kwargs['plugin_args']['retry_timeout']
             if  'max_tries' in kwargs['plugin_args']:
                 self._max_tries = kwargs['plugin_args']['max_tries']
+            if 'bsub_args' in kwargs['plugin_args']:
+                self._bsub_args = kwargs['plugin_args']['bsub_args']
         super(LSFPlugin, self).__init__(template, **kwargs)
 
     def _is_pending(self, taskid):


Test patch:
Repository: nipy/nipype

Issue:
TraitError: The 'luts' trait of a PicoPDFsInputSpec instance must be a list of from 1 to 3 items which are an existing file name, but a value of '/_subject_id_subj1/dtlutgen/bvecs.dat' <type 'str'> was specified.
When trying to run the demo "dmri_camino_dti.py" I encountered the following problem with the PicoPDFsInputSpec:

TraitError: The 'luts' trait of a PicoPDFsInputSpec instance must be a list of from 1 to 3 items which are an existing file name, but a value of '/_subject_id_subj1/dtlutgen/bvecs.dat' <type 'str'> was specified.
Error setting node input:
Node: picopdfs
input: luts

I browsed through the source code and I believe that the error lies in these two code snippits which are incompatible:

from interfaces/camino.dti.py in class PicoPDFsInputSpec:

``` python
luts = traits.List(File(exists=True), argstr='-luts %s', ...)
```

and in the same file in class DTLUTGenOutputSpec

``` python
dtLUT = File(exists=True, desc='Lookup Table')
```

and the code in the script:

``` python
dtlutgen = pe.Node(interface=camino.DTLUTGen(), name="dtlutgen")
dtlutgen.inputs.snr = 16.0
dtlutgen.inputs.inversion = 1
...
picopdfs = pe.Node(interface=camino.PicoPDFs(), name="picopdfs")
picopdfs.inputs.inputmodel = 'dt'
...
tractography.connect([(dtlutgen, picopdfs,[("dtLUT","luts")])])
```

It seems that the PicoDFSs requires a list as input (with a file in it), while the dtlutgen gives a file as output. 



Discussion:

Resolving patch:
diff --git a/nipype/interfaces/camino/dti.py b/nipype/interfaces/camino/dti.py
--- a/nipype/interfaces/camino/dti.py
+++ b/nipype/interfaces/camino/dti.py
@@ -8,7 +8,8 @@
 """
 from nipype.interfaces.base import (CommandLineInputSpec, CommandLine, traits,
                                     TraitedSpec, File, StdOutCommandLine,
-                                    StdOutCommandLineInputSpec, isdefined)
+                                    StdOutCommandLineInputSpec, isdefined,
+                                    InputMultiPath)
 from nipype.utils.filemanip import split_filename
 import os
 
@@ -337,7 +338,7 @@ class PicoPDFsInputSpec(StdOutCommandLineInputSpec):
     inputmodel = traits.Enum('dt', 'multitensor', 'pds',
         argstr='-inputmodel %s', position=2, desc='input model type', usedefault=True)
 
-    luts = traits.List(File(exists=True), argstr='-luts %s', minlen=1, maxlen=3, mandatory=True,
+    luts = InputMultiPath(File(exists=True), argstr='-luts %s', mandatory=True,
         desc='Files containing the lookup tables.'\
         'For tensor data, one lut must be specified for each type of inversion used in the image (one-tensor, two-tensor, three-tensor).'\
         'For pds, the number of LUTs must match -numpds (it is acceptable to use the same LUT several times - see example, above).'\


Test patch:
Repository: nipy/nipype

Issue:
FSL-Melodic bug
Hello,

I want to report a bug I have found when I was trying to execute melodic to get the networks of a group of subjects with the temporal concatenation option. I couldn't get any results in the directory I was indicating in the out_dir parameter and the report wasn't generated when the report parameter was set to true. I have found that the problem is that the separator that has to be specified for the in_files parameter in the MELODICInputSpec is a comma instead of a blank space (set by default):

in_files = InputMultiPath(
        File(exists=True), argstr="-i %s", mandatory=True, position=0, sep=",",
        desc="input file names (either single file name or a list)")

[model.py, line 1273]

I hope this helps to solve this issue in the next version of the package.

Thanks.



Discussion:

Resolving patch:
diff --git a/nipype/interfaces/fsl/model.py b/nipype/interfaces/fsl/model.py
--- a/nipype/interfaces/fsl/model.py
+++ b/nipype/interfaces/fsl/model.py
@@ -1272,7 +1272,8 @@ def _list_outputs(self):
 class MELODICInputSpec(FSLCommandInputSpec):
     in_files = InputMultiPath(
         File(exists=True), argstr="-i %s", mandatory=True, position=0,
-        desc="input file names (either single file name or a list)")
+        desc="input file names (either single file name or a list)",
+        sep=",")
     out_dir = Directory(
         argstr="-o %s", desc="output directory name", genfile=True)
     mask = File(exists=True, argstr="-m %s",


Test patch:
diff --git a/nipype/interfaces/fsl/tests/test_auto_MELODIC.py b/nipype/interfaces/fsl/tests/test_auto_MELODIC.py
--- a/nipype/interfaces/fsl/tests/test_auto_MELODIC.py
+++ b/nipype/interfaces/fsl/tests/test_auto_MELODIC.py
@@ -32,6 +32,7 @@ def test_MELODIC_inputs():
     in_files=dict(argstr='-i %s',
     mandatory=True,
     position=0,
+    sep=',',
     ),
     log_power=dict(argstr='--logPower',
     ),
Repository: nipy/nipype

Issue:
SGE plugin error
@hjmjohnson: seems like this is initialized only `plugin_args` is provided.

```
    415                               lines[-1]).groups()[0])
    416         self._pending[taskid] = node.output_dir()
--> 417         self._refQstatSubstitute.add_startup_job(taskid, cmd.cmdline)
    418         logger.debug('submitted sge task: %d for node %s with %s' %
    419                      (taskid, node._id, cmd.cmdline))

AttributeError: 'SGEPlugin' object has no attribute '_refQstatSubstitute'
```



Discussion:

Resolving patch:
diff --git a/nipype/pipeline/plugins/sge.py b/nipype/pipeline/plugins/sge.py
--- a/nipype/pipeline/plugins/sge.py
+++ b/nipype/pipeline/plugins/sge.py
@@ -350,8 +350,7 @@ def __init__(self, **kwargs):
                 instantQstat = kwargs['plugin_args']['qstatProgramPath']
             if 'qstatCachedProgramPath' in kwargs['plugin_args']:
                 cachedQstat = kwargs['plugin_args']['qstatCachedProgramPath']
-            self._refQstatSubstitute = QstatSubstitute(
-                instantQstat, cachedQstat)
+        self._refQstatSubstitute = QstatSubstitute(instantQstat, cachedQstat)
 
         super(SGEPlugin, self).__init__(template, **kwargs)
 


Test patch:
Repository: nipy/nipype

Issue:
interfaces.afni.preprocess.Copy creates incorrect 3dcopy command
When using outputtype = 'AFNI', interfaces.afni.preprocess.Copy will incorrectly add the -prefix flag to the 3dcopy command, like so:

c = afni.Copy()
c.inputs.in_file = 'bold1.nii.gz'
c.inputs.out_file = 'testcopy'
c.inputs.outputtype = 'AFNI'
c.cmdline

> '3dcopy -prefix testcopy bold1.nii.gz'

To which AFNI will reply:

Standard error:
++ 3dcopy: AFNI version=AFNI_2011_12_21_1014 (Sep 18 2014) [64-bit]
*\* FATAL ERROR: unknown option: -prefix
*\* Program compile date = Sep 18 2014
Return code: 1
Interface Copy failed to run. 



Discussion:

Resolving patch:
diff --git a/nipype/interfaces/afni/preprocess.py b/nipype/interfaces/afni/preprocess.py
--- a/nipype/interfaces/afni/preprocess.py
+++ b/nipype/interfaces/afni/preprocess.py
@@ -676,7 +676,7 @@ class CopyInputSpec(AFNICommandInputSpec):
                    exists=True,
                    copyfile=False)
     out_file = File(name_template="%s_copy", desc='output image file name',
-                    argstr='-prefix %s', name_source="in_file")
+                    argstr='%s', position=-1, name_source="in_file")
 
 
 class Copy(AFNICommand):
@@ -690,11 +690,26 @@ class Copy(AFNICommand):
     ========
 
     >>> from nipype.interfaces import afni as afni
-    >>> copy = afni.Copy()
-    >>> copy.inputs.in_file = 'functional.nii'
-    >>> copy.inputs.out_file = 'new_func.nii'
-    >>> res = copy.run() # doctest: +SKIP
-
+    >>> copy3d = afni.Copy()
+    >>> copy3d.inputs.in_file = 'functional.nii'
+    >>> copy3d.cmdline
+    '3dcopy functional.nii functional_copy'
+
+    >>> from copy import deepcopy
+    >>> copy3d_2 = deepcopy(copy3d)
+    >>> copy3d_2.inputs.outputtype = 'NIFTI'
+    >>> copy3d_2.cmdline
+    '3dcopy functional.nii functional_copy.nii'
+
+    >>> copy3d_3 = deepcopy(copy3d)
+    >>> copy3d_3.inputs.outputtype = 'NIFTI_GZ'
+    >>> copy3d_3.cmdline
+    '3dcopy functional.nii functional_copy.nii.gz'
+
+    >>> copy3d_4 = deepcopy(copy3d)
+    >>> copy3d_4.inputs.out_file = 'new_func.nii'
+    >>> copy3d_4.cmdline
+    '3dcopy functional.nii new_func.nii'
     """
 
     _cmd = '3dcopy'


Test patch:
diff --git a/nipype/interfaces/afni/tests/test_auto_Copy.py b/nipype/interfaces/afni/tests/test_auto_Copy.py
--- a/nipype/interfaces/afni/tests/test_auto_Copy.py
+++ b/nipype/interfaces/afni/tests/test_auto_Copy.py
@@ -16,9 +16,10 @@ def test_Copy_inputs():
     mandatory=True,
     position=-2,
     ),
-    out_file=dict(argstr='-prefix %s',
+    out_file=dict(argstr='%s',
     name_source='in_file',
     name_template='%s_copy',
+    position=-1,
     ),
     outputtype=dict(),
     terminal_output=dict(nohash=True,