a
    yn„fˆ  ã                   @  st   d dl mZ d dlZd dlZd dlmZ d dlmZ dZ	e 
¡ Zeƒ ddddddddddd	d
œdd„ƒZdd„ ZdS )é    )ÚannotationsN)Úhigh_level_function)ÚNumpyMetadata)Ú
to_featherFTÚzstdé   )Ú	list_to32Ústring_to32Úbytestring_to32Úemptyarray_toÚcategorical_as_dictionaryÚextensionarrayÚcount_nullsÚcompressionÚcompression_levelÚ	chunksizeÚfeather_versionc                c  s(   | fV  t | |||||||||	|
||ƒS )u  
    Args:
        array: Array-like data (anything #ak.to_layout recognizes).
        destination (str): Local destination path, passed to
            [pyarrow.feather.write_feather](https://arrow.apache.org/docs/python/generated/pyarrow.feather.write_feather.html#pyarrow.feather.write_feather).
        list_to32 (bool): If True, convert Awkward lists into 32-bit Arrow lists
            if they're small enough, even if it means an extra conversion. Otherwise,
            signed 32-bit #ak.types.ListType maps to Arrow `ListType`,
            signed 64-bit #ak.types.ListType maps to Arrow `LargeListType`,
            and unsigned 32-bit #ak.types.ListType picks whichever Arrow type its
            values fit into.
        string_to32 (bool): Same as the above for Arrow `string` and `large_string`.
        bytestring_to32 (bool): Same as the above for Arrow `binary` and `large_binary`.
        emptyarray_to (None or dtype): If None, #ak.types.UnknownType maps to Arrow's
            null type; otherwise, it is converted a given numeric dtype.
        categorical_as_dictionary (bool): If True, #ak.contents.IndexedArray and
            #ak.contents.IndexedOptionArray labeled with `__array__ = "categorical"`
            are mapped to Arrow `DictionaryArray`; otherwise, the projection is
            evaluated before conversion (always the case without
            `__array__ = "categorical"`).
        extensionarray (bool): If True, this function returns extended Arrow arrays
            (at all levels of nesting), which preserve metadata so that Awkward â†’
            Arrow â†’ Awkward preserves the array's #ak.types.Type (though not
            the #ak.forms.Form). If False, this function returns generic Arrow arrays
            that might be needed for third-party tools that don't recognize Arrow's
            extensions. Even with `extensionarray=False`, the values produced by
            Arrow's `to_pylist` method are the same as the values produced by Awkward's
            #ak.to_list.
        count_nulls (bool): If True, count the number of missing values at each level
            and include these in the resulting Arrow array, which makes some downstream
            applications faster. If False, skip the up-front cost of counting them.
        compression (None or str): Can be one of {â€œzstdâ€�, â€œlz4â€�, â€œuncompressedâ€�}. The
            default of None uses LZ4 for `feather_version=2` files if it is available, otherwise
            uncompressed. Passed to [pyarrow.feather.write_feather](https://arrow.apache.org/docs/python/generated/pyarrow.feather.write_feather.html#pyarrow.feather.write_feather).
        compression_level (None or int): Use a compression level particular to the chosen
            compressor. If None use the default compression level. Passed to [pyarrow.feather.write_feather](https://arrow.apache.org/docs/python/generated/pyarrow.feather.write_feather.html#pyarrow.feather.write_feather).
        chunksize (None or int): For `feather_version=2` files, this is the internal maximum size of Arrow RecordBatch
            chunks when writing the Arrow IPC file format. None means use the
            default, which is currently 64K. Passed to [pyarrow.feather.write_feather](https://arrow.apache.org/docs/python/generated/pyarrow.feather.write_feather.html#pyarrow.feather.write_feather).
        feather_version (int): Feather file version, passed to [pyarrow.feather.write_feather](https://arrow.apache.org/docs/python/generated/pyarrow.feather.write_feather.html#pyarrow.feather.write_feather).
            Version 2 is the current. Version 1 is the more limited legacy format. If not
            provided, version 2 is used.

    Writes an Awkward Array to a Feather file (through pyarrow).

        >>> array = ak.Array([[1.1, 2.2, 3.3], [], [4.4, 5.5]])
        >>> ak.to_feather(array, "filename.feather")

    If the `array` does not contain records at top-level, the Arrow table will
    consist of one field whose name is `""` iff. `extensionarray` is False.

    If `extensionarray` is True`, use a custom Arrow extension to store this array.
    Otherwise, generic Arrow arrays are used, and if the `array` does not
    contain records at top-level, the Arrow table will consist of one field whose
    name is `""`. See #ak.to_arrow_table for more details.

    See also #ak.from_feather.
    )Ú_impl)ÚarrayÚdestinationr   r	   r
   r   r   r   r   r   r   r   r   © r   úc/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/awkward/operations/ak_to_feather.pyr      s     Mór   c              
   C  s¸   dd l }tjjj| dddddddd�}tjj ||||||||¡}|	du rPd}	n|	du s`|	d u rdd}	zt |¡}W n* tyœ   td	t	|ƒj
› d
�ƒd ‚Y n0 |j |||	|
||¡ d S )Nr   TFÚerrorzas-characters)Zallow_recordZallow_unknownZnone_policyZregulararrayZuse_from_iterZprimitive_policyZstring_policyr   ÚnonezC'destination' argument of 'ak.to_feather' must be a path-like, not z2 ('array' argument is first; 'destination' second))Zpyarrow.featherÚakÚ
operationsZak_to_layoutr   Zak_to_arrow_tableÚosÚfsdecodeÚ	TypeErrorÚtypeÚ__name__ZfeatherZwrite_feather)r   r   r	   r
   r   r   r   r   r   r   r   r   r   ZpyarrowZlayoutÚtabler   r   r   r   o   sH    øøÿþÿr   )Ú
__future__r   r   Zawkwardr   Zawkward._dispatchr   Zawkward._nplikes.numpy_liker   Ú__all__ÚinstanceÚmetadatar   r   r   r   r   r   Ú<module>   s(   ò_