3
���h?h � @ s d Z ddlZddlZddlmZmZmZmZmZ ddl
mZm
Z ejjjZddljZddlmZmZmZmZmZmZmZmZ ejjZdddd d
dgZdd
ddgZd"dd�Zdd� Z G dd� de�Z!dd� Z"e!Z#d#dd�Zddddddddef dd �Z
dd� Z$dd� Z%d$d d
�Z&d%d!d�Z'dS )&a, :mod:`numpy.ma..mrecords`
Defines the equivalent of :class:`numpy.recarrays` for masked arrays,
where fields can be accessed as attributes.
Note that :class:`numpy.ma.MaskedArray` already supports structured datatypes
and the masking of individual fields.
.. moduleauthor:: Pierre Gerard-Marchant
� N)�bool_�dtype�ndarray�recarray�array)�
fromarrays�fromrecords)�MAError�MaskedArray�masked�nomask�masked_array�getdata�getmaskarray�filled�
MaskedRecords� mrecarrayr r �fromtextfile�addfield�_data�_mask�
_fieldmaskr c C s� t | �}dd� t|�D �}|dkr(|}nZt|ttf�r<|}n&t|t�rR|jd�}ntdt|� ��t |�}||k r�|||d� 7 }g }xbt ||| j
�D ]P\}}}|tkr�|d tkr�|j||d f� q�|j|� q�|j||d f� q�W t
j|�S )z�
Checks that field names ``descr`` are not reserved keywords.
If this is the case, a default 'f%i' is substituted. If the argument
`names` is not None, updates the field names to valid names.
c S s g | ]}d | �qS )zf%i� )�.0�ir r �2/tmp/pip-build-5_djhm0z/numpy/numpy/ma/mrecords.py�
<listcomp>6 s z_checknames.<locals>.<listcomp>N�,zillegal input names %sr � )�len�range�
isinstance�tuple�list�str�split� NameError�repr�zip�descr�reserved_fields�append�npr ) r) �namesZndescrZ
default_namesZ new_namesZnnames�n�d�tr r r �_checknames- s(
r1 c C s: dd� | j jD �}tj| j|d�}tdgt|� �|_|S )Nc S s g | ]}|d f�qS )z|b1r )r r. r r r r P s z"_get_fieldmask.<locals>.<listcomp>)r F)r r- r, �empty�shaper" |