zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
U
O±dCã@sdZddlmZmZmZddlmZmZdgZddddddddddd    d    d
d
d œZ    dd d œdd„Z
eedƒdd d œdd„ƒƒZ ee
dde ƒZ d S)z–
Functions in the ``as*array`` family that promote array-likes into arrays.
 
`require` fits this category despite its name not matching this pattern.
é)Úarray_function_dispatchÚset_array_function_like_docÚ
set_module)ÚarrayÚ
asanyarrayÚrequireÚCÚFÚAÚWÚOÚE)rZ C_CONTIGUOUSZ
CONTIGUOUSr    Z F_CONTIGUOUSZFORTRANr
ZALIGNEDr Z    WRITEABLEr ZOWNDATAr Z ENSUREARRAYN)ÚlikecCs|fS)N©)ÚaÚdtypeÚ requirementsrrrúJd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\numpy/core/_asarray.pyÚ_require_dispatchersrÚnumpycCsÒ|dk    rt||||dS|s(t||dSdd„|Dƒ}d|krN| d¡d}nd}d    }|d
d hkrltd ƒ‚n.d |kr„d }| d ¡nd
|kršd
}| d
¡t|||d|d }|D]}|j|s°| |¡Sq°|S)a¹
    Return an ndarray of the provided type that satisfies requirements.
 
    This function is useful to be sure that an array with the correct flags
    is returned for passing to compiled code (perhaps through ctypes).
 
    Parameters
    ----------
    a : array_like
       The object to be converted to a type-and-requirement-satisfying array.
    dtype : data-type
       The required data-type. If None preserve the current dtype. If your
       application requires the data to be in native byteorder, include
       a byteorder specification as a part of the dtype specification.
    requirements : str or sequence of str
       The requirements list can be any of the following
 
       * 'F_CONTIGUOUS' ('F') - ensure a Fortran-contiguous array
       * 'C_CONTIGUOUS' ('C') - ensure a C-contiguous array
       * 'ALIGNED' ('A')      - ensure a data-type aligned array
       * 'WRITEABLE' ('W')    - ensure a writable array
       * 'OWNDATA' ('O')      - ensure an array that owns its own data
       * 'ENSUREARRAY', ('E') - ensure a base array, instead of a subclass
    ${ARRAY_FUNCTION_LIKE}
 
        .. versionadded:: 1.20.0
 
    Returns
    -------
    out : ndarray
        Array with specified requirements and type if given.
 
    See Also
    --------
    asarray : Convert input to an ndarray.
    asanyarray : Convert to an ndarray, but pass through ndarray subclasses.
    ascontiguousarray : Convert input to a contiguous array.
    asfortranarray : Convert input to an ndarray with column-major
                     memory order.
    ndarray.flags : Information about the memory layout of the array.
 
    Notes
    -----
    The returned array will be guaranteed to have the listed requirements
    by making a copy if needed.
 
    Examples
    --------
    >>> x = np.arange(6).reshape(2,3)
    >>> x.flags
      C_CONTIGUOUS : True
      F_CONTIGUOUS : False
      OWNDATA : False
      WRITEABLE : True
      ALIGNED : True
      WRITEBACKIFCOPY : False
 
    >>> y = np.require(x, dtype=np.float32, requirements=['A', 'O', 'W', 'F'])
    >>> y.flags
      C_CONTIGUOUS : False
      F_CONTIGUOUS : True
      OWNDATA : True
      WRITEABLE : True
      ALIGNED : True
      WRITEBACKIFCOPY : False
 
    N)rrr)rcSsh|]}t| ¡’qSr)ÚPOSSIBLE_FLAGSÚupper)Ú.0ÚxrrrÚ    <setcomp>pszrequire.<locals>.<setcomp>r FTr
rr    z%Cannot specify both "C" and "F" order)rÚorderÚcopyÚsubok)Ú_require_with_likerÚremoveÚ
ValueErrorrÚflagsr)rrrrrrZarrÚproprrrrs8Fü 
 
 
 
T)Zuse_like)NN)NN) Ú__doc__Z    overridesrrrZ
multiarrayrrÚ__all__rrrrrrrrÚ<module>s8ú
iÿþ