B
    q\                 @   s:   d dl mZ d dlZd dlmZ dgZG dd deZdS )    )OrderedDictN)
isiterableFlagCollectionc               @   s    e Zd ZdZdd Zdd ZdS )r   a  
    The purpose of this class is to provide a dictionary for
    containing arrays of flags for the `NDData` class. Flags should be
    stored in Numpy arrays that have the same dimensions as the parent
    data, so the `FlagCollection` class adds shape checking to an
    ordered dictionary class.

    The `FlagCollection` should be initialized like an
    `~collections.OrderedDict`, but with the addition of a ``shape=``
    keyword argument used to pass the NDData shape.
    c             O   sF   d|kr(| d| _t| js0tdntdtj| f|| d S )Nshapez1FlagCollection shape should be an iterable objectz?FlagCollection should be initialized with the shape of the data)popr   r   
ValueError	Exceptionr   __init__)selfargskwargs r   =lib/python3.7/site-packages/astropy/nddata/flag_collection.pyr	      s    

zFlagCollection.__init__c             K   sN   t |tjrB|j| jkr,tj| ||f| qJtd|j| jntdd S )Nz3flags array shape {0} does not match data shape {1}z&flags should be given as a Numpy array)	
isinstancenpZndarrayr   r   __setitem__r   format	TypeError)r
   itemvaluer   r   r   r   r   '   s    zFlagCollection.__setitem__N)__name__
__module____qualname____doc__r	   r   r   r   r   r   r      s   )collectionsr   Znumpyr   Zastropy.utils.miscr   __all__r   r   r   r   r   <module>   s   