
    Pi                       d Z ddlmZ ddlmZ ddlZddlZddlm	Z	 ddl
mZ ddlmZ ddlmZmZmZ dd	lmZmZ dd
lmZ ddlmZmZmZmZmZmZ erddlmZm Z  ddlm!Z! d dZ" G d de          Z#	 d!d"dZ$d#dZ%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)

    )annotations)TYPE_CHECKINGN)BlockPlacement)Pandas4Warning)pandas_dtype)DatetimeTZDtypeExtensionDtypePeriodDtype)DatetimeArrayTimedeltaArray)extract_array)DatetimeLikeBlock
check_ndimensure_block_shapeextract_pandas_arrayget_block_typemaybe_coerce_values)	ArrayLikeDtype)Blockvaluesr   	placement
np.ndarrayreturnr   c                   | j         }t          |          }t          |          }t          |t                    r|j        st          | t          t          f          rt          | d          } t          |           }  || d|          S )a  
    This is an analogue to blocks.new_block(_2d) that ensures:
    1) correct dimension for EAs that support 2D (`ensure_block_shape`), and
    2) correct EA class for datetime64/timedelta64 (`maybe_coerce_values`).

    The input `values` is assumed to be either numpy array or ExtensionArray:
    - In case of a numpy array, it is assumed to already be in the expected
      shape for Blocks (2D, (cols, rows)).
    - In case of an ExtensionArray the input can be 1D, also for EAs that are
      internally stored as 2D.

    For the rest no preprocessing or validation is done, except for those dtypes
    that are internally stored as EAs but have an exact numpy equivalent (and at
    the moment use that numpy dtype), i.e. datetime64/timedelta64.
       )ndimr   r   )
dtyper   r   
isinstancer	   _supports_2dr   r   r   r   )r   r   r   klassplacement_objs        m/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/pandas/core/internals/api.py_make_blockr%   2   s      LE5!!E"9--M5.)) 4e.@ 4Z/F F 4 $F333 ((F5a=9999    c                  "    e Zd ZU dZded<   dZdS )_DatetimeTZBlockz0implement a datetime64 block with a tz attributer   r    N)__name__
__module____qualname____doc____annotations__	__slots__r)   r&   r$   r(   r(   O   s'         ::IIIr&   r(   r   Dtype | Nonec                   t          j        dt          d           |t          |          }t	          | ||          \  } }ddlm} ||u rt          | j        t                    rd}||p| j        }t          |          }n9|t          u r0t          | j        t                    st          j        | |          } t          |t                    st          |          }t!          | ||          }t          | j        t          t          f          r!t#          | d	          } t%          | |          } t'          | ||           t)          |           }  || ||
          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__
    zmake_block is deprecated and will be removed in a future version. Use pd.api.internals.create_dataframe_from_blocks or (recommended) higher-level public APIs instead.r   
stacklevelNr   )ExtensionBlock)r   T)extract_numpyr   )warningswarnr   r   r   pandas.core.internals.blocksr4   r    r   r
   r   r(   r   r   _simple_newr   _maybe_infer_ndimr   r   r   r   )r   r   r"   r   r   r4   s         r$   
make_blockr;   W   s    M	: 	    U##(==MFE;;;;;;:flK#H#H }%u%%	"	"	":flO+T+T	"* 
 
 
 i00 ."9--	VY55D&,o >?? 2 vT:::#FD11vy$''' ((F5di8888r&   r   r   
int | Noneintc                    |?t          | j        t          j                  st          |          dk    rd}n
d}n| j        }|S )H
    If `ndim` is not provided, infer it from placement and values.
    N   r   )r    r   nplenr   r   r   r   s      r$   r:   r:      sJ     |&,11 	9~~"";DKr&   c                \    t          j        dt          d           t          | ||          S )r?   zGmaybe_infer_ndim is deprecated and will be removed in a future version.r   r2   )r6   r7   r   r:   rC   s      r$   maybe_infer_ndimrE      s:     MQ   
 VY555r&   )r   r   r   r   r   r   )NNN)r   r0   r   r   )r   r   r   r<   r   r=   )'r-   
__future__r   typingr   r6   numpyrA   pandas._libs.internalsr   pandas.errorsr   pandas.core.dtypes.commonr   pandas.core.dtypes.dtypesr   r	   r
   pandas.core.arraysr   r   pandas.core.constructionr   r8   r   r   r   r   r   r   pandas._typingr   r   r   r%   r(   r;   r:   rE   r)   r&   r$   <module>rP      s    # " " " " "                  1 1 1 1 1 1 ( ( ( ( ( ( 2 2 2 2 2 2                 3 2 2 2 2 2                 3       
 322222: : : ::    (    EI>9 >9 >9 >9 >9B    	6 	6 	6 	6 	6 	6r&   