One Hat Cyber Team
Your IP :
216.73.216.216
Server IP :
162.240.179.46
Server :
Linux vps-14493116.nutrivittasaude.com.br 5.14.0-687.17.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jun 22 07:21:26 EDT 2026 x86_64
Server Software :
Apache
PHP Version :
8.2.32
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
lib64
/
python3.9
/
site-packages
/
numpy
/
__pycache__
/
View File Name :
ctypeslib.cpython-39.opt-1.pyc
a z[yc4D � @ s` d Z g d�ZddlZddlmZmZmZmZm Z ddl mZmZ zddl Z W n eyb dZ Y n0 e du r�dd� ZeZeZeZddlmZ eZn*ddlm mZ e�� Z[e jZd d � Zdd� Zg d �Zdd� ZG dd� de�Z G dd� de �Z!i Z"d(dd�Z#e du�r\dd� Z$dd� Z%e%� Z&dd� Z'dd� Z(dd� Z)d d!� Z*d"d#� Z+d)d$d%�Zd&d'� ZdS )*a7 ============================ ``ctypes`` Utility Functions ============================ See Also -------- load_library : Load a C library. ndpointer : Array restype/argtype with verification. as_ctypes : Create a ctypes array from an ndarray. as_array : Create an ndarray from a ctypes array. References ---------- .. [1] "SciPy Cookbook: ctypes", https://scipy-cookbook.readthedocs.io/items/Ctypes.html Examples -------- Load the C library: >>> _lib = np.ctypeslib.load_library('libmystuff', '.') #doctest: +SKIP Our result type, an ndarray that must be of type double, be 1-dimensional and is C-contiguous in memory: >>> array_1d_double = np.ctypeslib.ndpointer( ... dtype=np.double, ... ndim=1, flags='CONTIGUOUS') #doctest: +SKIP Our C-function typically takes an array and updates its values in-place. For example:: void foo_func(double* x, int length) { int i; for (i = 0; i < length; i++) { x[i] = i*i; } } We wrap it using: >>> _lib.foo_func.restype = None #doctest: +SKIP >>> _lib.foo_func.argtypes = [array_1d_double, c_int] #doctest: +SKIP Then, we're ready to call ``foo_func``: >>> out = np.empty(15, dtype=np.double) >>> _lib.foo_func(out, len(out)) #doctest: +SKIP )�load_library� ndpointer�c_intp� as_ctypes�as_array�as_ctypes_type� N)�integer�ndarray�dtype�asarray� frombuffer)� _flagdict�flagsobjc O s t d��dS )z� Dummy object that raises an ImportError if ctypes is not available. Raises ------ ImportError If ctypes is not available. zctypes is not available.N)�ImportError)�args�kwds� r �5/usr/lib64/python3.9/site-packages/numpy/ctypeslib.py�_dummyC s r )�intpc C s t jdk r ddl}|jddd� t�| �} t�|�}tj�| �d }|s�ddlm } |� }| | g}|d d �}||ks�|� d| | � n| g}tj�|�}tj�|�s�tj� |�}n|}|D ]F} tj�|| �} tj�| �r�zt j| W S t�y � Y q�0 q�td��dS )a It is possible to load a library using >>> lib = ctypes.cdll[<full_path_name>] # doctest: +SKIP But there are cross-platform considerations, such as library file extensions, plus the fact Windows will just load the first library it finds with that name. NumPy supplies the load_library function as a convenience. .. versionchanged:: 1.20.0 Allow libname and loader_path to take any :term:`python:path-like object`. Parameters ---------- libname : path-like Name of the library, which can have 'lib' as a prefix, but without an extension. loader_path : path-like Where the library can be found. Returns ------- ctypes.cdll[libpath] : library object A ctypes library object Raises ------ OSError If there is no library with the expected extension, or the library is defective and cannot be loaded. z1.0.1r NzAAll features of ctypes interface may not work with ctypes < 1.0.1� )� stacklevel� )�get_shared_lib_extensionT)Z is_python_extzno file with expected extension)�ctypes�__version__�warnings�warn�os�fsdecode�path�splitextZnumpy.distutils.misc_utilr �insert�abspath�isdir�dirname�join�existsZcdll�OSError)ZlibnameZloader_pathr �extr Zso_extZlibname_extZso_ext2�libdirZlnZlibpathr r r r Z s8 ! � r c C s d}| D ]}|t | 7 }q|S �Nr )r )Zflaglist�num�valr r r �_num_fromflags� s r. )ZC_CONTIGUOUSZF_CONTIGUOUSZALIGNEDZ WRITEABLEZOWNDATAZWRITEBACKIFCOPYc C s, g }t D ]}t| }| |@ r|�|� q|S �N)� _flagnamesr �append)r, �res�key�valuer r r �_flags_fromnum� s r5 c @ s e Zd Zedd� �ZdS )�_ndptrc C s� t |t�std��| jd ur6|j| jkr6td| j ��| jd urZ|j| jkrZtd| j ��| jd ur�|j| jkr�tdt | j� ��| j d ur�|jj| j @ | j kr�tdt | j � ��|jS )Nzargument must be an ndarrayzarray must have data type %szarray must have %d dimension(s)zarray must have shape %szarray must have flags %s)� isinstancer � TypeError�_dtype_r �_ndim_�ndim�_shape_�shape�str�_flags_�flagsr, r5 r )�cls�objr r r � from_param� s* � � � ��z_ndptr.from_paramN)�__name__� __module__�__qualname__�classmethodrC r r r r r6 � s r6 c @ s$ e Zd ZdZdd� Zedd� �ZdS )�_concrete_ndptrz� Like _ndptr, but with `_shape_` and `_dtype_` specified. Notably, this means the pointer has enough information to reconstruct the array, which is not generally true. c C s | j S )z� This method is called when this class is used as the .restype attribute for a shared-library function, to automatically wrap the pointer into an array. )�contents)�selfr r r �_check_retval_� s z_concrete_ndptr._check_retval_c C sD t | j| jf�}tj|j }t�| t�|��j}t ||d�j dd�S )z� Get an ndarray viewing the data pointed to by this pointer. This mirrors the `contents` attribute of a normal ctypes pointer �r r )Zaxis)�_dtyper9 r<