hyb
2026-01-07 c7f60dc7e9a36596f0e0d1787bd0cca4e9b57bcb
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
Ë
KñúhÖ2ãó”—ddlZddlmZddlZddlmZddlmZm    Z    m
Z
dgZ eZ gd¢Z dd    gZd
d dd    d œZed «Gd„de    ««Zy)éN)Ú nullcontext)Ú
set_moduleé)ÚdtypeÚndarrayÚuint8Úmemmap)ÚrÚcúr+úw+r r r
r )ÚreadonlyÚ copyonwriteÚ    readwriteÚwriteÚnumpycóP‡—eZdZdZdZeddddfd„Zd„Zd    „Zd ˆfd
„    Z    ˆfd „Z
ˆxZ S) r    aYCreate a memory-map to an array stored in a *binary* file on disk.
 
    Memory-mapped files are used for accessing small segments of large files
    on disk, without reading the entire file into memory.  NumPy's
    memmap's are array-like objects.  This differs from Python's ``mmap``
    module, which uses file-like objects.
 
    This subclass of ndarray has some unpleasant interactions with
    some operations, because it doesn't quite fit properly as a subclass.
    An alternative to using this subclass is to create the ``mmap``
    object yourself, then create an ndarray with ndarray.__new__ directly,
    passing the object created in its 'buffer=' parameter.
 
    This class may at some point be turned into a factory function
    which returns a view into an mmap buffer.
 
    Flush the memmap instance to write the changes to the file. Currently there
    is no API to close the underlying ``mmap``. It is tricky to ensure the
    resource is actually closed, since it may be shared between different
    memmap instances.
 
 
    Parameters
    ----------
    filename : str, file-like object, or pathlib.Path instance
        The file name or file object to be used as the array data buffer.
    dtype : data-type, optional
        The data-type used to interpret the file contents.
        Default is `uint8`.
    mode : {'r+', 'r', 'w+', 'c'}, optional
        The file is opened in this mode:
 
        +------+-------------------------------------------------------------+
        | 'r'  | Open existing file for reading only.                        |
        +------+-------------------------------------------------------------+
        | 'r+' | Open existing file for reading and writing.                 |
        +------+-------------------------------------------------------------+
        | 'w+' | Create or overwrite existing file for reading and writing.  |
        |      | If ``mode == 'w+'`` then `shape` must also be specified.    |
        +------+-------------------------------------------------------------+
        | 'c'  | Copy-on-write: assignments affect data in memory, but       |
        |      | changes are not saved to disk.  The file on disk is         |
        |      | read-only.                                                  |
        +------+-------------------------------------------------------------+
 
        Default is 'r+'.
    offset : int, optional
        In the file, array data starts at this offset. Since `offset` is
        measured in bytes, it should normally be a multiple of the byte-size
        of `dtype`. When ``mode != 'r'``, even positive offsets beyond end of
        file are valid; The file will be extended to accommodate the
        additional data. By default, ``memmap`` will start at the beginning of
        the file, even if ``filename`` is a file pointer ``fp`` and
        ``fp.tell() != 0``.
    shape : int or sequence of ints, optional
        The desired shape of the array. If ``mode == 'r'`` and the number
        of remaining bytes after `offset` is not a multiple of the byte-size
        of `dtype`, you must specify `shape`. By default, the returned array
        will be 1-D with the number of elements determined by file size
        and data-type.
 
        .. versionchanged:: 2.0
         The shape parameter can now be any integer sequence type, previously
         types were limited to tuple and int.
 
    order : {'C', 'F'}, optional
        Specify the order of the ndarray memory layout:
        :term:`row-major`, C-style or :term:`column-major`,
        Fortran-style.  This only has an effect if the shape is
        greater than 1-D.  The default order is 'C'.
 
    Attributes
    ----------
    filename : str or pathlib.Path instance
        Path to the mapped file.
    offset : int
        Offset position in the file.
    mode : str
        File mode.
 
    Methods
    -------
    flush
        Flush any changes in memory to file on disk.
        When you delete a memmap object, flush is called first to write
        changes to disk.
 
 
    See also
    --------
    lib.format.open_memmap : Create or load a memory-mapped ``.npy`` file.
 
    Notes
    -----
    The memmap object can be used anywhere an ndarray is accepted.
    Given a memmap ``fp``, ``isinstance(fp, numpy.ndarray)`` returns
    ``True``.
 
    Memory-mapped files cannot be larger than 2GB on 32-bit systems.
 
    When a memmap causes a file to be created or extended beyond its
    current size in the filesystem, the contents of the new part are
    unspecified. On systems with POSIX filesystem semantics, the extended
    part will be filled with zero bytes.
 
    Examples
    --------
    >>> import numpy as np
    >>> data = np.arange(12, dtype='float32')
    >>> data.resize((3,4))
 
    This example uses a temporary file so that doctest doesn't write
    files to your directory. You would use a 'normal' filename.
 
    >>> from tempfile import mkdtemp
    >>> import os.path as path
    >>> filename = path.join(mkdtemp(), 'newfile.dat')
 
    Create a memmap with dtype and shape that matches our data:
 
    >>> fp = np.memmap(filename, dtype='float32', mode='w+', shape=(3,4))
    >>> fp
    memmap([[0., 0., 0., 0.],
            [0., 0., 0., 0.],
            [0., 0., 0., 0.]], dtype=float32)
 
    Write data to memmap array:
 
    >>> fp[:] = data[:]
    >>> fp
    memmap([[  0.,   1.,   2.,   3.],
            [  4.,   5.,   6.,   7.],
            [  8.,   9.,  10.,  11.]], dtype=float32)
 
    >>> fp.filename == path.abspath(filename)
    True
 
    Flushes memory changes to disk in order to read them back
 
    >>> fp.flush()
 
    Load the memmap and verify data was stored:
 
    >>> newfp = np.memmap(filename, dtype='float32', mode='r', shape=(3,4))
    >>> newfp
    memmap([[  0.,   1.,   2.,   3.],
            [  4.,   5.,   6.,   7.],
            [  8.,   9.,  10.,  11.]], dtype=float32)
 
    Read-only memmap:
 
    >>> fpr = np.memmap(filename, dtype='float32', mode='r', shape=(3,4))
    >>> fpr.flags.writeable
    False
 
    Copy-on-write memmap:
 
    >>> fpc = np.memmap(filename, dtype='float32', mode='c', shape=(3,4))
    >>> fpc.flags.writeable
    True
 
    It's possible to assign to copy-on-write array, but values are only
    written into the memory copy of the array, and not written to disk:
 
    >>> fpc
    memmap([[  0.,   1.,   2.,   3.],
            [  4.,   5.,   6.,   7.],
            [  8.,   9.,  10.,  11.]], dtype=float32)
    >>> fpc[0,:] = 0
    >>> fpc
    memmap([[  0.,   0.,   0.,   0.],
            [  4.,   5.,   6.,   7.],
            [  8.,   9.,  10.,  11.]], dtype=float32)
 
    File on disk is unchanged:
 
    >>> fpr
    memmap([[  0.,   1.,   2.,   3.],
            [  4.,   5.,   6.,   7.],
            [  8.,   9.,  10.,  11.]], dtype=float32)
 
    Offset into a memmap:
 
    >>> fpo = np.memmap(filename, dtype='float32', mode='r', offset=16)
    >>> fpo
    memmap([  4.,   5.,   6.,   7.,   8.,   9.,  10.,  11.], dtype=float32)
 
    gYÀr rNÚCc    óv—ddl}ddl}    t|}|dk(r |€ td«‚t|d«r t|«} n%t|j|«|dk(rd    n|d
z«} | 5} | jdd «| j«} t|«}|j}|€| |z
}||zr td «‚||z}|f}nYt!|t"t
f«s    t%j&|«g}t#|«}t+j,d «}|D]}||z}Œ    t/|||zz«}|dvrGt1|d «}| |kr6| j|d z
d«| j3d«| j5«|dk(r |j6}n|d    k(r |j8}n |j:}|||j<zz
}||z}|dk(r#|dkDr||j<z }||j<z}||z
}|j| j?«|||¬«}tAjB||||||¬«}||_"||_#||_$t!||jJ«r|jM«|_'nXt| d«rEt!| jPtR«r+|jTjW| jP«|_'nd|_'ddd«|S#t$rJ}    |tvr7tt tj ««z}
td|
›d|›d«d‚Yd}    ~    Œd}    ~    wwxYw#t($rYŒ?wxYw#1swYSxYw)Nrzmode must be one of z (got ú)r z#shape must be given if mode == 'w+'Úreadr r
Úbéz?Size of available data is not a multiple of the data-type size.r)r r ó)ÚaccessÚoffset)rÚbufferrÚorderÚname),ÚmmapÚos.pathÚmode_equivalentsÚKeyErrorÚvalid_filemodesÚlistÚkeysÚ
ValueErrorÚhasattrrÚopenÚfspathÚseekÚtellÚ
dtypedescrÚitemsizeÚ
isinstanceÚtupleÚoperatorÚindexÚ    TypeErrorÚnpÚintpÚintÚmaxrÚflushÚ ACCESS_COPYÚ ACCESS_READÚ ACCESS_WRITEÚALLOCATIONGRANULARITYÚfilenorÚ__new__Ú_mmaprÚmodeÚPathLikeÚresolveÚfilenamerÚstrÚpathÚabspath)ÚsubtyperCrr@rÚshaperr ÚosÚeÚ    all_modesÚf_ctxÚfidÚflenÚdescrÚ_dbytesÚbytesÚsizeÚkÚaccÚstartÚ array_offsetÚmmÚselfs                        úEH:\Change_password\venv_build\Lib\site-packages\numpy/_core/memmap.pyr>zmemmap.__new__Øs?€ó    Ûð    Ü# DÑ)ˆDð 4Š<˜E˜MÜÐBÓCÐ Cä 8˜VÔ $Ü Ó)‰E䨗    ‘    ˜(Ó#Ø š ‘¨°Ñ4óˆEð
ðC    %cØ H‰HQ˜ŒNØ—8‘8“:ˆDܘuÓ%ˆEØ—n‘nˆGàˆ}ؘv™ Ø˜7’?Ü$ð&>ó?ð?à Ñ'Ø˜‘ä! %¬%´¨Ô7ðÜ!)§¡°Ó!6Р7˜ô˜e› Ü—w‘w˜q“zØòAؘA‘I‘Dðô˜ ¨¡Ñ/Ó0ˆEà|Ñ#ô˜E 1› Ø˜%’<Ø—H‘H˜U Q™Y¨Ô*Ø—I‘I˜eÔ$Ø—I‘I”KàsŠ{Ø×&Ñ&‘ؘ’Ø×&Ñ&‘à×'Ñ'à˜V d×&@Ñ&@Ñ@Ñ@ˆEØ U‰NˆEð˜Šz˜e ašiؘ×3Ñ3Ñ3Ø˜×3Ñ3Ñ3Ø! E™>ˆLØ—‘˜3Ÿ:™:›<¨°sÀ5ÓIˆBä—?‘? 7¨E¸ÀrØ*6¸eôEˆDàˆDŒJØ ˆDŒK؈DŒIä˜( B§K¡KÔ0ð!)× 0Ñ 0Ó 2• ܘ˜fÔ%¬*°S·X±X¼sÔ*Cà "§¡§¡°·±Ó 9• ð!%” ÷GC    %ðJˆ øôoò    Øœ?Ñ*Ü+¬dÔ3C×3HÑ3HÓ3JÓ.KÑK    Ü Ø*¨9¨-°v¸d¸XÀQÐGóàðõ+ûð    ûôF%òÚðú÷#C    %ðJˆ úsIŠ    KÁ$A0L.ÃLÃ+GL.Ë    LË?LÌLÌ    L+Ì'L.Ì*L+Ì+L.Ì.L8có
—t|d«r[tj||«rE|j|_|j|_|j
|_|j |_yd|_d|_d|_d|_y)Nr?)r(r4Úmay_share_memoryr?rCrr@)rXÚobjs  rYÚ__array_finalize__zmemmap.__array_finalize__8sc€Ü 3˜Ô  ¤R×%8Ñ%8¸¸sÔ%CØŸ™ˆDŒJØŸL™LˆDŒMØŸ*™*ˆDŒKØŸ™ˆDIàˆDŒJØ ˆDŒM؈DŒK؈DIócó€—|j2t|jd«r|jj«yyy)zÜ
        Write any changes in the array to the file on disk.
 
        For further information, see `memmap`.
 
        Parameters
        ----------
        None
 
        See Also
        --------
        memmap
 
        Nr8)Úbaser(r8)rXs rYr8z memmap.flushDs2€ð 9‰9Ð  ¤W¨T¯Y©Y¸Ô%@Ø I‰IO‰OÕ ð&AÐ  r^cóž•—t‰|||«}||ust|«tur|S|r|dS|j    t
j «S)N©)ÚsuperÚ__array_wrap__Útyper    Úviewr4r)rXÚarrÚcontextÚ return_scalarÚ    __class__s    €rYrdzmemmap.__array_wrap__VsPø€Ü‰gÑ$ S¨'Ó2ˆð
3‰;œ$˜t›*¬FÑ2؈Jñ ؐr‘7ˆNðx‰xœŸ
™
Ó#Ð#r^c󌕗t‰||«}t|«tur"|j€|j t ¬«S|S)N)re)rcÚ __getitem__rer    r?rfr)rXr2Úresrjs   €rYrlzmemmap.__getitem__gs=ø€Ü‰gÑ! %Ó(ˆÜ ‹9œÑ  3§9¡9Ð#4Ø—8‘8¤8Ó)Ð )؈
r^)NF) Ú__name__Ú
__module__Ú __qualname__Ú__doc__Ú__array_priority__rr>r]r8rdrlÚ __classcell__)rjs@rYr    r    s>ø„ñ{ðz Ðà).°TÀ!Ø #ó^ò@
òõ$$÷"ðr^)r1Ú
contextlibrrr4Ú numpy._utilsrÚnumericrrrÚ__all__r-r$Úwriteable_filemodesr"r    rbr^rYú<module>ryskðÛÝ"ãÝ#ç*Ñ*à ˆ*€à €
Ú(€Ø˜TlÐðØØØ ñ    Ðñ ˆGÓôSˆWóSóñSr^