3
d                 @   s:   d Z ddlZddlZddlZddlZdd ZdddZdS )z) Useful Functions for working with matlab    Nc             C   s   t jt j| tdS )z0Trivial little function to make 1xN float vector)Zdtype)npZ
atleast_2darrayfloat)vals r   :/tmp/pip-build-7vycvbft/nipype/nipype/utils/matlabtools.pyfltcols   s    r   c             C   sf   t jd}xVtdD ]B}tjdd| d}tjjtjj|j	d }|j
|rNP |j  qW td|S )a  Returns a temporary file-like object with valid matlab name.

    The file name is accessible as the .name attribute of the returned object.
    The caller is responsible for closing the returned object, at which time
    the underlying file gets deleted from the filesystem.

    Parameters
    ----------

      dir : str
        A path to use as the starting directory.  Note that this directory must
        already exist, it is NOT created if it doesn't (in that case, OSError
        is raised instead).

    Returns
    -------
      f : A file-like object.

    Examples
    --------

    >>> fn = mlab_tempfile()
    >>> import os
    >>> filename = os.path.basename(fn.name)
    >>> '-' not in filename
    True
    >>> fn.close()

    z^\w+$d   z.mZtmp_matlab_)suffixprefixdirr   z(Could not make temp file after 100 tries)recompilerangetempfileNamedTemporaryFileospathsplitextbasenamenamematchclose
ValueError)r   Z
valid_namenffnamer   r   r   mlab_tempfile   s    

r   )N)__doc__r   r   r   numpyr   r   r   r   r   r   r   <module>   s   