B
    W0d	                 @  s   d Z ddlmZ ddlZddlmZ ddlmZ ddl	m
Z
mZ ddlmZ ddlmZ dd	lmZmZmZmZmZmZmZ dd
ddddZddddddZdS )z
This is a pseudo-public API for downstream libraries.  We ask that downstream
authors

1) Try to avoid using internals directly altogether, and failing that,
2) Use only functions exposed here (or in core.internals)

    )annotationsN)BlockPlacement)Dtype)is_datetime64tz_dtypepandas_dtype)DatetimeArray)extract_array)BlockDatetimeTZBlock
check_ndimensure_block_shapeextract_pandas_arrayget_block_typemaybe_coerce_valueszDtype | Noner	   )dtypereturnc             C  s   |dk	rt |}t| ||\} }|dkr>|p0| j}t| |}n |tkr^t| js^tj| |d} t|t	spt	|}t
| ||}t| jrt| dd} t| |} t| || t| } || ||dS )a+  
    This is a pseudo-public analogue to blocks.new_block.

    We ask that downstream libraries use this rather than any fully-internal
    APIs, including but not limited to:

    - core.internals.blocks.make_block
    - Block.make_block
    - Block.make_block_same_class
    - Block.__init__
    N)r   T)Zextract_numpy)ndim	placement)r   r   r   r   r
   r   r   Z_simple_new
isinstancer   maybe_infer_ndimr   r   r   r   )valuesr   klassr   r    r   K/var/www/html/venv/lib/python3.7/site-packages/pandas/core/internals/api.py
make_block"   s"    



r   r   z
int | Noneint)r   r   r   c             C  s8   |dkr4t | jtjs.t|dkr(d}q4d}n| j}|S )zG
    If `ndim` is not provided, infer it from placment and values.
    N      )r   r   nplenr   )r   r   r   r   r   r   r   K   s    r   )NNN)__doc__
__future__r   numpyr   Zpandas._libs.internalsr   Zpandas._typingr   Zpandas.core.dtypes.commonr   r   Zpandas.core.arraysr   Zpandas.core.constructionr   Zpandas.core.internals.blocksr	   r
   r   r   r   r   r   r   r   r   r   r   r   <module>   s   $(