a
    ß™fb~  ã                   @   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   sL   d|v r(|  d¡| _t| jƒs0tdƒ‚ntdƒ‚tj| g|¢R i |¤Ž 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.9/site-packages/astropy/nddata/flag_collection.pyr	      s    

zFlagCollection.__init__c                 K   sR   t |tjƒrF|j| jkr0tj| ||fi |¤Ž qNtd |j| j¡ƒ‚ntdƒ‚d S )Nz1flags array shape {} does not match data shape {}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   