s42chen commited on
Commit
dbf69a9
·
verified ·
1 Parent(s): f9a9207

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. shared/package-files/15/1539ad7e8aa4b8df03778f1fe5381d928928c5837be7172747bf07c3e6cb4a78/pool.py +957 -0
  2. shared/package-files/15/15a709247c4f00fe846dd0ef5e9fef393d0cb63e338b941acea5b0c9d91d14e6/test_misc.py +817 -0
  3. shared/package-files/16/16033882a6d6169e8ab949d59fe1fc5085d9813c9d05e3b10dd6de6c9d06a547/Beirut +0 -0
  4. shared/package-files/16/16057baf8869a43ae675c8ed37fa22cbc022075ab517c84ff14080e58d1b0454/__main__.py +11 -0
  5. shared/package-files/16/1615c5f580983a25a294b6338e5133235341fda0dc79b4dbf38ffc201006675c/test_interval_example.py +242 -0
  6. shared/package-files/16/16174d2cf8c2ee4b900bf8573106bc61c1ce0092da4fa781cc0ee81047a46539/LICENSE +21 -0
  7. shared/package-files/16/161bc121d645c5143e753c246ffd2669d44a815042694310cfd239c6a8c4e624/languages.py +352 -0
  8. shared/package-files/16/16202e5d3dd3db194a39a8e3410eb9459308ceead1e5ba8b3f614567f5f17a80/parse.py +151 -0
  9. shared/package-files/16/1621ac63f7f370877e0f57bf09ddd5e5f95f0d2cc980e98713fe5acafb9b3cda/clip.h +63 -0
  10. shared/package-files/16/16250f6a659bf706f1c2b5552ad817c8688ba5bb02112f5b63da182bd752872a/utils.h +142 -0
  11. shared/package-files/16/162ad6a69cbabc486b6d8fa6503971c856ac28c734ef9d0a794ad1d1803fed8e/utils.py +15 -0
  12. shared/package-files/16/162b711c973429ddad4b91de60a5aae6f236df82e752f97aa0e4c7c885927917/sparse_sampled_addmm_native.h +24 -0
  13. shared/package-files/16/162d579e3864086d2da78dc072fa486a2bc3f98445a6e7e8e9f78622b7a7403a/_f_e_a_t.py +15 -0
  14. shared/package-files/16/163075cd4fb5bcc7339b62c5006a8bcd855bd839af6804216dd0b1ecc17346ac/adaptive_avg_pool3d_native.h +24 -0
  15. shared/package-files/16/16315ccfc573643485fa747e7456f2775c332f95d0a6ea48d1d6f6fabd05c8fe/span.h +132 -0
  16. shared/package-files/16/163614ad430017b84ece985a5c40ffffcca3785d074dc7194baab4e7ffeb1f8e/test_show_versions.py +81 -0
  17. shared/package-files/16/1636d924c27e84973e7d8272ee6aeaf8738702b9975290c0af58b5fcf84bdb48/_adaptive_avg_pool2d_backward_cuda_dispatch.h +23 -0
  18. shared/package-files/16/163b071d43e7da3411202efb5d2b90659ce4954f96087a447b155833d1c94eae/complex_compositeexplicitautograd_dispatch.h +23 -0
  19. shared/package-files/16/163bba5a7779d7347e96d8d948a5633f62d59ad18aa0f39d83b847c0088a9ffe/op_benchmark.py +103 -0
  20. shared/package-files/16/163e100a5507b6f3e19b191a44ccc141f6eed1dbd01d937b38d2e737ee20a84a/special_xlog1py_meta_dispatch.h +25 -0
  21. shared/package-files/16/163f29e6a13e46bd65a80c87234692802dd1617e7a3be816c28eb0bbe7944180/__init__.py +1 -0
  22. shared/package-files/16/1641c1829c716fefe077aaf51639cd85f30ecc0518c97a17289e9a6e28df7055/__init__.py +4 -0
  23. shared/package-files/16/164dc02c7215495e02c698a87b6e1b9a06424de3f6532d4c2804d076df55ed42/sym_size_ops.h +28 -0
  24. shared/package-files/16/164dcb5d8e9b43517220f52bd1286d7bd9c352277cf748a2e85a73eeb5f8a612/_backward_native.h +21 -0
  25. shared/package-files/16/1655950700404519eef420399ae5963287b752b58963ea7bf60cbc368a063bed/d555 +0 -0
  26. shared/package-files/16/1658d6c58ebb50d38279daa0fdab3f9d8e06b645381c3c2ac20a4b931534d00c/test_iterator.py +134 -0
  27. shared/package-files/16/165a53ae0740325ff9a6e376cc38ef766a2cc3c693bda083f878b61ad20afa4d/__init__.py +7 -0
  28. shared/package-files/16/165f49a1247ddbb7c2b41531f14122bee5e8aaca49b0a83133c249afe937de4e/external.py +77 -0
  29. shared/package-files/16/1666b1206c14c8de494a837d27883e7dbc6171ef489a9b7e2840d7a36c5c9c80/modularity_max.py +445 -0
  30. shared/package-files/16/16681e8936b15235f07ed8d28f2784ddce4ae0ea959d27c13fbe894967af2255/_linalg_slogdet_meta_dispatch.h +25 -0
  31. shared/package-files/16/16695fa2786e53414e5a6b54767a3fdf5de99cfbc68617f69d1362d92776a92f/co2.csv +2285 -0
  32. shared/package-files/16/166a6ba1392bf6f36244e784ed3edc4d0ea03b89c94cc31dcc9c02cc95f99216/byteswap.cpython-310-x86_64-linux-gnu.so +0 -0
  33. shared/package-files/16/166ca07d308c14c3e9dfe028c6389bf1a439027fe7b389d33eedb7d002e8bafb/METADATA +193 -0
  34. shared/package-files/16/167000925bfc3069bfa9bd948a50d0812ea5d1c52db620852948f1d339f65cd0/help.py +131 -0
  35. shared/package-files/16/1671a0ce3f2e545ed34eb2765fde08068ed75bf7b3610f03614c19f303fe3c84/_typing.py +86 -0
  36. shared/package-files/16/1675e56b6abeb397614ac63bf48c528051ddadcd8c689b04a58145a17042a438/fake_pg.py +32 -0
  37. shared/package-files/16/167630ab4c004780a2c738fe6bdaa1cae954484a4cca35fd00b6e3cdafd67bbe/junitxml.py +697 -0
  38. shared/package-files/16/1678951cfed6d980657a7a0c62142b383be8aaabc331296cd8900d1ad34f42db/numpy_init.h +27 -0
  39. shared/package-files/16/16794e45a9ab86b5a2e7da8c1925d42ffa71db4ac7f10020172ae9b48bf7431c/struct.pyi +38 -0
  40. shared/package-files/16/167cc93cfd0047407d3fee1b9119e091c1aea164f027e4726b5eb25951ef44eb/align_to.h +26 -0
  41. shared/package-files/16/16817666c6d6aa7c867bad911b142911ef7390f105c0f6e757f3bd78612b97fa/example.h +55 -0
  42. shared/package-files/16/1681a62321489c79277c4d74dcf6e20fae46530b269d85b3179a06cacd3706a6/Manila +0 -0
  43. shared/package-files/16/16838313427ffbc28805b352e513a41165603671773f0693a2a277f18b620185/test_datetimes.py +840 -0
  44. shared/package-files/16/1683c7bf59595992d349a2ec8f44c0b79dda3f3d8025182985606f4dfdf908d0/RECORD +11 -0
  45. shared/package-files/16/1685386a11e4259ebb7705977abe455cb8e38deb0a2a0fb0d89ab55f56c7ca60/arrayterator.pyi +14 -0
  46. shared/package-files/16/16868dbe4198217ac3eb198179dac99a6fe854b31ab6a6c6097734dbb0ae8244/spawnbase.py +525 -0
  47. shared/package-files/16/1686c73611bd08031e07f00e129ad4b3eed741d3e873562f7e65e1a330d9f293/test_vertex_cover.py +68 -0
  48. shared/package-files/16/16901795632d1d5adca028f544c09b78354f03a7e93bea43958fad6ecef79325/win32.py +683 -0
  49. shared/package-files/16/1695a2bbaee4805aaccc8441eb85c1c1dcb301736c3dc6a58a858266f0ad455d/norm_compositeexplicitautograd_dispatch.h +28 -0
  50. shared/package-files/16/1695bf5062546ea28711f9bc4b9e1c34442c7a82b26b87916d9e74c843904d0a/__init__.py +10 -0
shared/package-files/15/1539ad7e8aa4b8df03778f1fe5381d928928c5837be7172747bf07c3e6cb4a78/pool.py ADDED
@@ -0,0 +1,957 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # Module providing the `Pool` class for managing a process pool
3
+ #
4
+ # multiprocessing/pool.py
5
+ #
6
+ # Copyright (c) 2006-2008, R Oudkerk
7
+ # Licensed to PSF under a Contributor Agreement.
8
+ #
9
+
10
+ __all__ = ['Pool', 'ThreadPool']
11
+
12
+ #
13
+ # Imports
14
+ #
15
+
16
+ import collections
17
+ import itertools
18
+ import os
19
+ import queue
20
+ import threading
21
+ import time
22
+ import traceback
23
+ import types
24
+ import warnings
25
+
26
+ # If threading is available then ThreadPool should be provided. Therefore
27
+ # we avoid top-level imports which are liable to fail on some systems.
28
+ from . import util
29
+ from . import get_context, TimeoutError
30
+ from .connection import wait
31
+
32
+ #
33
+ # Constants representing the state of a pool
34
+ #
35
+
36
+ INIT = "INIT"
37
+ RUN = "RUN"
38
+ CLOSE = "CLOSE"
39
+ TERMINATE = "TERMINATE"
40
+
41
+ #
42
+ # Miscellaneous
43
+ #
44
+
45
+ job_counter = itertools.count()
46
+
47
+ def mapstar(args):
48
+ return list(map(*args))
49
+
50
+ def starmapstar(args):
51
+ return list(itertools.starmap(args[0], args[1]))
52
+
53
+ #
54
+ # Hack to embed stringification of remote traceback in local traceback
55
+ #
56
+
57
+ class RemoteTraceback(Exception):
58
+ def __init__(self, tb):
59
+ self.tb = tb
60
+ def __str__(self):
61
+ return self.tb
62
+
63
+ class ExceptionWithTraceback:
64
+ def __init__(self, exc, tb):
65
+ tb = traceback.format_exception(type(exc), exc, tb)
66
+ tb = ''.join(tb)
67
+ self.exc = exc
68
+ self.tb = '\n"""\n%s"""' % tb
69
+ def __reduce__(self):
70
+ return rebuild_exc, (self.exc, self.tb)
71
+
72
+ def rebuild_exc(exc, tb):
73
+ exc.__cause__ = RemoteTraceback(tb)
74
+ return exc
75
+
76
+ #
77
+ # Code run by worker processes
78
+ #
79
+
80
+ class MaybeEncodingError(Exception):
81
+ """Wraps possible unpickleable errors, so they can be
82
+ safely sent through the socket."""
83
+
84
+ def __init__(self, exc, value):
85
+ self.exc = repr(exc)
86
+ self.value = repr(value)
87
+ super(MaybeEncodingError, self).__init__(self.exc, self.value)
88
+
89
+ def __str__(self):
90
+ return "Error sending result: '%s'. Reason: '%s'" % (self.value,
91
+ self.exc)
92
+
93
+ def __repr__(self):
94
+ return "<%s: %s>" % (self.__class__.__name__, self)
95
+
96
+
97
+ def worker(inqueue, outqueue, initializer=None, initargs=(), maxtasks=None,
98
+ wrap_exception=False):
99
+ if (maxtasks is not None) and not (isinstance(maxtasks, int)
100
+ and maxtasks >= 1):
101
+ raise AssertionError("Maxtasks {!r} is not valid".format(maxtasks))
102
+ put = outqueue.put
103
+ get = inqueue.get
104
+ if hasattr(inqueue, '_writer'):
105
+ inqueue._writer.close()
106
+ outqueue._reader.close()
107
+
108
+ if initializer is not None:
109
+ initializer(*initargs)
110
+
111
+ completed = 0
112
+ while maxtasks is None or (maxtasks and completed < maxtasks):
113
+ try:
114
+ task = get()
115
+ except (EOFError, OSError):
116
+ util.debug('worker got EOFError or OSError -- exiting')
117
+ break
118
+
119
+ if task is None:
120
+ util.debug('worker got sentinel -- exiting')
121
+ break
122
+
123
+ job, i, func, args, kwds = task
124
+ try:
125
+ result = (True, func(*args, **kwds))
126
+ except Exception as e:
127
+ if wrap_exception and func is not _helper_reraises_exception:
128
+ e = ExceptionWithTraceback(e, e.__traceback__)
129
+ result = (False, e)
130
+ try:
131
+ put((job, i, result))
132
+ except Exception as e:
133
+ wrapped = MaybeEncodingError(e, result[1])
134
+ util.debug("Possible encoding error while sending result: %s" % (
135
+ wrapped))
136
+ put((job, i, (False, wrapped)))
137
+
138
+ task = job = result = func = args = kwds = None
139
+ completed += 1
140
+ util.debug('worker exiting after %d tasks' % completed)
141
+
142
+ def _helper_reraises_exception(ex):
143
+ 'Pickle-able helper function for use by _guarded_task_generation.'
144
+ raise ex
145
+
146
+ #
147
+ # Class representing a process pool
148
+ #
149
+
150
+ class _PoolCache(dict):
151
+ """
152
+ Class that implements a cache for the Pool class that will notify
153
+ the pool management threads every time the cache is emptied. The
154
+ notification is done by the use of a queue that is provided when
155
+ instantiating the cache.
156
+ """
157
+ def __init__(self, /, *args, notifier=None, **kwds):
158
+ self.notifier = notifier
159
+ super().__init__(*args, **kwds)
160
+
161
+ def __delitem__(self, item):
162
+ super().__delitem__(item)
163
+
164
+ # Notify that the cache is empty. This is important because the
165
+ # pool keeps maintaining workers until the cache gets drained. This
166
+ # eliminates a race condition in which a task is finished after the
167
+ # the pool's _handle_workers method has enter another iteration of the
168
+ # loop. In this situation, the only event that can wake up the pool
169
+ # is the cache to be emptied (no more tasks available).
170
+ if not self:
171
+ self.notifier.put(None)
172
+
173
+ class Pool(object):
174
+ '''
175
+ Class which supports an async version of applying functions to arguments.
176
+ '''
177
+ _wrap_exception = True
178
+
179
+ @staticmethod
180
+ def Process(ctx, *args, **kwds):
181
+ return ctx.Process(*args, **kwds)
182
+
183
+ def __init__(self, processes=None, initializer=None, initargs=(),
184
+ maxtasksperchild=None, context=None):
185
+ # Attributes initialized early to make sure that they exist in
186
+ # __del__() if __init__() raises an exception
187
+ self._pool = []
188
+ self._state = INIT
189
+
190
+ self._ctx = context or get_context()
191
+ self._setup_queues()
192
+ self._taskqueue = queue.SimpleQueue()
193
+ # The _change_notifier queue exist to wake up self._handle_workers()
194
+ # when the cache (self._cache) is empty or when there is a change in
195
+ # the _state variable of the thread that runs _handle_workers.
196
+ self._change_notifier = self._ctx.SimpleQueue()
197
+ self._cache = _PoolCache(notifier=self._change_notifier)
198
+ self._maxtasksperchild = maxtasksperchild
199
+ self._initializer = initializer
200
+ self._initargs = initargs
201
+
202
+ if processes is None:
203
+ processes = os.cpu_count() or 1
204
+ if processes < 1:
205
+ raise ValueError("Number of processes must be at least 1")
206
+ if maxtasksperchild is not None:
207
+ if not isinstance(maxtasksperchild, int) or maxtasksperchild <= 0:
208
+ raise ValueError("maxtasksperchild must be a positive int or None")
209
+
210
+ if initializer is not None and not callable(initializer):
211
+ raise TypeError('initializer must be a callable')
212
+
213
+ self._processes = processes
214
+ try:
215
+ self._repopulate_pool()
216
+ except Exception:
217
+ for p in self._pool:
218
+ if p.exitcode is None:
219
+ p.terminate()
220
+ for p in self._pool:
221
+ p.join()
222
+ raise
223
+
224
+ sentinels = self._get_sentinels()
225
+
226
+ self._worker_handler = threading.Thread(
227
+ target=Pool._handle_workers,
228
+ args=(self._cache, self._taskqueue, self._ctx, self.Process,
229
+ self._processes, self._pool, self._inqueue, self._outqueue,
230
+ self._initializer, self._initargs, self._maxtasksperchild,
231
+ self._wrap_exception, sentinels, self._change_notifier)
232
+ )
233
+ self._worker_handler.daemon = True
234
+ self._worker_handler._state = RUN
235
+ self._worker_handler.start()
236
+
237
+
238
+ self._task_handler = threading.Thread(
239
+ target=Pool._handle_tasks,
240
+ args=(self._taskqueue, self._quick_put, self._outqueue,
241
+ self._pool, self._cache)
242
+ )
243
+ self._task_handler.daemon = True
244
+ self._task_handler._state = RUN
245
+ self._task_handler.start()
246
+
247
+ self._result_handler = threading.Thread(
248
+ target=Pool._handle_results,
249
+ args=(self._outqueue, self._quick_get, self._cache)
250
+ )
251
+ self._result_handler.daemon = True
252
+ self._result_handler._state = RUN
253
+ self._result_handler.start()
254
+
255
+ self._terminate = util.Finalize(
256
+ self, self._terminate_pool,
257
+ args=(self._taskqueue, self._inqueue, self._outqueue, self._pool,
258
+ self._change_notifier, self._worker_handler, self._task_handler,
259
+ self._result_handler, self._cache),
260
+ exitpriority=15
261
+ )
262
+ self._state = RUN
263
+
264
+ # Copy globals as function locals to make sure that they are available
265
+ # during Python shutdown when the Pool is destroyed.
266
+ def __del__(self, _warn=warnings.warn, RUN=RUN):
267
+ if self._state == RUN:
268
+ _warn(f"unclosed running multiprocessing pool {self!r}",
269
+ ResourceWarning, source=self)
270
+ if getattr(self, '_change_notifier', None) is not None:
271
+ self._change_notifier.put(None)
272
+
273
+ def __repr__(self):
274
+ cls = self.__class__
275
+ return (f'<{cls.__module__}.{cls.__qualname__} '
276
+ f'state={self._state} '
277
+ f'pool_size={len(self._pool)}>')
278
+
279
+ def _get_sentinels(self):
280
+ task_queue_sentinels = [self._outqueue._reader]
281
+ self_notifier_sentinels = [self._change_notifier._reader]
282
+ return [*task_queue_sentinels, *self_notifier_sentinels]
283
+
284
+ @staticmethod
285
+ def _get_worker_sentinels(workers):
286
+ return [worker.sentinel for worker in
287
+ workers if hasattr(worker, "sentinel")]
288
+
289
+ @staticmethod
290
+ def _join_exited_workers(pool):
291
+ """Cleanup after any worker processes which have exited due to reaching
292
+ their specified lifetime. Returns True if any workers were cleaned up.
293
+ """
294
+ cleaned = False
295
+ for i in reversed(range(len(pool))):
296
+ worker = pool[i]
297
+ if worker.exitcode is not None:
298
+ # worker exited
299
+ util.debug('cleaning up worker %d' % i)
300
+ worker.join()
301
+ cleaned = True
302
+ del pool[i]
303
+ return cleaned
304
+
305
+ def _repopulate_pool(self):
306
+ return self._repopulate_pool_static(self._ctx, self.Process,
307
+ self._processes,
308
+ self._pool, self._inqueue,
309
+ self._outqueue, self._initializer,
310
+ self._initargs,
311
+ self._maxtasksperchild,
312
+ self._wrap_exception)
313
+
314
+ @staticmethod
315
+ def _repopulate_pool_static(ctx, Process, processes, pool, inqueue,
316
+ outqueue, initializer, initargs,
317
+ maxtasksperchild, wrap_exception):
318
+ """Bring the number of pool processes up to the specified number,
319
+ for use after reaping workers which have exited.
320
+ """
321
+ for i in range(processes - len(pool)):
322
+ w = Process(ctx, target=worker,
323
+ args=(inqueue, outqueue,
324
+ initializer,
325
+ initargs, maxtasksperchild,
326
+ wrap_exception))
327
+ w.name = w.name.replace('Process', 'PoolWorker')
328
+ w.daemon = True
329
+ w.start()
330
+ pool.append(w)
331
+ util.debug('added worker')
332
+
333
+ @staticmethod
334
+ def _maintain_pool(ctx, Process, processes, pool, inqueue, outqueue,
335
+ initializer, initargs, maxtasksperchild,
336
+ wrap_exception):
337
+ """Clean up any exited workers and start replacements for them.
338
+ """
339
+ if Pool._join_exited_workers(pool):
340
+ Pool._repopulate_pool_static(ctx, Process, processes, pool,
341
+ inqueue, outqueue, initializer,
342
+ initargs, maxtasksperchild,
343
+ wrap_exception)
344
+
345
+ def _setup_queues(self):
346
+ self._inqueue = self._ctx.SimpleQueue()
347
+ self._outqueue = self._ctx.SimpleQueue()
348
+ self._quick_put = self._inqueue._writer.send
349
+ self._quick_get = self._outqueue._reader.recv
350
+
351
+ def _check_running(self):
352
+ if self._state != RUN:
353
+ raise ValueError("Pool not running")
354
+
355
+ def apply(self, func, args=(), kwds={}):
356
+ '''
357
+ Equivalent of `func(*args, **kwds)`.
358
+ Pool must be running.
359
+ '''
360
+ return self.apply_async(func, args, kwds).get()
361
+
362
+ def map(self, func, iterable, chunksize=None):
363
+ '''
364
+ Apply `func` to each element in `iterable`, collecting the results
365
+ in a list that is returned.
366
+ '''
367
+ return self._map_async(func, iterable, mapstar, chunksize).get()
368
+
369
+ def starmap(self, func, iterable, chunksize=None):
370
+ '''
371
+ Like `map()` method but the elements of the `iterable` are expected to
372
+ be iterables as well and will be unpacked as arguments. Hence
373
+ `func` and (a, b) becomes func(a, b).
374
+ '''
375
+ return self._map_async(func, iterable, starmapstar, chunksize).get()
376
+
377
+ def starmap_async(self, func, iterable, chunksize=None, callback=None,
378
+ error_callback=None):
379
+ '''
380
+ Asynchronous version of `starmap()` method.
381
+ '''
382
+ return self._map_async(func, iterable, starmapstar, chunksize,
383
+ callback, error_callback)
384
+
385
+ def _guarded_task_generation(self, result_job, func, iterable):
386
+ '''Provides a generator of tasks for imap and imap_unordered with
387
+ appropriate handling for iterables which throw exceptions during
388
+ iteration.'''
389
+ try:
390
+ i = -1
391
+ for i, x in enumerate(iterable):
392
+ yield (result_job, i, func, (x,), {})
393
+ except Exception as e:
394
+ yield (result_job, i+1, _helper_reraises_exception, (e,), {})
395
+
396
+ def imap(self, func, iterable, chunksize=1):
397
+ '''
398
+ Equivalent of `map()` -- can be MUCH slower than `Pool.map()`.
399
+ '''
400
+ self._check_running()
401
+ if chunksize == 1:
402
+ result = IMapIterator(self)
403
+ self._taskqueue.put(
404
+ (
405
+ self._guarded_task_generation(result._job, func, iterable),
406
+ result._set_length
407
+ ))
408
+ return result
409
+ else:
410
+ if chunksize < 1:
411
+ raise ValueError(
412
+ "Chunksize must be 1+, not {0:n}".format(
413
+ chunksize))
414
+ task_batches = Pool._get_tasks(func, iterable, chunksize)
415
+ result = IMapIterator(self)
416
+ self._taskqueue.put(
417
+ (
418
+ self._guarded_task_generation(result._job,
419
+ mapstar,
420
+ task_batches),
421
+ result._set_length
422
+ ))
423
+ return (item for chunk in result for item in chunk)
424
+
425
+ def imap_unordered(self, func, iterable, chunksize=1):
426
+ '''
427
+ Like `imap()` method but ordering of results is arbitrary.
428
+ '''
429
+ self._check_running()
430
+ if chunksize == 1:
431
+ result = IMapUnorderedIterator(self)
432
+ self._taskqueue.put(
433
+ (
434
+ self._guarded_task_generation(result._job, func, iterable),
435
+ result._set_length
436
+ ))
437
+ return result
438
+ else:
439
+ if chunksize < 1:
440
+ raise ValueError(
441
+ "Chunksize must be 1+, not {0!r}".format(chunksize))
442
+ task_batches = Pool._get_tasks(func, iterable, chunksize)
443
+ result = IMapUnorderedIterator(self)
444
+ self._taskqueue.put(
445
+ (
446
+ self._guarded_task_generation(result._job,
447
+ mapstar,
448
+ task_batches),
449
+ result._set_length
450
+ ))
451
+ return (item for chunk in result for item in chunk)
452
+
453
+ def apply_async(self, func, args=(), kwds={}, callback=None,
454
+ error_callback=None):
455
+ '''
456
+ Asynchronous version of `apply()` method.
457
+ '''
458
+ self._check_running()
459
+ result = ApplyResult(self, callback, error_callback)
460
+ self._taskqueue.put(([(result._job, 0, func, args, kwds)], None))
461
+ return result
462
+
463
+ def map_async(self, func, iterable, chunksize=None, callback=None,
464
+ error_callback=None):
465
+ '''
466
+ Asynchronous version of `map()` method.
467
+ '''
468
+ return self._map_async(func, iterable, mapstar, chunksize, callback,
469
+ error_callback)
470
+
471
+ def _map_async(self, func, iterable, mapper, chunksize=None, callback=None,
472
+ error_callback=None):
473
+ '''
474
+ Helper function to implement map, starmap and their async counterparts.
475
+ '''
476
+ self._check_running()
477
+ if not hasattr(iterable, '__len__'):
478
+ iterable = list(iterable)
479
+
480
+ if chunksize is None:
481
+ chunksize, extra = divmod(len(iterable), len(self._pool) * 4)
482
+ if extra:
483
+ chunksize += 1
484
+ if len(iterable) == 0:
485
+ chunksize = 0
486
+
487
+ task_batches = Pool._get_tasks(func, iterable, chunksize)
488
+ result = MapResult(self, chunksize, len(iterable), callback,
489
+ error_callback=error_callback)
490
+ self._taskqueue.put(
491
+ (
492
+ self._guarded_task_generation(result._job,
493
+ mapper,
494
+ task_batches),
495
+ None
496
+ )
497
+ )
498
+ return result
499
+
500
+ @staticmethod
501
+ def _wait_for_updates(sentinels, change_notifier, timeout=None):
502
+ wait(sentinels, timeout=timeout)
503
+ while not change_notifier.empty():
504
+ change_notifier.get()
505
+
506
+ @classmethod
507
+ def _handle_workers(cls, cache, taskqueue, ctx, Process, processes,
508
+ pool, inqueue, outqueue, initializer, initargs,
509
+ maxtasksperchild, wrap_exception, sentinels,
510
+ change_notifier):
511
+ thread = threading.current_thread()
512
+
513
+ # Keep maintaining workers until the cache gets drained, unless the pool
514
+ # is terminated.
515
+ while thread._state == RUN or (cache and thread._state != TERMINATE):
516
+ cls._maintain_pool(ctx, Process, processes, pool, inqueue,
517
+ outqueue, initializer, initargs,
518
+ maxtasksperchild, wrap_exception)
519
+
520
+ current_sentinels = [*cls._get_worker_sentinels(pool), *sentinels]
521
+
522
+ cls._wait_for_updates(current_sentinels, change_notifier)
523
+ # send sentinel to stop workers
524
+ taskqueue.put(None)
525
+ util.debug('worker handler exiting')
526
+
527
+ @staticmethod
528
+ def _handle_tasks(taskqueue, put, outqueue, pool, cache):
529
+ thread = threading.current_thread()
530
+
531
+ for taskseq, set_length in iter(taskqueue.get, None):
532
+ task = None
533
+ try:
534
+ # iterating taskseq cannot fail
535
+ for task in taskseq:
536
+ if thread._state != RUN:
537
+ util.debug('task handler found thread._state != RUN')
538
+ break
539
+ try:
540
+ put(task)
541
+ except Exception as e:
542
+ job, idx = task[:2]
543
+ try:
544
+ cache[job]._set(idx, (False, e))
545
+ except KeyError:
546
+ pass
547
+ else:
548
+ if set_length:
549
+ util.debug('doing set_length()')
550
+ idx = task[1] if task else -1
551
+ set_length(idx + 1)
552
+ continue
553
+ break
554
+ finally:
555
+ task = taskseq = job = None
556
+ else:
557
+ util.debug('task handler got sentinel')
558
+
559
+ try:
560
+ # tell result handler to finish when cache is empty
561
+ util.debug('task handler sending sentinel to result handler')
562
+ outqueue.put(None)
563
+
564
+ # tell workers there is no more work
565
+ util.debug('task handler sending sentinel to workers')
566
+ for p in pool:
567
+ put(None)
568
+ except OSError:
569
+ util.debug('task handler got OSError when sending sentinels')
570
+
571
+ util.debug('task handler exiting')
572
+
573
+ @staticmethod
574
+ def _handle_results(outqueue, get, cache):
575
+ thread = threading.current_thread()
576
+
577
+ while 1:
578
+ try:
579
+ task = get()
580
+ except (OSError, EOFError):
581
+ util.debug('result handler got EOFError/OSError -- exiting')
582
+ return
583
+
584
+ if thread._state != RUN:
585
+ assert thread._state == TERMINATE, "Thread not in TERMINATE"
586
+ util.debug('result handler found thread._state=TERMINATE')
587
+ break
588
+
589
+ if task is None:
590
+ util.debug('result handler got sentinel')
591
+ break
592
+
593
+ job, i, obj = task
594
+ try:
595
+ cache[job]._set(i, obj)
596
+ except KeyError:
597
+ pass
598
+ task = job = obj = None
599
+
600
+ while cache and thread._state != TERMINATE:
601
+ try:
602
+ task = get()
603
+ except (OSError, EOFError):
604
+ util.debug('result handler got EOFError/OSError -- exiting')
605
+ return
606
+
607
+ if task is None:
608
+ util.debug('result handler ignoring extra sentinel')
609
+ continue
610
+ job, i, obj = task
611
+ try:
612
+ cache[job]._set(i, obj)
613
+ except KeyError:
614
+ pass
615
+ task = job = obj = None
616
+
617
+ if hasattr(outqueue, '_reader'):
618
+ util.debug('ensuring that outqueue is not full')
619
+ # If we don't make room available in outqueue then
620
+ # attempts to add the sentinel (None) to outqueue may
621
+ # block. There is guaranteed to be no more than 2 sentinels.
622
+ try:
623
+ for i in range(10):
624
+ if not outqueue._reader.poll():
625
+ break
626
+ get()
627
+ except (OSError, EOFError):
628
+ pass
629
+
630
+ util.debug('result handler exiting: len(cache)=%s, thread._state=%s',
631
+ len(cache), thread._state)
632
+
633
+ @staticmethod
634
+ def _get_tasks(func, it, size):
635
+ it = iter(it)
636
+ while 1:
637
+ x = tuple(itertools.islice(it, size))
638
+ if not x:
639
+ return
640
+ yield (func, x)
641
+
642
+ def __reduce__(self):
643
+ raise NotImplementedError(
644
+ 'pool objects cannot be passed between processes or pickled'
645
+ )
646
+
647
+ def close(self):
648
+ util.debug('closing pool')
649
+ if self._state == RUN:
650
+ self._state = CLOSE
651
+ self._worker_handler._state = CLOSE
652
+ self._change_notifier.put(None)
653
+
654
+ def terminate(self):
655
+ util.debug('terminating pool')
656
+ self._state = TERMINATE
657
+ self._terminate()
658
+
659
+ def join(self):
660
+ util.debug('joining pool')
661
+ if self._state == RUN:
662
+ raise ValueError("Pool is still running")
663
+ elif self._state not in (CLOSE, TERMINATE):
664
+ raise ValueError("In unknown state")
665
+ self._worker_handler.join()
666
+ self._task_handler.join()
667
+ self._result_handler.join()
668
+ for p in self._pool:
669
+ p.join()
670
+
671
+ @staticmethod
672
+ def _help_stuff_finish(inqueue, task_handler, size):
673
+ # task_handler may be blocked trying to put items on inqueue
674
+ util.debug('removing tasks from inqueue until task handler finished')
675
+ inqueue._rlock.acquire()
676
+ while task_handler.is_alive() and inqueue._reader.poll():
677
+ inqueue._reader.recv()
678
+ time.sleep(0)
679
+
680
+ @classmethod
681
+ def _terminate_pool(cls, taskqueue, inqueue, outqueue, pool, change_notifier,
682
+ worker_handler, task_handler, result_handler, cache):
683
+ # this is guaranteed to only be called once
684
+ util.debug('finalizing pool')
685
+
686
+ # Notify that the worker_handler state has been changed so the
687
+ # _handle_workers loop can be unblocked (and exited) in order to
688
+ # send the finalization sentinel all the workers.
689
+ worker_handler._state = TERMINATE
690
+ change_notifier.put(None)
691
+
692
+ task_handler._state = TERMINATE
693
+
694
+ util.debug('helping task handler/workers to finish')
695
+ cls._help_stuff_finish(inqueue, task_handler, len(pool))
696
+
697
+ if (not result_handler.is_alive()) and (len(cache) != 0):
698
+ raise AssertionError(
699
+ "Cannot have cache with result_hander not alive")
700
+
701
+ result_handler._state = TERMINATE
702
+ change_notifier.put(None)
703
+ outqueue.put(None) # sentinel
704
+
705
+ # We must wait for the worker handler to exit before terminating
706
+ # workers because we don't want workers to be restarted behind our back.
707
+ util.debug('joining worker handler')
708
+ if threading.current_thread() is not worker_handler:
709
+ worker_handler.join()
710
+
711
+ # Terminate workers which haven't already finished.
712
+ if pool and hasattr(pool[0], 'terminate'):
713
+ util.debug('terminating workers')
714
+ for p in pool:
715
+ if p.exitcode is None:
716
+ p.terminate()
717
+
718
+ util.debug('joining task handler')
719
+ if threading.current_thread() is not task_handler:
720
+ task_handler.join()
721
+
722
+ util.debug('joining result handler')
723
+ if threading.current_thread() is not result_handler:
724
+ result_handler.join()
725
+
726
+ if pool and hasattr(pool[0], 'terminate'):
727
+ util.debug('joining pool workers')
728
+ for p in pool:
729
+ if p.is_alive():
730
+ # worker has not yet exited
731
+ util.debug('cleaning up worker %d' % p.pid)
732
+ p.join()
733
+
734
+ def __enter__(self):
735
+ self._check_running()
736
+ return self
737
+
738
+ def __exit__(self, exc_type, exc_val, exc_tb):
739
+ self.terminate()
740
+
741
+ #
742
+ # Class whose instances are returned by `Pool.apply_async()`
743
+ #
744
+
745
+ class ApplyResult(object):
746
+
747
+ def __init__(self, pool, callback, error_callback):
748
+ self._pool = pool
749
+ self._event = threading.Event()
750
+ self._job = next(job_counter)
751
+ self._cache = pool._cache
752
+ self._callback = callback
753
+ self._error_callback = error_callback
754
+ self._cache[self._job] = self
755
+
756
+ def ready(self):
757
+ return self._event.is_set()
758
+
759
+ def successful(self):
760
+ if not self.ready():
761
+ raise ValueError("{0!r} not ready".format(self))
762
+ return self._success
763
+
764
+ def wait(self, timeout=None):
765
+ self._event.wait(timeout)
766
+
767
+ def get(self, timeout=None):
768
+ self.wait(timeout)
769
+ if not self.ready():
770
+ raise TimeoutError
771
+ if self._success:
772
+ return self._value
773
+ else:
774
+ raise self._value
775
+
776
+ def _set(self, i, obj):
777
+ self._success, self._value = obj
778
+ if self._callback and self._success:
779
+ self._callback(self._value)
780
+ if self._error_callback and not self._success:
781
+ self._error_callback(self._value)
782
+ self._event.set()
783
+ del self._cache[self._job]
784
+ self._pool = None
785
+
786
+ __class_getitem__ = classmethod(types.GenericAlias)
787
+
788
+ AsyncResult = ApplyResult # create alias -- see #17805
789
+
790
+ #
791
+ # Class whose instances are returned by `Pool.map_async()`
792
+ #
793
+
794
+ class MapResult(ApplyResult):
795
+
796
+ def __init__(self, pool, chunksize, length, callback, error_callback):
797
+ ApplyResult.__init__(self, pool, callback,
798
+ error_callback=error_callback)
799
+ self._success = True
800
+ self._value = [None] * length
801
+ self._chunksize = chunksize
802
+ if chunksize <= 0:
803
+ self._number_left = 0
804
+ self._event.set()
805
+ del self._cache[self._job]
806
+ else:
807
+ self._number_left = length//chunksize + bool(length % chunksize)
808
+
809
+ def _set(self, i, success_result):
810
+ self._number_left -= 1
811
+ success, result = success_result
812
+ if success and self._success:
813
+ self._value[i*self._chunksize:(i+1)*self._chunksize] = result
814
+ if self._number_left == 0:
815
+ if self._callback:
816
+ self._callback(self._value)
817
+ del self._cache[self._job]
818
+ self._event.set()
819
+ self._pool = None
820
+ else:
821
+ if not success and self._success:
822
+ # only store first exception
823
+ self._success = False
824
+ self._value = result
825
+ if self._number_left == 0:
826
+ # only consider the result ready once all jobs are done
827
+ if self._error_callback:
828
+ self._error_callback(self._value)
829
+ del self._cache[self._job]
830
+ self._event.set()
831
+ self._pool = None
832
+
833
+ #
834
+ # Class whose instances are returned by `Pool.imap()`
835
+ #
836
+
837
+ class IMapIterator(object):
838
+
839
+ def __init__(self, pool):
840
+ self._pool = pool
841
+ self._cond = threading.Condition(threading.Lock())
842
+ self._job = next(job_counter)
843
+ self._cache = pool._cache
844
+ self._items = collections.deque()
845
+ self._index = 0
846
+ self._length = None
847
+ self._unsorted = {}
848
+ self._cache[self._job] = self
849
+
850
+ def __iter__(self):
851
+ return self
852
+
853
+ def next(self, timeout=None):
854
+ with self._cond:
855
+ try:
856
+ item = self._items.popleft()
857
+ except IndexError:
858
+ if self._index == self._length:
859
+ self._pool = None
860
+ raise StopIteration from None
861
+ self._cond.wait(timeout)
862
+ try:
863
+ item = self._items.popleft()
864
+ except IndexError:
865
+ if self._index == self._length:
866
+ self._pool = None
867
+ raise StopIteration from None
868
+ raise TimeoutError from None
869
+
870
+ success, value = item
871
+ if success:
872
+ return value
873
+ raise value
874
+
875
+ __next__ = next # XXX
876
+
877
+ def _set(self, i, obj):
878
+ with self._cond:
879
+ if self._index == i:
880
+ self._items.append(obj)
881
+ self._index += 1
882
+ while self._index in self._unsorted:
883
+ obj = self._unsorted.pop(self._index)
884
+ self._items.append(obj)
885
+ self._index += 1
886
+ self._cond.notify()
887
+ else:
888
+ self._unsorted[i] = obj
889
+
890
+ if self._index == self._length:
891
+ del self._cache[self._job]
892
+ self._pool = None
893
+
894
+ def _set_length(self, length):
895
+ with self._cond:
896
+ self._length = length
897
+ if self._index == self._length:
898
+ self._cond.notify()
899
+ del self._cache[self._job]
900
+ self._pool = None
901
+
902
+ #
903
+ # Class whose instances are returned by `Pool.imap_unordered()`
904
+ #
905
+
906
+ class IMapUnorderedIterator(IMapIterator):
907
+
908
+ def _set(self, i, obj):
909
+ with self._cond:
910
+ self._items.append(obj)
911
+ self._index += 1
912
+ self._cond.notify()
913
+ if self._index == self._length:
914
+ del self._cache[self._job]
915
+ self._pool = None
916
+
917
+ #
918
+ #
919
+ #
920
+
921
+ class ThreadPool(Pool):
922
+ _wrap_exception = False
923
+
924
+ @staticmethod
925
+ def Process(ctx, *args, **kwds):
926
+ from .dummy import Process
927
+ return Process(*args, **kwds)
928
+
929
+ def __init__(self, processes=None, initializer=None, initargs=()):
930
+ Pool.__init__(self, processes, initializer, initargs)
931
+
932
+ def _setup_queues(self):
933
+ self._inqueue = queue.SimpleQueue()
934
+ self._outqueue = queue.SimpleQueue()
935
+ self._quick_put = self._inqueue.put
936
+ self._quick_get = self._outqueue.get
937
+
938
+ def _get_sentinels(self):
939
+ return [self._change_notifier._reader]
940
+
941
+ @staticmethod
942
+ def _get_worker_sentinels(workers):
943
+ return []
944
+
945
+ @staticmethod
946
+ def _help_stuff_finish(inqueue, task_handler, size):
947
+ # drain inqueue, and put sentinels at its head to make workers finish
948
+ try:
949
+ while True:
950
+ inqueue.get(block=False)
951
+ except queue.Empty:
952
+ pass
953
+ for i in range(size):
954
+ inqueue.put(None)
955
+
956
+ def _wait_for_updates(self, sentinels, change_notifier, timeout):
957
+ time.sleep(timeout)
shared/package-files/15/15a709247c4f00fe846dd0ef5e9fef393d0cb63e338b941acea5b0c9d91d14e6/test_misc.py ADDED
@@ -0,0 +1,817 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ # Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.
5
+ # Use of this source code is governed by a BSD-style license that can be
6
+ # found in the LICENSE file.
7
+
8
+ """
9
+ Miscellaneous tests.
10
+ """
11
+
12
+ import ast
13
+ import collections
14
+ import errno
15
+ import json
16
+ import os
17
+ import pickle
18
+ import socket
19
+ import stat
20
+
21
+ import psutil
22
+ import psutil.tests
23
+ from psutil import LINUX
24
+ from psutil import POSIX
25
+ from psutil import WINDOWS
26
+ from psutil._common import debug
27
+ from psutil._common import memoize
28
+ from psutil._common import memoize_when_activated
29
+ from psutil._common import supports_ipv6
30
+ from psutil._common import wrap_numbers
31
+ from psutil._compat import PY3
32
+ from psutil._compat import redirect_stderr
33
+ from psutil.tests import APPVEYOR
34
+ from psutil.tests import CI_TESTING
35
+ from psutil.tests import HAS_BATTERY
36
+ from psutil.tests import HAS_MEMORY_MAPS
37
+ from psutil.tests import HAS_NET_IO_COUNTERS
38
+ from psutil.tests import HAS_SENSORS_BATTERY
39
+ from psutil.tests import HAS_SENSORS_FANS
40
+ from psutil.tests import HAS_SENSORS_TEMPERATURES
41
+ from psutil.tests import PYTHON_EXE
42
+ from psutil.tests import ROOT_DIR
43
+ from psutil.tests import SCRIPTS_DIR
44
+ from psutil.tests import PsutilTestCase
45
+ from psutil.tests import import_module_by_path
46
+ from psutil.tests import mock
47
+ from psutil.tests import reload_module
48
+ from psutil.tests import sh
49
+ from psutil.tests import unittest
50
+
51
+
52
+ # ===================================================================
53
+ # --- Misc / generic tests.
54
+ # ===================================================================
55
+
56
+
57
+ class TestMisc(PsutilTestCase):
58
+
59
+ def test_process__repr__(self, func=repr):
60
+ p = psutil.Process(self.spawn_testproc().pid)
61
+ r = func(p)
62
+ self.assertIn("psutil.Process", r)
63
+ self.assertIn("pid=%s" % p.pid, r)
64
+ self.assertIn("name='%s'" % str(p.name()),
65
+ r.replace("name=u'", "name='"))
66
+ self.assertIn("status=", r)
67
+ self.assertNotIn("exitcode=", r)
68
+ p.terminate()
69
+ p.wait()
70
+ r = func(p)
71
+ self.assertIn("status='terminated'", r)
72
+ self.assertIn("exitcode=", r)
73
+
74
+ with mock.patch.object(psutil.Process, "name",
75
+ side_effect=psutil.ZombieProcess(os.getpid())):
76
+ p = psutil.Process()
77
+ r = func(p)
78
+ self.assertIn("pid=%s" % p.pid, r)
79
+ self.assertIn("status='zombie'", r)
80
+ self.assertNotIn("name=", r)
81
+ with mock.patch.object(psutil.Process, "name",
82
+ side_effect=psutil.NoSuchProcess(os.getpid())):
83
+ p = psutil.Process()
84
+ r = func(p)
85
+ self.assertIn("pid=%s" % p.pid, r)
86
+ self.assertIn("terminated", r)
87
+ self.assertNotIn("name=", r)
88
+ with mock.patch.object(psutil.Process, "name",
89
+ side_effect=psutil.AccessDenied(os.getpid())):
90
+ p = psutil.Process()
91
+ r = func(p)
92
+ self.assertIn("pid=%s" % p.pid, r)
93
+ self.assertNotIn("name=", r)
94
+
95
+ def test_process__str__(self):
96
+ self.test_process__repr__(func=str)
97
+
98
+ def test_no_such_process__repr__(self):
99
+ self.assertEqual(
100
+ repr(psutil.NoSuchProcess(321)),
101
+ "psutil.NoSuchProcess(pid=321, msg='process no longer exists')")
102
+ self.assertEqual(
103
+ repr(psutil.NoSuchProcess(321, name="name", msg="msg")),
104
+ "psutil.NoSuchProcess(pid=321, name='name', msg='msg')")
105
+
106
+ def test_no_such_process__str__(self):
107
+ self.assertEqual(
108
+ str(psutil.NoSuchProcess(321)),
109
+ "process no longer exists (pid=321)")
110
+ self.assertEqual(
111
+ str(psutil.NoSuchProcess(321, name="name", msg="msg")),
112
+ "msg (pid=321, name='name')")
113
+
114
+ def test_zombie_process__repr__(self):
115
+ self.assertEqual(
116
+ repr(psutil.ZombieProcess(321)),
117
+ 'psutil.ZombieProcess(pid=321, msg="PID still '
118
+ 'exists but it\'s a zombie")')
119
+ self.assertEqual(
120
+ repr(psutil.ZombieProcess(321, name="name", ppid=320, msg="foo")),
121
+ "psutil.ZombieProcess(pid=321, ppid=320, name='name', msg='foo')")
122
+
123
+ def test_zombie_process__str__(self):
124
+ self.assertEqual(
125
+ str(psutil.ZombieProcess(321)),
126
+ "PID still exists but it's a zombie (pid=321)")
127
+ self.assertEqual(
128
+ str(psutil.ZombieProcess(321, name="name", ppid=320, msg="foo")),
129
+ "foo (pid=321, ppid=320, name='name')")
130
+
131
+ def test_access_denied__repr__(self):
132
+ self.assertEqual(
133
+ repr(psutil.AccessDenied(321)),
134
+ "psutil.AccessDenied(pid=321)")
135
+ self.assertEqual(
136
+ repr(psutil.AccessDenied(321, name="name", msg="msg")),
137
+ "psutil.AccessDenied(pid=321, name='name', msg='msg')")
138
+
139
+ def test_access_denied__str__(self):
140
+ self.assertEqual(
141
+ str(psutil.AccessDenied(321)),
142
+ "(pid=321)")
143
+ self.assertEqual(
144
+ str(psutil.AccessDenied(321, name="name", msg="msg")),
145
+ "msg (pid=321, name='name')")
146
+
147
+ def test_timeout_expired__repr__(self):
148
+ self.assertEqual(
149
+ repr(psutil.TimeoutExpired(5)),
150
+ "psutil.TimeoutExpired(seconds=5, msg='timeout after 5 seconds')")
151
+ self.assertEqual(
152
+ repr(psutil.TimeoutExpired(5, pid=321, name="name")),
153
+ "psutil.TimeoutExpired(pid=321, name='name', seconds=5, "
154
+ "msg='timeout after 5 seconds')")
155
+
156
+ def test_timeout_expired__str__(self):
157
+ self.assertEqual(
158
+ str(psutil.TimeoutExpired(5)),
159
+ "timeout after 5 seconds")
160
+ self.assertEqual(
161
+ str(psutil.TimeoutExpired(5, pid=321, name="name")),
162
+ "timeout after 5 seconds (pid=321, name='name')")
163
+
164
+ def test_process__eq__(self):
165
+ p1 = psutil.Process()
166
+ p2 = psutil.Process()
167
+ self.assertEqual(p1, p2)
168
+ p2._ident = (0, 0)
169
+ self.assertNotEqual(p1, p2)
170
+ self.assertNotEqual(p1, 'foo')
171
+
172
+ def test_process__hash__(self):
173
+ s = set([psutil.Process(), psutil.Process()])
174
+ self.assertEqual(len(s), 1)
175
+
176
+ def test__all__(self):
177
+ dir_psutil = dir(psutil)
178
+ for name in dir_psutil:
179
+ if name in ('long', 'tests', 'test', 'PermissionError',
180
+ 'ProcessLookupError'):
181
+ continue
182
+ if not name.startswith('_'):
183
+ try:
184
+ __import__(name)
185
+ except ImportError:
186
+ if name not in psutil.__all__:
187
+ fun = getattr(psutil, name)
188
+ if fun is None:
189
+ continue
190
+ if (fun.__doc__ is not None and
191
+ 'deprecated' not in fun.__doc__.lower()):
192
+ self.fail('%r not in psutil.__all__' % name)
193
+
194
+ # Import 'star' will break if __all__ is inconsistent, see:
195
+ # https://github.com/giampaolo/psutil/issues/656
196
+ # Can't do `from psutil import *` as it won't work on python 3
197
+ # so we simply iterate over __all__.
198
+ for name in psutil.__all__:
199
+ self.assertIn(name, dir_psutil)
200
+
201
+ def test_version(self):
202
+ self.assertEqual('.'.join([str(x) for x in psutil.version_info]),
203
+ psutil.__version__)
204
+
205
+ def test_process_as_dict_no_new_names(self):
206
+ # See https://github.com/giampaolo/psutil/issues/813
207
+ p = psutil.Process()
208
+ p.foo = '1'
209
+ self.assertNotIn('foo', p.as_dict())
210
+
211
+ def test_memoize(self):
212
+ @memoize
213
+ def foo(*args, **kwargs):
214
+ "foo docstring"
215
+ calls.append(None)
216
+ return (args, kwargs)
217
+
218
+ calls = []
219
+ # no args
220
+ for x in range(2):
221
+ ret = foo()
222
+ expected = ((), {})
223
+ self.assertEqual(ret, expected)
224
+ self.assertEqual(len(calls), 1)
225
+ # with args
226
+ for x in range(2):
227
+ ret = foo(1)
228
+ expected = ((1, ), {})
229
+ self.assertEqual(ret, expected)
230
+ self.assertEqual(len(calls), 2)
231
+ # with args + kwargs
232
+ for x in range(2):
233
+ ret = foo(1, bar=2)
234
+ expected = ((1, ), {'bar': 2})
235
+ self.assertEqual(ret, expected)
236
+ self.assertEqual(len(calls), 3)
237
+ # clear cache
238
+ foo.cache_clear()
239
+ ret = foo()
240
+ expected = ((), {})
241
+ self.assertEqual(ret, expected)
242
+ self.assertEqual(len(calls), 4)
243
+ # docstring
244
+ self.assertEqual(foo.__doc__, "foo docstring")
245
+
246
+ def test_memoize_when_activated(self):
247
+ class Foo:
248
+
249
+ @memoize_when_activated
250
+ def foo(self):
251
+ calls.append(None)
252
+
253
+ f = Foo()
254
+ calls = []
255
+ f.foo()
256
+ f.foo()
257
+ self.assertEqual(len(calls), 2)
258
+
259
+ # activate
260
+ calls = []
261
+ f.foo.cache_activate(f)
262
+ f.foo()
263
+ f.foo()
264
+ self.assertEqual(len(calls), 1)
265
+
266
+ # deactivate
267
+ calls = []
268
+ f.foo.cache_deactivate(f)
269
+ f.foo()
270
+ f.foo()
271
+ self.assertEqual(len(calls), 2)
272
+
273
+ def test_parse_environ_block(self):
274
+ from psutil._common import parse_environ_block
275
+
276
+ def k(s):
277
+ return s.upper() if WINDOWS else s
278
+
279
+ self.assertEqual(parse_environ_block("a=1\0"),
280
+ {k("a"): "1"})
281
+ self.assertEqual(parse_environ_block("a=1\0b=2\0\0"),
282
+ {k("a"): "1", k("b"): "2"})
283
+ self.assertEqual(parse_environ_block("a=1\0b=\0\0"),
284
+ {k("a"): "1", k("b"): ""})
285
+ # ignore everything after \0\0
286
+ self.assertEqual(parse_environ_block("a=1\0b=2\0\0c=3\0"),
287
+ {k("a"): "1", k("b"): "2"})
288
+ # ignore everything that is not an assignment
289
+ self.assertEqual(parse_environ_block("xxx\0a=1\0"), {k("a"): "1"})
290
+ self.assertEqual(parse_environ_block("a=1\0=b=2\0"), {k("a"): "1"})
291
+ # do not fail if the block is incomplete
292
+ self.assertEqual(parse_environ_block("a=1\0b=2"), {k("a"): "1"})
293
+
294
+ def test_supports_ipv6(self):
295
+ self.addCleanup(supports_ipv6.cache_clear)
296
+ if supports_ipv6():
297
+ with mock.patch('psutil._common.socket') as s:
298
+ s.has_ipv6 = False
299
+ supports_ipv6.cache_clear()
300
+ assert not supports_ipv6()
301
+
302
+ supports_ipv6.cache_clear()
303
+ with mock.patch('psutil._common.socket.socket',
304
+ side_effect=socket.error) as s:
305
+ assert not supports_ipv6()
306
+ assert s.called
307
+
308
+ supports_ipv6.cache_clear()
309
+ with mock.patch('psutil._common.socket.socket',
310
+ side_effect=socket.gaierror) as s:
311
+ assert not supports_ipv6()
312
+ supports_ipv6.cache_clear()
313
+ assert s.called
314
+
315
+ supports_ipv6.cache_clear()
316
+ with mock.patch('psutil._common.socket.socket.bind',
317
+ side_effect=socket.gaierror) as s:
318
+ assert not supports_ipv6()
319
+ supports_ipv6.cache_clear()
320
+ assert s.called
321
+ else:
322
+ with self.assertRaises(Exception):
323
+ sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
324
+ try:
325
+ sock.bind(("::1", 0))
326
+ finally:
327
+ sock.close()
328
+
329
+ def test_isfile_strict(self):
330
+ from psutil._common import isfile_strict
331
+ this_file = os.path.abspath(__file__)
332
+ assert isfile_strict(this_file)
333
+ assert not isfile_strict(os.path.dirname(this_file))
334
+ with mock.patch('psutil._common.os.stat',
335
+ side_effect=OSError(errno.EPERM, "foo")):
336
+ self.assertRaises(OSError, isfile_strict, this_file)
337
+ with mock.patch('psutil._common.os.stat',
338
+ side_effect=OSError(errno.EACCES, "foo")):
339
+ self.assertRaises(OSError, isfile_strict, this_file)
340
+ with mock.patch('psutil._common.os.stat',
341
+ side_effect=OSError(errno.ENOENT, "foo")):
342
+ assert not isfile_strict(this_file)
343
+ with mock.patch('psutil._common.stat.S_ISREG', return_value=False):
344
+ assert not isfile_strict(this_file)
345
+
346
+ def test_serialization(self):
347
+ def check(ret):
348
+ if json is not None:
349
+ json.loads(json.dumps(ret))
350
+ a = pickle.dumps(ret)
351
+ b = pickle.loads(a)
352
+ self.assertEqual(ret, b)
353
+
354
+ check(psutil.Process().as_dict())
355
+ check(psutil.virtual_memory())
356
+ check(psutil.swap_memory())
357
+ check(psutil.cpu_times())
358
+ check(psutil.cpu_times_percent(interval=0))
359
+ check(psutil.net_io_counters())
360
+ if LINUX and not os.path.exists('/proc/diskstats'):
361
+ pass
362
+ else:
363
+ if not APPVEYOR:
364
+ check(psutil.disk_io_counters())
365
+ check(psutil.disk_partitions())
366
+ check(psutil.disk_usage(os.getcwd()))
367
+ check(psutil.users())
368
+
369
+ # XXX: https://github.com/pypa/setuptools/pull/2896
370
+ @unittest.skipIf(APPVEYOR, "temporarily disabled due to setuptools bug")
371
+ def test_setup_script(self):
372
+ setup_py = os.path.join(ROOT_DIR, 'setup.py')
373
+ if CI_TESTING and not os.path.exists(setup_py):
374
+ return self.skipTest("can't find setup.py")
375
+ module = import_module_by_path(setup_py)
376
+ self.assertRaises(SystemExit, module.setup)
377
+ self.assertEqual(module.get_version(), psutil.__version__)
378
+
379
+ def test_ad_on_process_creation(self):
380
+ # We are supposed to be able to instantiate Process also in case
381
+ # of zombie processes or access denied.
382
+ with mock.patch.object(psutil.Process, 'create_time',
383
+ side_effect=psutil.AccessDenied) as meth:
384
+ psutil.Process()
385
+ assert meth.called
386
+ with mock.patch.object(psutil.Process, 'create_time',
387
+ side_effect=psutil.ZombieProcess(1)) as meth:
388
+ psutil.Process()
389
+ assert meth.called
390
+ with mock.patch.object(psutil.Process, 'create_time',
391
+ side_effect=ValueError) as meth:
392
+ with self.assertRaises(ValueError):
393
+ psutil.Process()
394
+ assert meth.called
395
+
396
+ def test_sanity_version_check(self):
397
+ # see: https://github.com/giampaolo/psutil/issues/564
398
+ with mock.patch(
399
+ "psutil._psplatform.cext.version", return_value="0.0.0"):
400
+ with self.assertRaises(ImportError) as cm:
401
+ reload_module(psutil)
402
+ self.assertIn("version conflict", str(cm.exception).lower())
403
+
404
+ def test_debug(self):
405
+ if PY3:
406
+ from io import StringIO
407
+ else:
408
+ from StringIO import StringIO
409
+
410
+ with redirect_stderr(StringIO()) as f:
411
+ debug("hello")
412
+ msg = f.getvalue()
413
+ assert msg.startswith("psutil-debug"), msg
414
+ self.assertIn("hello", msg)
415
+ self.assertIn(__file__.replace('.pyc', '.py'), msg)
416
+
417
+ # supposed to use repr(exc)
418
+ with redirect_stderr(StringIO()) as f:
419
+ debug(ValueError("this is an error"))
420
+ msg = f.getvalue()
421
+ self.assertIn("ignoring ValueError", msg)
422
+ self.assertIn("'this is an error'", msg)
423
+
424
+ # supposed to use str(exc), because of extra info about file name
425
+ with redirect_stderr(StringIO()) as f:
426
+ exc = OSError(2, "no such file")
427
+ exc.filename = "/foo"
428
+ debug(exc)
429
+ msg = f.getvalue()
430
+ self.assertIn("no such file", msg)
431
+ self.assertIn("/foo", msg)
432
+
433
+
434
+ # ===================================================================
435
+ # --- Tests for wrap_numbers() function.
436
+ # ===================================================================
437
+
438
+
439
+ nt = collections.namedtuple('foo', 'a b c')
440
+
441
+
442
+ class TestWrapNumbers(PsutilTestCase):
443
+
444
+ def setUp(self):
445
+ wrap_numbers.cache_clear()
446
+
447
+ tearDown = setUp
448
+
449
+ def test_first_call(self):
450
+ input = {'disk1': nt(5, 5, 5)}
451
+ self.assertEqual(wrap_numbers(input, 'disk_io'), input)
452
+
453
+ def test_input_hasnt_changed(self):
454
+ input = {'disk1': nt(5, 5, 5)}
455
+ self.assertEqual(wrap_numbers(input, 'disk_io'), input)
456
+ self.assertEqual(wrap_numbers(input, 'disk_io'), input)
457
+
458
+ def test_increase_but_no_wrap(self):
459
+ input = {'disk1': nt(5, 5, 5)}
460
+ self.assertEqual(wrap_numbers(input, 'disk_io'), input)
461
+ input = {'disk1': nt(10, 15, 20)}
462
+ self.assertEqual(wrap_numbers(input, 'disk_io'), input)
463
+ input = {'disk1': nt(20, 25, 30)}
464
+ self.assertEqual(wrap_numbers(input, 'disk_io'), input)
465
+ input = {'disk1': nt(20, 25, 30)}
466
+ self.assertEqual(wrap_numbers(input, 'disk_io'), input)
467
+
468
+ def test_wrap(self):
469
+ # let's say 100 is the threshold
470
+ input = {'disk1': nt(100, 100, 100)}
471
+ self.assertEqual(wrap_numbers(input, 'disk_io'), input)
472
+ # first wrap restarts from 10
473
+ input = {'disk1': nt(100, 100, 10)}
474
+ self.assertEqual(wrap_numbers(input, 'disk_io'),
475
+ {'disk1': nt(100, 100, 110)})
476
+ # then it remains the same
477
+ input = {'disk1': nt(100, 100, 10)}
478
+ self.assertEqual(wrap_numbers(input, 'disk_io'),
479
+ {'disk1': nt(100, 100, 110)})
480
+ # then it goes up
481
+ input = {'disk1': nt(100, 100, 90)}
482
+ self.assertEqual(wrap_numbers(input, 'disk_io'),
483
+ {'disk1': nt(100, 100, 190)})
484
+ # then it wraps again
485
+ input = {'disk1': nt(100, 100, 20)}
486
+ self.assertEqual(wrap_numbers(input, 'disk_io'),
487
+ {'disk1': nt(100, 100, 210)})
488
+ # and remains the same
489
+ input = {'disk1': nt(100, 100, 20)}
490
+ self.assertEqual(wrap_numbers(input, 'disk_io'),
491
+ {'disk1': nt(100, 100, 210)})
492
+ # now wrap another num
493
+ input = {'disk1': nt(50, 100, 20)}
494
+ self.assertEqual(wrap_numbers(input, 'disk_io'),
495
+ {'disk1': nt(150, 100, 210)})
496
+ # and again
497
+ input = {'disk1': nt(40, 100, 20)}
498
+ self.assertEqual(wrap_numbers(input, 'disk_io'),
499
+ {'disk1': nt(190, 100, 210)})
500
+ # keep it the same
501
+ input = {'disk1': nt(40, 100, 20)}
502
+ self.assertEqual(wrap_numbers(input, 'disk_io'),
503
+ {'disk1': nt(190, 100, 210)})
504
+
505
+ def test_changing_keys(self):
506
+ # Emulate a case where the second call to disk_io()
507
+ # (or whatever) provides a new disk, then the new disk
508
+ # disappears on the third call.
509
+ input = {'disk1': nt(5, 5, 5)}
510
+ self.assertEqual(wrap_numbers(input, 'disk_io'), input)
511
+ input = {'disk1': nt(5, 5, 5),
512
+ 'disk2': nt(7, 7, 7)}
513
+ self.assertEqual(wrap_numbers(input, 'disk_io'), input)
514
+ input = {'disk1': nt(8, 8, 8)}
515
+ self.assertEqual(wrap_numbers(input, 'disk_io'), input)
516
+
517
+ def test_changing_keys_w_wrap(self):
518
+ input = {'disk1': nt(50, 50, 50),
519
+ 'disk2': nt(100, 100, 100)}
520
+ self.assertEqual(wrap_numbers(input, 'disk_io'), input)
521
+ # disk 2 wraps
522
+ input = {'disk1': nt(50, 50, 50),
523
+ 'disk2': nt(100, 100, 10)}
524
+ self.assertEqual(wrap_numbers(input, 'disk_io'),
525
+ {'disk1': nt(50, 50, 50),
526
+ 'disk2': nt(100, 100, 110)})
527
+ # disk 2 disappears
528
+ input = {'disk1': nt(50, 50, 50)}
529
+ self.assertEqual(wrap_numbers(input, 'disk_io'), input)
530
+
531
+ # then it appears again; the old wrap is supposed to be
532
+ # gone.
533
+ input = {'disk1': nt(50, 50, 50),
534
+ 'disk2': nt(100, 100, 100)}
535
+ self.assertEqual(wrap_numbers(input, 'disk_io'), input)
536
+ # remains the same
537
+ input = {'disk1': nt(50, 50, 50),
538
+ 'disk2': nt(100, 100, 100)}
539
+ self.assertEqual(wrap_numbers(input, 'disk_io'), input)
540
+ # and then wraps again
541
+ input = {'disk1': nt(50, 50, 50),
542
+ 'disk2': nt(100, 100, 10)}
543
+ self.assertEqual(wrap_numbers(input, 'disk_io'),
544
+ {'disk1': nt(50, 50, 50),
545
+ 'disk2': nt(100, 100, 110)})
546
+
547
+ def test_real_data(self):
548
+ d = {'nvme0n1': (300, 508, 640, 1571, 5970, 1987, 2049, 451751, 47048),
549
+ 'nvme0n1p1': (1171, 2, 5600256, 1024, 516, 0, 0, 0, 8),
550
+ 'nvme0n1p2': (54, 54, 2396160, 5165056, 4, 24, 30, 1207, 28),
551
+ 'nvme0n1p3': (2389, 4539, 5154, 150, 4828, 1844, 2019, 398, 348)}
552
+ self.assertEqual(wrap_numbers(d, 'disk_io'), d)
553
+ self.assertEqual(wrap_numbers(d, 'disk_io'), d)
554
+ # decrease this ↓
555
+ d = {'nvme0n1': (100, 508, 640, 1571, 5970, 1987, 2049, 451751, 47048),
556
+ 'nvme0n1p1': (1171, 2, 5600256, 1024, 516, 0, 0, 0, 8),
557
+ 'nvme0n1p2': (54, 54, 2396160, 5165056, 4, 24, 30, 1207, 28),
558
+ 'nvme0n1p3': (2389, 4539, 5154, 150, 4828, 1844, 2019, 398, 348)}
559
+ out = wrap_numbers(d, 'disk_io')
560
+ self.assertEqual(out['nvme0n1'][0], 400)
561
+
562
+ # --- cache tests
563
+
564
+ def test_cache_first_call(self):
565
+ input = {'disk1': nt(5, 5, 5)}
566
+ wrap_numbers(input, 'disk_io')
567
+ cache = wrap_numbers.cache_info()
568
+ self.assertEqual(cache[0], {'disk_io': input})
569
+ self.assertEqual(cache[1], {'disk_io': {}})
570
+ self.assertEqual(cache[2], {'disk_io': {}})
571
+
572
+ def test_cache_call_twice(self):
573
+ input = {'disk1': nt(5, 5, 5)}
574
+ wrap_numbers(input, 'disk_io')
575
+ input = {'disk1': nt(10, 10, 10)}
576
+ wrap_numbers(input, 'disk_io')
577
+ cache = wrap_numbers.cache_info()
578
+ self.assertEqual(cache[0], {'disk_io': input})
579
+ self.assertEqual(
580
+ cache[1],
581
+ {'disk_io': {('disk1', 0): 0, ('disk1', 1): 0, ('disk1', 2): 0}})
582
+ self.assertEqual(cache[2], {'disk_io': {}})
583
+
584
+ def test_cache_wrap(self):
585
+ # let's say 100 is the threshold
586
+ input = {'disk1': nt(100, 100, 100)}
587
+ wrap_numbers(input, 'disk_io')
588
+
589
+ # first wrap restarts from 10
590
+ input = {'disk1': nt(100, 100, 10)}
591
+ wrap_numbers(input, 'disk_io')
592
+ cache = wrap_numbers.cache_info()
593
+ self.assertEqual(cache[0], {'disk_io': input})
594
+ self.assertEqual(
595
+ cache[1],
596
+ {'disk_io': {('disk1', 0): 0, ('disk1', 1): 0, ('disk1', 2): 100}})
597
+ self.assertEqual(cache[2], {'disk_io': {'disk1': set([('disk1', 2)])}})
598
+
599
+ def assert_():
600
+ cache = wrap_numbers.cache_info()
601
+ self.assertEqual(
602
+ cache[1],
603
+ {'disk_io': {('disk1', 0): 0, ('disk1', 1): 0,
604
+ ('disk1', 2): 100}})
605
+ self.assertEqual(cache[2],
606
+ {'disk_io': {'disk1': set([('disk1', 2)])}})
607
+
608
+ # then it remains the same
609
+ input = {'disk1': nt(100, 100, 10)}
610
+ wrap_numbers(input, 'disk_io')
611
+ cache = wrap_numbers.cache_info()
612
+ self.assertEqual(cache[0], {'disk_io': input})
613
+ assert_()
614
+
615
+ # then it goes up
616
+ input = {'disk1': nt(100, 100, 90)}
617
+ wrap_numbers(input, 'disk_io')
618
+ cache = wrap_numbers.cache_info()
619
+ self.assertEqual(cache[0], {'disk_io': input})
620
+ assert_()
621
+
622
+ # then it wraps again
623
+ input = {'disk1': nt(100, 100, 20)}
624
+ wrap_numbers(input, 'disk_io')
625
+ cache = wrap_numbers.cache_info()
626
+ self.assertEqual(cache[0], {'disk_io': input})
627
+ self.assertEqual(
628
+ cache[1],
629
+ {'disk_io': {('disk1', 0): 0, ('disk1', 1): 0, ('disk1', 2): 190}})
630
+ self.assertEqual(cache[2], {'disk_io': {'disk1': set([('disk1', 2)])}})
631
+
632
+ def test_cache_changing_keys(self):
633
+ input = {'disk1': nt(5, 5, 5)}
634
+ wrap_numbers(input, 'disk_io')
635
+ input = {'disk1': nt(5, 5, 5),
636
+ 'disk2': nt(7, 7, 7)}
637
+ wrap_numbers(input, 'disk_io')
638
+ cache = wrap_numbers.cache_info()
639
+ self.assertEqual(cache[0], {'disk_io': input})
640
+ self.assertEqual(
641
+ cache[1],
642
+ {'disk_io': {('disk1', 0): 0, ('disk1', 1): 0, ('disk1', 2): 0}})
643
+ self.assertEqual(cache[2], {'disk_io': {}})
644
+
645
+ def test_cache_clear(self):
646
+ input = {'disk1': nt(5, 5, 5)}
647
+ wrap_numbers(input, 'disk_io')
648
+ wrap_numbers(input, 'disk_io')
649
+ wrap_numbers.cache_clear('disk_io')
650
+ self.assertEqual(wrap_numbers.cache_info(), ({}, {}, {}))
651
+ wrap_numbers.cache_clear('disk_io')
652
+ wrap_numbers.cache_clear('?!?')
653
+
654
+ @unittest.skipIf(not HAS_NET_IO_COUNTERS, 'not supported')
655
+ def test_cache_clear_public_apis(self):
656
+ if not psutil.disk_io_counters() or not psutil.net_io_counters():
657
+ return self.skipTest("no disks or NICs available")
658
+ psutil.disk_io_counters()
659
+ psutil.net_io_counters()
660
+ caches = wrap_numbers.cache_info()
661
+ for cache in caches:
662
+ self.assertIn('psutil.disk_io_counters', cache)
663
+ self.assertIn('psutil.net_io_counters', cache)
664
+
665
+ psutil.disk_io_counters.cache_clear()
666
+ caches = wrap_numbers.cache_info()
667
+ for cache in caches:
668
+ self.assertIn('psutil.net_io_counters', cache)
669
+ self.assertNotIn('psutil.disk_io_counters', cache)
670
+
671
+ psutil.net_io_counters.cache_clear()
672
+ caches = wrap_numbers.cache_info()
673
+ self.assertEqual(caches, ({}, {}, {}))
674
+
675
+
676
+ # ===================================================================
677
+ # --- Example script tests
678
+ # ===================================================================
679
+
680
+
681
+ @unittest.skipIf(not os.path.exists(SCRIPTS_DIR),
682
+ "can't locate scripts directory")
683
+ class TestScripts(PsutilTestCase):
684
+ """Tests for scripts in the "scripts" directory."""
685
+
686
+ @staticmethod
687
+ def assert_stdout(exe, *args, **kwargs):
688
+ exe = '%s' % os.path.join(SCRIPTS_DIR, exe)
689
+ cmd = [PYTHON_EXE, exe]
690
+ for arg in args:
691
+ cmd.append(arg)
692
+ try:
693
+ out = sh(cmd, **kwargs).strip()
694
+ except RuntimeError as err:
695
+ if 'AccessDenied' in str(err):
696
+ return str(err)
697
+ else:
698
+ raise
699
+ assert out, out
700
+ return out
701
+
702
+ @staticmethod
703
+ def assert_syntax(exe, args=None):
704
+ exe = os.path.join(SCRIPTS_DIR, exe)
705
+ if PY3:
706
+ f = open(exe, 'rt', encoding='utf8')
707
+ else:
708
+ f = open(exe, 'rt')
709
+ with f:
710
+ src = f.read()
711
+ ast.parse(src)
712
+
713
+ def test_coverage(self):
714
+ # make sure all example scripts have a test method defined
715
+ meths = dir(self)
716
+ for name in os.listdir(SCRIPTS_DIR):
717
+ if name.endswith('.py'):
718
+ if 'test_' + os.path.splitext(name)[0] not in meths:
719
+ # self.assert_stdout(name)
720
+ self.fail('no test defined for %r script'
721
+ % os.path.join(SCRIPTS_DIR, name))
722
+
723
+ @unittest.skipIf(not POSIX, "POSIX only")
724
+ def test_executable(self):
725
+ for root, dirs, files in os.walk(SCRIPTS_DIR):
726
+ for file in files:
727
+ if file.endswith('.py'):
728
+ path = os.path.join(root, file)
729
+ if not stat.S_IXUSR & os.stat(path)[stat.ST_MODE]:
730
+ raise self.fail('%r is not executable' % path)
731
+
732
+ def test_disk_usage(self):
733
+ self.assert_stdout('disk_usage.py')
734
+
735
+ def test_free(self):
736
+ self.assert_stdout('free.py')
737
+
738
+ def test_meminfo(self):
739
+ self.assert_stdout('meminfo.py')
740
+
741
+ def test_procinfo(self):
742
+ self.assert_stdout('procinfo.py', str(os.getpid()))
743
+
744
+ @unittest.skipIf(CI_TESTING and not psutil.users(), "no users")
745
+ def test_who(self):
746
+ self.assert_stdout('who.py')
747
+
748
+ def test_ps(self):
749
+ self.assert_stdout('ps.py')
750
+
751
+ def test_pstree(self):
752
+ self.assert_stdout('pstree.py')
753
+
754
+ def test_netstat(self):
755
+ self.assert_stdout('netstat.py')
756
+
757
+ def test_ifconfig(self):
758
+ self.assert_stdout('ifconfig.py')
759
+
760
+ @unittest.skipIf(not HAS_MEMORY_MAPS, "not supported")
761
+ def test_pmap(self):
762
+ self.assert_stdout('pmap.py', str(os.getpid()))
763
+
764
+ def test_procsmem(self):
765
+ if 'uss' not in psutil.Process().memory_full_info()._fields:
766
+ raise self.skipTest("not supported")
767
+ self.assert_stdout('procsmem.py')
768
+
769
+ def test_killall(self):
770
+ self.assert_syntax('killall.py')
771
+
772
+ def test_nettop(self):
773
+ self.assert_syntax('nettop.py')
774
+
775
+ def test_top(self):
776
+ self.assert_syntax('top.py')
777
+
778
+ def test_iotop(self):
779
+ self.assert_syntax('iotop.py')
780
+
781
+ def test_pidof(self):
782
+ output = self.assert_stdout('pidof.py', psutil.Process().name())
783
+ self.assertIn(str(os.getpid()), output)
784
+
785
+ @unittest.skipIf(not WINDOWS, "WINDOWS only")
786
+ def test_winservices(self):
787
+ self.assert_stdout('winservices.py')
788
+
789
+ def test_cpu_distribution(self):
790
+ self.assert_syntax('cpu_distribution.py')
791
+
792
+ @unittest.skipIf(not HAS_SENSORS_TEMPERATURES, "not supported")
793
+ def test_temperatures(self):
794
+ if not psutil.sensors_temperatures():
795
+ self.skipTest("no temperatures")
796
+ self.assert_stdout('temperatures.py')
797
+
798
+ @unittest.skipIf(not HAS_SENSORS_FANS, "not supported")
799
+ def test_fans(self):
800
+ if not psutil.sensors_fans():
801
+ self.skipTest("no fans")
802
+ self.assert_stdout('fans.py')
803
+
804
+ @unittest.skipIf(not HAS_SENSORS_BATTERY, "not supported")
805
+ @unittest.skipIf(not HAS_BATTERY, "no battery")
806
+ def test_battery(self):
807
+ self.assert_stdout('battery.py')
808
+
809
+ @unittest.skipIf(not HAS_SENSORS_BATTERY, "not supported")
810
+ @unittest.skipIf(not HAS_BATTERY, "no battery")
811
+ def test_sensors(self):
812
+ self.assert_stdout('sensors.py')
813
+
814
+
815
+ if __name__ == '__main__':
816
+ from psutil.tests.runner import run_from_name
817
+ run_from_name(__file__)
shared/package-files/16/16033882a6d6169e8ab949d59fe1fc5085d9813c9d05e3b10dd6de6c9d06a547/Beirut ADDED
Binary file (732 Bytes). View file
 
shared/package-files/16/16057baf8869a43ae675c8ed37fa22cbc022075ab517c84ff14080e58d1b0454/__main__.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2012 Anaconda, Inc
2
+ # SPDX-License-Identifier: BSD-3-Clause
3
+ import sys
4
+
5
+ from conda.deprecations import deprecated
6
+
7
+ from .cli.main import main
8
+
9
+ deprecated.module("23.9", "24.3", addendum="Use `conda env` instead.")
10
+
11
+ sys.exit(main())
shared/package-files/16/1615c5f580983a25a294b6338e5133235341fda0dc79b4dbf38ffc201006675c/test_interval_example.py ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ This test is used by `docs/source/extending/interval-example.rst`.
3
+
4
+ The "magictoken" comments are used as markers for the beginning and ending of
5
+ example code.
6
+ """
7
+ import unittest
8
+
9
+
10
+ class IntervalExampleTest(unittest.TestCase):
11
+
12
+ def test_interval_class_usage(self):
13
+ # magictoken.interval_py_class.begin
14
+ class Interval(object):
15
+ """
16
+ A half-open interval on the real number line.
17
+ """
18
+ def __init__(self, lo, hi):
19
+ self.lo = lo
20
+ self.hi = hi
21
+
22
+ def __repr__(self):
23
+ return 'Interval(%f, %f)' % (self.lo, self.hi)
24
+
25
+ @property
26
+ def width(self):
27
+ return self.hi - self.lo
28
+ # magictoken.interval_py_class.end
29
+
30
+ # magictoken.interval_type_class.begin
31
+ from numba import types
32
+
33
+ class IntervalType(types.Type):
34
+ def __init__(self):
35
+ super(IntervalType, self).__init__(name='Interval')
36
+
37
+ interval_type = IntervalType()
38
+ # magictoken.interval_type_class.end
39
+
40
+ # magictoken.interval_typeof_register.begin
41
+ from numba.extending import typeof_impl
42
+
43
+ @typeof_impl.register(Interval)
44
+ def typeof_index(val, c):
45
+ return interval_type
46
+ # magictoken.interval_typeof_register.end
47
+
48
+ # magictoken.numba_type_register.begin
49
+ from numba.extending import as_numba_type
50
+
51
+ as_numba_type.register(Interval, interval_type)
52
+ # magictoken.numba_type_register.end
53
+
54
+ # magictoken.numba_type_callable.begin
55
+ from numba.extending import type_callable
56
+
57
+ @type_callable(Interval)
58
+ def type_interval(context):
59
+ def typer(lo, hi):
60
+ if isinstance(lo, types.Float) and isinstance(hi, types.Float):
61
+ return interval_type
62
+ return typer
63
+ # magictoken.numba_type_callable.end
64
+
65
+ # magictoken.interval_model.begin
66
+ from numba.extending import models, register_model
67
+
68
+ @register_model(IntervalType)
69
+ class IntervalModel(models.StructModel):
70
+ def __init__(self, dmm, fe_type):
71
+ members = [('lo', types.float64),
72
+ ('hi', types.float64),]
73
+ models.StructModel.__init__(self, dmm, fe_type, members)
74
+ # magictoken.interval_model.end
75
+
76
+ # magictoken.interval_attribute_wrapper.begin
77
+ from numba.extending import make_attribute_wrapper
78
+
79
+ make_attribute_wrapper(IntervalType, 'lo', 'lo')
80
+ make_attribute_wrapper(IntervalType, 'hi', 'hi')
81
+ # magictoken.interval_attribute_wrapper.end
82
+
83
+ # magictoken.interval_overload_attribute.begin
84
+ from numba.extending import overload_attribute
85
+
86
+ @overload_attribute(IntervalType, "width")
87
+ def get_width(interval):
88
+ def getter(interval):
89
+ return interval.hi - interval.lo
90
+ return getter
91
+ # magictoken.interval_overload_attribute.end
92
+
93
+ # magictoken.interval_lower_builtin.begin
94
+ from numba.extending import lower_builtin
95
+ from numba.core import cgutils
96
+
97
+ @lower_builtin(Interval, types.Float, types.Float)
98
+ def impl_interval(context, builder, sig, args):
99
+ typ = sig.return_type
100
+ lo, hi = args
101
+ interval = cgutils.create_struct_proxy(typ)(context, builder)
102
+ interval.lo = lo
103
+ interval.hi = hi
104
+ return interval._getvalue()
105
+ # magictoken.interval_lower_builtin.end
106
+
107
+ # magictoken.interval_unbox.begin
108
+ from numba.extending import unbox, NativeValue
109
+ from contextlib import ExitStack
110
+
111
+ @unbox(IntervalType)
112
+ def unbox_interval(typ, obj, c):
113
+ """
114
+ Convert a Interval object to a native interval structure.
115
+ """
116
+ is_error_ptr = cgutils.alloca_once_value(c.builder, cgutils.false_bit)
117
+ interval = cgutils.create_struct_proxy(typ)(c.context, c.builder)
118
+
119
+ with ExitStack() as stack:
120
+ lo_obj = c.pyapi.object_getattr_string(obj, "lo")
121
+ with cgutils.early_exit_if_null(c.builder, stack, lo_obj):
122
+ c.builder.store(cgutils.true_bit, is_error_ptr)
123
+ lo_native = c.unbox(types.float64, lo_obj)
124
+ c.pyapi.decref(lo_obj)
125
+ with cgutils.early_exit_if(c.builder, stack, lo_native.is_error):
126
+ c.builder.store(cgutils.true_bit, is_error_ptr)
127
+
128
+ hi_obj = c.pyapi.object_getattr_string(obj, "hi")
129
+ with cgutils.early_exit_if_null(c.builder, stack, hi_obj):
130
+ c.builder.store(cgutils.true_bit, is_error_ptr)
131
+ hi_native = c.unbox(types.float64, hi_obj)
132
+ c.pyapi.decref(hi_obj)
133
+ with cgutils.early_exit_if(c.builder, stack, hi_native.is_error):
134
+ c.builder.store(cgutils.true_bit, is_error_ptr)
135
+
136
+ interval.lo = lo_native.value
137
+ interval.hi = hi_native.value
138
+
139
+ return NativeValue(interval._getvalue(), is_error=c.builder.load(is_error_ptr))
140
+ # magictoken.interval_unbox.end
141
+
142
+ # magictoken.interval_box.begin
143
+ from numba.extending import box
144
+
145
+ @box(IntervalType)
146
+ def box_interval(typ, val, c):
147
+ """
148
+ Convert a native interval structure to an Interval object.
149
+ """
150
+ ret_ptr = cgutils.alloca_once(c.builder, c.pyapi.pyobj)
151
+ fail_obj = c.pyapi.get_null_object()
152
+
153
+ with ExitStack() as stack:
154
+ interval = cgutils.create_struct_proxy(typ)(c.context, c.builder, value=val)
155
+ lo_obj = c.box(types.float64, interval.lo)
156
+ with cgutils.early_exit_if_null(c.builder, stack, lo_obj):
157
+ c.builder.store(fail_obj, ret_ptr)
158
+
159
+ hi_obj = c.box(types.float64, interval.hi)
160
+ with cgutils.early_exit_if_null(c.builder, stack, hi_obj):
161
+ c.pyapi.decref(lo_obj)
162
+ c.builder.store(fail_obj, ret_ptr)
163
+
164
+ class_obj = c.pyapi.unserialize(c.pyapi.serialize_object(Interval))
165
+ with cgutils.early_exit_if_null(c.builder, stack, class_obj):
166
+ c.pyapi.decref(lo_obj)
167
+ c.pyapi.decref(hi_obj)
168
+ c.builder.store(fail_obj, ret_ptr)
169
+
170
+ # NOTE: The result of this call is not checked as the clean up
171
+ # has to occur regardless of whether it is successful. If it
172
+ # fails `res` is set to NULL and a Python exception is set.
173
+ res = c.pyapi.call_function_objargs(class_obj, (lo_obj, hi_obj))
174
+ c.pyapi.decref(lo_obj)
175
+ c.pyapi.decref(hi_obj)
176
+ c.pyapi.decref(class_obj)
177
+ c.builder.store(res, ret_ptr)
178
+
179
+ return c.builder.load(ret_ptr)
180
+ # magictoken.interval_box.end
181
+
182
+ # magictoken.interval_usage.begin
183
+ from numba import njit
184
+
185
+ @njit
186
+ def inside_interval(interval, x):
187
+ return interval.lo <= x < interval.hi
188
+
189
+ @njit
190
+ def interval_width(interval):
191
+ return interval.width
192
+
193
+ @njit
194
+ def sum_intervals(i, j):
195
+ return Interval(i.lo + j.lo, i.hi + j.hi)
196
+ # magictoken.interval_usage.end
197
+
198
+ def check_equal_intervals(x, y):
199
+ self.assertIsInstance(x, Interval)
200
+ self.assertIsInstance(y, Interval)
201
+ self.assertEqual(x.lo, y.lo)
202
+ self.assertEqual(x.hi, y.hi)
203
+
204
+ a = Interval(2, 3)
205
+ b = Interval(4, 5)
206
+ c = Interval(6, 8)
207
+
208
+ # Test box-unbox
209
+ return_func = njit(lambda x: x)
210
+ check_equal_intervals(a, return_func(a))
211
+
212
+ # Test .width attribute
213
+ self.assertEqual(a.width, interval_width(a))
214
+
215
+ # Test exceptions
216
+ class NotAFloat:
217
+ def __float__(self):
218
+ raise RuntimeError("I am not a float")
219
+
220
+ # TODO: This should produce a `RuntimeError`, but the `unbox` handler for `float` ignores
221
+ # the error raised by `__float__`, leading to a subsequent `TypeError` cause by passing
222
+ # `NULL` to `PyFloat_AsDouble`.
223
+ # This isn't the fault of the `Interval` extension that is being testing
224
+ # in this file.
225
+ with self.assertRaises(TypeError):
226
+ interval_width(Interval(2, NotAFloat()))
227
+
228
+ bad_interval = Interval(1, 2)
229
+ del bad_interval.hi
230
+
231
+ with self.assertRaises(AttributeError):
232
+ interval_width(bad_interval)
233
+
234
+ # Test .lo and .hi usage
235
+ self.assertFalse(inside_interval(a, 5))
236
+
237
+ # Test native Interval constructor
238
+ check_equal_intervals(c, sum_intervals(a, b))
239
+
240
+
241
+ if __name__ == '__main__':
242
+ unittest.main()
shared/package-files/16/16174d2cf8c2ee4b900bf8573106bc61c1ce0092da4fa781cc0ee81047a46539/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019-2021 Anthon van der Neut, Ruamel bvba
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
shared/package-files/16/161bc121d645c5143e753c246ffd2669d44a815042694310cfd239c6a8c4e624/languages.py ADDED
@@ -0,0 +1,352 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Metadata about languages used by our model training code for our
3
+ SingleByteCharSetProbers. Could be used for other things in the future.
4
+
5
+ This code is based on the language metadata from the uchardet project.
6
+ """
7
+
8
+ from string import ascii_letters
9
+ from typing import List, Optional
10
+
11
+ # TODO: Add Ukrainian (KOI8-U)
12
+
13
+
14
+ class Language:
15
+ """Metadata about a language useful for training models
16
+
17
+ :ivar name: The human name for the language, in English.
18
+ :type name: str
19
+ :ivar iso_code: 2-letter ISO 639-1 if possible, 3-letter ISO code otherwise,
20
+ or use another catalog as a last resort.
21
+ :type iso_code: str
22
+ :ivar use_ascii: Whether or not ASCII letters should be included in trained
23
+ models.
24
+ :type use_ascii: bool
25
+ :ivar charsets: The charsets we want to support and create data for.
26
+ :type charsets: list of str
27
+ :ivar alphabet: The characters in the language's alphabet. If `use_ascii` is
28
+ `True`, you only need to add those not in the ASCII set.
29
+ :type alphabet: str
30
+ :ivar wiki_start_pages: The Wikipedia pages to start from if we're crawling
31
+ Wikipedia for training data.
32
+ :type wiki_start_pages: list of str
33
+ """
34
+
35
+ def __init__(
36
+ self,
37
+ name: Optional[str] = None,
38
+ iso_code: Optional[str] = None,
39
+ use_ascii: bool = True,
40
+ charsets: Optional[List[str]] = None,
41
+ alphabet: Optional[str] = None,
42
+ wiki_start_pages: Optional[List[str]] = None,
43
+ ) -> None:
44
+ super().__init__()
45
+ self.name = name
46
+ self.iso_code = iso_code
47
+ self.use_ascii = use_ascii
48
+ self.charsets = charsets
49
+ if self.use_ascii:
50
+ if alphabet:
51
+ alphabet += ascii_letters
52
+ else:
53
+ alphabet = ascii_letters
54
+ elif not alphabet:
55
+ raise ValueError("Must supply alphabet if use_ascii is False")
56
+ self.alphabet = "".join(sorted(set(alphabet))) if alphabet else None
57
+ self.wiki_start_pages = wiki_start_pages
58
+
59
+ def __repr__(self) -> str:
60
+ param_str = ", ".join(
61
+ f"{k}={v!r}" for k, v in self.__dict__.items() if not k.startswith("_")
62
+ )
63
+ return f"{self.__class__.__name__}({param_str})"
64
+
65
+
66
+ LANGUAGES = {
67
+ "Arabic": Language(
68
+ name="Arabic",
69
+ iso_code="ar",
70
+ use_ascii=False,
71
+ # We only support encodings that use isolated
72
+ # forms, because the current recommendation is
73
+ # that the rendering system handles presentation
74
+ # forms. This means we purposefully skip IBM864.
75
+ charsets=["ISO-8859-6", "WINDOWS-1256", "CP720", "CP864"],
76
+ alphabet="ءآأؤإئابةتثجحخدذرزسشصضطظعغػؼؽؾؿـفقكلمنهوىيًٌٍَُِّ",
77
+ wiki_start_pages=["الصفحة_الرئيسية"],
78
+ ),
79
+ "Belarusian": Language(
80
+ name="Belarusian",
81
+ iso_code="be",
82
+ use_ascii=False,
83
+ charsets=["ISO-8859-5", "WINDOWS-1251", "IBM866", "MacCyrillic"],
84
+ alphabet="АБВГДЕЁЖЗІЙКЛМНОПРСТУЎФХЦЧШЫЬЭЮЯабвгдеёжзійклмнопрстуўфхцчшыьэюяʼ",
85
+ wiki_start_pages=["Галоўная_старонка"],
86
+ ),
87
+ "Bulgarian": Language(
88
+ name="Bulgarian",
89
+ iso_code="bg",
90
+ use_ascii=False,
91
+ charsets=["ISO-8859-5", "WINDOWS-1251", "IBM855"],
92
+ alphabet="АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЬЮЯабвгдежзийклмнопрстуфхцчшщъьюя",
93
+ wiki_start_pages=["Начална_страница"],
94
+ ),
95
+ "Czech": Language(
96
+ name="Czech",
97
+ iso_code="cz",
98
+ use_ascii=True,
99
+ charsets=["ISO-8859-2", "WINDOWS-1250"],
100
+ alphabet="áčďéěíňóřšťúůýžÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ",
101
+ wiki_start_pages=["Hlavní_strana"],
102
+ ),
103
+ "Danish": Language(
104
+ name="Danish",
105
+ iso_code="da",
106
+ use_ascii=True,
107
+ charsets=["ISO-8859-1", "ISO-8859-15", "WINDOWS-1252", "MacRoman"],
108
+ alphabet="æøåÆØÅ",
109
+ wiki_start_pages=["Forside"],
110
+ ),
111
+ "German": Language(
112
+ name="German",
113
+ iso_code="de",
114
+ use_ascii=True,
115
+ charsets=["ISO-8859-1", "ISO-8859-15", "WINDOWS-1252", "MacRoman"],
116
+ alphabet="äöüßẞÄÖÜ",
117
+ wiki_start_pages=["Wikipedia:Hauptseite"],
118
+ ),
119
+ "Greek": Language(
120
+ name="Greek",
121
+ iso_code="el",
122
+ use_ascii=False,
123
+ charsets=["ISO-8859-7", "WINDOWS-1253"],
124
+ alphabet="αβγδεζηθικλμνξοπρσςτυφχψωάέήίόύώΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΣΤΥΦΧΨΩΆΈΉΊΌΎΏ",
125
+ wiki_start_pages=["Πύλη:Κύρια"],
126
+ ),
127
+ "English": Language(
128
+ name="English",
129
+ iso_code="en",
130
+ use_ascii=True,
131
+ charsets=["ISO-8859-1", "WINDOWS-1252", "MacRoman"],
132
+ wiki_start_pages=["Main_Page"],
133
+ ),
134
+ "Esperanto": Language(
135
+ name="Esperanto",
136
+ iso_code="eo",
137
+ # Q, W, X, and Y not used at all
138
+ use_ascii=False,
139
+ charsets=["ISO-8859-3"],
140
+ alphabet="abcĉdefgĝhĥijĵklmnoprsŝtuŭvzABCĈDEFGĜHĤIJĴKLMNOPRSŜTUŬVZ",
141
+ wiki_start_pages=["Vikipedio:Ĉefpaĝo"],
142
+ ),
143
+ "Spanish": Language(
144
+ name="Spanish",
145
+ iso_code="es",
146
+ use_ascii=True,
147
+ charsets=["ISO-8859-1", "ISO-8859-15", "WINDOWS-1252", "MacRoman"],
148
+ alphabet="ñáéíóúüÑÁÉÍÓÚÜ",
149
+ wiki_start_pages=["Wikipedia:Portada"],
150
+ ),
151
+ "Estonian": Language(
152
+ name="Estonian",
153
+ iso_code="et",
154
+ use_ascii=False,
155
+ charsets=["ISO-8859-4", "ISO-8859-13", "WINDOWS-1257"],
156
+ # C, F, Š, Q, W, X, Y, Z, Ž are only for
157
+ # loanwords
158
+ alphabet="ABDEGHIJKLMNOPRSTUVÕÄÖÜabdeghijklmnoprstuvõäöü",
159
+ wiki_start_pages=["Esileht"],
160
+ ),
161
+ "Finnish": Language(
162
+ name="Finnish",
163
+ iso_code="fi",
164
+ use_ascii=True,
165
+ charsets=["ISO-8859-1", "ISO-8859-15", "WINDOWS-1252", "MacRoman"],
166
+ alphabet="ÅÄÖŠŽåäöšž",
167
+ wiki_start_pages=["Wikipedia:Etusivu"],
168
+ ),
169
+ "French": Language(
170
+ name="French",
171
+ iso_code="fr",
172
+ use_ascii=True,
173
+ charsets=["ISO-8859-1", "ISO-8859-15", "WINDOWS-1252", "MacRoman"],
174
+ alphabet="œàâçèéîïùûêŒÀÂÇÈÉÎÏÙÛÊ",
175
+ wiki_start_pages=["Wikipédia:Accueil_principal", "Bœuf (animal)"],
176
+ ),
177
+ "Hebrew": Language(
178
+ name="Hebrew",
179
+ iso_code="he",
180
+ use_ascii=False,
181
+ charsets=["ISO-8859-8", "WINDOWS-1255"],
182
+ alphabet="אבגדהוזחטיךכלםמןנסעףפץצקרשתװױײ",
183
+ wiki_start_pages=["עמוד_ראשי"],
184
+ ),
185
+ "Croatian": Language(
186
+ name="Croatian",
187
+ iso_code="hr",
188
+ # Q, W, X, Y are only used for foreign words.
189
+ use_ascii=False,
190
+ charsets=["ISO-8859-2", "WINDOWS-1250"],
191
+ alphabet="abcčćdđefghijklmnoprsštuvzžABCČĆDĐEFGHIJKLMNOPRSŠTUVZŽ",
192
+ wiki_start_pages=["Glavna_stranica"],
193
+ ),
194
+ "Hungarian": Language(
195
+ name="Hungarian",
196
+ iso_code="hu",
197
+ # Q, W, X, Y are only used for foreign words.
198
+ use_ascii=False,
199
+ charsets=["ISO-8859-2", "WINDOWS-1250"],
200
+ alphabet="abcdefghijklmnoprstuvzáéíóöőúüűABCDEFGHIJKLMNOPRSTUVZÁÉÍÓÖŐÚÜŰ",
201
+ wiki_start_pages=["Kezdőlap"],
202
+ ),
203
+ "Italian": Language(
204
+ name="Italian",
205
+ iso_code="it",
206
+ use_ascii=True,
207
+ charsets=["ISO-8859-1", "ISO-8859-15", "WINDOWS-1252", "MacRoman"],
208
+ alphabet="ÀÈÉÌÒÓÙàèéìòóù",
209
+ wiki_start_pages=["Pagina_principale"],
210
+ ),
211
+ "Lithuanian": Language(
212
+ name="Lithuanian",
213
+ iso_code="lt",
214
+ use_ascii=False,
215
+ charsets=["ISO-8859-13", "WINDOWS-1257", "ISO-8859-4"],
216
+ # Q, W, and X not used at all
217
+ alphabet="AĄBCČDEĘĖFGHIĮYJKLMNOPRSŠTUŲŪVZŽaąbcčdeęėfghiįyjklmnoprsštuųūvzž",
218
+ wiki_start_pages=["Pagrindinis_puslapis"],
219
+ ),
220
+ "Latvian": Language(
221
+ name="Latvian",
222
+ iso_code="lv",
223
+ use_ascii=False,
224
+ charsets=["ISO-8859-13", "WINDOWS-1257", "ISO-8859-4"],
225
+ # Q, W, X, Y are only for loanwords
226
+ alphabet="AĀBCČDEĒFGĢHIĪJKĶLĻMNŅOPRSŠTUŪVZŽaābcčdeēfgģhiījkķlļmnņoprsštuūvzž",
227
+ wiki_start_pages=["Sākumlapa"],
228
+ ),
229
+ "Macedonian": Language(
230
+ name="Macedonian",
231
+ iso_code="mk",
232
+ use_ascii=False,
233
+ charsets=["ISO-8859-5", "WINDOWS-1251", "MacCyrillic", "IBM855"],
234
+ alphabet="АБВГДЃЕЖЗЅИЈКЛЉМНЊОПРСТЌУФХЦЧЏШабвгдѓежзѕијклљмнњопрстќуфхцчџш",
235
+ wiki_start_pages=["Главна_страница"],
236
+ ),
237
+ "Dutch": Language(
238
+ name="Dutch",
239
+ iso_code="nl",
240
+ use_ascii=True,
241
+ charsets=["ISO-8859-1", "WINDOWS-1252", "MacRoman"],
242
+ wiki_start_pages=["Hoofdpagina"],
243
+ ),
244
+ "Polish": Language(
245
+ name="Polish",
246
+ iso_code="pl",
247
+ # Q and X are only used for foreign words.
248
+ use_ascii=False,
249
+ charsets=["ISO-8859-2", "WINDOWS-1250"],
250
+ alphabet="AĄBCĆDEĘFGHIJKLŁMNŃOÓPRSŚTUWYZŹŻaąbcćdeęfghijklłmnńoóprsśtuwyzźż",
251
+ wiki_start_pages=["Wikipedia:Strona_główna"],
252
+ ),
253
+ "Portuguese": Language(
254
+ name="Portuguese",
255
+ iso_code="pt",
256
+ use_ascii=True,
257
+ charsets=["ISO-8859-1", "ISO-8859-15", "WINDOWS-1252", "MacRoman"],
258
+ alphabet="ÁÂÃÀÇÉÊÍÓÔÕÚáâãàçéêíóôõú",
259
+ wiki_start_pages=["Wikipédia:Página_principal"],
260
+ ),
261
+ "Romanian": Language(
262
+ name="Romanian",
263
+ iso_code="ro",
264
+ use_ascii=True,
265
+ charsets=["ISO-8859-2", "WINDOWS-1250"],
266
+ alphabet="ăâîșțĂÂÎȘȚ",
267
+ wiki_start_pages=["Pagina_principală"],
268
+ ),
269
+ "Russian": Language(
270
+ name="Russian",
271
+ iso_code="ru",
272
+ use_ascii=False,
273
+ charsets=[
274
+ "ISO-8859-5",
275
+ "WINDOWS-1251",
276
+ "KOI8-R",
277
+ "MacCyrillic",
278
+ "IBM866",
279
+ "IBM855",
280
+ ],
281
+ alphabet="абвгдеёжзийклмнопрстуфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ",
282
+ wiki_start_pages=["Заглавная_страница"],
283
+ ),
284
+ "Slovak": Language(
285
+ name="Slovak",
286
+ iso_code="sk",
287
+ use_ascii=True,
288
+ charsets=["ISO-8859-2", "WINDOWS-1250"],
289
+ alphabet="áäčďéíĺľňóôŕšťúýžÁÄČĎÉÍĹĽŇÓÔŔŠŤÚÝŽ",
290
+ wiki_start_pages=["Hlavná_stránka"],
291
+ ),
292
+ "Slovene": Language(
293
+ name="Slovene",
294
+ iso_code="sl",
295
+ # Q, W, X, Y are only used for foreign words.
296
+ use_ascii=False,
297
+ charsets=["ISO-8859-2", "WINDOWS-1250"],
298
+ alphabet="abcčdefghijklmnoprsštuvzžABCČDEFGHIJKLMNOPRSŠTUVZŽ",
299
+ wiki_start_pages=["Glavna_stran"],
300
+ ),
301
+ # Serbian can be written in both Latin and Cyrillic, but there's no
302
+ # simple way to get the Latin alphabet pages from Wikipedia through
303
+ # the API, so for now we just support Cyrillic.
304
+ "Serbian": Language(
305
+ name="Serbian",
306
+ iso_code="sr",
307
+ alphabet="АБВГДЂЕЖЗИЈКЛЉМНЊОПРСТЋУФХЦЧЏШабвгдђежзијклљмнњопрстћуфхцчџш",
308
+ charsets=["ISO-8859-5", "WINDOWS-1251", "MacCyrillic", "IBM855"],
309
+ wiki_start_pages=["Главна_страна"],
310
+ ),
311
+ "Thai": Language(
312
+ name="Thai",
313
+ iso_code="th",
314
+ use_ascii=False,
315
+ charsets=["ISO-8859-11", "TIS-620", "CP874"],
316
+ alphabet="กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำิีึืฺุู฿เแโใไๅๆ็่้๊๋์ํ๎๏๐๑๒๓๔๕๖๗๘๙๚๛",
317
+ wiki_start_pages=["หน้าหลัก"],
318
+ ),
319
+ "Turkish": Language(
320
+ name="Turkish",
321
+ iso_code="tr",
322
+ # Q, W, and X are not used by Turkish
323
+ use_ascii=False,
324
+ charsets=["ISO-8859-3", "ISO-8859-9", "WINDOWS-1254"],
325
+ alphabet="abcçdefgğhıijklmnoöprsştuüvyzâîûABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZÂÎÛ",
326
+ wiki_start_pages=["Ana_Sayfa"],
327
+ ),
328
+ "Vietnamese": Language(
329
+ name="Vietnamese",
330
+ iso_code="vi",
331
+ use_ascii=False,
332
+ # Windows-1258 is the only common 8-bit
333
+ # Vietnamese encoding supported by Python.
334
+ # From Wikipedia:
335
+ # For systems that lack support for Unicode,
336
+ # dozens of 8-bit Vietnamese code pages are
337
+ # available.[1] The most common are VISCII
338
+ # (TCVN 5712:1993), VPS, and Windows-1258.[3]
339
+ # Where ASCII is required, such as when
340
+ # ensuring readability in plain text e-mail,
341
+ # Vietnamese letters are often encoded
342
+ # according to Vietnamese Quoted-Readable
343
+ # (VIQR) or VSCII Mnemonic (VSCII-MNEM),[4]
344
+ # though usage of either variable-width
345
+ # scheme has declined dramatically following
346
+ # the adoption of Unicode on the World Wide
347
+ # Web.
348
+ charsets=["WINDOWS-1258"],
349
+ alphabet="aăâbcdđeêghiklmnoôơpqrstuưvxyAĂÂBCDĐEÊGHIKLMNOÔƠPQRSTUƯVXY",
350
+ wiki_start_pages=["Chữ_Quốc_ngữ"],
351
+ ),
352
+ }
shared/package-files/16/16202e5d3dd3db194a39a8e3410eb9459308ceead1e5ba8b3f614567f5f17a80/parse.py ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from collections import defaultdict, namedtuple
2
+ from typing import Any, Dict, List, Optional, Set, Tuple
3
+
4
+ import yaml
5
+
6
+ from torchgen.executorch.model import ETKernelIndex, ETKernelKey
7
+
8
+ from torchgen.gen import LineLoader, parse_native_yaml
9
+ from torchgen.model import (
10
+ BackendMetadata,
11
+ DispatchKey,
12
+ FunctionSchema,
13
+ NativeFunction,
14
+ OperatorName,
15
+ )
16
+ from torchgen.utils import NamespaceHelper
17
+
18
+ # Parse native_functions.yaml into a sequence of NativeFunctions and ET Backend Indices.
19
+ ETParsedYaml = namedtuple("ETParsedYaml", ["native_functions", "et_kernel_indices"])
20
+
21
+ # Fields in native_functions.yaml used to determine which kernels should be used
22
+ ET_FIELDS = ["kernels", "type_alias", "dim_order_alias"]
23
+
24
+
25
+ def parse_from_yaml(ei: Dict[str, object]) -> Dict[ETKernelKey, BackendMetadata]:
26
+ """Given a loaded yaml representing kernel assignment information, extract the
27
+ mapping from `kernel keys` to `BackendMetadata` (the latter representing the kernel instance)
28
+
29
+ Args:
30
+ ei: Dict keys {kernels, type_alias, dim_order_alias}
31
+ See ETKernelKey for description of arguments
32
+ """
33
+ e = ei.copy()
34
+ if (kernels := e.pop("kernels", None)) is None:
35
+ return {}
36
+
37
+ type_alias: Dict[str, List[str]] = e.pop("type_alias", {}) # type: ignore[assignment]
38
+ dim_order_alias: Dict[str, List[str]] = e.pop("dim_order_alias", {}) # type: ignore[assignment]
39
+ dim_order_alias.pop("__line__", None)
40
+
41
+ kernel_mapping: Dict[ETKernelKey, BackendMetadata] = {}
42
+
43
+ for entry in kernels: # type: ignore[attr-defined]
44
+ arg_meta = entry.get("arg_meta")
45
+ if arg_meta is not None:
46
+ arg_meta.pop("__line__")
47
+
48
+ kernel_name = entry.get("kernel_name")
49
+ namespace_helper = NamespaceHelper.from_namespaced_entity(
50
+ kernel_name, max_level=3
51
+ )
52
+ kernel_namespace = namespace_helper.get_cpp_namespace(default="at")
53
+ backend_metadata = BackendMetadata(
54
+ kernel=namespace_helper.entity_name,
55
+ structured=False,
56
+ cpp_namespace=(kernel_namespace + "::native"),
57
+ )
58
+
59
+ kernel_keys = (
60
+ [ETKernelKey((), default=True)]
61
+ if arg_meta is None
62
+ else ETKernelKey.gen_from_yaml(arg_meta, type_alias, dim_order_alias) # type: ignore[arg-type]
63
+ )
64
+
65
+ for kernel_key in kernel_keys:
66
+ assert kernel_key not in kernel_mapping, (
67
+ "Duplicate kernel key: " + str(kernel_key) + " " + str(e)
68
+ )
69
+ kernel_mapping[kernel_key] = backend_metadata
70
+
71
+ return kernel_mapping
72
+
73
+
74
+ def parse_et_yaml_struct(es: object) -> ETKernelIndex:
75
+ """Given a loaded yaml representing a list of operators, for each op extract the mapping
76
+ of `kernel keys` to `BackendMetadata` (the latter representing the kernel instance
77
+ that should be used by the kernel key).
78
+ """
79
+ indices: Dict[OperatorName, Dict[ETKernelKey, BackendMetadata]] = {}
80
+ for ei in es: # type: ignore[attr-defined]
81
+ e = ei.copy()
82
+
83
+ funcs = e.pop("func")
84
+ assert isinstance(funcs, str), f"not a str: {funcs}"
85
+ namespace_helper = NamespaceHelper.from_namespaced_entity(
86
+ namespaced_entity=funcs, max_level=1
87
+ )
88
+ opname = FunctionSchema.parse(namespace_helper.entity_name).name
89
+
90
+ assert opname not in indices, f"Duplicate func found in yaml: {opname} already"
91
+
92
+ if len(index := parse_from_yaml(e)) != 0:
93
+ indices[opname] = index
94
+
95
+ return ETKernelIndex(indices)
96
+
97
+
98
+ def extract_kernel_fields(es: object) -> Dict[OperatorName, Dict[str, Any]]:
99
+ """Given a loaded yaml representing a list of operators, extract the
100
+ kernel key related fields indexed by the operator name.
101
+ """
102
+ fields: Dict[OperatorName, Dict[str, Any]] = defaultdict(dict)
103
+ for ei in es: # type: ignore[attr-defined]
104
+ funcs = ei.get("func")
105
+ assert isinstance(funcs, str), f"not a str: {funcs}"
106
+ namespace_helper = NamespaceHelper.from_namespaced_entity(
107
+ namespaced_entity=funcs, max_level=1
108
+ )
109
+ opname = FunctionSchema.parse(namespace_helper.entity_name).name
110
+
111
+ for field in ET_FIELDS:
112
+ if (value := ei.get(field)) is not None:
113
+ fields[opname][field] = value
114
+
115
+ return fields
116
+
117
+
118
+ def parse_et_yaml(
119
+ path: str,
120
+ tags_yaml_path: str,
121
+ ignore_keys: Optional[Set[DispatchKey]] = None,
122
+ skip_native_fns_gen: bool = False,
123
+ ) -> Tuple[List[NativeFunction], Dict[OperatorName, Dict[str, Any]]]:
124
+ """Parse native_functions.yaml into NativeFunctions and an Operator Indexed Dict
125
+ of fields to persist from native_functions.yaml to functions.yaml
126
+ """
127
+ with open(path) as f:
128
+ es = yaml.load(f, Loader=LineLoader)
129
+
130
+ et_kernel = extract_kernel_fields(es)
131
+
132
+ # Remove ET specific fields from entries for BC compatibility
133
+ strip_et_fields(es)
134
+
135
+ native_yaml = parse_native_yaml(
136
+ path,
137
+ tags_yaml_path,
138
+ ignore_keys,
139
+ skip_native_fns_gen=skip_native_fns_gen,
140
+ loaded_yaml=es,
141
+ )
142
+ return native_yaml.native_functions, et_kernel
143
+
144
+
145
+ def strip_et_fields(es: object) -> None:
146
+ """Given a loaded yaml representing a list of operators,
147
+ remove ET specific fields from every entries for BC compatibility
148
+ """
149
+ for entry in es: # type: ignore[attr-defined]
150
+ for field in ET_FIELDS:
151
+ entry.pop(field, None)
shared/package-files/16/1621ac63f7f370877e0f57bf09ddd5e5f95f0d2cc980e98713fe5acafb9b3cda/clip.h ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+
3
+ // @generated by torchgen/gen.py from Function.h
4
+
5
+ #include <ATen/Context.h>
6
+ #include <ATen/DeviceGuard.h>
7
+ #include <ATen/TensorUtils.h>
8
+ #include <ATen/TracerMode.h>
9
+ #include <ATen/core/Generator.h>
10
+ #include <ATen/core/Reduction.h>
11
+ #include <ATen/core/Tensor.h>
12
+ #include <c10/core/Scalar.h>
13
+ #include <c10/core/Storage.h>
14
+ #include <c10/core/TensorOptions.h>
15
+ #include <c10/util/Deprecated.h>
16
+ #include <c10/util/Optional.h>
17
+
18
+
19
+
20
+ #include <ATen/ops/clip_ops.h>
21
+
22
+ namespace at {
23
+
24
+
25
+ // aten::clip(Tensor self, Scalar? min=None, Scalar? max=None) -> Tensor
26
+ inline at::Tensor clip(const at::Tensor & self, const c10::optional<at::Scalar> & min, const c10::optional<at::Scalar> & max=c10::nullopt) {
27
+ return at::_ops::clip::call(self, min, max);
28
+ }
29
+
30
+ // aten::clip.Tensor(Tensor self, Tensor? min=None, Tensor? max=None) -> Tensor
31
+ inline at::Tensor clip(const at::Tensor & self, const c10::optional<at::Tensor> & min={}, const c10::optional<at::Tensor> & max={}) {
32
+ return at::_ops::clip_Tensor::call(self, min, max);
33
+ }
34
+
35
+ // aten::clip_(Tensor(a!) self, Scalar? min=None, Scalar? max=None) -> Tensor(a!)
36
+ inline at::Tensor & clip_(at::Tensor & self, const c10::optional<at::Scalar> & min, const c10::optional<at::Scalar> & max=c10::nullopt) {
37
+ return at::_ops::clip_::call(self, min, max);
38
+ }
39
+
40
+ // aten::clip_.Tensor(Tensor(a!) self, Tensor? min=None, Tensor? max=None) -> Tensor(a!)
41
+ inline at::Tensor & clip_(at::Tensor & self, const c10::optional<at::Tensor> & min={}, const c10::optional<at::Tensor> & max={}) {
42
+ return at::_ops::clip__Tensor::call(self, min, max);
43
+ }
44
+
45
+ // aten::clip.out(Tensor self, Scalar? min=None, Scalar? max=None, *, Tensor(a!) out) -> Tensor(a!)
46
+ inline at::Tensor & clip_out(at::Tensor & out, const at::Tensor & self, const c10::optional<at::Scalar> & min, const c10::optional<at::Scalar> & max=c10::nullopt) {
47
+ return at::_ops::clip_out::call(self, min, max, out);
48
+ }
49
+ // aten::clip.out(Tensor self, Scalar? min=None, Scalar? max=None, *, Tensor(a!) out) -> Tensor(a!)
50
+ inline at::Tensor & clip_outf(const at::Tensor & self, const c10::optional<at::Scalar> & min, const c10::optional<at::Scalar> & max, at::Tensor & out) {
51
+ return at::_ops::clip_out::call(self, min, max, out);
52
+ }
53
+
54
+ // aten::clip.Tensor_out(Tensor self, Tensor? min=None, Tensor? max=None, *, Tensor(a!) out) -> Tensor(a!)
55
+ inline at::Tensor & clip_out(at::Tensor & out, const at::Tensor & self, const c10::optional<at::Tensor> & min={}, const c10::optional<at::Tensor> & max={}) {
56
+ return at::_ops::clip_Tensor_out::call(self, min, max, out);
57
+ }
58
+ // aten::clip.Tensor_out(Tensor self, Tensor? min=None, Tensor? max=None, *, Tensor(a!) out) -> Tensor(a!)
59
+ inline at::Tensor & clip_outf(const at::Tensor & self, const c10::optional<at::Tensor> & min, const c10::optional<at::Tensor> & max, at::Tensor & out) {
60
+ return at::_ops::clip_Tensor_out::call(self, min, max, out);
61
+ }
62
+
63
+ }
shared/package-files/16/16250f6a659bf706f1c2b5552ad817c8688ba5bb02112f5b63da182bd752872a/utils.h ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+
3
+ #include <ATen/Tensor.h>
4
+ #include <ATen/core/List.h>
5
+ #include <c10/core/DeviceType.h>
6
+ #include <c10/core/SymIntArrayRef.h>
7
+ #include <c10/util/ArrayRef.h>
8
+ #include <c10/util/Logging.h>
9
+ #include <c10/util/Optional.h>
10
+ #include <c10/util/OptionalArrayRef.h>
11
+ #include <torch/csrc/inductor/aoti_torch/c/shim.h>
12
+ #include <torch/csrc/inductor/aoti_torch/tensor_converter.h>
13
+
14
+ #define AOTI_TORCH_CONVERT_EXCEPTION_TO_ERROR_CODE(...) \
15
+ try { \
16
+ __VA_ARGS__ \
17
+ } catch (const std::exception& e) { \
18
+ LOG(ERROR) << "Exception in aoti_torch: " << e.what(); \
19
+ return AOTI_TORCH_FAILURE; \
20
+ } catch (...) { \
21
+ LOG(ERROR) << "Exception in aoti_torch: UNKNOWN"; \
22
+ return AOTI_TORCH_FAILURE; \
23
+ } \
24
+ return AOTI_TORCH_SUCCESS;
25
+
26
+ namespace torch::aot_inductor {
27
+
28
+ // utility functions to convert a pointer to an optional value
29
+ template <class T>
30
+ inline c10::optional<T> pointer_to_optional(T* ptr) {
31
+ return ptr ? c10::make_optional(*ptr) : c10::nullopt;
32
+ }
33
+
34
+ template <class T, class U, typename = std::enable_if_t<!std::is_same_v<T, U>>>
35
+ inline c10::optional<T> pointer_to_optional(U* ptr) {
36
+ return ptr ? c10::make_optional<T>(T(*ptr)) : c10::nullopt;
37
+ }
38
+
39
+ template <>
40
+ inline c10::optional<at::Tensor> pointer_to_optional(AtenTensorHandle* ptr) {
41
+ return ptr ? c10::make_optional(*tensor_handle_to_tensor_pointer(*ptr))
42
+ : c10::nullopt;
43
+ }
44
+
45
+ template <>
46
+ inline c10::optional<at::Tensor> pointer_to_optional(
47
+ const AtenTensorHandle* ptr) {
48
+ return ptr ? c10::make_optional(*tensor_handle_to_tensor_pointer(*ptr))
49
+ : c10::nullopt;
50
+ }
51
+
52
+ inline c10::optional<c10::Device> pointer_to_optional_device(
53
+ int32_t* device_type,
54
+ int32_t device_index) {
55
+ return device_type ? c10::make_optional(c10::Device(
56
+ static_cast<c10::DeviceType>(*device_type),
57
+ static_cast<c10::DeviceIndex>(device_index)))
58
+ : c10::nullopt;
59
+ }
60
+
61
+ // utility functions to convert a pointer to a list
62
+ template <typename T>
63
+ struct is_optional : std::false_type {};
64
+ template <typename T>
65
+ struct is_optional<c10::optional<T>> : std::true_type {};
66
+
67
+ template <class T>
68
+ inline c10::ArrayRef<T> pointer_to_list(T* ptr, int64_t len) {
69
+ return c10::ArrayRef<T>(ptr, len);
70
+ }
71
+
72
+ template <
73
+ class T,
74
+ class U,
75
+ typename = std::enable_if_t<!std::is_same_v<T, U>>,
76
+ typename = std::enable_if_t<!is_optional<T>::value>>
77
+ inline std::vector<T> pointer_to_list(U* ptr, int64_t len) {
78
+ // std::vector<T> will be implicitly converted to c10::ArrayRef<T> at the call
79
+ // site
80
+ std::vector<T> result;
81
+ result.reserve(len);
82
+ for (int64_t i = 0; i < len; i++) {
83
+ result.emplace_back(T(ptr[i]));
84
+ }
85
+ return result;
86
+ }
87
+
88
+ template <class T, class U, typename = std::enable_if_t<is_optional<T>::value>>
89
+ inline std::vector<T> pointer_to_list(U** ptr, int64_t len) {
90
+ // Here U** denotes a list of optional arguments
91
+ // std::vector<T> will be implicitly converted to c10::ArrayRef<T> at the call
92
+ // site
93
+ std::vector<T> result;
94
+ result.reserve(len);
95
+ for (int64_t i = 0; i < len; i++) {
96
+ result.emplace_back(pointer_to_optional(ptr[i]));
97
+ }
98
+ return result;
99
+ }
100
+
101
+ template <>
102
+ inline std::vector<at::Tensor> pointer_to_list(
103
+ const AtenTensorHandle* ptr,
104
+ int64_t len) {
105
+ std::vector<at::Tensor> result;
106
+ result.reserve(len);
107
+ for (int64_t i = 0; i < len; i++) {
108
+ result.emplace_back(*tensor_handle_to_tensor_pointer(*ptr));
109
+ }
110
+ return result;
111
+ }
112
+
113
+ template <>
114
+ inline std::vector<c10::optional<at::Tensor>> pointer_to_list(
115
+ const AtenTensorHandle** ptr,
116
+ int64_t len) {
117
+ std::vector<c10::optional<at::Tensor>> result;
118
+ result.reserve(len);
119
+ for (int64_t i = 0; i < len; i++) {
120
+ result.emplace_back(pointer_to_optional<at::Tensor>(ptr[i]));
121
+ }
122
+ return result;
123
+ }
124
+
125
+ template <int N>
126
+ inline std::array<bool, N> pointer_to_list(const int32_t* ptr) {
127
+ std::array<bool, N> result;
128
+ std::copy(ptr, ptr + N, result.begin());
129
+ return result;
130
+ }
131
+
132
+ // utility functions to convert a pointer to a list of optional values
133
+ template <class T, class U>
134
+ inline c10::optional<c10::ArrayRef<T>> pointer_to_optional_list(
135
+ U** ptr,
136
+ int64_t len) {
137
+ return ptr
138
+ ? c10::make_optional<c10::ArrayRef<T>>(pointer_to_list<T>(*ptr, len))
139
+ : c10::nullopt;
140
+ }
141
+
142
+ } // namespace torch::aot_inductor
shared/package-files/16/162ad6a69cbabc486b6d8fa6503971c856ac28c734ef9d0a794ad1d1803fed8e/utils.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # flake8: noqa: F401
2
+ r"""Quantized Reference Modules.
3
+
4
+ This module is in the process of migration to
5
+ `torch/ao/nn/quantized/reference`, and is kept here for
6
+ compatibility while the migration process is ongoing.
7
+ If you are adding a new entry/functionality, please, add it to the
8
+ appropriate file under the `torch/ao/nn/quantized/reference`,
9
+ while adding an import statement here.
10
+ """
11
+ from torch.ao.nn.quantized.reference.modules.utils import _quantize_weight
12
+ from torch.ao.nn.quantized.reference.modules.utils import _quantize_and_dequantize_weight
13
+ from torch.ao.nn.quantized.reference.modules.utils import _save_weight_qparams
14
+ from torch.ao.nn.quantized.reference.modules.utils import _get_weight_qparam_keys
15
+ from torch.ao.nn.quantized.reference.modules.utils import ReferenceQuantizedModule
shared/package-files/16/162b711c973429ddad4b91de60a5aae6f236df82e752f97aa0e4c7c885927917/sparse_sampled_addmm_native.h ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+
3
+ // @generated by torchgen/gen.py from NativeFunction.h
4
+
5
+ #include <c10/core/Scalar.h>
6
+ #include <c10/core/Storage.h>
7
+ #include <c10/core/TensorOptions.h>
8
+ #include <c10/util/Deprecated.h>
9
+ #include <c10/util/Optional.h>
10
+ #include <c10/core/QScheme.h>
11
+ #include <ATen/core/Reduction.h>
12
+ #include <ATen/core/Tensor.h>
13
+ #include <tuple>
14
+ #include <vector>
15
+
16
+
17
+ namespace at {
18
+ namespace native {
19
+ TORCH_API at::Tensor sparse_sampled_addmm_sparse_csr_cpu(const at::Tensor & self, const at::Tensor & mat1, const at::Tensor & mat2, const at::Scalar & beta=1, const at::Scalar & alpha=1);
20
+ TORCH_API at::Tensor & sparse_sampled_addmm_out_sparse_csr_cpu(const at::Tensor & self, const at::Tensor & mat1, const at::Tensor & mat2, const at::Scalar & beta, const at::Scalar & alpha, at::Tensor & out);
21
+ TORCH_API at::Tensor sparse_sampled_addmm_sparse_csr_cuda(const at::Tensor & self, const at::Tensor & mat1, const at::Tensor & mat2, const at::Scalar & beta=1, const at::Scalar & alpha=1);
22
+ TORCH_API at::Tensor & sparse_sampled_addmm_out_sparse_csr_cuda(const at::Tensor & self, const at::Tensor & mat1, const at::Tensor & mat2, const at::Scalar & beta, const at::Scalar & alpha, at::Tensor & out);
23
+ } // namespace native
24
+ } // namespace at
shared/package-files/16/162d579e3864086d2da78dc072fa486a2bc3f98445a6e7e8e9f78622b7a7403a/_f_e_a_t.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from .otBase import BaseTTXConverter
2
+
3
+
4
+ class table__f_e_a_t(BaseTTXConverter):
5
+ """Feature name table
6
+
7
+ The feature name table is an AAT (Apple Advanced Typography) table for
8
+ storing font features, settings, and their human-readable names. It should
9
+ not be confused with the ``Feat`` table or the OpenType Layout ``GSUB``/``GPOS``
10
+ tables.
11
+
12
+ See also https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6feat.html
13
+ """
14
+
15
+ pass
shared/package-files/16/163075cd4fb5bcc7339b62c5006a8bcd855bd839af6804216dd0b1ecc17346ac/adaptive_avg_pool3d_native.h ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+
3
+ // @generated by torchgen/gen.py from NativeFunction.h
4
+
5
+ #include <c10/core/Scalar.h>
6
+ #include <c10/core/Storage.h>
7
+ #include <c10/core/TensorOptions.h>
8
+ #include <c10/util/Deprecated.h>
9
+ #include <c10/util/Optional.h>
10
+ #include <c10/core/QScheme.h>
11
+ #include <ATen/core/Reduction.h>
12
+ #include <ATen/core/Tensor.h>
13
+ #include <tuple>
14
+ #include <vector>
15
+
16
+
17
+ namespace at {
18
+ namespace native {
19
+ TORCH_API at::Tensor adaptive_avg_pool3d_symint(const at::Tensor & self, c10::SymIntArrayRef output_size);
20
+ TORCH_API at::Tensor & adaptive_avg_pool3d_out_cpu(const at::Tensor & self, at::IntArrayRef output_size, at::Tensor & out);
21
+ TORCH_API at::Tensor & adaptive_avg_pool3d_out_cuda(const at::Tensor & self, at::IntArrayRef output_size, at::Tensor & out);
22
+ TORCH_API at::Tensor & adaptive_avg_pool3d_out_quantized_cpu(const at::Tensor & self, at::IntArrayRef output_size, at::Tensor & out);
23
+ } // namespace native
24
+ } // namespace at
shared/package-files/16/16315ccfc573643485fa747e7456f2775c332f95d0a6ea48d1d6f6fabd05c8fe/span.h ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Licensed to the Apache Software Foundation (ASF) under one
2
+ // or more contributor license agreements. See the NOTICE file
3
+ // distributed with this work for additional information
4
+ // regarding copyright ownership. The ASF licenses this file
5
+ // to you under the Apache License, Version 2.0 (the
6
+ // "License"); you may not use this file except in compliance
7
+ // with the License. You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing,
12
+ // software distributed under the License is distributed on an
13
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ // KIND, either express or implied. See the License for the
15
+ // specific language governing permissions and limitations
16
+ // under the License.
17
+
18
+ #pragma once
19
+
20
+ #include <cstddef>
21
+ #include <cstdint>
22
+ #include <cstring>
23
+ #include <iterator>
24
+ #include <type_traits>
25
+
26
+ namespace arrow::util {
27
+
28
+ template <class T>
29
+ class span;
30
+
31
+ /// std::span polyfill.
32
+ ///
33
+ /// Does not support static extents.
34
+ template <typename T>
35
+ class span {
36
+ static_assert(sizeof(T),
37
+ R"(
38
+ std::span allows contiguous_iterators instead of just pointers, the enforcement
39
+ of which requires T to be a complete type. arrow::util::span does not support
40
+ contiguous_iterators, but T is still required to be a complete type to prevent
41
+ writing code which would break when it is replaced by std::span.)");
42
+
43
+ public:
44
+ using element_type = T;
45
+ using value_type = std::remove_cv_t<T>;
46
+ using iterator = T*;
47
+ using const_iterator = T const*;
48
+
49
+ span() = default;
50
+ span(const span&) = default;
51
+ span& operator=(const span&) = default;
52
+
53
+ template <typename M, typename = std::enable_if_t<std::is_same_v<T, M const>>>
54
+ // NOLINTNEXTLINE runtime/explicit
55
+ constexpr span(span<M> mut) : span{mut.data(), mut.size()} {}
56
+
57
+ constexpr span(T* data, size_t count) : data_{data}, size_{count} {}
58
+
59
+ constexpr span(T* begin, T* end)
60
+ : data_{begin}, size_{static_cast<size_t>(end - begin)} {}
61
+
62
+ template <typename R, typename RD = decltype(std::data(std::declval<R>())),
63
+ typename RS = decltype(std::size(std::declval<R>())),
64
+ typename E = std::enable_if_t<std::is_constructible_v<T*, RD> &&
65
+ std::is_constructible_v<size_t, RS>>>
66
+ // NOLINTNEXTLINE runtime/explicit, non-const reference
67
+ constexpr span(R&& range) : data_{std::data(range)}, size_{std::size(range)} {}
68
+
69
+ constexpr T* begin() const { return data_; }
70
+ constexpr T* end() const { return data_ + size_; }
71
+ constexpr T* data() const { return data_; }
72
+
73
+ constexpr size_t size() const { return size_; }
74
+ constexpr size_t size_bytes() const { return size_ * sizeof(T); }
75
+ constexpr bool empty() const { return size_ == 0; }
76
+
77
+ constexpr T& operator[](size_t i) { return data_[i]; }
78
+ constexpr const T& operator[](size_t i) const { return data_[i]; }
79
+
80
+ constexpr span subspan(size_t offset) const {
81
+ if (offset > size_) return {data_, data_};
82
+ return {data_ + offset, size_ - offset};
83
+ }
84
+
85
+ constexpr span subspan(size_t offset, size_t count) const {
86
+ auto out = subspan(offset);
87
+ if (count < out.size_) {
88
+ out.size_ = count;
89
+ }
90
+ return out;
91
+ }
92
+
93
+ constexpr bool operator==(const span& other) const {
94
+ if (size_ != other.size_) return false;
95
+
96
+ if constexpr (std::is_integral_v<T>) {
97
+ if (size_ == 0) {
98
+ return true; // memcmp does not handle null pointers, even if size_ == 0
99
+ }
100
+ return std::memcmp(data_, other.data_, size_bytes()) == 0;
101
+ } else {
102
+ T* ptr = data_;
103
+ for (T const& e : other) {
104
+ if (*ptr++ != e) return false;
105
+ }
106
+ return true;
107
+ }
108
+ }
109
+ constexpr bool operator!=(const span& other) const { return !(*this == other); }
110
+
111
+ private:
112
+ T* data_{};
113
+ size_t size_{};
114
+ };
115
+
116
+ template <typename R>
117
+ span(R& range) -> span<std::remove_pointer_t<decltype(std::data(range))>>;
118
+
119
+ template <typename T>
120
+ span(T*, size_t) -> span<T>;
121
+
122
+ template <typename T>
123
+ constexpr span<std::byte const> as_bytes(span<T> s) {
124
+ return {reinterpret_cast<const std::byte*>(s.data()), s.size_bytes()};
125
+ }
126
+
127
+ template <typename T>
128
+ constexpr span<std::byte> as_writable_bytes(span<T> s) {
129
+ return {reinterpret_cast<std::byte*>(s.data()), s.size_bytes()};
130
+ }
131
+
132
+ } // namespace arrow::util
shared/package-files/16/163614ad430017b84ece985a5c40ffffcca3785d074dc7194baab4e7ffeb1f8e/test_show_versions.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import os
3
+ import re
4
+
5
+ from pandas.util._print_versions import (
6
+ _get_dependency_info,
7
+ _get_sys_info,
8
+ )
9
+
10
+ import pandas as pd
11
+
12
+
13
+ def test_show_versions(tmpdir):
14
+ # GH39701
15
+ as_json = os.path.join(tmpdir, "test_output.json")
16
+
17
+ pd.show_versions(as_json=as_json)
18
+
19
+ with open(as_json, encoding="utf-8") as fd:
20
+ # check if file output is valid JSON, will raise an exception if not
21
+ result = json.load(fd)
22
+
23
+ # Basic check that each version element is found in output
24
+ expected = {
25
+ "system": _get_sys_info(),
26
+ "dependencies": _get_dependency_info(),
27
+ }
28
+
29
+ assert result == expected
30
+
31
+
32
+ def test_show_versions_console_json(capsys):
33
+ # GH39701
34
+ pd.show_versions(as_json=True)
35
+ stdout = capsys.readouterr().out
36
+
37
+ # check valid json is printed to the console if as_json is True
38
+ result = json.loads(stdout)
39
+
40
+ # Basic check that each version element is found in output
41
+ expected = {
42
+ "system": _get_sys_info(),
43
+ "dependencies": _get_dependency_info(),
44
+ }
45
+
46
+ assert result == expected
47
+
48
+
49
+ def test_show_versions_console(capsys):
50
+ # gh-32041
51
+ # gh-32041
52
+ pd.show_versions(as_json=False)
53
+ result = capsys.readouterr().out
54
+
55
+ # check header
56
+ assert "INSTALLED VERSIONS" in result
57
+
58
+ # check full commit hash
59
+ assert re.search(r"commit\s*:\s[0-9a-f]{40}\n", result)
60
+
61
+ # check required dependency
62
+ # 2020-12-09 npdev has "dirty" in the tag
63
+ # 2022-05-25 npdev released with RC wo/ "dirty".
64
+ # Just ensure we match [0-9]+\..* since npdev version is variable
65
+ assert re.search(r"numpy\s*:\s[0-9]+\..*\n", result)
66
+
67
+ # check optional dependency
68
+ assert re.search(r"pyarrow\s*:\s([0-9]+.*|None)\n", result)
69
+
70
+
71
+ def test_json_output_match(capsys, tmpdir):
72
+ # GH39701
73
+ pd.show_versions(as_json=True)
74
+ result_console = capsys.readouterr().out
75
+
76
+ out_path = os.path.join(tmpdir, "test_json.json")
77
+ pd.show_versions(as_json=out_path)
78
+ with open(out_path, encoding="utf-8") as out_fd:
79
+ result_file = out_fd.read()
80
+
81
+ assert result_console == result_file
shared/package-files/16/1636d924c27e84973e7d8272ee6aeaf8738702b9975290c0af58b5fcf84bdb48/_adaptive_avg_pool2d_backward_cuda_dispatch.h ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
3
+
4
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
5
+
6
+ // The only #includes we need are for custom classes that have defaults in the C++ API
7
+ #include <c10/core/MemoryFormat.h>
8
+ #include <c10/core/Scalar.h>
9
+ #include <ATen/core/Reduction.h>
10
+
11
+ // Forward declarations of any types needed in the operator signatures.
12
+ // We can't directly include these classes because it will cause circular include dependencies.
13
+ // This file is included by TensorBody.h, which defines the Tensor class.
14
+ #include <ATen/core/ATen_fwd.h>
15
+
16
+ namespace at {
17
+
18
+ namespace cuda {
19
+
20
+ TORCH_API at::Tensor _adaptive_avg_pool2d_backward(const at::Tensor & grad_output, const at::Tensor & self);
21
+
22
+ } // namespace cuda
23
+ } // namespace at
shared/package-files/16/163b071d43e7da3411202efb5d2b90659ce4954f96087a447b155833d1c94eae/complex_compositeexplicitautograd_dispatch.h ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
3
+
4
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
5
+
6
+ // The only #includes we need are for custom classes that have defaults in the C++ API
7
+ #include <c10/core/MemoryFormat.h>
8
+ #include <c10/core/Scalar.h>
9
+ #include <ATen/core/Reduction.h>
10
+
11
+ // Forward declarations of any types needed in the operator signatures.
12
+ // We can't directly include these classes because it will cause circular include dependencies.
13
+ // This file is included by TensorBody.h, which defines the Tensor class.
14
+ #include <ATen/core/ATen_fwd.h>
15
+
16
+ namespace at {
17
+
18
+ namespace compositeexplicitautograd {
19
+
20
+ TORCH_API at::Tensor complex(const at::Tensor & real, const at::Tensor & imag);
21
+
22
+ } // namespace compositeexplicitautograd
23
+ } // namespace at
shared/package-files/16/163bba5a7779d7347e96d8d948a5633f62d59ad18aa0f39d83b847c0088a9ffe/op_benchmark.py ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Example use of Timer and op fuzzers to measure kernel performance.
2
+
3
+ $ python -m examples.op_benchmark
4
+ """
5
+
6
+ import numpy as np
7
+ import torch
8
+
9
+ from torch.utils.benchmark import Timer
10
+ from torch.utils.benchmark.op_fuzzers.binary import BinaryOpFuzzer
11
+ from torch.utils.benchmark.op_fuzzers.unary import UnaryOpFuzzer
12
+
13
+
14
+ _MEASURE_TIME = 1.0
15
+
16
+
17
+ def assert_dicts_equal(dict_0, dict_1):
18
+ """Builtin dict comparison will not compare numpy arrays.
19
+ e.g.
20
+ x = {"a": np.ones((2, 1))}
21
+ x == x # Raises ValueError
22
+ """
23
+ assert set(dict_0.keys()) == set(dict_0.keys())
24
+ assert all(np.all(v == dict_1[k]) for k, v in dict_0.items() if k != "dtype")
25
+
26
+
27
+ def run(n, stmt, fuzzer_cls):
28
+ float_iter = fuzzer_cls(seed=0, dtype=torch.float32).take(n)
29
+ int_iter = fuzzer_cls(seed=0, dtype=torch.int32).take(n)
30
+ raw_results = []
31
+ for i, (float_values, int_values) in enumerate(zip(float_iter, int_iter)):
32
+ float_tensors, float_tensor_params, float_params = float_values
33
+ int_tensors, int_tensor_params, int_params = int_values
34
+
35
+ # This benchmark assumes that the two fuzzers generate identically
36
+ # sized and strided Tensors, since the same seed is used.
37
+ assert_dicts_equal(float_params, int_params)
38
+ assert_dicts_equal(float_tensor_params["x"], int_tensor_params["x"])
39
+
40
+ float_measurement, int_measurement = (
41
+ Timer(
42
+ stmt,
43
+ globals=tensors,
44
+ ).blocked_autorange(min_run_time=_MEASURE_TIME)
45
+ for tensors in (float_tensors, int_tensors)
46
+ )
47
+
48
+ descriptions = []
49
+ for name in float_tensors:
50
+ shape_str = "(" + ", ".join([
51
+ f"2 ** {int(np.log2(i))}"
52
+ if 2 ** int(np.log2(i)) == i and i > 1
53
+ else str(i)
54
+ for i in float_tensors[name].shape
55
+ ]) + ")"
56
+ order = float_tensor_params[name]["order"]
57
+ order_str = ("" if all(order == np.arange(len(order))) else str(tuple(order)))
58
+ steps = float_tensor_params[name]["steps"]
59
+ steps_str = str(steps) if sum(steps) > len(steps) else ""
60
+ descriptions.append((name, shape_str, order_str, steps_str))
61
+ raw_results.append((float_measurement, int_measurement, descriptions))
62
+
63
+ print(f"\r{i + 1} / {n}", end="")
64
+ print()
65
+
66
+ parsed_results, name_len, shape_len, order_len, steps_len = [], 0, 0, 0, 0
67
+ for float_measurement, int_measurement, descriptions in raw_results:
68
+ t_float = float_measurement.median * 1e6
69
+ t_int = int_measurement.median * 1e6
70
+ rel_diff = abs(t_float - t_int) / (t_float + t_int) * 2
71
+ parsed_results.append((t_float, t_int, rel_diff, descriptions))
72
+ for name, shape, order, steps in descriptions:
73
+ name_len = max(name_len, len(name))
74
+ shape_len = max(shape_len, len(shape))
75
+ order_len = max(order_len, len(order))
76
+ steps_len = max(steps_len, len(steps))
77
+
78
+ parsed_results.sort(key=lambda x: x[2])
79
+
80
+ print(f"stmt: {stmt}")
81
+ print(f" diff faster{'':>17}{' ' * name_len} ", end="")
82
+ print(f"{'shape'.ljust(shape_len)}{'':>16}{'order'.ljust(order_len)}", end="")
83
+ print(f" steps\n{'-' * 100}")
84
+ for results, spacer in [(parsed_results[:10], "..."), (parsed_results[-10:], "")]:
85
+ for t_float, t_int, rel_diff, descriptions in results:
86
+ time_str = [f"{rel_diff * 100:>4.1f}% {'int' if t_int < t_float else 'float':<20}"]
87
+ time_str.extend(["".ljust(len(time_str[0])) for _ in descriptions[:-1]])
88
+ for t_str, (name, shape, order, steps) in zip(time_str, descriptions):
89
+ name = f"{name}:".ljust(name_len + 1)
90
+ shape = shape.ljust(shape_len + 10)
91
+ order = order.ljust(order_len)
92
+ print(f"{t_str} {name} {shape}| {order} | {steps}")
93
+ print(spacer)
94
+
95
+
96
+ def main():
97
+ run(n=100, stmt="torch.median(x, dim=0)", fuzzer_cls=UnaryOpFuzzer)
98
+ run(n=100, stmt="torch.square(x)", fuzzer_cls=UnaryOpFuzzer)
99
+ run(n=100, stmt="x + y", fuzzer_cls=BinaryOpFuzzer)
100
+
101
+
102
+ if __name__ == "__main__":
103
+ main()
shared/package-files/16/163e100a5507b6f3e19b191a44ccc141f6eed1dbd01d937b38d2e737ee20a84a/special_xlog1py_meta_dispatch.h ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
3
+
4
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
5
+
6
+ // The only #includes we need are for custom classes that have defaults in the C++ API
7
+ #include <c10/core/MemoryFormat.h>
8
+ #include <c10/core/Scalar.h>
9
+ #include <ATen/core/Reduction.h>
10
+
11
+ // Forward declarations of any types needed in the operator signatures.
12
+ // We can't directly include these classes because it will cause circular include dependencies.
13
+ // This file is included by TensorBody.h, which defines the Tensor class.
14
+ #include <ATen/core/ATen_fwd.h>
15
+
16
+ namespace at {
17
+
18
+ namespace meta {
19
+
20
+ TORCH_API at::Tensor special_xlog1py(const at::Tensor & self, const at::Tensor & other);
21
+ TORCH_API at::Tensor & special_xlog1py_out(at::Tensor & out, const at::Tensor & self, const at::Tensor & other);
22
+ TORCH_API at::Tensor & special_xlog1py_outf(const at::Tensor & self, const at::Tensor & other, at::Tensor & out);
23
+
24
+ } // namespace meta
25
+ } // namespace at
shared/package-files/16/163f29e6a13e46bd65a80c87234692802dd1617e7a3be816c28eb0bbe7944180/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ # Stub __init__.py for sympy.functions.elementary
shared/package-files/16/1641c1829c716fefe077aaf51639cd85f30ecc0518c97a17289e9a6e28df7055/__init__.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ """Subpackage containing all of pip's command line interface related code
2
+ """
3
+
4
+ # This file intentionally does not import submodules
shared/package-files/16/164dc02c7215495e02c698a87b6e1b9a06424de3f6532d4c2804d076df55ed42/sym_size_ops.h ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+
3
+ // @generated by torchgen/gen.py from Operator.h
4
+
5
+ #include <tuple>
6
+ #include <vector>
7
+
8
+ // Forward declarations of any types needed in the operator signatures.
9
+ // We can't directly include these classes because it will cause circular include dependencies.
10
+ // This file is included by TensorBody.h, which defines the Tensor class.
11
+ #include <ATen/core/ATen_fwd.h>
12
+
13
+ namespace at {
14
+ namespace _ops {
15
+
16
+
17
+ struct TORCH_API sym_size_int {
18
+ using schema = c10::SymInt (const at::Tensor &, int64_t);
19
+ using ptr_schema = schema*;
20
+ // See Note [static constexpr char* members for windows NVCC]
21
+ STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::sym_size")
22
+ STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "int")
23
+ STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "sym_size.int(Tensor self, int dim) -> SymInt")
24
+ static c10::SymInt call(const at::Tensor & self, int64_t dim);
25
+ static c10::SymInt redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, int64_t dim);
26
+ };
27
+
28
+ }} // namespace at::_ops
shared/package-files/16/164dcb5d8e9b43517220f52bd1286d7bd9c352277cf748a2e85a73eeb5f8a612/_backward_native.h ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+
3
+ // @generated by torchgen/gen.py from NativeFunction.h
4
+
5
+ #include <c10/core/Scalar.h>
6
+ #include <c10/core/Storage.h>
7
+ #include <c10/core/TensorOptions.h>
8
+ #include <c10/util/Deprecated.h>
9
+ #include <c10/util/Optional.h>
10
+ #include <c10/core/QScheme.h>
11
+ #include <ATen/core/Reduction.h>
12
+ #include <ATen/core/Tensor.h>
13
+ #include <tuple>
14
+ #include <vector>
15
+
16
+
17
+ namespace at {
18
+ namespace native {
19
+ TORCH_API void _backward(const at::Tensor & self, at::TensorList inputs, const c10::optional<at::Tensor> & gradient={}, c10::optional<bool> retain_graph=c10::nullopt, bool create_graph=false);
20
+ } // namespace native
21
+ } // namespace at
shared/package-files/16/1655950700404519eef420399ae5963287b752b58963ea7bf60cbc368a063bed/d555 ADDED
Binary file (1.48 kB). View file
 
shared/package-files/16/1658d6c58ebb50d38279daa0fdab3f9d8e06b645381c3c2ac20a4b931534d00c/test_iterator.py ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Tests that work on both the Python and C engines but do not have a
3
+ specific classification into the other test modules.
4
+ """
5
+ from io import StringIO
6
+
7
+ import pytest
8
+
9
+ from pandas import (
10
+ DataFrame,
11
+ concat,
12
+ )
13
+ import pandas._testing as tm
14
+
15
+ pytestmark = pytest.mark.filterwarnings(
16
+ "ignore:Passing a BlockManager to DataFrame:DeprecationWarning"
17
+ )
18
+
19
+
20
+ def test_iterator(all_parsers):
21
+ # see gh-6607
22
+ data = """index,A,B,C,D
23
+ foo,2,3,4,5
24
+ bar,7,8,9,10
25
+ baz,12,13,14,15
26
+ qux,12,13,14,15
27
+ foo2,12,13,14,15
28
+ bar2,12,13,14,15
29
+ """
30
+ parser = all_parsers
31
+ kwargs = {"index_col": 0}
32
+
33
+ expected = parser.read_csv(StringIO(data), **kwargs)
34
+
35
+ if parser.engine == "pyarrow":
36
+ msg = "The 'iterator' option is not supported with the 'pyarrow' engine"
37
+ with pytest.raises(ValueError, match=msg):
38
+ parser.read_csv(StringIO(data), iterator=True, **kwargs)
39
+ return
40
+
41
+ with parser.read_csv(StringIO(data), iterator=True, **kwargs) as reader:
42
+ first_chunk = reader.read(3)
43
+ tm.assert_frame_equal(first_chunk, expected[:3])
44
+
45
+ last_chunk = reader.read(5)
46
+ tm.assert_frame_equal(last_chunk, expected[3:])
47
+
48
+
49
+ def test_iterator2(all_parsers):
50
+ parser = all_parsers
51
+ data = """A,B,C
52
+ foo,1,2,3
53
+ bar,4,5,6
54
+ baz,7,8,9
55
+ """
56
+
57
+ if parser.engine == "pyarrow":
58
+ msg = "The 'iterator' option is not supported with the 'pyarrow' engine"
59
+ with pytest.raises(ValueError, match=msg):
60
+ parser.read_csv(StringIO(data), iterator=True)
61
+ return
62
+
63
+ with parser.read_csv(StringIO(data), iterator=True) as reader:
64
+ result = list(reader)
65
+
66
+ expected = DataFrame(
67
+ [[1, 2, 3], [4, 5, 6], [7, 8, 9]],
68
+ index=["foo", "bar", "baz"],
69
+ columns=["A", "B", "C"],
70
+ )
71
+ tm.assert_frame_equal(result[0], expected)
72
+
73
+
74
+ def test_iterator_stop_on_chunksize(all_parsers):
75
+ # gh-3967: stopping iteration when chunksize is specified
76
+ parser = all_parsers
77
+ data = """A,B,C
78
+ foo,1,2,3
79
+ bar,4,5,6
80
+ baz,7,8,9
81
+ """
82
+ if parser.engine == "pyarrow":
83
+ msg = "The 'chunksize' option is not supported with the 'pyarrow' engine"
84
+ with pytest.raises(ValueError, match=msg):
85
+ parser.read_csv(StringIO(data), chunksize=1)
86
+ return
87
+
88
+ with parser.read_csv(StringIO(data), chunksize=1) as reader:
89
+ result = list(reader)
90
+
91
+ assert len(result) == 3
92
+ expected = DataFrame(
93
+ [[1, 2, 3], [4, 5, 6], [7, 8, 9]],
94
+ index=["foo", "bar", "baz"],
95
+ columns=["A", "B", "C"],
96
+ )
97
+ tm.assert_frame_equal(concat(result), expected)
98
+
99
+
100
+ @pytest.mark.parametrize(
101
+ "kwargs", [{"iterator": True, "chunksize": 1}, {"iterator": True}, {"chunksize": 1}]
102
+ )
103
+ def test_iterator_skipfooter_errors(all_parsers, kwargs):
104
+ msg = "'skipfooter' not supported for iteration"
105
+ parser = all_parsers
106
+ data = "a\n1\n2"
107
+
108
+ if parser.engine == "pyarrow":
109
+ msg = (
110
+ "The '(chunksize|iterator)' option is not supported with the "
111
+ "'pyarrow' engine"
112
+ )
113
+
114
+ with pytest.raises(ValueError, match=msg):
115
+ with parser.read_csv(StringIO(data), skipfooter=1, **kwargs) as _:
116
+ pass
117
+
118
+
119
+ def test_iteration_open_handle(all_parsers):
120
+ parser = all_parsers
121
+ kwargs = {"header": None}
122
+
123
+ with tm.ensure_clean() as path:
124
+ with open(path, "w", encoding="utf-8") as f:
125
+ f.write("AAA\nBBB\nCCC\nDDD\nEEE\nFFF\nGGG")
126
+
127
+ with open(path, encoding="utf-8") as f:
128
+ for line in f:
129
+ if "CCC" in line:
130
+ break
131
+
132
+ result = parser.read_csv(f, **kwargs)
133
+ expected = DataFrame({0: ["DDD", "EEE", "FFF", "GGG"]})
134
+ tm.assert_frame_equal(result, expected)
shared/package-files/16/165a53ae0740325ff9a6e376cc38ef766a2cc3c693bda083f878b61ad20afa4d/__init__.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ from pandas.tests.extension.list.array import (
2
+ ListArray,
3
+ ListDtype,
4
+ make_data,
5
+ )
6
+
7
+ __all__ = ["ListArray", "ListDtype", "make_data"]
shared/package-files/16/165f49a1247ddbb7c2b41531f14122bee5e8aaca49b0a83133c249afe937de4e/external.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2014 Anaconda, Inc
2
+ # SPDX-License-Identifier: BSD-3-Clause
3
+ import os
4
+ import stat
5
+ from glob import glob
6
+ from os.path import expanduser, isfile, join
7
+
8
+ from ..conda_interface import root_dir
9
+ from ..utils import on_win
10
+
11
+
12
+ def find_executable(executable, prefix=None, all_matches=False):
13
+ # dir_paths is referenced as a module-level variable
14
+ # in other code
15
+ global dir_paths
16
+ result = None
17
+ if on_win:
18
+ dir_paths = [
19
+ join(root_dir, "Scripts"),
20
+ join(root_dir, "Library\\mingw-w64\\bin"),
21
+ join(root_dir, "Library\\usr\\bin"),
22
+ join(root_dir, "Library\\bin"),
23
+ ]
24
+ if prefix:
25
+ dir_paths[0:0] = [
26
+ join(prefix, "Scripts"),
27
+ join(prefix, "Library\\mingw-w64\\bin"),
28
+ join(prefix, "Library\\usr\\bin"),
29
+ join(prefix, "Library\\bin"),
30
+ ]
31
+ else:
32
+ dir_paths = [
33
+ join(root_dir, "bin"),
34
+ ]
35
+ if prefix:
36
+ dir_paths.insert(0, join(prefix, "bin"))
37
+
38
+ dir_paths.extend(os.environ["PATH"].split(os.pathsep))
39
+ if on_win:
40
+ exts = (".exe", ".bat", "")
41
+ else:
42
+ exts = ("",)
43
+
44
+ all_matches_found = []
45
+ for dir_path in dir_paths:
46
+ for ext in exts:
47
+ path = expanduser(join(dir_path, executable + ext))
48
+ if isfile(path):
49
+ st = os.stat(path)
50
+ if on_win or st.st_mode & stat.S_IEXEC:
51
+ if all_matches:
52
+ all_matches_found.append(path)
53
+ else:
54
+ result = path
55
+ break
56
+ if not result and any([f in executable for f in ("*", "?", ".")]):
57
+ matches = glob(os.path.join(dir_path, executable), recursive=True)
58
+ if matches:
59
+ if all_matches:
60
+ all_matches_found.extend(matches)
61
+ else:
62
+ result = matches[0]
63
+ break
64
+ if result:
65
+ break
66
+ return result or all_matches_found
67
+
68
+
69
+ def find_preferably_prefixed_executable(
70
+ executable, build_prefix=None, all_matches=False
71
+ ):
72
+ found = find_executable("*" + executable, build_prefix, all_matches)
73
+ if not found:
74
+ # It is possible to force non-prefixed exes by passing os.sep as the
75
+ # first character in executable. basename makes this work.
76
+ found = find_executable(os.path.basename(executable), build_prefix)
77
+ return found
shared/package-files/16/1666b1206c14c8de494a837d27883e7dbc6171ef489a9b7e2840d7a36c5c9c80/modularity_max.py ADDED
@@ -0,0 +1,445 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Functions for detecting communities based on modularity."""
2
+
3
+ from collections import defaultdict
4
+
5
+ import networkx as nx
6
+ from networkx.algorithms.community.quality import modularity
7
+ from networkx.utils import not_implemented_for
8
+ from networkx.utils.mapped_queue import MappedQueue
9
+
10
+ __all__ = [
11
+ "greedy_modularity_communities",
12
+ "naive_greedy_modularity_communities",
13
+ ]
14
+
15
+
16
+ def _greedy_modularity_communities_generator(G, weight=None, resolution=1):
17
+ r"""Yield community partitions of G and the modularity change at each step.
18
+
19
+ This function performs Clauset-Newman-Moore greedy modularity maximization [2]_
20
+ At each step of the process it yields the change in modularity that will occur in
21
+ the next step followed by yielding the new community partition after that step.
22
+
23
+ Greedy modularity maximization begins with each node in its own community
24
+ and repeatedly joins the pair of communities that lead to the largest
25
+ modularity until one community contains all nodes (the partition has one set).
26
+
27
+ This function maximizes the generalized modularity, where `resolution`
28
+ is the resolution parameter, often expressed as $\gamma$.
29
+ See :func:`~networkx.algorithms.community.quality.modularity`.
30
+
31
+ Parameters
32
+ ----------
33
+ G : NetworkX graph
34
+
35
+ weight : string or None, optional (default=None)
36
+ The name of an edge attribute that holds the numerical value used
37
+ as a weight. If None, then each edge has weight 1.
38
+ The degree is the sum of the edge weights adjacent to the node.
39
+
40
+ resolution : float (default=1)
41
+ If resolution is less than 1, modularity favors larger communities.
42
+ Greater than 1 favors smaller communities.
43
+
44
+ Yields
45
+ ------
46
+ Alternating yield statements produce the following two objects:
47
+
48
+ communities: dict_values
49
+ A dict_values of frozensets of nodes, one for each community.
50
+ This represents a partition of the nodes of the graph into communities.
51
+ The first yield is the partition with each node in its own community.
52
+
53
+ dq: float
54
+ The change in modularity when merging the next two communities
55
+ that leads to the largest modularity.
56
+
57
+ See Also
58
+ --------
59
+ modularity
60
+
61
+ References
62
+ ----------
63
+ .. [1] Newman, M. E. J. "Networks: An Introduction", page 224
64
+ Oxford University Press 2011.
65
+ .. [2] Clauset, A., Newman, M. E., & Moore, C.
66
+ "Finding community structure in very large networks."
67
+ Physical Review E 70(6), 2004.
68
+ .. [3] Reichardt and Bornholdt "Statistical Mechanics of Community
69
+ Detection" Phys. Rev. E74, 2006.
70
+ .. [4] Newman, M. E. J."Analysis of weighted networks"
71
+ Physical Review E 70(5 Pt 2):056131, 2004.
72
+ """
73
+ directed = G.is_directed()
74
+ N = G.number_of_nodes()
75
+
76
+ # Count edges (or the sum of edge-weights for weighted graphs)
77
+ m = G.size(weight)
78
+ q0 = 1 / m
79
+
80
+ # Calculate degrees (notation from the papers)
81
+ # a : the fraction of (weighted) out-degree for each node
82
+ # b : the fraction of (weighted) in-degree for each node
83
+ if directed:
84
+ a = {node: deg_out * q0 for node, deg_out in G.out_degree(weight=weight)}
85
+ b = {node: deg_in * q0 for node, deg_in in G.in_degree(weight=weight)}
86
+ else:
87
+ a = b = {node: deg * q0 * 0.5 for node, deg in G.degree(weight=weight)}
88
+
89
+ # this preliminary step collects the edge weights for each node pair
90
+ # It handles multigraph and digraph and works fine for graph.
91
+ dq_dict = defaultdict(lambda: defaultdict(float))
92
+ for u, v, wt in G.edges(data=weight, default=1):
93
+ if u == v:
94
+ continue
95
+ dq_dict[u][v] += wt
96
+ dq_dict[v][u] += wt
97
+
98
+ # now scale and subtract the expected edge-weights term
99
+ for u, nbrdict in dq_dict.items():
100
+ for v, wt in nbrdict.items():
101
+ dq_dict[u][v] = q0 * wt - resolution * (a[u] * b[v] + b[u] * a[v])
102
+
103
+ # Use -dq to get a max_heap instead of a min_heap
104
+ # dq_heap holds a heap for each node's neighbors
105
+ dq_heap = {u: MappedQueue({(u, v): -dq for v, dq in dq_dict[u].items()}) for u in G}
106
+ # H -> all_dq_heap holds a heap with the best items for each node
107
+ H = MappedQueue([dq_heap[n].heap[0] for n in G if len(dq_heap[n]) > 0])
108
+
109
+ # Initialize single-node communities
110
+ communities = {n: frozenset([n]) for n in G}
111
+ yield communities.values()
112
+
113
+ # Merge the two communities that lead to the largest modularity
114
+ while len(H) > 1:
115
+ # Find best merge
116
+ # Remove from heap of row maxes
117
+ # Ties will be broken by choosing the pair with lowest min community id
118
+ try:
119
+ negdq, u, v = H.pop()
120
+ except IndexError:
121
+ break
122
+ dq = -negdq
123
+ yield dq
124
+ # Remove best merge from row u heap
125
+ dq_heap[u].pop()
126
+ # Push new row max onto H
127
+ if len(dq_heap[u]) > 0:
128
+ H.push(dq_heap[u].heap[0])
129
+ # If this element was also at the root of row v, we need to remove the
130
+ # duplicate entry from H
131
+ if dq_heap[v].heap[0] == (v, u):
132
+ H.remove((v, u))
133
+ # Remove best merge from row v heap
134
+ dq_heap[v].remove((v, u))
135
+ # Push new row max onto H
136
+ if len(dq_heap[v]) > 0:
137
+ H.push(dq_heap[v].heap[0])
138
+ else:
139
+ # Duplicate wasn't in H, just remove from row v heap
140
+ dq_heap[v].remove((v, u))
141
+
142
+ # Perform merge
143
+ communities[v] = frozenset(communities[u] | communities[v])
144
+ del communities[u]
145
+
146
+ # Get neighbor communities connected to the merged communities
147
+ u_nbrs = set(dq_dict[u])
148
+ v_nbrs = set(dq_dict[v])
149
+ all_nbrs = (u_nbrs | v_nbrs) - {u, v}
150
+ both_nbrs = u_nbrs & v_nbrs
151
+ # Update dq for merge of u into v
152
+ for w in all_nbrs:
153
+ # Calculate new dq value
154
+ if w in both_nbrs:
155
+ dq_vw = dq_dict[v][w] + dq_dict[u][w]
156
+ elif w in v_nbrs:
157
+ dq_vw = dq_dict[v][w] - resolution * (a[u] * b[w] + a[w] * b[u])
158
+ else: # w in u_nbrs
159
+ dq_vw = dq_dict[u][w] - resolution * (a[v] * b[w] + a[w] * b[v])
160
+ # Update rows v and w
161
+ for row, col in [(v, w), (w, v)]:
162
+ dq_heap_row = dq_heap[row]
163
+ # Update dict for v,w only (u is removed below)
164
+ dq_dict[row][col] = dq_vw
165
+ # Save old max of per-row heap
166
+ if len(dq_heap_row) > 0:
167
+ d_oldmax = dq_heap_row.heap[0]
168
+ else:
169
+ d_oldmax = None
170
+ # Add/update heaps
171
+ d = (row, col)
172
+ d_negdq = -dq_vw
173
+ # Save old value for finding heap index
174
+ if w in v_nbrs:
175
+ # Update existing element in per-row heap
176
+ dq_heap_row.update(d, d, priority=d_negdq)
177
+ else:
178
+ # We're creating a new nonzero element, add to heap
179
+ dq_heap_row.push(d, priority=d_negdq)
180
+ # Update heap of row maxes if necessary
181
+ if d_oldmax is None:
182
+ # No entries previously in this row, push new max
183
+ H.push(d, priority=d_negdq)
184
+ else:
185
+ # We've updated an entry in this row, has the max changed?
186
+ row_max = dq_heap_row.heap[0]
187
+ if d_oldmax != row_max or d_oldmax.priority != row_max.priority:
188
+ H.update(d_oldmax, row_max)
189
+
190
+ # Remove row/col u from dq_dict matrix
191
+ for w in dq_dict[u]:
192
+ # Remove from dict
193
+ dq_old = dq_dict[w][u]
194
+ del dq_dict[w][u]
195
+ # Remove from heaps if we haven't already
196
+ if w != v:
197
+ # Remove both row and column
198
+ for row, col in [(w, u), (u, w)]:
199
+ dq_heap_row = dq_heap[row]
200
+ # Check if replaced dq is row max
201
+ d_old = (row, col)
202
+ if dq_heap_row.heap[0] == d_old:
203
+ # Update per-row heap and heap of row maxes
204
+ dq_heap_row.remove(d_old)
205
+ H.remove(d_old)
206
+ # Update row max
207
+ if len(dq_heap_row) > 0:
208
+ H.push(dq_heap_row.heap[0])
209
+ else:
210
+ # Only update per-row heap
211
+ dq_heap_row.remove(d_old)
212
+
213
+ del dq_dict[u]
214
+ # Mark row u as deleted, but keep placeholder
215
+ dq_heap[u] = MappedQueue()
216
+ # Merge u into v and update a
217
+ a[v] += a[u]
218
+ a[u] = 0
219
+ if directed:
220
+ b[v] += b[u]
221
+ b[u] = 0
222
+
223
+ yield communities.values()
224
+
225
+
226
+ def greedy_modularity_communities(
227
+ G,
228
+ weight=None,
229
+ resolution=1,
230
+ cutoff=1,
231
+ best_n=None,
232
+ ):
233
+ r"""Find communities in G using greedy modularity maximization.
234
+
235
+ This function uses Clauset-Newman-Moore greedy modularity maximization [2]_
236
+ to find the community partition with the largest modularity.
237
+
238
+ Greedy modularity maximization begins with each node in its own community
239
+ and repeatedly joins the pair of communities that lead to the largest
240
+ modularity until no further increase in modularity is possible (a maximum).
241
+ Two keyword arguments adjust the stopping condition. `cutoff` is a lower
242
+ limit on the number of communities so you can stop the process before
243
+ reaching a maximum (used to save computation time). `best_n` is an upper
244
+ limit on the number of communities so you can make the process continue
245
+ until at most n communities remain even if the maximum modularity occurs
246
+ for more. To obtain exactly n communities, set both `cutoff` and `best_n` to n.
247
+
248
+ This function maximizes the generalized modularity, where `resolution`
249
+ is the resolution parameter, often expressed as $\gamma$.
250
+ See :func:`~networkx.algorithms.community.quality.modularity`.
251
+
252
+ Parameters
253
+ ----------
254
+ G : NetworkX graph
255
+
256
+ weight : string or None, optional (default=None)
257
+ The name of an edge attribute that holds the numerical value used
258
+ as a weight. If None, then each edge has weight 1.
259
+ The degree is the sum of the edge weights adjacent to the node.
260
+
261
+ resolution : float, optional (default=1)
262
+ If resolution is less than 1, modularity favors larger communities.
263
+ Greater than 1 favors smaller communities.
264
+
265
+ cutoff : int, optional (default=1)
266
+ A minimum number of communities below which the merging process stops.
267
+ The process stops at this number of communities even if modularity
268
+ is not maximized. The goal is to let the user stop the process early.
269
+ The process stops before the cutoff if it finds a maximum of modularity.
270
+
271
+ best_n : int or None, optional (default=None)
272
+ A maximum number of communities above which the merging process will
273
+ not stop. This forces community merging to continue after modularity
274
+ starts to decrease until `best_n` communities remain.
275
+ If ``None``, don't force it to continue beyond a maximum.
276
+
277
+ Raises
278
+ ------
279
+ ValueError : If the `cutoff` or `best_n` value is not in the range
280
+ ``[1, G.number_of_nodes()]``, or if `best_n` < `cutoff`.
281
+
282
+ Returns
283
+ -------
284
+ communities: list
285
+ A list of frozensets of nodes, one for each community.
286
+ Sorted by length with largest communities first.
287
+
288
+ Examples
289
+ --------
290
+ >>> G = nx.karate_club_graph()
291
+ >>> c = nx.community.greedy_modularity_communities(G)
292
+ >>> sorted(c[0])
293
+ [8, 14, 15, 18, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
294
+
295
+ See Also
296
+ --------
297
+ modularity
298
+
299
+ References
300
+ ----------
301
+ .. [1] Newman, M. E. J. "Networks: An Introduction", page 224
302
+ Oxford University Press 2011.
303
+ .. [2] Clauset, A., Newman, M. E., & Moore, C.
304
+ "Finding community structure in very large networks."
305
+ Physical Review E 70(6), 2004.
306
+ .. [3] Reichardt and Bornholdt "Statistical Mechanics of Community
307
+ Detection" Phys. Rev. E74, 2006.
308
+ .. [4] Newman, M. E. J."Analysis of weighted networks"
309
+ Physical Review E 70(5 Pt 2):056131, 2004.
310
+ """
311
+ if (cutoff < 1) or (cutoff > G.number_of_nodes()):
312
+ raise ValueError(f"cutoff must be between 1 and {len(G)}. Got {cutoff}.")
313
+ if best_n is not None:
314
+ if (best_n < 1) or (best_n > G.number_of_nodes()):
315
+ raise ValueError(f"best_n must be between 1 and {len(G)}. Got {best_n}.")
316
+ if best_n < cutoff:
317
+ raise ValueError(f"Must have best_n >= cutoff. Got {best_n} < {cutoff}")
318
+ if best_n == 1:
319
+ return [set(G)]
320
+ else:
321
+ best_n = G.number_of_nodes()
322
+
323
+ # retrieve generator object to construct output
324
+ community_gen = _greedy_modularity_communities_generator(
325
+ G, weight=weight, resolution=resolution
326
+ )
327
+
328
+ # construct the first best community
329
+ communities = next(community_gen)
330
+
331
+ # continue merging communities until one of the breaking criteria is satisfied
332
+ while len(communities) > cutoff:
333
+ try:
334
+ dq = next(community_gen)
335
+ # StopIteration occurs when communities are the connected components
336
+ except StopIteration:
337
+ communities = sorted(communities, key=len, reverse=True)
338
+ # if best_n requires more merging, merge big sets for highest modularity
339
+ while len(communities) > best_n:
340
+ comm1, comm2, *rest = communities
341
+ communities = [comm1 ^ comm2]
342
+ communities.extend(rest)
343
+ return communities
344
+
345
+ # keep going unless max_mod is reached or best_n says to merge more
346
+ if dq < 0 and len(communities) <= best_n:
347
+ break
348
+ communities = next(community_gen)
349
+
350
+ return sorted(communities, key=len, reverse=True)
351
+
352
+
353
+ @not_implemented_for("directed")
354
+ @not_implemented_for("multigraph")
355
+ def naive_greedy_modularity_communities(G, resolution=1, weight=None):
356
+ r"""Find communities in G using greedy modularity maximization.
357
+
358
+ This implementation is O(n^4), much slower than alternatives, but it is
359
+ provided as an easy-to-understand reference implementation.
360
+
361
+ Greedy modularity maximization begins with each node in its own community
362
+ and joins the pair of communities that most increases modularity until no
363
+ such pair exists.
364
+
365
+ This function maximizes the generalized modularity, where `resolution`
366
+ is the resolution parameter, often expressed as $\gamma$.
367
+ See :func:`~networkx.algorithms.community.quality.modularity`.
368
+
369
+ Parameters
370
+ ----------
371
+ G : NetworkX graph
372
+
373
+ resolution : float (default=1)
374
+ If resolution is less than 1, modularity favors larger communities.
375
+ Greater than 1 favors smaller communities.
376
+
377
+ weight : string or None, optional (default=None)
378
+ The name of an edge attribute that holds the numerical value used
379
+ as a weight. If None, then each edge has weight 1.
380
+ The degree is the sum of the edge weights adjacent to the node.
381
+
382
+ Returns
383
+ -------
384
+ list
385
+ A list of sets of nodes, one for each community.
386
+ Sorted by length with largest communities first.
387
+
388
+ Examples
389
+ --------
390
+ >>> G = nx.karate_club_graph()
391
+ >>> c = nx.community.naive_greedy_modularity_communities(G)
392
+ >>> sorted(c[0])
393
+ [8, 14, 15, 18, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
394
+
395
+ See Also
396
+ --------
397
+ greedy_modularity_communities
398
+ modularity
399
+ """
400
+ # First create one community for each node
401
+ communities = [frozenset([u]) for u in G.nodes()]
402
+ # Track merges
403
+ merges = []
404
+ # Greedily merge communities until no improvement is possible
405
+ old_modularity = None
406
+ new_modularity = modularity(G, communities, resolution=resolution, weight=weight)
407
+ while old_modularity is None or new_modularity > old_modularity:
408
+ # Save modularity for comparison
409
+ old_modularity = new_modularity
410
+ # Find best pair to merge
411
+ trial_communities = list(communities)
412
+ to_merge = None
413
+ for i, u in enumerate(communities):
414
+ for j, v in enumerate(communities):
415
+ # Skip i==j and empty communities
416
+ if j <= i or len(u) == 0 or len(v) == 0:
417
+ continue
418
+ # Merge communities u and v
419
+ trial_communities[j] = u | v
420
+ trial_communities[i] = frozenset([])
421
+ trial_modularity = modularity(
422
+ G, trial_communities, resolution=resolution, weight=weight
423
+ )
424
+ if trial_modularity >= new_modularity:
425
+ # Check if strictly better or tie
426
+ if trial_modularity > new_modularity:
427
+ # Found new best, save modularity and group indexes
428
+ new_modularity = trial_modularity
429
+ to_merge = (i, j, new_modularity - old_modularity)
430
+ elif to_merge and min(i, j) < min(to_merge[0], to_merge[1]):
431
+ # Break ties by choosing pair with lowest min id
432
+ new_modularity = trial_modularity
433
+ to_merge = (i, j, new_modularity - old_modularity)
434
+ # Un-merge
435
+ trial_communities[i] = u
436
+ trial_communities[j] = v
437
+ if to_merge is not None:
438
+ # If the best merge improves modularity, use it
439
+ merges.append(to_merge)
440
+ i, j, dq = to_merge
441
+ u, v = communities[i], communities[j]
442
+ communities[j] = u | v
443
+ communities[i] = frozenset([])
444
+ # Remove empty communities and sort
445
+ return sorted((c for c in communities if len(c) > 0), key=len, reverse=True)
shared/package-files/16/16681e8936b15235f07ed8d28f2784ddce4ae0ea959d27c13fbe894967af2255/_linalg_slogdet_meta_dispatch.h ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
3
+
4
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
5
+
6
+ // The only #includes we need are for custom classes that have defaults in the C++ API
7
+ #include <c10/core/MemoryFormat.h>
8
+ #include <c10/core/Scalar.h>
9
+ #include <ATen/core/Reduction.h>
10
+
11
+ // Forward declarations of any types needed in the operator signatures.
12
+ // We can't directly include these classes because it will cause circular include dependencies.
13
+ // This file is included by TensorBody.h, which defines the Tensor class.
14
+ #include <ATen/core/ATen_fwd.h>
15
+
16
+ namespace at {
17
+
18
+ namespace meta {
19
+
20
+ TORCH_API ::std::tuple<at::Tensor,at::Tensor,at::Tensor,at::Tensor> _linalg_slogdet(const at::Tensor & A);
21
+ TORCH_API ::std::tuple<at::Tensor &,at::Tensor &,at::Tensor &,at::Tensor &> _linalg_slogdet_out(at::Tensor & sign, at::Tensor & logabsdet, at::Tensor & LU, at::Tensor & pivots, const at::Tensor & A);
22
+ TORCH_API ::std::tuple<at::Tensor &,at::Tensor &,at::Tensor &,at::Tensor &> _linalg_slogdet_outf(const at::Tensor & A, at::Tensor & sign, at::Tensor & logabsdet, at::Tensor & LU, at::Tensor & pivots);
23
+
24
+ } // namespace meta
25
+ } // namespace at
shared/package-files/16/16695fa2786e53414e5a6b54767a3fdf5de99cfbc68617f69d1362d92776a92f/co2.csv ADDED
@@ -0,0 +1,2285 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ date,co2
2
+ 19580329,316.1
3
+ 19580405,317.3
4
+ 19580412,317.6
5
+ 19580419,317.5
6
+ 19580426,316.4
7
+ 19580503,316.9
8
+ 19580510,
9
+ 19580517,317.5
10
+ 19580524,317.9
11
+ 19580531,
12
+ 19580607,
13
+ 19580614,
14
+ 19580621,
15
+ 19580628,
16
+ 19580705,315.8
17
+ 19580712,315.8
18
+ 19580719,315.4
19
+ 19580726,315.5
20
+ 19580802,315.6
21
+ 19580809,315.1
22
+ 19580816,315.0
23
+ 19580823,
24
+ 19580830,314.1
25
+ 19580906,313.5
26
+ 19580913,
27
+ 19580920,
28
+ 19580927,
29
+ 19581004,
30
+ 19581011,
31
+ 19581018,
32
+ 19581025,
33
+ 19581101,
34
+ 19581108,313.0
35
+ 19581115,313.2
36
+ 19581122,313.5
37
+ 19581129,314.0
38
+ 19581206,314.5
39
+ 19581213,314.4
40
+ 19581220,314.7
41
+ 19581227,315.2
42
+ 19590103,315.2
43
+ 19590110,315.5
44
+ 19590117,315.6
45
+ 19590124,315.8
46
+ 19590131,315.4
47
+ 19590207,
48
+ 19590214,316.9
49
+ 19590221,316.6
50
+ 19590228,316.6
51
+ 19590307,316.8
52
+ 19590314,
53
+ 19590321,316.7
54
+ 19590328,316.7
55
+ 19590404,317.7
56
+ 19590411,317.1
57
+ 19590418,317.6
58
+ 19590425,318.3
59
+ 19590502,318.2
60
+ 19590509,318.7
61
+ 19590516,318.0
62
+ 19590523,318.4
63
+ 19590530,
64
+ 19590606,318.5
65
+ 19590613,318.1
66
+ 19590620,317.8
67
+ 19590627,317.7
68
+ 19590704,316.8
69
+ 19590711,316.8
70
+ 19590718,316.4
71
+ 19590725,316.1
72
+ 19590801,315.6
73
+ 19590808,314.9
74
+ 19590815,
75
+ 19590822,315.0
76
+ 19590829,314.1
77
+ 19590905,314.4
78
+ 19590912,313.9
79
+ 19590919,313.5
80
+ 19590926,313.5
81
+ 19591003,313.0
82
+ 19591010,313.1
83
+ 19591017,313.4
84
+ 19591024,313.4
85
+ 19591031,314.1
86
+ 19591107,314.4
87
+ 19591114,314.8
88
+ 19591121,315.2
89
+ 19591128,315.1
90
+ 19591205,315.0
91
+ 19591212,315.6
92
+ 19591219,315.8
93
+ 19591226,315.7
94
+ 19600102,315.7
95
+ 19600109,316.4
96
+ 19600116,316.7
97
+ 19600123,316.5
98
+ 19600130,316.6
99
+ 19600206,316.6
100
+ 19600213,316.9
101
+ 19600220,317.4
102
+ 19600227,317.0
103
+ 19600305,316.9
104
+ 19600312,317.7
105
+ 19600319,318.0
106
+ 19600326,317.7
107
+ 19600402,318.6
108
+ 19600409,319.3
109
+ 19600416,319.0
110
+ 19600423,319.0
111
+ 19600430,319.7
112
+ 19600507,319.9
113
+ 19600514,319.8
114
+ 19600521,320.0
115
+ 19600528,320.0
116
+ 19600604,319.4
117
+ 19600611,320.0
118
+ 19600618,319.4
119
+ 19600625,319.0
120
+ 19600702,318.1
121
+ 19600709,318.6
122
+ 19600716,318.4
123
+ 19600723,317.9
124
+ 19600730,317.3
125
+ 19600806,316.6
126
+ 19600813,316.7
127
+ 19600820,315.1
128
+ 19600827,314.7
129
+ 19600903,314.7
130
+ 19600910,314.5
131
+ 19600917,314.2
132
+ 19600924,313.3
133
+ 19601001,313.6
134
+ 19601008,313.3
135
+ 19601015,313.9
136
+ 19601022,314.2
137
+ 19601029,314.2
138
+ 19601105,314.5
139
+ 19601112,315.1
140
+ 19601119,315.1
141
+ 19601126,315.4
142
+ 19601203,315.8
143
+ 19601210,316.0
144
+ 19601217,316.2
145
+ 19601224,316.4
146
+ 19601231,316.6
147
+ 19610107,316.7
148
+ 19610114,317.0
149
+ 19610121,317.0
150
+ 19610128,317.0
151
+ 19610204,317.0
152
+ 19610211,317.7
153
+ 19610218,317.9
154
+ 19610225,318.0
155
+ 19610304,318.0
156
+ 19610311,318.5
157
+ 19610318,318.9
158
+ 19610325,318.7
159
+ 19610401,319.4
160
+ 19610408,319.5
161
+ 19610415,318.9
162
+ 19610422,319.7
163
+ 19610429,319.6
164
+ 19610506,320.6
165
+ 19610513,320.4
166
+ 19610520,320.6
167
+ 19610527,320.3
168
+ 19610603,320.0
169
+ 19610610,320.0
170
+ 19610617,319.6
171
+ 19610624,319.4
172
+ 19610701,319.2
173
+ 19610708,319.0
174
+ 19610715,318.4
175
+ 19610722,317.1
176
+ 19610729,317.9
177
+ 19610805,317.9
178
+ 19610812,317.3
179
+ 19610819,316.7
180
+ 19610826,315.2
181
+ 19610902,315.2
182
+ 19610909,314.9
183
+ 19610916,314.5
184
+ 19610923,315.0
185
+ 19610930,315.6
186
+ 19611007,314.9
187
+ 19611014,315.4
188
+ 19611021,315.4
189
+ 19611028,315.7
190
+ 19611104,315.8
191
+ 19611111,315.7
192
+ 19611118,316.2
193
+ 19611125,316.5
194
+ 19611202,316.5
195
+ 19611209,317.0
196
+ 19611216,316.9
197
+ 19611223,317.1
198
+ 19611230,317.4
199
+ 19620106,317.9
200
+ 19620113,318.1
201
+ 19620120,318.0
202
+ 19620127,317.7
203
+ 19620203,318.0
204
+ 19620210,318.3
205
+ 19620217,318.9
206
+ 19620224,319.3
207
+ 19620303,319.2
208
+ 19620310,319.4
209
+ 19620317,319.9
210
+ 19620324,319.7
211
+ 19620331,320.2
212
+ 19620407,320.2
213
+ 19620414,321.0
214
+ 19620421,320.7
215
+ 19620428,320.3
216
+ 19620505,320.8
217
+ 19620512,320.7
218
+ 19620519,321.0
219
+ 19620526,321.1
220
+ 19620602,320.9
221
+ 19620609,320.8
222
+ 19620616,320.5
223
+ 19620623,320.1
224
+ 19620630,320.2
225
+ 19620707,320.1
226
+ 19620714,319.9
227
+ 19620721,319.0
228
+ 19620728,318.7
229
+ 19620804,318.6
230
+ 19620811,317.2
231
+ 19620818,317.4
232
+ 19620825,
233
+ 19620901,
234
+ 19620908,
235
+ 19620915,316.6
236
+ 19620922,315.7
237
+ 19620929,315.9
238
+ 19621006,315.1
239
+ 19621013,315.4
240
+ 19621020,315.7
241
+ 19621027,315.7
242
+ 19621103,315.9
243
+ 19621110,316.4
244
+ 19621117,316.9
245
+ 19621124,317.0
246
+ 19621201,317.1
247
+ 19621208,317.3
248
+ 19621215,317.6
249
+ 19621222,318.1
250
+ 19621229,
251
+ 19630105,318.5
252
+ 19630112,318.7
253
+ 19630119,318.9
254
+ 19630126,318.8
255
+ 19630202,318.7
256
+ 19630209,318.9
257
+ 19630216,
258
+ 19630223,319.3
259
+ 19630302,319.3
260
+ 19630309,319.7
261
+ 19630316,319.8
262
+ 19630323,320.3
263
+ 19630330,320.2
264
+ 19630406,320.3
265
+ 19630413,320.9
266
+ 19630420,322.0
267
+ 19630427,321.9
268
+ 19630504,
269
+ 19630511,321.9
270
+ 19630518,322.2
271
+ 19630525,322.2
272
+ 19630601,322.3
273
+ 19630608,322.0
274
+ 19630615,321.8
275
+ 19630622,320.8
276
+ 19630629,320.4
277
+ 19630706,320.1
278
+ 19630713,319.8
279
+ 19630720,319.5
280
+ 19630727,319.0
281
+ 19630803,318.6
282
+ 19630810,318.2
283
+ 19630817,317.7
284
+ 19630824,317.1
285
+ 19630831,316.4
286
+ 19630907,316.8
287
+ 19630914,315.9
288
+ 19630921,316.0
289
+ 19630928,315.9
290
+ 19631005,316.2
291
+ 19631012,315.6
292
+ 19631019,316.1
293
+ 19631026,316.3
294
+ 19631102,316.6
295
+ 19631109,316.8
296
+ 19631116,317.1
297
+ 19631123,
298
+ 19631130,317.5
299
+ 19631207,318.0
300
+ 19631214,318.2
301
+ 19631221,318.5
302
+ 19631228,318.7
303
+ 19640104,319.0
304
+ 19640111,319.4
305
+ 19640118,319.8
306
+ 19640125,
307
+ 19640201,
308
+ 19640208,
309
+ 19640215,
310
+ 19640222,
311
+ 19640229,
312
+ 19640307,
313
+ 19640314,
314
+ 19640321,
315
+ 19640328,
316
+ 19640404,
317
+ 19640411,
318
+ 19640418,
319
+ 19640425,
320
+ 19640502,
321
+ 19640509,
322
+ 19640516,
323
+ 19640523,
324
+ 19640530,322.0
325
+ 19640606,322.0
326
+ 19640613,
327
+ 19640620,
328
+ 19640627,321.5
329
+ 19640704,321.1
330
+ 19640711,319.9
331
+ 19640718,320.2
332
+ 19640725,320.0
333
+ 19640801,319.1
334
+ 19640808,
335
+ 19640815,318.6
336
+ 19640822,318.2
337
+ 19640829,318.1
338
+ 19640905,317.4
339
+ 19640912,316.5
340
+ 19640919,315.5
341
+ 19640926,317.0
342
+ 19641003,316.9
343
+ 19641010,316.5
344
+ 19641017,316.8
345
+ 19641024,317.0
346
+ 19641031,317.6
347
+ 19641107,317.7
348
+ 19641114,317.6
349
+ 19641121,317.5
350
+ 19641128,318.1
351
+ 19641205,318.4
352
+ 19641212,318.5
353
+ 19641219,318.9
354
+ 19641226,318.9
355
+ 19650102,319.0
356
+ 19650109,319.1
357
+ 19650116,319.1
358
+ 19650123,319.7
359
+ 19650130,320.1
360
+ 19650206,320.2
361
+ 19650213,320.1
362
+ 19650220,320.7
363
+ 19650227,320.8
364
+ 19650306,321.0
365
+ 19650313,320.9
366
+ 19650320,320.4
367
+ 19650327,321.4
368
+ 19650403,321.9
369
+ 19650410,322.2
370
+ 19650417,322.1
371
+ 19650424,321.8
372
+ 19650501,322.4
373
+ 19650508,322.2
374
+ 19650515,321.9
375
+ 19650522,321.6
376
+ 19650529,322.2
377
+ 19650605,321.8
378
+ 19650612,321.7
379
+ 19650619,321.7
380
+ 19650626,321.9
381
+ 19650703,321.9
382
+ 19650710,321.8
383
+ 19650717,321.7
384
+ 19650724,320.4
385
+ 19650731,319.4
386
+ 19650807,319.4
387
+ 19650814,318.0
388
+ 19650821,318.8
389
+ 19650828,318.7
390
+ 19650904,318.3
391
+ 19650911,318.0
392
+ 19650918,318.2
393
+ 19650925,316.8
394
+ 19651002,316.6
395
+ 19651009,317.2
396
+ 19651016,317.8
397
+ 19651023,317.5
398
+ 19651030,317.6
399
+ 19651106,318.3
400
+ 19651113,319.2
401
+ 19651120,318.9
402
+ 19651127,319.1
403
+ 19651204,319.0
404
+ 19651211,319.3
405
+ 19651218,319.3
406
+ 19651225,319.7
407
+ 19660101,319.6
408
+ 19660108,320.4
409
+ 19660115,320.6
410
+ 19660122,321.0
411
+ 19660129,321.1
412
+ 19660205,321.2
413
+ 19660212,321.7
414
+ 19660219,321.6
415
+ 19660226,321.8
416
+ 19660305,322.1
417
+ 19660312,322.1
418
+ 19660319,322.5
419
+ 19660326,322.8
420
+ 19660402,323.5
421
+ 19660409,323.6
422
+ 19660416,323.8
423
+ 19660423,323.9
424
+ 19660430,323.5
425
+ 19660507,324.0
426
+ 19660514,324.1
427
+ 19660521,323.7
428
+ 19660528,324.3
429
+ 19660604,324.0
430
+ 19660611,323.8
431
+ 19660618,323.7
432
+ 19660625,323.3
433
+ 19660702,322.8
434
+ 19660709,322.9
435
+ 19660716,
436
+ 19660723,
437
+ 19660730,
438
+ 19660806,321.3
439
+ 19660813,320.8
440
+ 19660820,319.1
441
+ 19660827,319.6
442
+ 19660903,319.9
443
+ 19660910,318.2
444
+ 19660917,318.4
445
+ 19660924,318.3
446
+ 19661001,317.9
447
+ 19661008,317.9
448
+ 19661015,318.2
449
+ 19661022,318.6
450
+ 19661029,318.3
451
+ 19661105,
452
+ 19661112,319.5
453
+ 19661119,320.0
454
+ 19661126,320.2
455
+ 19661203,320.8
456
+ 19661210,320.8
457
+ 19661217,321.1
458
+ 19661224,321.3
459
+ 19661231,321.3
460
+ 19670107,321.9
461
+ 19670114,322.9
462
+ 19670121,
463
+ 19670128,
464
+ 19670204,322.1
465
+ 19670211,322.2
466
+ 19670218,322.8
467
+ 19670225,322.6
468
+ 19670304,322.9
469
+ 19670311,322.6
470
+ 19670318,323.3
471
+ 19670325,323.2
472
+ 19670401,323.1
473
+ 19670408,324.2
474
+ 19670415,324.4
475
+ 19670422,324.6
476
+ 19670429,325.1
477
+ 19670506,325.2
478
+ 19670513,324.7
479
+ 19670520,325.0
480
+ 19670527,324.9
481
+ 19670603,324.9
482
+ 19670610,324.6
483
+ 19670617,323.3
484
+ 19670624,323.5
485
+ 19670701,322.8
486
+ 19670708,322.8
487
+ 19670715,322.4
488
+ 19670722,322.4
489
+ 19670729,322.0
490
+ 19670805,321.6
491
+ 19670812,321.4
492
+ 19670819,320.4
493
+ 19670826,320.0
494
+ 19670902,320.0
495
+ 19670909,319.4
496
+ 19670916,319.3
497
+ 19670923,319.0
498
+ 19670930,318.8
499
+ 19671007,318.8
500
+ 19671014,319.8
501
+ 19671021,319.4
502
+ 19671028,319.8
503
+ 19671104,320.0
504
+ 19671111,320.3
505
+ 19671118,320.9
506
+ 19671125,321.5
507
+ 19671202,321.4
508
+ 19671209,321.8
509
+ 19671216,322.2
510
+ 19671223,321.9
511
+ 19671230,322.3
512
+ 19680106,322.4
513
+ 19680113,322.5
514
+ 19680120,322.5
515
+ 19680127,322.8
516
+ 19680203,322.6
517
+ 19680210,323.1
518
+ 19680217,323.4
519
+ 19680224,323.1
520
+ 19680302,323.1
521
+ 19680309,323.8
522
+ 19680316,323.8
523
+ 19680323,324.2
524
+ 19680330,324.7
525
+ 19680406,324.7
526
+ 19680413,325.0
527
+ 19680420,324.8
528
+ 19680427,325.4
529
+ 19680504,325.6
530
+ 19680511,325.0
531
+ 19680518,325.5
532
+ 19680525,325.8
533
+ 19680601,325.6
534
+ 19680608,325.7
535
+ 19680615,325.5
536
+ 19680622,324.9
537
+ 19680629,324.6
538
+ 19680706,324.7
539
+ 19680713,324.1
540
+ 19680720,323.9
541
+ 19680727,323.4
542
+ 19680803,322.4
543
+ 19680810,322.2
544
+ 19680817,322.0
545
+ 19680824,321.7
546
+ 19680831,321.4
547
+ 19680907,320.4
548
+ 19680914,321.1
549
+ 19680921,319.7
550
+ 19680928,319.8
551
+ 19681005,320.5
552
+ 19681012,320.5
553
+ 19681019,320.2
554
+ 19681026,319.9
555
+ 19681102,320.7
556
+ 19681109,320.8
557
+ 19681116,321.4
558
+ 19681123,321.7
559
+ 19681130,322.0
560
+ 19681207,322.4
561
+ 19681214,322.9
562
+ 19681221,323.3
563
+ 19681228,323.1
564
+ 19690104,323.3
565
+ 19690111,324.0
566
+ 19690118,324.3
567
+ 19690125,324.1
568
+ 19690201,324.1
569
+ 19690208,323.9
570
+ 19690215,324.3
571
+ 19690222,324.8
572
+ 19690301,325.1
573
+ 19690308,325.5
574
+ 19690315,325.7
575
+ 19690322,325.9
576
+ 19690329,325.8
577
+ 19690405,326.2
578
+ 19690412,327.1
579
+ 19690419,326.5
580
+ 19690426,326.5
581
+ 19690503,327.5
582
+ 19690510,327.8
583
+ 19690517,326.8
584
+ 19690524,326.9
585
+ 19690531,327.4
586
+ 19690607,326.5
587
+ 19690614,326.7
588
+ 19690621,326.7
589
+ 19690628,326.3
590
+ 19690705,326.1
591
+ 19690712,326.0
592
+ 19690719,325.7
593
+ 19690726,325.4
594
+ 19690802,324.5
595
+ 19690809,324.5
596
+ 19690816,323.1
597
+ 19690823,322.5
598
+ 19690830,323.1
599
+ 19690906,322.2
600
+ 19690913,322.7
601
+ 19690920,322.8
602
+ 19690927,321.9
603
+ 19691004,321.5
604
+ 19691011,321.8
605
+ 19691018,322.0
606
+ 19691025,321.9
607
+ 19691101,322.2
608
+ 19691108,322.6
609
+ 19691115,322.7
610
+ 19691122,323.1
611
+ 19691129,323.5
612
+ 19691206,323.9
613
+ 19691213,323.9
614
+ 19691220,324.2
615
+ 19691227,324.5
616
+ 19700103,324.7
617
+ 19700110,325.4
618
+ 19700117,325.0
619
+ 19700124,324.8
620
+ 19700131,325.5
621
+ 19700207,325.7
622
+ 19700214,326.0
623
+ 19700221,326.3
624
+ 19700228,326.1
625
+ 19700307,326.8
626
+ 19700314,326.8
627
+ 19700321,327.5
628
+ 19700328,326.9
629
+ 19700404,328.2
630
+ 19700411,327.8
631
+ 19700418,327.8
632
+ 19700425,328.5
633
+ 19700502,327.9
634
+ 19700509,327.5
635
+ 19700516,328.0
636
+ 19700523,328.3
637
+ 19700530,327.9
638
+ 19700606,327.5
639
+ 19700613,327.8
640
+ 19700620,327.7
641
+ 19700627,327.2
642
+ 19700704,327.2
643
+ 19700711,326.2
644
+ 19700718,326.2
645
+ 19700725,325.6
646
+ 19700801,325.2
647
+ 19700808,325.2
648
+ 19700815,324.8
649
+ 19700822,324.8
650
+ 19700829,323.3
651
+ 19700905,322.9
652
+ 19700912,323.5
653
+ 19700919,323.1
654
+ 19700926,323.1
655
+ 19701003,323.2
656
+ 19701010,323.5
657
+ 19701017,322.9
658
+ 19701024,323.0
659
+ 19701031,323.1
660
+ 19701107,323.6
661
+ 19701114,323.7
662
+ 19701121,324.2
663
+ 19701128,324.7
664
+ 19701205,324.7
665
+ 19701212,325.0
666
+ 19701219,325.2
667
+ 19701226,325.5
668
+ 19710102,325.7
669
+ 19710109,325.8
670
+ 19710116,325.9
671
+ 19710123,326.7
672
+ 19710130,326.6
673
+ 19710206,326.5
674
+ 19710213,326.4
675
+ 19710220,326.7
676
+ 19710227,327.0
677
+ 19710306,327.1
678
+ 19710313,327.3
679
+ 19710320,327.0
680
+ 19710327,327.4
681
+ 19710403,327.4
682
+ 19710410,327.1
683
+ 19710417,327.7
684
+ 19710424,328.5
685
+ 19710501,328.2
686
+ 19710508,329.0
687
+ 19710515,329.2
688
+ 19710522,328.9
689
+ 19710529,328.8
690
+ 19710605,328.5
691
+ 19710612,328.8
692
+ 19710619,328.1
693
+ 19710626,328.5
694
+ 19710703,327.9
695
+ 19710710,327.8
696
+ 19710717,327.5
697
+ 19710724,326.2
698
+ 19710731,326.7
699
+ 19710807,326.1
700
+ 19710814,325.6
701
+ 19710821,325.3
702
+ 19710828,324.0
703
+ 19710904,323.6
704
+ 19710911,323.5
705
+ 19710918,323.2
706
+ 19710925,323.3
707
+ 19711002,323.3
708
+ 19711009,322.9
709
+ 19711016,323.5
710
+ 19711023,323.6
711
+ 19711030,324.4
712
+ 19711106,324.3
713
+ 19711113,324.5
714
+ 19711120,325.0
715
+ 19711127,325.5
716
+ 19711204,325.3
717
+ 19711211,325.9
718
+ 19711218,326.2
719
+ 19711225,326.3
720
+ 19720101,326.6
721
+ 19720108,326.6
722
+ 19720115,326.6
723
+ 19720122,326.6
724
+ 19720129,327.2
725
+ 19720205,327.4
726
+ 19720212,327.9
727
+ 19720219,327.8
728
+ 19720226,327.4
729
+ 19720304,327.5
730
+ 19720311,327.1
731
+ 19720318,327.7
732
+ 19720325,328.6
733
+ 19720401,328.9
734
+ 19720408,329.4
735
+ 19720415,329.8
736
+ 19720422,330.1
737
+ 19720429,330.0
738
+ 19720506,330.0
739
+ 19720513,329.7
740
+ 19720520,330.1
741
+ 19720527,330.2
742
+ 19720603,329.7
743
+ 19720610,329.1
744
+ 19720617,329.0
745
+ 19720624,328.5
746
+ 19720701,328.6
747
+ 19720708,328.3
748
+ 19720715,327.7
749
+ 19720722,328.1
750
+ 19720729,327.5
751
+ 19720805,326.9
752
+ 19720812,326.6
753
+ 19720819,326.5
754
+ 19720826,325.0
755
+ 19720902,325.4
756
+ 19720909,325.7
757
+ 19720916,324.8
758
+ 19720923,324.2
759
+ 19720930,324.2
760
+ 19721007,324.8
761
+ 19721014,325.5
762
+ 19721021,325.1
763
+ 19721028,325.8
764
+ 19721104,326.3
765
+ 19721111,326.1
766
+ 19721118,326.4
767
+ 19721125,326.9
768
+ 19721202,326.9
769
+ 19721209,327.1
770
+ 19721216,327.6
771
+ 19721223,327.9
772
+ 19721230,328.2
773
+ 19730106,328.4
774
+ 19730113,328.4
775
+ 19730120,328.6
776
+ 19730127,328.8
777
+ 19730203,329.1
778
+ 19730210,329.5
779
+ 19730217,329.6
780
+ 19730224,329.7
781
+ 19730303,329.9
782
+ 19730310,330.1
783
+ 19730317,330.5
784
+ 19730324,330.8
785
+ 19730331,330.6
786
+ 19730407,331.2
787
+ 19730414,331.1
788
+ 19730421,331.9
789
+ 19730428,332.1
790
+ 19730505,332.2
791
+ 19730512,332.3
792
+ 19730519,332.6
793
+ 19730526,332.5
794
+ 19730602,332.2
795
+ 19730609,332.5
796
+ 19730616,332.0
797
+ 19730623,331.6
798
+ 19730630,331.4
799
+ 19730707,331.5
800
+ 19730714,331.0
801
+ 19730721,330.0
802
+ 19730728,330.1
803
+ 19730804,330.0
804
+ 19730811,329.5
805
+ 19730818,329.3
806
+ 19730825,328.5
807
+ 19730901,328.4
808
+ 19730908,327.6
809
+ 19730915,327.8
810
+ 19730922,327.1
811
+ 19730929,326.6
812
+ 19731006,327.0
813
+ 19731013,327.4
814
+ 19731020,327.4
815
+ 19731027,327.1
816
+ 19731103,327.5
817
+ 19731110,328.0
818
+ 19731117,328.2
819
+ 19731124,328.5
820
+ 19731201,329.0
821
+ 19731208,328.7
822
+ 19731215,328.6
823
+ 19731222,328.2
824
+ 19731229,328.7
825
+ 19740105,328.9
826
+ 19740112,329.2
827
+ 19740119,329.4
828
+ 19740126,329.8
829
+ 19740202,330.5
830
+ 19740209,330.8
831
+ 19740216,330.6
832
+ 19740223,330.6
833
+ 19740302,330.7
834
+ 19740309,331.2
835
+ 19740316,332.1
836
+ 19740323,332.0
837
+ 19740330,331.5
838
+ 19740406,332.4
839
+ 19740413,332.1
840
+ 19740420,332.9
841
+ 19740427,333.1
842
+ 19740504,332.9
843
+ 19740511,333.0
844
+ 19740518,333.2
845
+ 19740525,332.8
846
+ 19740601,332.9
847
+ 19740608,332.0
848
+ 19740615,332.0
849
+ 19740622,332.2
850
+ 19740629,331.7
851
+ 19740706,331.7
852
+ 19740713,331.2
853
+ 19740720,330.4
854
+ 19740727,331.0
855
+ 19740803,330.0
856
+ 19740810,329.9
857
+ 19740817,329.2
858
+ 19740824,328.9
859
+ 19740831,328.1
860
+ 19740907,328.0
861
+ 19740914,327.3
862
+ 19740921,326.9
863
+ 19740928,327.3
864
+ 19741005,327.3
865
+ 19741012,327.0
866
+ 19741019,327.5
867
+ 19741026,327.7
868
+ 19741102,327.9
869
+ 19741109,328.0
870
+ 19741116,328.8
871
+ 19741123,328.6
872
+ 19741130,328.7
873
+ 19741207,329.5
874
+ 19741214,329.7
875
+ 19741221,329.8
876
+ 19741228,329.7
877
+ 19750104,329.9
878
+ 19750111,329.8
879
+ 19750118,330.2
880
+ 19750125,331.1
881
+ 19750201,331.1
882
+ 19750208,331.4
883
+ 19750215,331.0
884
+ 19750222,331.7
885
+ 19750301,331.8
886
+ 19750308,331.6
887
+ 19750315,331.9
888
+ 19750322,332.2
889
+ 19750329,332.5
890
+ 19750405,333.0
891
+ 19750412,333.5
892
+ 19750419,333.5
893
+ 19750426,333.1
894
+ 19750503,333.9
895
+ 19750510,333.9
896
+ 19750517,333.7
897
+ 19750524,333.7
898
+ 19750531,334.1
899
+ 19750607,333.8
900
+ 19750614,333.3
901
+ 19750621,333.4
902
+ 19750628,333.1
903
+ 19750705,332.7
904
+ 19750712,332.0
905
+ 19750719,331.0
906
+ 19750726,331.5
907
+ 19750802,330.8
908
+ 19750809,330.7
909
+ 19750816,330.3
910
+ 19750823,329.3
911
+ 19750830,328.8
912
+ 19750906,329.4
913
+ 19750913,328.5
914
+ 19750920,328.0
915
+ 19750927,328.2
916
+ 19751004,328.0
917
+ 19751011,328.0
918
+ 19751018,328.5
919
+ 19751025,328.8
920
+ 19751101,329.3
921
+ 19751108,329.2
922
+ 19751115,329.1
923
+ 19751122,329.5
924
+ 19751129,330.1
925
+ 19751206,330.3
926
+ 19751213,330.5
927
+ 19751220,331.1
928
+ 19751227,331.2
929
+ 19760103,331.5
930
+ 19760110,331.5
931
+ 19760117,331.7
932
+ 19760124,331.8
933
+ 19760131,332.2
934
+ 19760207,332.1
935
+ 19760214,332.5
936
+ 19760221,333.2
937
+ 19760228,332.4
938
+ 19760306,332.8
939
+ 19760313,333.6
940
+ 19760320,333.1
941
+ 19760327,334.3
942
+ 19760403,334.7
943
+ 19760410,334.2
944
+ 19760417,334.4
945
+ 19760424,334.5
946
+ 19760501,334.7
947
+ 19760508,334.3
948
+ 19760515,334.6
949
+ 19760522,335.4
950
+ 19760529,334.8
951
+ 19760605,334.3
952
+ 19760612,334.6
953
+ 19760619,334.3
954
+ 19760626,
955
+ 19760703,333.6
956
+ 19760710,333.4
957
+ 19760717,332.8
958
+ 19760724,332.4
959
+ 19760731,332.1
960
+ 19760807,331.7
961
+ 19760814,330.6
962
+ 19760821,330.6
963
+ 19760828,330.0
964
+ 19760904,329.7
965
+ 19760911,330.0
966
+ 19760918,329.3
967
+ 19760925,328.4
968
+ 19761002,328.8
969
+ 19761009,329.0
970
+ 19761016,329.6
971
+ 19761023,329.1
972
+ 19761030,329.0
973
+ 19761106,329.8
974
+ 19761113,330.4
975
+ 19761120,330.5
976
+ 19761127,330.7
977
+ 19761204,331.1
978
+ 19761211,331.3
979
+ 19761218,331.9
980
+ 19761225,332.2
981
+ 19770101,332.5
982
+ 19770108,332.4
983
+ 19770115,333.1
984
+ 19770122,333.2
985
+ 19770129,333.2
986
+ 19770205,333.4
987
+ 19770212,333.3
988
+ 19770219,333.4
989
+ 19770226,333.6
990
+ 19770305,334.1
991
+ 19770312,334.6
992
+ 19770319,335.1
993
+ 19770326,335.0
994
+ 19770402,335.5
995
+ 19770409,335.9
996
+ 19770416,336.0
997
+ 19770423,336.1
998
+ 19770430,336.7
999
+ 19770507,336.8
1000
+ 19770514,336.4
1001
+ 19770521,336.8
1002
+ 19770528,336.7
1003
+ 19770604,336.4
1004
+ 19770611,336.3
1005
+ 19770618,336.1
1006
+ 19770625,336.0
1007
+ 19770702,335.5
1008
+ 19770709,335.1
1009
+ 19770716,335.1
1010
+ 19770723,334.6
1011
+ 19770730,333.7
1012
+ 19770806,333.0
1013
+ 19770813,332.9
1014
+ 19770820,332.8
1015
+ 19770827,332.8
1016
+ 19770903,332.1
1017
+ 19770910,331.2
1018
+ 19770917,332.1
1019
+ 19770924,330.9
1020
+ 19771001,330.4
1021
+ 19771008,330.9
1022
+ 19771015,331.5
1023
+ 19771022,331.5
1024
+ 19771029,331.7
1025
+ 19771105,332.1
1026
+ 19771112,332.0
1027
+ 19771119,332.5
1028
+ 19771126,332.8
1029
+ 19771203,333.2
1030
+ 19771210,333.5
1031
+ 19771217,333.8
1032
+ 19771224,334.2
1033
+ 19771231,334.6
1034
+ 19780107,334.2
1035
+ 19780114,334.6
1036
+ 19780121,335.4
1037
+ 19780128,335.9
1038
+ 19780204,335.0
1039
+ 19780211,335.1
1040
+ 19780218,335.6
1041
+ 19780225,335.7
1042
+ 19780304,336.2
1043
+ 19780311,336.1
1044
+ 19780318,336.8
1045
+ 19780325,337.3
1046
+ 19780401,337.0
1047
+ 19780408,337.9
1048
+ 19780415,337.9
1049
+ 19780422,337.4
1050
+ 19780429,338.0
1051
+ 19780506,338.0
1052
+ 19780513,338.1
1053
+ 19780520,337.8
1054
+ 19780527,337.9
1055
+ 19780603,338.4
1056
+ 19780610,338.2
1057
+ 19780617,337.8
1058
+ 19780624,337.3
1059
+ 19780701,337.6
1060
+ 19780708,336.7
1061
+ 19780715,336.7
1062
+ 19780722,335.9
1063
+ 19780729,335.6
1064
+ 19780805,335.1
1065
+ 19780812,334.8
1066
+ 19780819,334.4
1067
+ 19780826,334.3
1068
+ 19780902,333.8
1069
+ 19780909,332.8
1070
+ 19780916,332.1
1071
+ 19780923,332.3
1072
+ 19780930,332.7
1073
+ 19781007,332.1
1074
+ 19781014,332.4
1075
+ 19781021,333.0
1076
+ 19781028,333.1
1077
+ 19781104,333.5
1078
+ 19781111,333.8
1079
+ 19781118,333.8
1080
+ 19781125,334.2
1081
+ 19781202,334.5
1082
+ 19781209,334.8
1083
+ 19781216,335.1
1084
+ 19781223,335.1
1085
+ 19781230,335.3
1086
+ 19790106,335.3
1087
+ 19790113,335.9
1088
+ 19790120,336.8
1089
+ 19790127,336.9
1090
+ 19790203,336.9
1091
+ 19790210,336.5
1092
+ 19790217,336.7
1093
+ 19790224,336.7
1094
+ 19790303,337.1
1095
+ 19790310,337.7
1096
+ 19790317,337.4
1097
+ 19790324,339.0
1098
+ 19790331,338.8
1099
+ 19790407,338.1
1100
+ 19790414,338.6
1101
+ 19790421,339.2
1102
+ 19790428,339.6
1103
+ 19790505,339.3
1104
+ 19790512,338.8
1105
+ 19790519,339.8
1106
+ 19790526,339.6
1107
+ 19790602,339.9
1108
+ 19790609,339.5
1109
+ 19790616,338.9
1110
+ 19790623,338.9
1111
+ 19790630,339.0
1112
+ 19790707,338.2
1113
+ 19790714,337.8
1114
+ 19790721,337.3
1115
+ 19790728,336.8
1116
+ 19790804,337.0
1117
+ 19790811,336.5
1118
+ 19790818,336.1
1119
+ 19790825,334.5
1120
+ 19790901,334.4
1121
+ 19790908,334.0
1122
+ 19790915,334.2
1123
+ 19790922,333.2
1124
+ 19790929,334.1
1125
+ 19791006,334.1
1126
+ 19791013,333.9
1127
+ 19791020,333.7
1128
+ 19791027,334.1
1129
+ 19791103,334.7
1130
+ 19791110,334.8
1131
+ 19791117,335.5
1132
+ 19791124,335.6
1133
+ 19791201,335.9
1134
+ 19791208,336.5
1135
+ 19791215,336.7
1136
+ 19791222,336.8
1137
+ 19791229,337.4
1138
+ 19800105,337.6
1139
+ 19800112,337.4
1140
+ 19800119,338.3
1141
+ 19800126,338.4
1142
+ 19800202,338.0
1143
+ 19800209,338.1
1144
+ 19800216,338.6
1145
+ 19800223,338.2
1146
+ 19800301,339.3
1147
+ 19800308,339.5
1148
+ 19800315,340.0
1149
+ 19800322,340.5
1150
+ 19800329,341.0
1151
+ 19800405,340.4
1152
+ 19800412,340.9
1153
+ 19800419,340.7
1154
+ 19800426,341.0
1155
+ 19800503,341.5
1156
+ 19800510,341.3
1157
+ 19800517,341.3
1158
+ 19800524,340.9
1159
+ 19800531,341.7
1160
+ 19800607,341.3
1161
+ 19800614,341.3
1162
+ 19800621,340.8
1163
+ 19800628,340.4
1164
+ 19800705,340.4
1165
+ 19800712,339.7
1166
+ 19800719,338.5
1167
+ 19800726,338.9
1168
+ 19800802,337.9
1169
+ 19800809,337.7
1170
+ 19800816,337.7
1171
+ 19800823,337.7
1172
+ 19800830,337.0
1173
+ 19800906,336.6
1174
+ 19800913,335.7
1175
+ 19800920,335.2
1176
+ 19800927,336.0
1177
+ 19801004,335.8
1178
+ 19801011,335.8
1179
+ 19801018,336.1
1180
+ 19801025,336.4
1181
+ 19801101,336.6
1182
+ 19801108,336.9
1183
+ 19801115,337.1
1184
+ 19801122,337.3
1185
+ 19801129,337.4
1186
+ 19801206,337.7
1187
+ 19801213,338.1
1188
+ 19801220,338.3
1189
+ 19801227,338.7
1190
+ 19810103,338.9
1191
+ 19810110,339.1
1192
+ 19810117,339.3
1193
+ 19810124,339.3
1194
+ 19810131,339.5
1195
+ 19810207,340.5
1196
+ 19810214,340.0
1197
+ 19810221,340.2
1198
+ 19810228,341.1
1199
+ 19810307,340.7
1200
+ 19810314,341.0
1201
+ 19810321,341.8
1202
+ 19810328,342.1
1203
+ 19810404,342.4
1204
+ 19810411,342.4
1205
+ 19810418,342.7
1206
+ 19810425,342.3
1207
+ 19810502,342.9
1208
+ 19810509,343.0
1209
+ 19810516,342.8
1210
+ 19810523,342.7
1211
+ 19810530,342.7
1212
+ 19810606,342.6
1213
+ 19810613,342.5
1214
+ 19810620,341.8
1215
+ 19810627,341.6
1216
+ 19810704,341.0
1217
+ 19810711,340.8
1218
+ 19810718,339.7
1219
+ 19810725,340.2
1220
+ 19810801,339.5
1221
+ 19810808,338.9
1222
+ 19810815,338.4
1223
+ 19810822,337.5
1224
+ 19810829,337.7
1225
+ 19810905,337.2
1226
+ 19810912,337.0
1227
+ 19810919,336.7
1228
+ 19810926,335.9
1229
+ 19811003,336.3
1230
+ 19811010,336.6
1231
+ 19811017,337.1
1232
+ 19811024,337.2
1233
+ 19811031,337.5
1234
+ 19811107,337.8
1235
+ 19811114,338.1
1236
+ 19811121,338.5
1237
+ 19811128,339.3
1238
+ 19811205,339.2
1239
+ 19811212,339.4
1240
+ 19811219,339.6
1241
+ 19811226,340.2
1242
+ 19820102,340.2
1243
+ 19820109,340.3
1244
+ 19820116,340.7
1245
+ 19820123,341.1
1246
+ 19820130,341.2
1247
+ 19820206,341.9
1248
+ 19820213,341.1
1249
+ 19820220,341.1
1250
+ 19820227,342.1
1251
+ 19820306,342.6
1252
+ 19820313,342.6
1253
+ 19820320,342.7
1254
+ 19820327,342.8
1255
+ 19820403,342.9
1256
+ 19820410,343.3
1257
+ 19820417,343.5
1258
+ 19820424,344.2
1259
+ 19820501,343.8
1260
+ 19820508,343.6
1261
+ 19820515,344.2
1262
+ 19820522,344.1
1263
+ 19820529,344.1
1264
+ 19820605,343.4
1265
+ 19820612,343.5
1266
+ 19820619,343.4
1267
+ 19820626,342.9
1268
+ 19820703,342.5
1269
+ 19820710,342.0
1270
+ 19820717,342.0
1271
+ 19820724,341.8
1272
+ 19820731,341.3
1273
+ 19820807,340.5
1274
+ 19820814,340.0
1275
+ 19820821,339.7
1276
+ 19820828,338.3
1277
+ 19820904,338.8
1278
+ 19820911,338.6
1279
+ 19820918,337.8
1280
+ 19820925,336.9
1281
+ 19821002,337.3
1282
+ 19821009,338.0
1283
+ 19821016,337.6
1284
+ 19821023,337.9
1285
+ 19821030,338.7
1286
+ 19821106,338.4
1287
+ 19821113,339.2
1288
+ 19821120,339.7
1289
+ 19821127,339.8
1290
+ 19821204,339.8
1291
+ 19821211,340.4
1292
+ 19821218,340.7
1293
+ 19821225,340.8
1294
+ 19830101,340.9
1295
+ 19830108,341.4
1296
+ 19830115,341.5
1297
+ 19830122,341.2
1298
+ 19830129,341.7
1299
+ 19830205,342.0
1300
+ 19830212,342.7
1301
+ 19830219,342.5
1302
+ 19830226,342.8
1303
+ 19830305,342.3
1304
+ 19830312,342.5
1305
+ 19830319,344.0
1306
+ 19830326,343.8
1307
+ 19830402,344.0
1308
+ 19830409,344.8
1309
+ 19830416,345.0
1310
+ 19830423,345.3
1311
+ 19830430,345.4
1312
+ 19830507,345.4
1313
+ 19830514,345.7
1314
+ 19830521,345.8
1315
+ 19830528,345.7
1316
+ 19830604,345.6
1317
+ 19830611,345.6
1318
+ 19830618,345.0
1319
+ 19830625,344.9
1320
+ 19830702,344.7
1321
+ 19830709,344.5
1322
+ 19830716,343.7
1323
+ 19830723,343.6
1324
+ 19830730,342.6
1325
+ 19830806,343.0
1326
+ 19830813,341.7
1327
+ 19830820,342.1
1328
+ 19830827,341.8
1329
+ 19830903,339.9
1330
+ 19830910,339.9
1331
+ 19830917,339.8
1332
+ 19830924,339.9
1333
+ 19831001,339.8
1334
+ 19831008,339.7
1335
+ 19831015,340.1
1336
+ 19831022,340.2
1337
+ 19831029,340.3
1338
+ 19831105,340.8
1339
+ 19831112,341.0
1340
+ 19831119,341.1
1341
+ 19831126,341.7
1342
+ 19831203,341.8
1343
+ 19831210,342.8
1344
+ 19831217,343.3
1345
+ 19831224,343.6
1346
+ 19831231,343.4
1347
+ 19840107,343.7
1348
+ 19840114,343.4
1349
+ 19840121,343.5
1350
+ 19840128,344.1
1351
+ 19840204,344.3
1352
+ 19840211,344.5
1353
+ 19840218,344.3
1354
+ 19840225,344.6
1355
+ 19840303,344.8
1356
+ 19840310,344.9
1357
+ 19840317,345.4
1358
+ 19840324,345.6
1359
+ 19840331,
1360
+ 19840407,
1361
+ 19840414,
1362
+ 19840421,
1363
+ 19840428,347.4
1364
+ 19840505,347.4
1365
+ 19840512,347.7
1366
+ 19840519,347.3
1367
+ 19840526,347.0
1368
+ 19840602,347.0
1369
+ 19840609,347.0
1370
+ 19840616,346.8
1371
+ 19840623,346.3
1372
+ 19840630,346.2
1373
+ 19840707,345.8
1374
+ 19840714,345.4
1375
+ 19840721,345.2
1376
+ 19840728,344.4
1377
+ 19840804,344.0
1378
+ 19840811,344.1
1379
+ 19840818,343.1
1380
+ 19840825,342.0
1381
+ 19840901,341.6
1382
+ 19840908,340.6
1383
+ 19840915,341.3
1384
+ 19840922,341.3
1385
+ 19840929,340.8
1386
+ 19841006,341.1
1387
+ 19841013,341.3
1388
+ 19841020,341.9
1389
+ 19841027,341.6
1390
+ 19841103,342.0
1391
+ 19841110,342.6
1392
+ 19841117,343.1
1393
+ 19841124,343.7
1394
+ 19841201,343.6
1395
+ 19841208,343.9
1396
+ 19841215,344.2
1397
+ 19841222,344.5
1398
+ 19841229,344.5
1399
+ 19850105,344.7
1400
+ 19850112,345.0
1401
+ 19850119,345.0
1402
+ 19850126,345.0
1403
+ 19850202,345.9
1404
+ 19850209,345.5
1405
+ 19850216,345.8
1406
+ 19850223,346.3
1407
+ 19850302,346.7
1408
+ 19850309,347.1
1409
+ 19850316,347.5
1410
+ 19850323,347.7
1411
+ 19850330,348.2
1412
+ 19850406,348.0
1413
+ 19850413,348.0
1414
+ 19850420,348.5
1415
+ 19850427,348.8
1416
+ 19850504,348.8
1417
+ 19850511,349.3
1418
+ 19850518,349.1
1419
+ 19850525,348.1
1420
+ 19850601,349.0
1421
+ 19850608,348.4
1422
+ 19850615,348.2
1423
+ 19850622,347.9
1424
+ 19850629,347.4
1425
+ 19850706,346.9
1426
+ 19850713,346.8
1427
+ 19850720,346.4
1428
+ 19850727,345.7
1429
+ 19850803,
1430
+ 19850810,344.7
1431
+ 19850817,344.5
1432
+ 19850824,344.3
1433
+ 19850831,343.7
1434
+ 19850907,344.2
1435
+ 19850914,343.3
1436
+ 19850921,342.4
1437
+ 19850928,342.1
1438
+ 19851005,342.4
1439
+ 19851012,342.5
1440
+ 19851019,343.1
1441
+ 19851026,343.2
1442
+ 19851102,343.3
1443
+ 19851109,343.7
1444
+ 19851116,344.2
1445
+ 19851123,344.6
1446
+ 19851130,345.3
1447
+ 19851207,345.3
1448
+ 19851214,345.6
1449
+ 19851221,345.1
1450
+ 19851228,346.3
1451
+ 19860104,346.4
1452
+ 19860111,346.0
1453
+ 19860118,346.2
1454
+ 19860125,346.4
1455
+ 19860201,346.2
1456
+ 19860208,346.8
1457
+ 19860215,347.1
1458
+ 19860222,347.2
1459
+ 19860301,347.0
1460
+ 19860308,346.6
1461
+ 19860315,347.2
1462
+ 19860322,349.1
1463
+ 19860329,348.8
1464
+ 19860405,349.2
1465
+ 19860412,349.4
1466
+ 19860419,349.3
1467
+ 19860426,350.2
1468
+ 19860503,349.9
1469
+ 19860510,350.1
1470
+ 19860517,350.2
1471
+ 19860524,350.1
1472
+ 19860531,350.1
1473
+ 19860607,349.7
1474
+ 19860614,349.5
1475
+ 19860621,349.4
1476
+ 19860628,348.9
1477
+ 19860705,348.6
1478
+ 19860712,347.7
1479
+ 19860719,347.6
1480
+ 19860726,347.4
1481
+ 19860802,346.6
1482
+ 19860809,346.2
1483
+ 19860816,345.5
1484
+ 19860823,345.6
1485
+ 19860830,345.2
1486
+ 19860906,345.0
1487
+ 19860913,345.3
1488
+ 19860920,344.4
1489
+ 19860927,344.5
1490
+ 19861004,343.9
1491
+ 19861011,344.1
1492
+ 19861018,343.9
1493
+ 19861025,344.5
1494
+ 19861101,345.1
1495
+ 19861108,345.3
1496
+ 19861115,345.6
1497
+ 19861122,345.7
1498
+ 19861129,346.4
1499
+ 19861206,346.9
1500
+ 19861213,346.7
1501
+ 19861220,346.9
1502
+ 19861227,347.0
1503
+ 19870103,347.6
1504
+ 19870110,348.3
1505
+ 19870117,348.2
1506
+ 19870124,347.9
1507
+ 19870131,348.0
1508
+ 19870207,347.9
1509
+ 19870214,348.2
1510
+ 19870221,348.5
1511
+ 19870228,349.4
1512
+ 19870307,348.8
1513
+ 19870314,349.2
1514
+ 19870321,349.7
1515
+ 19870328,350.2
1516
+ 19870404,350.8
1517
+ 19870411,350.2
1518
+ 19870418,351.1
1519
+ 19870425,351.3
1520
+ 19870502,351.4
1521
+ 19870509,352.0
1522
+ 19870516,351.7
1523
+ 19870523,351.9
1524
+ 19870530,351.7
1525
+ 19870606,351.6
1526
+ 19870613,351.1
1527
+ 19870620,351.0
1528
+ 19870627,350.9
1529
+ 19870704,349.7
1530
+ 19870711,349.8
1531
+ 19870718,348.8
1532
+ 19870725,349.5
1533
+ 19870801,349.0
1534
+ 19870808,348.1
1535
+ 19870815,348.6
1536
+ 19870822,348.0
1537
+ 19870829,346.7
1538
+ 19870905,347.0
1539
+ 19870912,346.6
1540
+ 19870919,346.2
1541
+ 19870926,345.8
1542
+ 19871003,345.7
1543
+ 19871010,346.3
1544
+ 19871017,346.5
1545
+ 19871024,346.8
1546
+ 19871031,346.9
1547
+ 19871107,347.3
1548
+ 19871114,347.6
1549
+ 19871121,348.1
1550
+ 19871128,348.7
1551
+ 19871205,348.6
1552
+ 19871212,348.8
1553
+ 19871219,349.1
1554
+ 19871226,349.2
1555
+ 19880102,349.7
1556
+ 19880109,350.2
1557
+ 19880116,350.2
1558
+ 19880123,350.7
1559
+ 19880130,351.2
1560
+ 19880206,351.8
1561
+ 19880213,351.3
1562
+ 19880220,351.5
1563
+ 19880227,352.5
1564
+ 19880305,352.8
1565
+ 19880312,351.8
1566
+ 19880319,351.7
1567
+ 19880326,352.2
1568
+ 19880402,353.1
1569
+ 19880409,353.5
1570
+ 19880416,353.1
1571
+ 19880423,354.0
1572
+ 19880430,354.2
1573
+ 19880507,353.7
1574
+ 19880514,354.3
1575
+ 19880521,354.5
1576
+ 19880528,354.2
1577
+ 19880604,354.1
1578
+ 19880611,354.2
1579
+ 19880618,353.6
1580
+ 19880625,353.1
1581
+ 19880702,353.0
1582
+ 19880709,352.5
1583
+ 19880716,352.6
1584
+ 19880723,351.9
1585
+ 19880730,351.1
1586
+ 19880806,350.9
1587
+ 19880813,350.3
1588
+ 19880820,350.4
1589
+ 19880827,349.6
1590
+ 19880903,349.3
1591
+ 19880910,348.7
1592
+ 19880917,348.9
1593
+ 19880924,348.1
1594
+ 19881001,348.8
1595
+ 19881008,348.8
1596
+ 19881015,348.6
1597
+ 19881022,349.4
1598
+ 19881029,349.2
1599
+ 19881105,349.7
1600
+ 19881112,349.8
1601
+ 19881119,350.1
1602
+ 19881126,350.4
1603
+ 19881203,350.5
1604
+ 19881210,351.0
1605
+ 19881217,351.6
1606
+ 19881224,351.3
1607
+ 19881231,352.4
1608
+ 19890107,352.7
1609
+ 19890114,352.9
1610
+ 19890121,352.5
1611
+ 19890128,353.0
1612
+ 19890204,352.8
1613
+ 19890211,352.6
1614
+ 19890218,353.2
1615
+ 19890225,353.4
1616
+ 19890304,353.1
1617
+ 19890311,353.4
1618
+ 19890318,353.5
1619
+ 19890325,354.4
1620
+ 19890401,354.5
1621
+ 19890408,355.0
1622
+ 19890415,355.4
1623
+ 19890422,356.0
1624
+ 19890429,355.9
1625
+ 19890506,355.3
1626
+ 19890513,355.8
1627
+ 19890520,355.6
1628
+ 19890527,355.7
1629
+ 19890603,355.8
1630
+ 19890610,355.0
1631
+ 19890617,354.8
1632
+ 19890624,354.9
1633
+ 19890701,354.5
1634
+ 19890708,354.7
1635
+ 19890715,353.8
1636
+ 19890722,353.1
1637
+ 19890729,353.2
1638
+ 19890805,352.6
1639
+ 19890812,352.2
1640
+ 19890819,351.1
1641
+ 19890826,350.4
1642
+ 19890902,350.7
1643
+ 19890909,350.2
1644
+ 19890916,349.4
1645
+ 19890923,349.3
1646
+ 19890930,349.7
1647
+ 19891007,349.9
1648
+ 19891014,349.7
1649
+ 19891021,350.2
1650
+ 19891028,350.4
1651
+ 19891104,350.6
1652
+ 19891111,351.2
1653
+ 19891118,351.6
1654
+ 19891125,351.4
1655
+ 19891202,352.0
1656
+ 19891209,352.1
1657
+ 19891216,352.4
1658
+ 19891223,352.5
1659
+ 19891230,353.4
1660
+ 19900106,353.4
1661
+ 19900113,353.5
1662
+ 19900120,353.8
1663
+ 19900127,353.9
1664
+ 19900203,354.1
1665
+ 19900210,355.0
1666
+ 19900217,354.8
1667
+ 19900224,354.7
1668
+ 19900303,355.7
1669
+ 19900310,354.9
1670
+ 19900317,355.8
1671
+ 19900324,355.1
1672
+ 19900331,355.9
1673
+ 19900407,356.1
1674
+ 19900414,355.9
1675
+ 19900421,356.6
1676
+ 19900428,356.1
1677
+ 19900505,357.3
1678
+ 19900512,357.0
1679
+ 19900519,356.9
1680
+ 19900526,357.1
1681
+ 19900602,357.0
1682
+ 19900609,356.6
1683
+ 19900616,355.6
1684
+ 19900623,355.5
1685
+ 19900630,355.7
1686
+ 19900707,355.5
1687
+ 19900714,354.0
1688
+ 19900721,354.5
1689
+ 19900728,354.7
1690
+ 19900804,353.5
1691
+ 19900811,353.2
1692
+ 19900818,352.9
1693
+ 19900825,352.0
1694
+ 19900901,350.9
1695
+ 19900908,350.7
1696
+ 19900915,351.3
1697
+ 19900922,350.9
1698
+ 19900929,350.9
1699
+ 19901006,351.1
1700
+ 19901013,351.0
1701
+ 19901020,351.4
1702
+ 19901027,351.4
1703
+ 19901103,352.1
1704
+ 19901110,352.6
1705
+ 19901117,353.0
1706
+ 19901124,353.1
1707
+ 19901201,353.6
1708
+ 19901208,354.0
1709
+ 19901215,353.8
1710
+ 19901222,354.5
1711
+ 19901229,354.8
1712
+ 19910105,354.2
1713
+ 19910112,354.7
1714
+ 19910119,354.8
1715
+ 19910126,355.0
1716
+ 19910202,355.2
1717
+ 19910209,355.2
1718
+ 19910216,356.4
1719
+ 19910223,355.8
1720
+ 19910302,356.4
1721
+ 19910309,357.2
1722
+ 19910316,357.6
1723
+ 19910323,356.9
1724
+ 19910330,357.9
1725
+ 19910406,358.3
1726
+ 19910413,357.8
1727
+ 19910420,359.1
1728
+ 19910427,359.2
1729
+ 19910504,359.1
1730
+ 19910511,358.9
1731
+ 19910518,360.0
1732
+ 19910525,359.0
1733
+ 19910601,358.5
1734
+ 19910608,358.4
1735
+ 19910615,358.2
1736
+ 19910622,358.1
1737
+ 19910629,357.7
1738
+ 19910706,357.2
1739
+ 19910713,356.5
1740
+ 19910720,355.2
1741
+ 19910727,355.3
1742
+ 19910803,354.8
1743
+ 19910810,354.6
1744
+ 19910817,353.7
1745
+ 19910824,353.0
1746
+ 19910831,353.2
1747
+ 19910907,353.0
1748
+ 19910914,352.1
1749
+ 19910921,351.8
1750
+ 19910928,351.6
1751
+ 19911005,351.7
1752
+ 19911012,352.1
1753
+ 19911019,352.5
1754
+ 19911026,352.7
1755
+ 19911102,353.4
1756
+ 19911109,353.7
1757
+ 19911116,353.5
1758
+ 19911123,353.8
1759
+ 19911130,354.3
1760
+ 19911207,354.5
1761
+ 19911214,354.9
1762
+ 19911221,355.2
1763
+ 19911228,355.5
1764
+ 19920104,355.6
1765
+ 19920111,356.0
1766
+ 19920118,356.1
1767
+ 19920125,355.9
1768
+ 19920201,356.0
1769
+ 19920208,356.7
1770
+ 19920215,357.3
1771
+ 19920222,356.9
1772
+ 19920229,356.5
1773
+ 19920307,357.3
1774
+ 19920314,357.8
1775
+ 19920321,358.1
1776
+ 19920328,358.4
1777
+ 19920404,358.5
1778
+ 19920411,358.9
1779
+ 19920418,359.7
1780
+ 19920425,359.2
1781
+ 19920502,359.6
1782
+ 19920509,359.7
1783
+ 19920516,358.6
1784
+ 19920523,359.6
1785
+ 19920530,360.2
1786
+ 19920606,360.0
1787
+ 19920613,359.4
1788
+ 19920620,358.7
1789
+ 19920627,358.4
1790
+ 19920704,358.4
1791
+ 19920711,357.2
1792
+ 19920718,356.3
1793
+ 19920725,356.1
1794
+ 19920801,354.9
1795
+ 19920808,355.3
1796
+ 19920815,355.3
1797
+ 19920822,354.5
1798
+ 19920829,354.3
1799
+ 19920905,353.5
1800
+ 19920912,353.6
1801
+ 19920919,352.3
1802
+ 19920926,352.7
1803
+ 19921003,353.6
1804
+ 19921010,353.3
1805
+ 19921017,353.2
1806
+ 19921024,353.5
1807
+ 19921031,353.5
1808
+ 19921107,353.9
1809
+ 19921114,353.8
1810
+ 19921121,354.5
1811
+ 19921128,354.6
1812
+ 19921205,354.8
1813
+ 19921212,355.3
1814
+ 19921219,355.4
1815
+ 19921226,355.9
1816
+ 19930102,356.2
1817
+ 19930109,356.9
1818
+ 19930116,356.7
1819
+ 19930123,356.6
1820
+ 19930130,357.0
1821
+ 19930206,356.6
1822
+ 19930213,357.2
1823
+ 19930220,357.3
1824
+ 19930227,357.6
1825
+ 19930306,358.3
1826
+ 19930313,358.5
1827
+ 19930320,358.1
1828
+ 19930327,358.8
1829
+ 19930403,359.1
1830
+ 19930410,358.8
1831
+ 19930417,359.4
1832
+ 19930424,360.0
1833
+ 19930501,359.6
1834
+ 19930508,359.7
1835
+ 19930515,360.7
1836
+ 19930522,360.6
1837
+ 19930529,360.3
1838
+ 19930605,359.7
1839
+ 19930612,359.9
1840
+ 19930619,359.3
1841
+ 19930626,359.1
1842
+ 19930703,357.9
1843
+ 19930710,358.0
1844
+ 19930717,358.1
1845
+ 19930724,356.6
1846
+ 19930731,356.5
1847
+ 19930807,355.8
1848
+ 19930814,355.9
1849
+ 19930821,354.9
1850
+ 19930828,354.7
1851
+ 19930904,354.3
1852
+ 19930911,353.2
1853
+ 19930918,353.8
1854
+ 19930925,353.8
1855
+ 19931002,353.8
1856
+ 19931009,353.8
1857
+ 19931016,354.0
1858
+ 19931023,354.4
1859
+ 19931030,354.3
1860
+ 19931106,354.7
1861
+ 19931113,355.1
1862
+ 19931120,355.6
1863
+ 19931127,356.0
1864
+ 19931204,356.2
1865
+ 19931211,356.5
1866
+ 19931218,356.9
1867
+ 19931225,357.5
1868
+ 19940101,358.1
1869
+ 19940108,358.1
1870
+ 19940115,358.4
1871
+ 19940122,358.3
1872
+ 19940129,358.7
1873
+ 19940205,358.4
1874
+ 19940212,358.6
1875
+ 19940219,359.0
1876
+ 19940226,359.6
1877
+ 19940305,358.7
1878
+ 19940312,359.8
1879
+ 19940319,360.4
1880
+ 19940326,360.8
1881
+ 19940402,360.6
1882
+ 19940409,361.0
1883
+ 19940416,361.0
1884
+ 19940423,361.3
1885
+ 19940430,362.2
1886
+ 19940507,361.6
1887
+ 19940514,361.4
1888
+ 19940521,361.7
1889
+ 19940528,361.9
1890
+ 19940604,361.0
1891
+ 19940611,361.0
1892
+ 19940618,360.9
1893
+ 19940625,360.7
1894
+ 19940702,360.2
1895
+ 19940709,359.9
1896
+ 19940716,359.4
1897
+ 19940723,359.0
1898
+ 19940730,358.8
1899
+ 19940806,358.1
1900
+ 19940813,357.5
1901
+ 19940820,357.6
1902
+ 19940827,356.3
1903
+ 19940903,356.4
1904
+ 19940910,356.4
1905
+ 19940917,355.4
1906
+ 19940924,355.5
1907
+ 19941001,355.4
1908
+ 19941008,355.8
1909
+ 19941015,356.0
1910
+ 19941022,356.3
1911
+ 19941029,356.6
1912
+ 19941105,356.9
1913
+ 19941112,357.4
1914
+ 19941119,357.9
1915
+ 19941126,358.1
1916
+ 19941203,358.4
1917
+ 19941210,359.1
1918
+ 19941217,359.2
1919
+ 19941224,359.1
1920
+ 19941231,359.5
1921
+ 19950107,359.6
1922
+ 19950114,360.2
1923
+ 19950121,360.1
1924
+ 19950128,360.0
1925
+ 19950204,360.6
1926
+ 19950211,361.0
1927
+ 19950218,360.8
1928
+ 19950225,361.3
1929
+ 19950304,362.2
1930
+ 19950311,361.2
1931
+ 19950318,360.9
1932
+ 19950325,362.0
1933
+ 19950401,363.8
1934
+ 19950408,363.4
1935
+ 19950415,363.3
1936
+ 19950422,362.8
1937
+ 19950429,363.5
1938
+ 19950506,363.2
1939
+ 19950513,364.1
1940
+ 19950520,364.1
1941
+ 19950527,363.4
1942
+ 19950603,363.9
1943
+ 19950610,363.4
1944
+ 19950617,362.9
1945
+ 19950624,362.8
1946
+ 19950701,362.5
1947
+ 19950708,362.2
1948
+ 19950715,361.9
1949
+ 19950722,361.5
1950
+ 19950729,360.9
1951
+ 19950805,360.4
1952
+ 19950812,359.2
1953
+ 19950819,358.7
1954
+ 19950826,359.2
1955
+ 19950902,357.3
1956
+ 19950909,358.5
1957
+ 19950916,358.5
1958
+ 19950923,358.2
1959
+ 19950930,357.5
1960
+ 19951007,357.6
1961
+ 19951014,357.6
1962
+ 19951021,358.0
1963
+ 19951028,358.2
1964
+ 19951104,359.1
1965
+ 19951111,359.4
1966
+ 19951118,359.6
1967
+ 19951125,359.8
1968
+ 19951202,360.1
1969
+ 19951209,360.4
1970
+ 19951216,360.5
1971
+ 19951223,360.8
1972
+ 19951230,361.7
1973
+ 19960106,361.8
1974
+ 19960113,362.0
1975
+ 19960120,362.1
1976
+ 19960127,362.2
1977
+ 19960203,362.6
1978
+ 19960210,363.1
1979
+ 19960217,363.0
1980
+ 19960224,364.0
1981
+ 19960302,363.8
1982
+ 19960309,363.6
1983
+ 19960316,364.1
1984
+ 19960323,364.5
1985
+ 19960330,364.3
1986
+ 19960406,364.5
1987
+ 19960413,364.8
1988
+ 19960420,364.4
1989
+ 19960427,365.1
1990
+ 19960504,364.9
1991
+ 19960511,365.3
1992
+ 19960518,365.7
1993
+ 19960525,365.4
1994
+ 19960601,364.8
1995
+ 19960608,365.1
1996
+ 19960615,365.2
1997
+ 19960622,365.0
1998
+ 19960629,364.3
1999
+ 19960706,364.1
2000
+ 19960713,363.7
2001
+ 19960720,363.3
2002
+ 19960727,362.8
2003
+ 19960803,361.7
2004
+ 19960810,362.1
2005
+ 19960817,361.2
2006
+ 19960824,360.8
2007
+ 19960831,360.8
2008
+ 19960907,359.8
2009
+ 19960914,359.8
2010
+ 19960921,359.0
2011
+ 19960928,359.0
2012
+ 19961005,359.4
2013
+ 19961012,359.5
2014
+ 19961019,359.8
2015
+ 19961026,359.8
2016
+ 19961102,359.9
2017
+ 19961109,360.5
2018
+ 19961116,360.7
2019
+ 19961123,361.2
2020
+ 19961130,361.4
2021
+ 19961207,361.9
2022
+ 19961214,362.6
2023
+ 19961221,362.4
2024
+ 19961228,362.6
2025
+ 19970104,362.9
2026
+ 19970111,363.0
2027
+ 19970118,363.1
2028
+ 19970125,363.5
2029
+ 19970201,363.2
2030
+ 19970208,364.1
2031
+ 19970215,364.0
2032
+ 19970222,364.2
2033
+ 19970301,364.5
2034
+ 19970308,364.1
2035
+ 19970315,364.1
2036
+ 19970322,364.7
2037
+ 19970329,365.4
2038
+ 19970405,365.8
2039
+ 19970412,366.2
2040
+ 19970419,366.6
2041
+ 19970426,366.7
2042
+ 19970503,366.7
2043
+ 19970510,366.8
2044
+ 19970517,367.0
2045
+ 19970524,366.6
2046
+ 19970531,366.3
2047
+ 19970607,365.7
2048
+ 19970614,365.6
2049
+ 19970621,365.5
2050
+ 19970628,365.1
2051
+ 19970705,365.0
2052
+ 19970712,364.6
2053
+ 19970719,364.1
2054
+ 19970726,363.8
2055
+ 19970802,363.3
2056
+ 19970809,363.3
2057
+ 19970816,362.6
2058
+ 19970823,361.5
2059
+ 19970830,361.6
2060
+ 19970906,360.6
2061
+ 19970913,360.2
2062
+ 19970920,360.0
2063
+ 19970927,359.8
2064
+ 19971004,360.5
2065
+ 19971011,360.4
2066
+ 19971018,361.0
2067
+ 19971025,361.1
2068
+ 19971101,361.7
2069
+ 19971108,362.1
2070
+ 19971115,362.0
2071
+ 19971122,362.6
2072
+ 19971129,363.5
2073
+ 19971206,363.9
2074
+ 19971213,363.9
2075
+ 19971220,364.2
2076
+ 19971227,365.0
2077
+ 19980103,365.2
2078
+ 19980110,365.3
2079
+ 19980117,365.3
2080
+ 19980124,365.3
2081
+ 19980131,365.6
2082
+ 19980207,366.0
2083
+ 19980214,365.5
2084
+ 19980221,366.0
2085
+ 19980228,367.3
2086
+ 19980307,367.0
2087
+ 19980314,366.6
2088
+ 19980321,367.4
2089
+ 19980328,368.5
2090
+ 19980404,368.6
2091
+ 19980411,368.6
2092
+ 19980418,368.0
2093
+ 19980425,368.9
2094
+ 19980502,369.1
2095
+ 19980509,368.8
2096
+ 19980516,368.5
2097
+ 19980523,369.6
2098
+ 19980530,369.7
2099
+ 19980606,369.4
2100
+ 19980613,368.8
2101
+ 19980620,368.5
2102
+ 19980627,368.3
2103
+ 19980704,368.0
2104
+ 19980711,367.5
2105
+ 19980718,367.6
2106
+ 19980725,367.3
2107
+ 19980801,366.8
2108
+ 19980808,366.4
2109
+ 19980815,365.6
2110
+ 19980822,365.6
2111
+ 19980829,364.2
2112
+ 19980905,364.7
2113
+ 19980912,363.9
2114
+ 19980919,363.5
2115
+ 19980926,363.6
2116
+ 19981003,364.0
2117
+ 19981010,364.1
2118
+ 19981017,364.4
2119
+ 19981024,364.4
2120
+ 19981031,364.7
2121
+ 19981107,365.0
2122
+ 19981114,365.4
2123
+ 19981121,365.8
2124
+ 19981128,366.0
2125
+ 19981205,366.4
2126
+ 19981212,366.7
2127
+ 19981219,367.3
2128
+ 19981226,367.3
2129
+ 19990102,367.5
2130
+ 19990109,367.8
2131
+ 19990116,367.8
2132
+ 19990123,368.3
2133
+ 19990130,369.2
2134
+ 19990206,369.1
2135
+ 19990213,368.8
2136
+ 19990220,369.0
2137
+ 19990227,368.5
2138
+ 19990306,368.1
2139
+ 19990313,369.5
2140
+ 19990320,370.2
2141
+ 19990327,370.6
2142
+ 19990403,371.1
2143
+ 19990410,371.5
2144
+ 19990417,371.0
2145
+ 19990424,370.3
2146
+ 19990501,370.8
2147
+ 19990508,371.3
2148
+ 19990515,371.0
2149
+ 19990522,370.8
2150
+ 19990529,370.3
2151
+ 19990605,370.9
2152
+ 19990612,370.3
2153
+ 19990619,369.9
2154
+ 19990626,369.9
2155
+ 19990703,369.4
2156
+ 19990710,370.1
2157
+ 19990717,369.5
2158
+ 19990724,368.6
2159
+ 19990731,367.4
2160
+ 19990807,367.6
2161
+ 19990814,366.7
2162
+ 19990821,366.4
2163
+ 19990828,366.1
2164
+ 19990904,364.1
2165
+ 19990911,364.7
2166
+ 19990918,365.2
2167
+ 19990925,364.7
2168
+ 19991002,364.5
2169
+ 19991009,365.0
2170
+ 19991016,364.9
2171
+ 19991023,365.6
2172
+ 19991030,365.7
2173
+ 19991106,366.2
2174
+ 19991113,366.7
2175
+ 19991120,366.6
2176
+ 19991127,367.1
2177
+ 19991204,367.4
2178
+ 19991211,368.0
2179
+ 19991218,368.0
2180
+ 19991225,368.2
2181
+ 20000101,368.6
2182
+ 20000108,368.5
2183
+ 20000115,369.0
2184
+ 20000122,369.8
2185
+ 20000129,369.2
2186
+ 20000205,369.1
2187
+ 20000212,369.6
2188
+ 20000219,369.3
2189
+ 20000226,369.5
2190
+ 20000304,370.0
2191
+ 20000311,370.0
2192
+ 20000318,370.9
2193
+ 20000325,370.7
2194
+ 20000401,370.9
2195
+ 20000408,371.7
2196
+ 20000415,371.8
2197
+ 20000422,372.0
2198
+ 20000429,371.3
2199
+ 20000506,371.2
2200
+ 20000513,371.7
2201
+ 20000520,371.9
2202
+ 20000527,371.8
2203
+ 20000603,371.9
2204
+ 20000610,371.6
2205
+ 20000617,371.7
2206
+ 20000624,371.3
2207
+ 20000701,370.8
2208
+ 20000708,370.0
2209
+ 20000715,370.2
2210
+ 20000722,369.7
2211
+ 20000729,369.0
2212
+ 20000805,368.7
2213
+ 20000812,368.3
2214
+ 20000819,367.7
2215
+ 20000826,367.1
2216
+ 20000902,367.2
2217
+ 20000909,366.7
2218
+ 20000916,366.2
2219
+ 20000923,366.2
2220
+ 20000930,366.4
2221
+ 20001007,366.3
2222
+ 20001014,366.6
2223
+ 20001021,366.7
2224
+ 20001028,367.3
2225
+ 20001104,367.6
2226
+ 20001111,368.0
2227
+ 20001118,368.6
2228
+ 20001125,368.3
2229
+ 20001202,369.0
2230
+ 20001209,369.6
2231
+ 20001216,369.3
2232
+ 20001223,369.5
2233
+ 20001230,369.8
2234
+ 20010106,369.8
2235
+ 20010113,370.2
2236
+ 20010120,369.9
2237
+ 20010127,370.8
2238
+ 20010203,371.3
2239
+ 20010210,371.1
2240
+ 20010217,371.7
2241
+ 20010224,371.2
2242
+ 20010303,372.2
2243
+ 20010310,372.2
2244
+ 20010317,372.1
2245
+ 20010324,371.8
2246
+ 20010331,372.0
2247
+ 20010407,372.7
2248
+ 20010414,372.7
2249
+ 20010421,373.0
2250
+ 20010428,372.7
2251
+ 20010505,373.7
2252
+ 20010512,373.9
2253
+ 20010519,373.7
2254
+ 20010526,373.9
2255
+ 20010602,373.8
2256
+ 20010609,373.1
2257
+ 20010616,372.8
2258
+ 20010623,372.9
2259
+ 20010630,372.7
2260
+ 20010707,372.1
2261
+ 20010714,371.3
2262
+ 20010721,371.2
2263
+ 20010728,370.6
2264
+ 20010804,369.9
2265
+ 20010811,369.5
2266
+ 20010818,369.3
2267
+ 20010825,369.0
2268
+ 20010901,368.4
2269
+ 20010908,368.2
2270
+ 20010915,368.0
2271
+ 20010922,367.4
2272
+ 20010929,367.4
2273
+ 20011006,367.8
2274
+ 20011013,367.6
2275
+ 20011020,368.1
2276
+ 20011027,368.7
2277
+ 20011103,368.7
2278
+ 20011110,368.8
2279
+ 20011117,369.7
2280
+ 20011124,370.3
2281
+ 20011201,370.3
2282
+ 20011208,370.8
2283
+ 20011215,371.2
2284
+ 20011222,371.3
2285
+ 20011229,371.5
shared/package-files/16/166a6ba1392bf6f36244e784ed3edc4d0ea03b89c94cc31dcc9c02cc95f99216/byteswap.cpython-310-x86_64-linux-gnu.so ADDED
Binary file (49.8 kB). View file
 
shared/package-files/16/166ca07d308c14c3e9dfe028c6389bf1a439027fe7b389d33eedb7d002e8bafb/METADATA ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.4
2
+ Name: wrapt
3
+ Version: 2.5.1
4
+ Summary: Module for decorators, wrappers and monkey patching.
5
+ Author-email: Graham Dumpleton <Graham.Dumpleton@gmail.com>
6
+ License-Expression: BSD-2-Clause
7
+ Project-URL: Homepage, https://github.com/GrahamDumpleton/wrapt
8
+ Project-URL: Bug Tracker, https://github.com/GrahamDumpleton/wrapt/issues/
9
+ Project-URL: Changelog, https://wrapt.readthedocs.io/en/latest/changes.html
10
+ Project-URL: Documentation, https://wrapt.readthedocs.io/
11
+ Keywords: wrapper,proxy,decorator
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Programming Language :: Python :: 3.15
21
+ Classifier: Programming Language :: Python :: Implementation :: CPython
22
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/x-rst
25
+ License-File: LICENSE
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest; extra == "dev"
28
+ Requires-Dist: setuptools; extra == "dev"
29
+ Dynamic: license-file
30
+
31
+ .. image:: https://raw.githubusercontent.com/GrahamDumpleton/wrapt/develop/docs/_static/wrapt-logo.svg
32
+ :alt: wrapt
33
+ :width: 182px
34
+
35
+ wrapt
36
+ =====
37
+
38
+ |PyPI| |Documentation|
39
+
40
+ A Python module for decorators, wrappers and monkey patching.
41
+
42
+ Overview
43
+ --------
44
+
45
+ The **wrapt** module provides a transparent object proxy for Python, which can be used as the basis for the construction of function wrappers and decorator functions.
46
+
47
+ The **wrapt** module focuses very much on correctness. It goes way beyond existing mechanisms such as ``functools.wraps()`` to ensure that decorators preserve introspectability, signatures, type checking abilities etc. The decorators that can be constructed using this module will work in far more scenarios than typical decorators and provide more predictable and consistent behaviour.
48
+
49
+ To ensure that the overhead is as minimal as possible, a C extension module is used for performance critical components. An automatic fallback to a pure Python implementation is also provided where a target system does not have a compiler to allow the C extension to be compiled.
50
+
51
+ Key Features
52
+ ------------
53
+
54
+ * **Universal decorators** that work with functions, methods, classmethods, staticmethods, and classes
55
+ * **Transparent object proxies** for advanced wrapping scenarios
56
+ * **Monkey patching utilities** for safe runtime modifications
57
+ * **C extension** for optimal performance with Python fallback
58
+ * **Comprehensive introspection preservation** (signatures, annotations, etc.)
59
+ * **Thread-safe decorator implementations**
60
+
61
+ Installation
62
+ ------------
63
+
64
+ Install from PyPI using pip::
65
+
66
+ pip install wrapt
67
+
68
+ Supported Python Versions
69
+ --------------------------
70
+
71
+ * Python 3.9+
72
+ * CPython and PyPy implementations
73
+
74
+ Documentation
75
+ -------------
76
+
77
+ For comprehensive documentation, examples, and advanced usage patterns, visit:
78
+
79
+ * https://wrapt.readthedocs.io/
80
+
81
+ Quick Start
82
+ -----------
83
+
84
+ To implement your decorator you need to first define a wrapper function.
85
+ This will be called each time a decorated function is called. The wrapper
86
+ function needs to take four positional arguments:
87
+
88
+ * ``wrapped`` - The wrapped function which in turns needs to be called by your wrapper function.
89
+ * ``instance`` - The object to which the wrapped function was bound when it was called.
90
+ * ``args`` - The list of positional arguments supplied when the decorated function was called.
91
+ * ``kwargs`` - The dictionary of keyword arguments supplied when the decorated function was called.
92
+
93
+ The wrapper function would do whatever it needs to, but would usually in
94
+ turn call the wrapped function that is passed in via the ``wrapped``
95
+ argument.
96
+
97
+ The decorator ``@wrapt.decorator`` then needs to be applied to the wrapper
98
+ function to convert it into a decorator which can in turn be applied to
99
+ other functions.
100
+
101
+ .. code-block:: python
102
+
103
+ import wrapt
104
+
105
+ @wrapt.decorator
106
+ def pass_through(wrapped, instance, args, kwargs):
107
+ return wrapped(*args, **kwargs)
108
+
109
+ @pass_through
110
+ def function():
111
+ pass
112
+
113
+ If you wish to implement a decorator which accepts arguments, then wrap the
114
+ definition of the decorator in a function closure. Any arguments supplied
115
+ to the outer function when the decorator is applied, will be available to
116
+ the inner wrapper when the wrapped function is called.
117
+
118
+ .. code-block:: python
119
+
120
+ import wrapt
121
+
122
+ def with_arguments(myarg1, myarg2):
123
+ @wrapt.decorator
124
+ def wrapper(wrapped, instance, args, kwargs):
125
+ return wrapped(*args, **kwargs)
126
+ return wrapper
127
+
128
+ @with_arguments(1, 2)
129
+ def function():
130
+ pass
131
+
132
+ When applied to a normal function or static method, the wrapper function
133
+ when called will be passed ``None`` as the ``instance`` argument.
134
+
135
+ When applied to an instance method, the wrapper function when called will
136
+ be passed the instance of the class the method is being called on as the
137
+ ``instance`` argument. This will be the case even when the instance method
138
+ was called explicitly via the class and the instance passed as the first
139
+ argument. That is, the instance will never be passed as part of ``args``.
140
+
141
+ When applied to a class method, the wrapper function when called will be
142
+ passed the class type as the ``instance`` argument.
143
+
144
+ When applied to a class, the wrapper function when called will be passed
145
+ ``None`` as the ``instance`` argument. The ``wrapped`` argument in this
146
+ case will be the class.
147
+
148
+ The above rules can be summarised with the following example.
149
+
150
+ .. code-block:: python
151
+
152
+ import inspect
153
+
154
+ @wrapt.decorator
155
+ def universal(wrapped, instance, args, kwargs):
156
+ if instance is None:
157
+ if inspect.isclass(wrapped):
158
+ # Decorator was applied to a class.
159
+ return wrapped(*args, **kwargs)
160
+ else:
161
+ # Decorator was applied to a function or staticmethod.
162
+ return wrapped(*args, **kwargs)
163
+ else:
164
+ if inspect.isclass(instance):
165
+ # Decorator was applied to a classmethod.
166
+ return wrapped(*args, **kwargs)
167
+ else:
168
+ # Decorator was applied to an instancemethod.
169
+ return wrapped(*args, **kwargs)
170
+
171
+ Using these checks it is therefore possible to create a universal decorator
172
+ that can be applied in all situations. It is no longer necessary to create
173
+ different variants of decorators for normal functions and instance methods,
174
+ or use additional wrappers to convert a function decorator into one that
175
+ will work for instance methods.
176
+
177
+ In all cases, the wrapped function passed to the wrapper function is called
178
+ in the same way, with ``args`` and ``kwargs`` being passed. The
179
+ ``instance`` argument doesn't need to be used in calling the wrapped
180
+ function.
181
+
182
+ Links
183
+ -----
184
+
185
+ * **Documentation**: https://wrapt.readthedocs.io/
186
+ * **Source Code**: https://github.com/GrahamDumpleton/wrapt
187
+ * **Bug Reports**: https://github.com/GrahamDumpleton/wrapt/issues/
188
+ * **Changelog**: https://wrapt.readthedocs.io/en/latest/changes.html
189
+
190
+ .. |PyPI| image:: https://img.shields.io/pypi/v/wrapt.svg?logo=python&cacheSeconds=3600
191
+ :target: https://pypi.python.org/pypi/wrapt
192
+ .. |Documentation| image:: https://img.shields.io/badge/docs-wrapt.readthedocs.io-blue.svg
193
+ :target: https://wrapt.readthedocs.io/
shared/package-files/16/167000925bfc3069bfa9bd948a50d0812ea5d1c52db620852948f1d339f65cd0/help.py ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Module containing bug report helper(s)."""
2
+
3
+ import json
4
+ import platform
5
+ import ssl
6
+ import sys
7
+
8
+ from pip._vendor import idna
9
+ from pip._vendor import urllib3
10
+
11
+ from . import __version__ as requests_version
12
+
13
+ charset_normalizer = None
14
+
15
+ try:
16
+ from pip._vendor import chardet
17
+ except ImportError:
18
+ chardet = None
19
+
20
+ try:
21
+ from pip._vendor.urllib3.contrib import pyopenssl
22
+ except ImportError:
23
+ pyopenssl = None
24
+ OpenSSL = None
25
+ cryptography = None
26
+ else:
27
+ import cryptography
28
+ import OpenSSL
29
+
30
+
31
+ def _implementation():
32
+ """Return a dict with the Python implementation and version.
33
+
34
+ Provide both the name and the version of the Python implementation
35
+ currently running. For example, on CPython 3.10.3 it will return
36
+ {'name': 'CPython', 'version': '3.10.3'}.
37
+
38
+ This function works best on CPython and PyPy: in particular, it probably
39
+ doesn't work for Jython or IronPython. Future investigation should be done
40
+ to work out the correct shape of the code for those platforms.
41
+ """
42
+ implementation = platform.python_implementation()
43
+
44
+ if implementation == "CPython":
45
+ implementation_version = platform.python_version()
46
+ elif implementation == "PyPy":
47
+ implementation_version = "{}.{}.{}".format(
48
+ sys.pypy_version_info.major,
49
+ sys.pypy_version_info.minor,
50
+ sys.pypy_version_info.micro,
51
+ )
52
+ if sys.pypy_version_info.releaselevel != "final":
53
+ implementation_version = "".join(
54
+ [implementation_version, sys.pypy_version_info.releaselevel]
55
+ )
56
+ elif implementation == "Jython":
57
+ implementation_version = platform.python_version() # Complete Guess
58
+ elif implementation == "IronPython":
59
+ implementation_version = platform.python_version() # Complete Guess
60
+ else:
61
+ implementation_version = "Unknown"
62
+
63
+ return {"name": implementation, "version": implementation_version}
64
+
65
+
66
+ def info():
67
+ """Generate information for a bug report."""
68
+ try:
69
+ platform_info = {
70
+ "system": platform.system(),
71
+ "release": platform.release(),
72
+ }
73
+ except OSError:
74
+ platform_info = {
75
+ "system": "Unknown",
76
+ "release": "Unknown",
77
+ }
78
+
79
+ implementation_info = _implementation()
80
+ urllib3_info = {"version": urllib3.__version__}
81
+ charset_normalizer_info = {"version": None}
82
+ chardet_info = {"version": None}
83
+ if charset_normalizer:
84
+ charset_normalizer_info = {"version": charset_normalizer.__version__}
85
+ if chardet:
86
+ chardet_info = {"version": chardet.__version__}
87
+
88
+ pyopenssl_info = {
89
+ "version": None,
90
+ "openssl_version": "",
91
+ }
92
+ if OpenSSL:
93
+ pyopenssl_info = {
94
+ "version": OpenSSL.__version__,
95
+ "openssl_version": f"{OpenSSL.SSL.OPENSSL_VERSION_NUMBER:x}",
96
+ }
97
+ cryptography_info = {
98
+ "version": getattr(cryptography, "__version__", ""),
99
+ }
100
+ idna_info = {
101
+ "version": getattr(idna, "__version__", ""),
102
+ }
103
+
104
+ system_ssl = ssl.OPENSSL_VERSION_NUMBER
105
+ system_ssl_info = {"version": f"{system_ssl:x}" if system_ssl is not None else ""}
106
+
107
+ return {
108
+ "platform": platform_info,
109
+ "implementation": implementation_info,
110
+ "system_ssl": system_ssl_info,
111
+ "using_pyopenssl": pyopenssl is not None,
112
+ "using_charset_normalizer": chardet is None,
113
+ "pyOpenSSL": pyopenssl_info,
114
+ "urllib3": urllib3_info,
115
+ "chardet": chardet_info,
116
+ "charset_normalizer": charset_normalizer_info,
117
+ "cryptography": cryptography_info,
118
+ "idna": idna_info,
119
+ "requests": {
120
+ "version": requests_version,
121
+ },
122
+ }
123
+
124
+
125
+ def main():
126
+ """Pretty-print the bug information as JSON."""
127
+ print(json.dumps(info(), sort_keys=True, indent=2))
128
+
129
+
130
+ if __name__ == "__main__":
131
+ main()
shared/package-files/16/1671a0ce3f2e545ed34eb2765fde08068ed75bf7b3610f03614c19f303fe3c84/_typing.py ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+
19
+ from typing import (
20
+ Any,
21
+ Callable,
22
+ Optional,
23
+ TypeVar,
24
+ Union,
25
+ )
26
+
27
+ try:
28
+ from typing import Literal, Protocol
29
+ except ImportError:
30
+ from typing_extensions import Literal, Protocol
31
+
32
+ import datetime
33
+ import decimal
34
+
35
+ from .._typing import PrimitiveType
36
+ from . import types
37
+ from .column import Column
38
+
39
+ ColumnOrName = Union[Column, str]
40
+ ColumnOrName_ = TypeVar("ColumnOrName_", bound=ColumnOrName)
41
+ DecimalLiteral = decimal.Decimal
42
+ DateTimeLiteral = Union[datetime.datetime, datetime.date]
43
+ LiteralType = PrimitiveType
44
+ AtomicDataTypeOrString = Union[types.AtomicType, str]
45
+ DataTypeOrString = Union[types.DataType, str]
46
+ OptionalPrimitiveType = Optional[PrimitiveType]
47
+
48
+ AtomicValue = TypeVar(
49
+ "AtomicValue",
50
+ datetime.datetime,
51
+ datetime.date,
52
+ decimal.Decimal,
53
+ bool,
54
+ str,
55
+ int,
56
+ float,
57
+ )
58
+
59
+ RowLike = TypeVar("RowLike", list[Any], tuple[Any, ...], types.Row)
60
+
61
+ SQLBatchedUDFType = Literal[100]
62
+
63
+
64
+ class SupportsOpen(Protocol):
65
+ def open(self, partition_id: int, epoch_id: int) -> bool: ...
66
+
67
+
68
+ class SupportsProcess(Protocol):
69
+ def process(self, row: types.Row) -> None: ...
70
+
71
+
72
+ class SupportsClose(Protocol):
73
+ def close(self, error: Exception) -> None: ...
74
+
75
+
76
+ class UserDefinedFunctionLike(Protocol):
77
+ func: Callable[..., Any]
78
+ evalType: int
79
+ deterministic: bool
80
+
81
+ @property
82
+ def returnType(self) -> types.DataType: ...
83
+
84
+ def __call__(self, *args: ColumnOrName) -> Column: ...
85
+
86
+ def asNondeterministic(self) -> "UserDefinedFunctionLike": ...
shared/package-files/16/1675e56b6abeb397614ac63bf48c528051ddadcd8c689b04a58145a17042a438/fake_pg.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # mypy: ignore-errors
2
+
3
+ import torch.distributed as dist
4
+
5
+ from torch._C._distributed_c10d import (
6
+ FakeProcessGroup,
7
+ )
8
+
9
+
10
+ class FakeStore(dist.Store):
11
+ """
12
+ A fake store is a fake Key-Value store simply for initialization usage
13
+ the of fake process group, one can either use FakeStore or HashStore.
14
+ """
15
+ pass
16
+
17
+
18
+ def _create_fake_pg(prefix_store, rank, world_size, timeout):
19
+ """
20
+ A fake process group (not related to FakeTensor) is a process group which
21
+ doesn't actually do any communication, it just hallucinates some
22
+ communication. You can run a single rank with a fake process group
23
+ without needing multiple processes (simulates per-rank behavior)
24
+
25
+ NOTE: This is not a real process group, and it would produce wrong results
26
+ for every collective. It should be used as a convinient tool when playing
27
+ with distributed but don't care about the actual data.
28
+ """
29
+ return FakeProcessGroup(rank, world_size)
30
+
31
+
32
+ dist.Backend.register_backend("fake", _create_fake_pg, devices=['cpu', 'cuda'])
shared/package-files/16/167630ab4c004780a2c738fe6bdaa1cae954484a4cca35fd00b6e3cdafd67bbe/junitxml.py ADDED
@@ -0,0 +1,697 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # mypy: allow-untyped-defs
2
+ """Report test results in JUnit-XML format, for use with Jenkins and build
3
+ integration servers.
4
+
5
+ Based on initial code from Ross Lawley.
6
+
7
+ Output conforms to
8
+ https://github.com/jenkinsci/xunit-plugin/blob/master/src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from datetime import datetime
14
+ from datetime import timezone
15
+ import functools
16
+ import os
17
+ import platform
18
+ import re
19
+ from typing import Callable
20
+ from typing import Match
21
+ import xml.etree.ElementTree as ET
22
+
23
+ from _pytest import nodes
24
+ from _pytest import timing
25
+ from _pytest._code.code import ExceptionRepr
26
+ from _pytest._code.code import ReprFileLocation
27
+ from _pytest.config import Config
28
+ from _pytest.config import filename_arg
29
+ from _pytest.config.argparsing import Parser
30
+ from _pytest.fixtures import FixtureRequest
31
+ from _pytest.reports import TestReport
32
+ from _pytest.stash import StashKey
33
+ from _pytest.terminal import TerminalReporter
34
+ import pytest
35
+
36
+
37
+ xml_key = StashKey["LogXML"]()
38
+
39
+
40
+ def bin_xml_escape(arg: object) -> str:
41
+ r"""Visually escape invalid XML characters.
42
+
43
+ For example, transforms
44
+ 'hello\aworld\b'
45
+ into
46
+ 'hello#x07world#x08'
47
+ Note that the #xABs are *not* XML escapes - missing the ampersand &#xAB.
48
+ The idea is to escape visually for the user rather than for XML itself.
49
+ """
50
+
51
+ def repl(matchobj: Match[str]) -> str:
52
+ i = ord(matchobj.group())
53
+ if i <= 0xFF:
54
+ return f"#x{i:02X}"
55
+ else:
56
+ return f"#x{i:04X}"
57
+
58
+ # The spec range of valid chars is:
59
+ # Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
60
+ # For an unknown(?) reason, we disallow #x7F (DEL) as well.
61
+ illegal_xml_re = (
62
+ "[^\u0009\u000a\u000d\u0020-\u007e\u0080-\ud7ff\ue000-\ufffd\u10000-\u10ffff]"
63
+ )
64
+ return re.sub(illegal_xml_re, repl, str(arg))
65
+
66
+
67
+ def merge_family(left, right) -> None:
68
+ result = {}
69
+ for kl, vl in left.items():
70
+ for kr, vr in right.items():
71
+ if not isinstance(vl, list):
72
+ raise TypeError(type(vl))
73
+ result[kl] = vl + vr
74
+ left.update(result)
75
+
76
+
77
+ families = {}
78
+ families["_base"] = {"testcase": ["classname", "name"]}
79
+ families["_base_legacy"] = {"testcase": ["file", "line", "url"]}
80
+
81
+ # xUnit 1.x inherits legacy attributes.
82
+ families["xunit1"] = families["_base"].copy()
83
+ merge_family(families["xunit1"], families["_base_legacy"])
84
+
85
+ # xUnit 2.x uses strict base attributes.
86
+ families["xunit2"] = families["_base"]
87
+
88
+
89
+ class _NodeReporter:
90
+ def __init__(self, nodeid: str | TestReport, xml: LogXML) -> None:
91
+ self.id = nodeid
92
+ self.xml = xml
93
+ self.add_stats = self.xml.add_stats
94
+ self.family = self.xml.family
95
+ self.duration = 0.0
96
+ self.properties: list[tuple[str, str]] = []
97
+ self.nodes: list[ET.Element] = []
98
+ self.attrs: dict[str, str] = {}
99
+
100
+ def append(self, node: ET.Element) -> None:
101
+ self.xml.add_stats(node.tag)
102
+ self.nodes.append(node)
103
+
104
+ def add_property(self, name: str, value: object) -> None:
105
+ self.properties.append((str(name), bin_xml_escape(value)))
106
+
107
+ def add_attribute(self, name: str, value: object) -> None:
108
+ self.attrs[str(name)] = bin_xml_escape(value)
109
+
110
+ def make_properties_node(self) -> ET.Element | None:
111
+ """Return a Junit node containing custom properties, if any."""
112
+ if self.properties:
113
+ properties = ET.Element("properties")
114
+ for name, value in self.properties:
115
+ properties.append(ET.Element("property", name=name, value=value))
116
+ return properties
117
+ return None
118
+
119
+ def record_testreport(self, testreport: TestReport) -> None:
120
+ names = mangle_test_address(testreport.nodeid)
121
+ existing_attrs = self.attrs
122
+ classnames = names[:-1]
123
+ if self.xml.prefix:
124
+ classnames.insert(0, self.xml.prefix)
125
+ attrs: dict[str, str] = {
126
+ "classname": ".".join(classnames),
127
+ "name": bin_xml_escape(names[-1]),
128
+ "file": testreport.location[0],
129
+ }
130
+ if testreport.location[1] is not None:
131
+ attrs["line"] = str(testreport.location[1])
132
+ if hasattr(testreport, "url"):
133
+ attrs["url"] = testreport.url
134
+ self.attrs = attrs
135
+ self.attrs.update(existing_attrs) # Restore any user-defined attributes.
136
+
137
+ # Preserve legacy testcase behavior.
138
+ if self.family == "xunit1":
139
+ return
140
+
141
+ # Filter out attributes not permitted by this test family.
142
+ # Including custom attributes because they are not valid here.
143
+ temp_attrs = {}
144
+ for key in self.attrs:
145
+ if key in families[self.family]["testcase"]:
146
+ temp_attrs[key] = self.attrs[key]
147
+ self.attrs = temp_attrs
148
+
149
+ def to_xml(self) -> ET.Element:
150
+ testcase = ET.Element("testcase", self.attrs, time=f"{self.duration:.3f}")
151
+ properties = self.make_properties_node()
152
+ if properties is not None:
153
+ testcase.append(properties)
154
+ testcase.extend(self.nodes)
155
+ return testcase
156
+
157
+ def _add_simple(self, tag: str, message: str, data: str | None = None) -> None:
158
+ node = ET.Element(tag, message=message)
159
+ node.text = bin_xml_escape(data)
160
+ self.append(node)
161
+
162
+ def write_captured_output(self, report: TestReport) -> None:
163
+ if not self.xml.log_passing_tests and report.passed:
164
+ return
165
+
166
+ content_out = report.capstdout
167
+ content_log = report.caplog
168
+ content_err = report.capstderr
169
+ if self.xml.logging == "no":
170
+ return
171
+ content_all = ""
172
+ if self.xml.logging in ["log", "all"]:
173
+ content_all = self._prepare_content(content_log, " Captured Log ")
174
+ if self.xml.logging in ["system-out", "out-err", "all"]:
175
+ content_all += self._prepare_content(content_out, " Captured Out ")
176
+ self._write_content(report, content_all, "system-out")
177
+ content_all = ""
178
+ if self.xml.logging in ["system-err", "out-err", "all"]:
179
+ content_all += self._prepare_content(content_err, " Captured Err ")
180
+ self._write_content(report, content_all, "system-err")
181
+ content_all = ""
182
+ if content_all:
183
+ self._write_content(report, content_all, "system-out")
184
+
185
+ def _prepare_content(self, content: str, header: str) -> str:
186
+ return "\n".join([header.center(80, "-"), content, ""])
187
+
188
+ def _write_content(self, report: TestReport, content: str, jheader: str) -> None:
189
+ tag = ET.Element(jheader)
190
+ tag.text = bin_xml_escape(content)
191
+ self.append(tag)
192
+
193
+ def append_pass(self, report: TestReport) -> None:
194
+ self.add_stats("passed")
195
+
196
+ def append_failure(self, report: TestReport) -> None:
197
+ # msg = str(report.longrepr.reprtraceback.extraline)
198
+ if hasattr(report, "wasxfail"):
199
+ self._add_simple("skipped", "xfail-marked test passes unexpectedly")
200
+ else:
201
+ assert report.longrepr is not None
202
+ reprcrash: ReprFileLocation | None = getattr(
203
+ report.longrepr, "reprcrash", None
204
+ )
205
+ if reprcrash is not None:
206
+ message = reprcrash.message
207
+ else:
208
+ message = str(report.longrepr)
209
+ message = bin_xml_escape(message)
210
+ self._add_simple("failure", message, str(report.longrepr))
211
+
212
+ def append_collect_error(self, report: TestReport) -> None:
213
+ # msg = str(report.longrepr.reprtraceback.extraline)
214
+ assert report.longrepr is not None
215
+ self._add_simple("error", "collection failure", str(report.longrepr))
216
+
217
+ def append_collect_skipped(self, report: TestReport) -> None:
218
+ self._add_simple("skipped", "collection skipped", str(report.longrepr))
219
+
220
+ def append_error(self, report: TestReport) -> None:
221
+ assert report.longrepr is not None
222
+ reprcrash: ReprFileLocation | None = getattr(report.longrepr, "reprcrash", None)
223
+ if reprcrash is not None:
224
+ reason = reprcrash.message
225
+ else:
226
+ reason = str(report.longrepr)
227
+
228
+ if report.when == "teardown":
229
+ msg = f'failed on teardown with "{reason}"'
230
+ else:
231
+ msg = f'failed on setup with "{reason}"'
232
+ self._add_simple("error", bin_xml_escape(msg), str(report.longrepr))
233
+
234
+ def append_skipped(self, report: TestReport) -> None:
235
+ if hasattr(report, "wasxfail"):
236
+ xfailreason = report.wasxfail
237
+ if xfailreason.startswith("reason: "):
238
+ xfailreason = xfailreason[8:]
239
+ xfailreason = bin_xml_escape(xfailreason)
240
+ skipped = ET.Element("skipped", type="pytest.xfail", message=xfailreason)
241
+ self.append(skipped)
242
+ else:
243
+ assert isinstance(report.longrepr, tuple)
244
+ filename, lineno, skipreason = report.longrepr
245
+ if skipreason.startswith("Skipped: "):
246
+ skipreason = skipreason[9:]
247
+ details = f"{filename}:{lineno}: {skipreason}"
248
+
249
+ skipped = ET.Element(
250
+ "skipped", type="pytest.skip", message=bin_xml_escape(skipreason)
251
+ )
252
+ skipped.text = bin_xml_escape(details)
253
+ self.append(skipped)
254
+ self.write_captured_output(report)
255
+
256
+ def finalize(self) -> None:
257
+ data = self.to_xml()
258
+ self.__dict__.clear()
259
+ # Type ignored because mypy doesn't like overriding a method.
260
+ # Also the return value doesn't match...
261
+ self.to_xml = lambda: data # type: ignore[method-assign]
262
+
263
+
264
+ def _warn_incompatibility_with_xunit2(
265
+ request: FixtureRequest, fixture_name: str
266
+ ) -> None:
267
+ """Emit a PytestWarning about the given fixture being incompatible with newer xunit revisions."""
268
+ from _pytest.warning_types import PytestWarning
269
+
270
+ xml = request.config.stash.get(xml_key, None)
271
+ if xml is not None and xml.family not in ("xunit1", "legacy"):
272
+ request.node.warn(
273
+ PytestWarning(
274
+ f"{fixture_name} is incompatible with junit_family '{xml.family}' (use 'legacy' or 'xunit1')"
275
+ )
276
+ )
277
+
278
+
279
+ @pytest.fixture
280
+ def record_property(request: FixtureRequest) -> Callable[[str, object], None]:
281
+ """Add extra properties to the calling test.
282
+
283
+ User properties become part of the test report and are available to the
284
+ configured reporters, like JUnit XML.
285
+
286
+ The fixture is callable with ``name, value``. The value is automatically
287
+ XML-encoded.
288
+
289
+ Example::
290
+
291
+ def test_function(record_property):
292
+ record_property("example_key", 1)
293
+ """
294
+ _warn_incompatibility_with_xunit2(request, "record_property")
295
+
296
+ def append_property(name: str, value: object) -> None:
297
+ request.node.user_properties.append((name, value))
298
+
299
+ return append_property
300
+
301
+
302
+ @pytest.fixture
303
+ def record_xml_attribute(request: FixtureRequest) -> Callable[[str, object], None]:
304
+ """Add extra xml attributes to the tag for the calling test.
305
+
306
+ The fixture is callable with ``name, value``. The value is
307
+ automatically XML-encoded.
308
+ """
309
+ from _pytest.warning_types import PytestExperimentalApiWarning
310
+
311
+ request.node.warn(
312
+ PytestExperimentalApiWarning("record_xml_attribute is an experimental feature")
313
+ )
314
+
315
+ _warn_incompatibility_with_xunit2(request, "record_xml_attribute")
316
+
317
+ # Declare noop
318
+ def add_attr_noop(name: str, value: object) -> None:
319
+ pass
320
+
321
+ attr_func = add_attr_noop
322
+
323
+ xml = request.config.stash.get(xml_key, None)
324
+ if xml is not None:
325
+ node_reporter = xml.node_reporter(request.node.nodeid)
326
+ attr_func = node_reporter.add_attribute
327
+
328
+ return attr_func
329
+
330
+
331
+ def _check_record_param_type(param: str, v: str) -> None:
332
+ """Used by record_testsuite_property to check that the given parameter name is of the proper
333
+ type."""
334
+ __tracebackhide__ = True
335
+ if not isinstance(v, str):
336
+ msg = "{param} parameter needs to be a string, but {g} given" # type: ignore[unreachable]
337
+ raise TypeError(msg.format(param=param, g=type(v).__name__))
338
+
339
+
340
+ @pytest.fixture(scope="session")
341
+ def record_testsuite_property(request: FixtureRequest) -> Callable[[str, object], None]:
342
+ """Record a new ``<property>`` tag as child of the root ``<testsuite>``.
343
+
344
+ This is suitable to writing global information regarding the entire test
345
+ suite, and is compatible with ``xunit2`` JUnit family.
346
+
347
+ This is a ``session``-scoped fixture which is called with ``(name, value)``. Example:
348
+
349
+ .. code-block:: python
350
+
351
+ def test_foo(record_testsuite_property):
352
+ record_testsuite_property("ARCH", "PPC")
353
+ record_testsuite_property("STORAGE_TYPE", "CEPH")
354
+
355
+ :param name:
356
+ The property name.
357
+ :param value:
358
+ The property value. Will be converted to a string.
359
+
360
+ .. warning::
361
+
362
+ Currently this fixture **does not work** with the
363
+ `pytest-xdist <https://github.com/pytest-dev/pytest-xdist>`__ plugin. See
364
+ :issue:`7767` for details.
365
+ """
366
+ __tracebackhide__ = True
367
+
368
+ def record_func(name: str, value: object) -> None:
369
+ """No-op function in case --junit-xml was not passed in the command-line."""
370
+ __tracebackhide__ = True
371
+ _check_record_param_type("name", name)
372
+
373
+ xml = request.config.stash.get(xml_key, None)
374
+ if xml is not None:
375
+ record_func = xml.add_global_property
376
+ return record_func
377
+
378
+
379
+ def pytest_addoption(parser: Parser) -> None:
380
+ group = parser.getgroup("terminal reporting")
381
+ group.addoption(
382
+ "--junitxml",
383
+ "--junit-xml",
384
+ action="store",
385
+ dest="xmlpath",
386
+ metavar="path",
387
+ type=functools.partial(filename_arg, optname="--junitxml"),
388
+ default=None,
389
+ help="Create junit-xml style report file at given path",
390
+ )
391
+ group.addoption(
392
+ "--junitprefix",
393
+ "--junit-prefix",
394
+ action="store",
395
+ metavar="str",
396
+ default=None,
397
+ help="Prepend prefix to classnames in junit-xml output",
398
+ )
399
+ parser.addini(
400
+ "junit_suite_name", "Test suite name for JUnit report", default="pytest"
401
+ )
402
+ parser.addini(
403
+ "junit_logging",
404
+ "Write captured log messages to JUnit report: "
405
+ "one of no|log|system-out|system-err|out-err|all",
406
+ default="no",
407
+ )
408
+ parser.addini(
409
+ "junit_log_passing_tests",
410
+ "Capture log information for passing tests to JUnit report: ",
411
+ type="bool",
412
+ default=True,
413
+ )
414
+ parser.addini(
415
+ "junit_duration_report",
416
+ "Duration time to report: one of total|call",
417
+ default="total",
418
+ ) # choices=['total', 'call'])
419
+ parser.addini(
420
+ "junit_family",
421
+ "Emit XML for schema: one of legacy|xunit1|xunit2",
422
+ default="xunit2",
423
+ )
424
+
425
+
426
+ def pytest_configure(config: Config) -> None:
427
+ xmlpath = config.option.xmlpath
428
+ # Prevent opening xmllog on worker nodes (xdist).
429
+ if xmlpath and not hasattr(config, "workerinput"):
430
+ junit_family = config.getini("junit_family")
431
+ config.stash[xml_key] = LogXML(
432
+ xmlpath,
433
+ config.option.junitprefix,
434
+ config.getini("junit_suite_name"),
435
+ config.getini("junit_logging"),
436
+ config.getini("junit_duration_report"),
437
+ junit_family,
438
+ config.getini("junit_log_passing_tests"),
439
+ )
440
+ config.pluginmanager.register(config.stash[xml_key])
441
+
442
+
443
+ def pytest_unconfigure(config: Config) -> None:
444
+ xml = config.stash.get(xml_key, None)
445
+ if xml:
446
+ del config.stash[xml_key]
447
+ config.pluginmanager.unregister(xml)
448
+
449
+
450
+ def mangle_test_address(address: str) -> list[str]:
451
+ path, possible_open_bracket, params = address.partition("[")
452
+ names = path.split("::")
453
+ # Convert file path to dotted path.
454
+ names[0] = names[0].replace(nodes.SEP, ".")
455
+ names[0] = re.sub(r"\.py$", "", names[0])
456
+ # Put any params back.
457
+ names[-1] += possible_open_bracket + params
458
+ return names
459
+
460
+
461
+ class LogXML:
462
+ def __init__(
463
+ self,
464
+ logfile,
465
+ prefix: str | None,
466
+ suite_name: str = "pytest",
467
+ logging: str = "no",
468
+ report_duration: str = "total",
469
+ family="xunit1",
470
+ log_passing_tests: bool = True,
471
+ ) -> None:
472
+ logfile = os.path.expanduser(os.path.expandvars(logfile))
473
+ self.logfile = os.path.normpath(os.path.abspath(logfile))
474
+ self.prefix = prefix
475
+ self.suite_name = suite_name
476
+ self.logging = logging
477
+ self.log_passing_tests = log_passing_tests
478
+ self.report_duration = report_duration
479
+ self.family = family
480
+ self.stats: dict[str, int] = dict.fromkeys(
481
+ ["error", "passed", "failure", "skipped"], 0
482
+ )
483
+ self.node_reporters: dict[tuple[str | TestReport, object], _NodeReporter] = {}
484
+ self.node_reporters_ordered: list[_NodeReporter] = []
485
+ self.global_properties: list[tuple[str, str]] = []
486
+
487
+ # List of reports that failed on call but teardown is pending.
488
+ self.open_reports: list[TestReport] = []
489
+ self.cnt_double_fail_tests = 0
490
+
491
+ # Replaces convenience family with real family.
492
+ if self.family == "legacy":
493
+ self.family = "xunit1"
494
+
495
+ def finalize(self, report: TestReport) -> None:
496
+ nodeid = getattr(report, "nodeid", report)
497
+ # Local hack to handle xdist report order.
498
+ workernode = getattr(report, "node", None)
499
+ reporter = self.node_reporters.pop((nodeid, workernode))
500
+
501
+ for propname, propvalue in report.user_properties:
502
+ reporter.add_property(propname, str(propvalue))
503
+
504
+ if reporter is not None:
505
+ reporter.finalize()
506
+
507
+ def node_reporter(self, report: TestReport | str) -> _NodeReporter:
508
+ nodeid: str | TestReport = getattr(report, "nodeid", report)
509
+ # Local hack to handle xdist report order.
510
+ workernode = getattr(report, "node", None)
511
+
512
+ key = nodeid, workernode
513
+
514
+ if key in self.node_reporters:
515
+ # TODO: breaks for --dist=each
516
+ return self.node_reporters[key]
517
+
518
+ reporter = _NodeReporter(nodeid, self)
519
+
520
+ self.node_reporters[key] = reporter
521
+ self.node_reporters_ordered.append(reporter)
522
+
523
+ return reporter
524
+
525
+ def add_stats(self, key: str) -> None:
526
+ if key in self.stats:
527
+ self.stats[key] += 1
528
+
529
+ def _opentestcase(self, report: TestReport) -> _NodeReporter:
530
+ reporter = self.node_reporter(report)
531
+ reporter.record_testreport(report)
532
+ return reporter
533
+
534
+ def pytest_runtest_logreport(self, report: TestReport) -> None:
535
+ """Handle a setup/call/teardown report, generating the appropriate
536
+ XML tags as necessary.
537
+
538
+ Note: due to plugins like xdist, this hook may be called in interlaced
539
+ order with reports from other nodes. For example:
540
+
541
+ Usual call order:
542
+ -> setup node1
543
+ -> call node1
544
+ -> teardown node1
545
+ -> setup node2
546
+ -> call node2
547
+ -> teardown node2
548
+
549
+ Possible call order in xdist:
550
+ -> setup node1
551
+ -> call node1
552
+ -> setup node2
553
+ -> call node2
554
+ -> teardown node2
555
+ -> teardown node1
556
+ """
557
+ close_report = None
558
+ if report.passed:
559
+ if report.when == "call": # ignore setup/teardown
560
+ reporter = self._opentestcase(report)
561
+ reporter.append_pass(report)
562
+ elif report.failed:
563
+ if report.when == "teardown":
564
+ # The following vars are needed when xdist plugin is used.
565
+ report_wid = getattr(report, "worker_id", None)
566
+ report_ii = getattr(report, "item_index", None)
567
+ close_report = next(
568
+ (
569
+ rep
570
+ for rep in self.open_reports
571
+ if (
572
+ rep.nodeid == report.nodeid
573
+ and getattr(rep, "item_index", None) == report_ii
574
+ and getattr(rep, "worker_id", None) == report_wid
575
+ )
576
+ ),
577
+ None,
578
+ )
579
+ if close_report:
580
+ # We need to open new testcase in case we have failure in
581
+ # call and error in teardown in order to follow junit
582
+ # schema.
583
+ self.finalize(close_report)
584
+ self.cnt_double_fail_tests += 1
585
+ reporter = self._opentestcase(report)
586
+ if report.when == "call":
587
+ reporter.append_failure(report)
588
+ self.open_reports.append(report)
589
+ if not self.log_passing_tests:
590
+ reporter.write_captured_output(report)
591
+ else:
592
+ reporter.append_error(report)
593
+ elif report.skipped:
594
+ reporter = self._opentestcase(report)
595
+ reporter.append_skipped(report)
596
+ self.update_testcase_duration(report)
597
+ if report.when == "teardown":
598
+ reporter = self._opentestcase(report)
599
+ reporter.write_captured_output(report)
600
+
601
+ self.finalize(report)
602
+ report_wid = getattr(report, "worker_id", None)
603
+ report_ii = getattr(report, "item_index", None)
604
+ close_report = next(
605
+ (
606
+ rep
607
+ for rep in self.open_reports
608
+ if (
609
+ rep.nodeid == report.nodeid
610
+ and getattr(rep, "item_index", None) == report_ii
611
+ and getattr(rep, "worker_id", None) == report_wid
612
+ )
613
+ ),
614
+ None,
615
+ )
616
+ if close_report:
617
+ self.open_reports.remove(close_report)
618
+
619
+ def update_testcase_duration(self, report: TestReport) -> None:
620
+ """Accumulate total duration for nodeid from given report and update
621
+ the Junit.testcase with the new total if already created."""
622
+ if self.report_duration in {"total", report.when}:
623
+ reporter = self.node_reporter(report)
624
+ reporter.duration += getattr(report, "duration", 0.0)
625
+
626
+ def pytest_collectreport(self, report: TestReport) -> None:
627
+ if not report.passed:
628
+ reporter = self._opentestcase(report)
629
+ if report.failed:
630
+ reporter.append_collect_error(report)
631
+ else:
632
+ reporter.append_collect_skipped(report)
633
+
634
+ def pytest_internalerror(self, excrepr: ExceptionRepr) -> None:
635
+ reporter = self.node_reporter("internal")
636
+ reporter.attrs.update(classname="pytest", name="internal")
637
+ reporter._add_simple("error", "internal error", str(excrepr))
638
+
639
+ def pytest_sessionstart(self) -> None:
640
+ self.suite_start_time = timing.time()
641
+
642
+ def pytest_sessionfinish(self) -> None:
643
+ dirname = os.path.dirname(os.path.abspath(self.logfile))
644
+ # exist_ok avoids filesystem race conditions between checking path existence and requesting creation
645
+ os.makedirs(dirname, exist_ok=True)
646
+
647
+ with open(self.logfile, "w", encoding="utf-8") as logfile:
648
+ suite_stop_time = timing.time()
649
+ suite_time_delta = suite_stop_time - self.suite_start_time
650
+
651
+ numtests = (
652
+ self.stats["passed"]
653
+ + self.stats["failure"]
654
+ + self.stats["skipped"]
655
+ + self.stats["error"]
656
+ - self.cnt_double_fail_tests
657
+ )
658
+ logfile.write('<?xml version="1.0" encoding="utf-8"?>')
659
+
660
+ suite_node = ET.Element(
661
+ "testsuite",
662
+ name=self.suite_name,
663
+ errors=str(self.stats["error"]),
664
+ failures=str(self.stats["failure"]),
665
+ skipped=str(self.stats["skipped"]),
666
+ tests=str(numtests),
667
+ time=f"{suite_time_delta:.3f}",
668
+ timestamp=datetime.fromtimestamp(self.suite_start_time, timezone.utc)
669
+ .astimezone()
670
+ .isoformat(),
671
+ hostname=platform.node(),
672
+ )
673
+ global_properties = self._get_global_properties_node()
674
+ if global_properties is not None:
675
+ suite_node.append(global_properties)
676
+ for node_reporter in self.node_reporters_ordered:
677
+ suite_node.append(node_reporter.to_xml())
678
+ testsuites = ET.Element("testsuites")
679
+ testsuites.append(suite_node)
680
+ logfile.write(ET.tostring(testsuites, encoding="unicode"))
681
+
682
+ def pytest_terminal_summary(self, terminalreporter: TerminalReporter) -> None:
683
+ terminalreporter.write_sep("-", f"generated xml file: {self.logfile}")
684
+
685
+ def add_global_property(self, name: str, value: object) -> None:
686
+ __tracebackhide__ = True
687
+ _check_record_param_type("name", name)
688
+ self.global_properties.append((name, bin_xml_escape(value)))
689
+
690
+ def _get_global_properties_node(self) -> ET.Element | None:
691
+ """Return a Junit node containing custom properties, if any."""
692
+ if self.global_properties:
693
+ properties = ET.Element("properties")
694
+ for name, value in self.global_properties:
695
+ properties.append(ET.Element("property", name=name, value=value))
696
+ return properties
697
+ return None
shared/package-files/16/1678951cfed6d980657a7a0c62142b383be8aaabc331296cd8900d1ad34f42db/numpy_init.h ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Licensed to the Apache Software Foundation (ASF) under one
2
+ // or more contributor license agreements. See the NOTICE file
3
+ // distributed with this work for additional information
4
+ // regarding copyright ownership. The ASF licenses this file
5
+ // to you under the Apache License, Version 2.0 (the
6
+ // "License"); you may not use this file except in compliance
7
+ // with the License. You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing,
12
+ // software distributed under the License is distributed on an
13
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ // KIND, either express or implied. See the License for the
15
+ // specific language governing permissions and limitations
16
+ // under the License.
17
+
18
+ #pragma once
19
+
20
+ #include "arrow/python/platform.h"
21
+ #include "arrow/python/visibility.h"
22
+
23
+ namespace arrow::py {
24
+ ARROW_PYTHON_EXPORT
25
+ int arrow_init_numpy();
26
+ bool has_numpy();
27
+ } // namespace arrow::py
shared/package-files/16/16794e45a9ab86b5a2e7da8c1925d42ffa71db4ac7f10020172ae9b48bf7431c/struct.pyi ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ from array import array
3
+ from mmap import mmap
4
+ from typing import Any, Iterator, Text, Tuple, Union
5
+
6
+ class error(Exception): ...
7
+
8
+ _FmtType = Union[bytes, Text]
9
+ if sys.version_info >= (3,):
10
+ _BufferType = Union[array[int], bytes, bytearray, memoryview, mmap]
11
+ _WriteBufferType = Union[array, bytearray, memoryview, mmap]
12
+ else:
13
+ _BufferType = Union[array[int], bytes, bytearray, buffer, memoryview, mmap]
14
+ _WriteBufferType = Union[array[Any], bytearray, buffer, memoryview, mmap]
15
+
16
+ def pack(fmt: _FmtType, *v: Any) -> bytes: ...
17
+ def pack_into(fmt: _FmtType, buffer: _WriteBufferType, offset: int, *v: Any) -> None: ...
18
+ def unpack(__format: _FmtType, __buffer: _BufferType) -> Tuple[Any, ...]: ...
19
+ def unpack_from(__format: _FmtType, buffer: _BufferType, offset: int = ...) -> Tuple[Any, ...]: ...
20
+
21
+ if sys.version_info >= (3, 4):
22
+ def iter_unpack(__format: _FmtType, __buffer: _BufferType) -> Iterator[Tuple[Any, ...]]: ...
23
+
24
+ def calcsize(__format: _FmtType) -> int: ...
25
+
26
+ class Struct:
27
+ if sys.version_info >= (3, 7):
28
+ format: str
29
+ else:
30
+ format: bytes
31
+ size: int
32
+ def __init__(self, format: _FmtType) -> None: ...
33
+ def pack(self, *v: Any) -> bytes: ...
34
+ def pack_into(self, buffer: _WriteBufferType, offset: int, *v: Any) -> None: ...
35
+ def unpack(self, __buffer: _BufferType) -> Tuple[Any, ...]: ...
36
+ def unpack_from(self, buffer: _BufferType, offset: int = ...) -> Tuple[Any, ...]: ...
37
+ if sys.version_info >= (3, 4):
38
+ def iter_unpack(self, __buffer: _BufferType) -> Iterator[Tuple[Any, ...]]: ...
shared/package-files/16/167cc93cfd0047407d3fee1b9119e091c1aea164f027e4726b5eb25951ef44eb/align_to.h ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+
3
+ // @generated by torchgen/gen.py from Function.h
4
+
5
+ #include <ATen/Context.h>
6
+ #include <ATen/DeviceGuard.h>
7
+ #include <ATen/TensorUtils.h>
8
+ #include <ATen/TracerMode.h>
9
+ #include <ATen/core/Generator.h>
10
+ #include <ATen/core/Reduction.h>
11
+ #include <ATen/core/Tensor.h>
12
+ #include <c10/core/Scalar.h>
13
+ #include <c10/core/Storage.h>
14
+ #include <c10/core/TensorOptions.h>
15
+ #include <c10/util/Deprecated.h>
16
+ #include <c10/util/Optional.h>
17
+
18
+
19
+
20
+ #include <ATen/ops/align_to_ops.h>
21
+
22
+ namespace at {
23
+
24
+
25
+
26
+ }
shared/package-files/16/16817666c6d6aa7c867bad911b142911ef7390f105c0f6e757f3bd78612b97fa/example.h ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+
3
+ #include <torch/types.h>
4
+
5
+ namespace torch {
6
+ namespace data {
7
+
8
+ /// An `Example` from a dataset.
9
+ ///
10
+ /// A dataset consists of data and an associated target (label).
11
+ template <typename Data = at::Tensor, typename Target = at::Tensor>
12
+ struct Example {
13
+ using DataType = Data;
14
+ using TargetType = Target;
15
+
16
+ Example() = default;
17
+ Example(Data data, Target target)
18
+ : data(std::move(data)), target(std::move(target)) {}
19
+
20
+ Data data;
21
+ Target target;
22
+ };
23
+
24
+ namespace example {
25
+ using NoTarget = void;
26
+ } // namespace example
27
+
28
+ /// A specialization for `Example` that does not have a target.
29
+ ///
30
+ /// This class exists so that code can be written for a templated `Example`
31
+ /// type, and work both for labeled and unlabeled datasets.
32
+ template <typename Data>
33
+ struct Example<Data, example::NoTarget> {
34
+ using DataType = Data;
35
+ using TargetType = example::NoTarget;
36
+
37
+ Example() = default;
38
+ /* implicit */ Example(Data data) : data(std::move(data)) {}
39
+
40
+ // When a DataLoader returns an Example like this, that example should be
41
+ // implicitly convertible to the underlying data type.
42
+
43
+ operator Data&() {
44
+ return data;
45
+ }
46
+ operator const Data&() const {
47
+ return data;
48
+ }
49
+
50
+ Data data;
51
+ };
52
+
53
+ using TensorExample = Example<at::Tensor, example::NoTarget>;
54
+ } // namespace data
55
+ } // namespace torch
shared/package-files/16/1681a62321489c79277c4d74dcf6e20fae46530b269d85b3179a06cacd3706a6/Manila ADDED
Binary file (274 Bytes). View file
 
shared/package-files/16/16838313427ffbc28805b352e513a41165603671773f0693a2a277f18b620185/test_datetimes.py ADDED
@@ -0,0 +1,840 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Tests for DatetimeArray
3
+ """
4
+ from __future__ import annotations
5
+
6
+ from datetime import timedelta
7
+ import operator
8
+
9
+ try:
10
+ from zoneinfo import ZoneInfo
11
+ except ImportError:
12
+ # Cannot assign to a type
13
+ ZoneInfo = None # type: ignore[misc, assignment]
14
+
15
+ import numpy as np
16
+ import pytest
17
+
18
+ from pandas._libs.tslibs import tz_compare
19
+
20
+ from pandas.core.dtypes.dtypes import DatetimeTZDtype
21
+
22
+ import pandas as pd
23
+ import pandas._testing as tm
24
+ from pandas.core.arrays import (
25
+ DatetimeArray,
26
+ TimedeltaArray,
27
+ )
28
+
29
+
30
+ class TestNonNano:
31
+ @pytest.fixture(params=["s", "ms", "us"])
32
+ def unit(self, request):
33
+ """Fixture returning parametrized time units"""
34
+ return request.param
35
+
36
+ @pytest.fixture
37
+ def dtype(self, unit, tz_naive_fixture):
38
+ tz = tz_naive_fixture
39
+ if tz is None:
40
+ return np.dtype(f"datetime64[{unit}]")
41
+ else:
42
+ return DatetimeTZDtype(unit=unit, tz=tz)
43
+
44
+ @pytest.fixture
45
+ def dta_dti(self, unit, dtype):
46
+ tz = getattr(dtype, "tz", None)
47
+
48
+ dti = pd.date_range("2016-01-01", periods=55, freq="D", tz=tz)
49
+ if tz is None:
50
+ arr = np.asarray(dti).astype(f"M8[{unit}]")
51
+ else:
52
+ arr = np.asarray(dti.tz_convert("UTC").tz_localize(None)).astype(
53
+ f"M8[{unit}]"
54
+ )
55
+
56
+ dta = DatetimeArray._simple_new(arr, dtype=dtype)
57
+ return dta, dti
58
+
59
+ @pytest.fixture
60
+ def dta(self, dta_dti):
61
+ dta, dti = dta_dti
62
+ return dta
63
+
64
+ def test_non_nano(self, unit, dtype):
65
+ arr = np.arange(5, dtype=np.int64).view(f"M8[{unit}]")
66
+ dta = DatetimeArray._simple_new(arr, dtype=dtype)
67
+
68
+ assert dta.dtype == dtype
69
+ assert dta[0].unit == unit
70
+ assert tz_compare(dta.tz, dta[0].tz)
71
+ assert (dta[0] == dta[:1]).all()
72
+
73
+ @pytest.mark.parametrize(
74
+ "field", DatetimeArray._field_ops + DatetimeArray._bool_ops
75
+ )
76
+ def test_fields(self, unit, field, dtype, dta_dti):
77
+ dta, dti = dta_dti
78
+
79
+ assert (dti == dta).all()
80
+
81
+ res = getattr(dta, field)
82
+ expected = getattr(dti._data, field)
83
+ tm.assert_numpy_array_equal(res, expected)
84
+
85
+ def test_normalize(self, unit):
86
+ dti = pd.date_range("2016-01-01 06:00:00", periods=55, freq="D")
87
+ arr = np.asarray(dti).astype(f"M8[{unit}]")
88
+
89
+ dta = DatetimeArray._simple_new(arr, dtype=arr.dtype)
90
+
91
+ assert not dta.is_normalized
92
+
93
+ # TODO: simplify once we can just .astype to other unit
94
+ exp = np.asarray(dti.normalize()).astype(f"M8[{unit}]")
95
+ expected = DatetimeArray._simple_new(exp, dtype=exp.dtype)
96
+
97
+ res = dta.normalize()
98
+ tm.assert_extension_array_equal(res, expected)
99
+
100
+ def test_simple_new_requires_match(self, unit):
101
+ arr = np.arange(5, dtype=np.int64).view(f"M8[{unit}]")
102
+ dtype = DatetimeTZDtype(unit, "UTC")
103
+
104
+ dta = DatetimeArray._simple_new(arr, dtype=dtype)
105
+ assert dta.dtype == dtype
106
+
107
+ wrong = DatetimeTZDtype("ns", "UTC")
108
+ with pytest.raises(AssertionError, match=""):
109
+ DatetimeArray._simple_new(arr, dtype=wrong)
110
+
111
+ def test_std_non_nano(self, unit):
112
+ dti = pd.date_range("2016-01-01", periods=55, freq="D")
113
+ arr = np.asarray(dti).astype(f"M8[{unit}]")
114
+
115
+ dta = DatetimeArray._simple_new(arr, dtype=arr.dtype)
116
+
117
+ # we should match the nano-reso std, but floored to our reso.
118
+ res = dta.std()
119
+ assert res._creso == dta._creso
120
+ assert res == dti.std().floor(unit)
121
+
122
+ @pytest.mark.filterwarnings("ignore:Converting to PeriodArray.*:UserWarning")
123
+ def test_to_period(self, dta_dti):
124
+ dta, dti = dta_dti
125
+ result = dta.to_period("D")
126
+ expected = dti._data.to_period("D")
127
+
128
+ tm.assert_extension_array_equal(result, expected)
129
+
130
+ def test_iter(self, dta):
131
+ res = next(iter(dta))
132
+ expected = dta[0]
133
+
134
+ assert type(res) is pd.Timestamp
135
+ assert res._value == expected._value
136
+ assert res._creso == expected._creso
137
+ assert res == expected
138
+
139
+ def test_astype_object(self, dta):
140
+ result = dta.astype(object)
141
+ assert all(x._creso == dta._creso for x in result)
142
+ assert all(x == y for x, y in zip(result, dta))
143
+
144
+ def test_to_pydatetime(self, dta_dti):
145
+ dta, dti = dta_dti
146
+
147
+ result = dta.to_pydatetime()
148
+ expected = dti.to_pydatetime()
149
+ tm.assert_numpy_array_equal(result, expected)
150
+
151
+ @pytest.mark.parametrize("meth", ["time", "timetz", "date"])
152
+ def test_time_date(self, dta_dti, meth):
153
+ dta, dti = dta_dti
154
+
155
+ result = getattr(dta, meth)
156
+ expected = getattr(dti, meth)
157
+ tm.assert_numpy_array_equal(result, expected)
158
+
159
+ def test_format_native_types(self, unit, dtype, dta_dti):
160
+ # In this case we should get the same formatted values with our nano
161
+ # version dti._data as we do with the non-nano dta
162
+ dta, dti = dta_dti
163
+
164
+ res = dta._format_native_types()
165
+ exp = dti._data._format_native_types()
166
+ tm.assert_numpy_array_equal(res, exp)
167
+
168
+ def test_repr(self, dta_dti, unit):
169
+ dta, dti = dta_dti
170
+
171
+ assert repr(dta) == repr(dti._data).replace("[ns", f"[{unit}")
172
+
173
+ # TODO: tests with td64
174
+ def test_compare_mismatched_resolutions(self, comparison_op):
175
+ # comparison that numpy gets wrong bc of silent overflows
176
+ op = comparison_op
177
+
178
+ iinfo = np.iinfo(np.int64)
179
+ vals = np.array([iinfo.min, iinfo.min + 1, iinfo.max], dtype=np.int64)
180
+
181
+ # Construct so that arr2[1] < arr[1] < arr[2] < arr2[2]
182
+ arr = np.array(vals).view("M8[ns]")
183
+ arr2 = arr.view("M8[s]")
184
+
185
+ left = DatetimeArray._simple_new(arr, dtype=arr.dtype)
186
+ right = DatetimeArray._simple_new(arr2, dtype=arr2.dtype)
187
+
188
+ if comparison_op is operator.eq:
189
+ expected = np.array([False, False, False])
190
+ elif comparison_op is operator.ne:
191
+ expected = np.array([True, True, True])
192
+ elif comparison_op in [operator.lt, operator.le]:
193
+ expected = np.array([False, False, True])
194
+ else:
195
+ expected = np.array([False, True, False])
196
+
197
+ result = op(left, right)
198
+ tm.assert_numpy_array_equal(result, expected)
199
+
200
+ result = op(left[1], right)
201
+ tm.assert_numpy_array_equal(result, expected)
202
+
203
+ if op not in [operator.eq, operator.ne]:
204
+ # check that numpy still gets this wrong; if it is fixed we may be
205
+ # able to remove compare_mismatched_resolutions
206
+ np_res = op(left._ndarray, right._ndarray)
207
+ tm.assert_numpy_array_equal(np_res[1:], ~expected[1:])
208
+
209
+ def test_add_mismatched_reso_doesnt_downcast(self):
210
+ # https://github.com/pandas-dev/pandas/pull/48748#issuecomment-1260181008
211
+ td = pd.Timedelta(microseconds=1)
212
+ dti = pd.date_range("2016-01-01", periods=3) - td
213
+ dta = dti._data.as_unit("us")
214
+
215
+ res = dta + td.as_unit("us")
216
+ # even though the result is an even number of days
217
+ # (so we _could_ downcast to unit="s"), we do not.
218
+ assert res.unit == "us"
219
+
220
+ @pytest.mark.parametrize(
221
+ "scalar",
222
+ [
223
+ timedelta(hours=2),
224
+ pd.Timedelta(hours=2),
225
+ np.timedelta64(2, "h"),
226
+ np.timedelta64(2 * 3600 * 1000, "ms"),
227
+ pd.offsets.Minute(120),
228
+ pd.offsets.Hour(2),
229
+ ],
230
+ )
231
+ def test_add_timedeltalike_scalar_mismatched_reso(self, dta_dti, scalar):
232
+ dta, dti = dta_dti
233
+
234
+ td = pd.Timedelta(scalar)
235
+ exp_unit = tm.get_finest_unit(dta.unit, td.unit)
236
+
237
+ expected = (dti + td)._data.as_unit(exp_unit)
238
+ result = dta + scalar
239
+ tm.assert_extension_array_equal(result, expected)
240
+
241
+ result = scalar + dta
242
+ tm.assert_extension_array_equal(result, expected)
243
+
244
+ expected = (dti - td)._data.as_unit(exp_unit)
245
+ result = dta - scalar
246
+ tm.assert_extension_array_equal(result, expected)
247
+
248
+ def test_sub_datetimelike_scalar_mismatch(self):
249
+ dti = pd.date_range("2016-01-01", periods=3)
250
+ dta = dti._data.as_unit("us")
251
+
252
+ ts = dta[0].as_unit("s")
253
+
254
+ result = dta - ts
255
+ expected = (dti - dti[0])._data.as_unit("us")
256
+ assert result.dtype == "m8[us]"
257
+ tm.assert_extension_array_equal(result, expected)
258
+
259
+ def test_sub_datetime64_reso_mismatch(self):
260
+ dti = pd.date_range("2016-01-01", periods=3)
261
+ left = dti._data.as_unit("s")
262
+ right = left.as_unit("ms")
263
+
264
+ result = left - right
265
+ exp_values = np.array([0, 0, 0], dtype="m8[ms]")
266
+ expected = TimedeltaArray._simple_new(
267
+ exp_values,
268
+ dtype=exp_values.dtype,
269
+ )
270
+ tm.assert_extension_array_equal(result, expected)
271
+ result2 = right - left
272
+ tm.assert_extension_array_equal(result2, expected)
273
+
274
+
275
+ class TestDatetimeArrayComparisons:
276
+ # TODO: merge this into tests/arithmetic/test_datetime64 once it is
277
+ # sufficiently robust
278
+
279
+ def test_cmp_dt64_arraylike_tznaive(self, comparison_op):
280
+ # arbitrary tz-naive DatetimeIndex
281
+ op = comparison_op
282
+
283
+ dti = pd.date_range("2016-01-1", freq="MS", periods=9, tz=None)
284
+ arr = dti._data
285
+ assert arr.freq == dti.freq
286
+ assert arr.tz == dti.tz
287
+
288
+ right = dti
289
+
290
+ expected = np.ones(len(arr), dtype=bool)
291
+ if comparison_op.__name__ in ["ne", "gt", "lt"]:
292
+ # for these the comparisons should be all-False
293
+ expected = ~expected
294
+
295
+ result = op(arr, arr)
296
+ tm.assert_numpy_array_equal(result, expected)
297
+ for other in [
298
+ right,
299
+ np.array(right),
300
+ list(right),
301
+ tuple(right),
302
+ right.astype(object),
303
+ ]:
304
+ result = op(arr, other)
305
+ tm.assert_numpy_array_equal(result, expected)
306
+
307
+ result = op(other, arr)
308
+ tm.assert_numpy_array_equal(result, expected)
309
+
310
+
311
+ class TestDatetimeArray:
312
+ def test_astype_ns_to_ms_near_bounds(self):
313
+ # GH#55979
314
+ ts = pd.Timestamp("1677-09-21 00:12:43.145225")
315
+ target = ts.as_unit("ms")
316
+
317
+ dta = DatetimeArray._from_sequence([ts], dtype="M8[ns]")
318
+ assert (dta.view("i8") == ts.as_unit("ns").value).all()
319
+
320
+ result = dta.astype("M8[ms]")
321
+ assert result[0] == target
322
+
323
+ expected = DatetimeArray._from_sequence([ts], dtype="M8[ms]")
324
+ assert (expected.view("i8") == target._value).all()
325
+
326
+ tm.assert_datetime_array_equal(result, expected)
327
+
328
+ def test_astype_non_nano_tznaive(self):
329
+ dti = pd.date_range("2016-01-01", periods=3)
330
+
331
+ res = dti.astype("M8[s]")
332
+ assert res.dtype == "M8[s]"
333
+
334
+ dta = dti._data
335
+ res = dta.astype("M8[s]")
336
+ assert res.dtype == "M8[s]"
337
+ assert isinstance(res, pd.core.arrays.DatetimeArray) # used to be ndarray
338
+
339
+ def test_astype_non_nano_tzaware(self):
340
+ dti = pd.date_range("2016-01-01", periods=3, tz="UTC")
341
+
342
+ res = dti.astype("M8[s, US/Pacific]")
343
+ assert res.dtype == "M8[s, US/Pacific]"
344
+
345
+ dta = dti._data
346
+ res = dta.astype("M8[s, US/Pacific]")
347
+ assert res.dtype == "M8[s, US/Pacific]"
348
+
349
+ # from non-nano to non-nano, preserving reso
350
+ res2 = res.astype("M8[s, UTC]")
351
+ assert res2.dtype == "M8[s, UTC]"
352
+ assert not tm.shares_memory(res2, res)
353
+
354
+ res3 = res.astype("M8[s, UTC]", copy=False)
355
+ assert res2.dtype == "M8[s, UTC]"
356
+ assert tm.shares_memory(res3, res)
357
+
358
+ def test_astype_to_same(self):
359
+ arr = DatetimeArray._from_sequence(
360
+ ["2000"], dtype=DatetimeTZDtype(tz="US/Central")
361
+ )
362
+ result = arr.astype(DatetimeTZDtype(tz="US/Central"), copy=False)
363
+ assert result is arr
364
+
365
+ @pytest.mark.parametrize("dtype", ["datetime64[ns]", "datetime64[ns, UTC]"])
366
+ @pytest.mark.parametrize(
367
+ "other", ["datetime64[ns]", "datetime64[ns, UTC]", "datetime64[ns, CET]"]
368
+ )
369
+ def test_astype_copies(self, dtype, other):
370
+ # https://github.com/pandas-dev/pandas/pull/32490
371
+ ser = pd.Series([1, 2], dtype=dtype)
372
+ orig = ser.copy()
373
+
374
+ err = False
375
+ if (dtype == "datetime64[ns]") ^ (other == "datetime64[ns]"):
376
+ # deprecated in favor of tz_localize
377
+ err = True
378
+
379
+ if err:
380
+ if dtype == "datetime64[ns]":
381
+ msg = "Use obj.tz_localize instead or series.dt.tz_localize instead"
382
+ else:
383
+ msg = "from timezone-aware dtype to timezone-naive dtype"
384
+ with pytest.raises(TypeError, match=msg):
385
+ ser.astype(other)
386
+ else:
387
+ t = ser.astype(other)
388
+ t[:] = pd.NaT
389
+ tm.assert_series_equal(ser, orig)
390
+
391
+ @pytest.mark.parametrize("dtype", [int, np.int32, np.int64, "uint32", "uint64"])
392
+ def test_astype_int(self, dtype):
393
+ arr = DatetimeArray._from_sequence(
394
+ [pd.Timestamp("2000"), pd.Timestamp("2001")], dtype="M8[ns]"
395
+ )
396
+
397
+ if np.dtype(dtype) != np.int64:
398
+ with pytest.raises(TypeError, match=r"Do obj.astype\('int64'\)"):
399
+ arr.astype(dtype)
400
+ return
401
+
402
+ result = arr.astype(dtype)
403
+ expected = arr._ndarray.view("i8")
404
+ tm.assert_numpy_array_equal(result, expected)
405
+
406
+ def test_astype_to_sparse_dt64(self):
407
+ # GH#50082
408
+ dti = pd.date_range("2016-01-01", periods=4)
409
+ dta = dti._data
410
+ result = dta.astype("Sparse[datetime64[ns]]")
411
+
412
+ assert result.dtype == "Sparse[datetime64[ns]]"
413
+ assert (result == dta).all()
414
+
415
+ def test_tz_setter_raises(self):
416
+ arr = DatetimeArray._from_sequence(
417
+ ["2000"], dtype=DatetimeTZDtype(tz="US/Central")
418
+ )
419
+ with pytest.raises(AttributeError, match="tz_localize"):
420
+ arr.tz = "UTC"
421
+
422
+ def test_setitem_str_impute_tz(self, tz_naive_fixture):
423
+ # Like for getitem, if we are passed a naive-like string, we impute
424
+ # our own timezone.
425
+ tz = tz_naive_fixture
426
+
427
+ data = np.array([1, 2, 3], dtype="M8[ns]")
428
+ dtype = data.dtype if tz is None else DatetimeTZDtype(tz=tz)
429
+ arr = DatetimeArray._from_sequence(data, dtype=dtype)
430
+ expected = arr.copy()
431
+
432
+ ts = pd.Timestamp("2020-09-08 16:50").tz_localize(tz)
433
+ setter = str(ts.tz_localize(None))
434
+
435
+ # Setting a scalar tznaive string
436
+ expected[0] = ts
437
+ arr[0] = setter
438
+ tm.assert_equal(arr, expected)
439
+
440
+ # Setting a listlike of tznaive strings
441
+ expected[1] = ts
442
+ arr[:2] = [setter, setter]
443
+ tm.assert_equal(arr, expected)
444
+
445
+ def test_setitem_different_tz_raises(self):
446
+ # pre-2.0 we required exact tz match, in 2.0 we require only
447
+ # tzawareness-match
448
+ data = np.array([1, 2, 3], dtype="M8[ns]")
449
+ arr = DatetimeArray._from_sequence(
450
+ data, copy=False, dtype=DatetimeTZDtype(tz="US/Central")
451
+ )
452
+ with pytest.raises(TypeError, match="Cannot compare tz-naive and tz-aware"):
453
+ arr[0] = pd.Timestamp("2000")
454
+
455
+ ts = pd.Timestamp("2000", tz="US/Eastern")
456
+ arr[0] = ts
457
+ assert arr[0] == ts.tz_convert("US/Central")
458
+
459
+ def test_setitem_clears_freq(self):
460
+ a = pd.date_range("2000", periods=2, freq="D", tz="US/Central")._data
461
+ a[0] = pd.Timestamp("2000", tz="US/Central")
462
+ assert a.freq is None
463
+
464
+ @pytest.mark.parametrize(
465
+ "obj",
466
+ [
467
+ pd.Timestamp("2021-01-01"),
468
+ pd.Timestamp("2021-01-01").to_datetime64(),
469
+ pd.Timestamp("2021-01-01").to_pydatetime(),
470
+ ],
471
+ )
472
+ def test_setitem_objects(self, obj):
473
+ # make sure we accept datetime64 and datetime in addition to Timestamp
474
+ dti = pd.date_range("2000", periods=2, freq="D")
475
+ arr = dti._data
476
+
477
+ arr[0] = obj
478
+ assert arr[0] == obj
479
+
480
+ def test_repeat_preserves_tz(self):
481
+ dti = pd.date_range("2000", periods=2, freq="D", tz="US/Central")
482
+ arr = dti._data
483
+
484
+ repeated = arr.repeat([1, 1])
485
+
486
+ # preserves tz and values, but not freq
487
+ expected = DatetimeArray._from_sequence(arr.asi8, dtype=arr.dtype)
488
+ tm.assert_equal(repeated, expected)
489
+
490
+ def test_value_counts_preserves_tz(self):
491
+ dti = pd.date_range("2000", periods=2, freq="D", tz="US/Central")
492
+ arr = dti._data.repeat([4, 3])
493
+
494
+ result = arr.value_counts()
495
+
496
+ # Note: not tm.assert_index_equal, since `freq`s do not match
497
+ assert result.index.equals(dti)
498
+
499
+ arr[-2] = pd.NaT
500
+ result = arr.value_counts(dropna=False)
501
+ expected = pd.Series([4, 2, 1], index=[dti[0], dti[1], pd.NaT], name="count")
502
+ tm.assert_series_equal(result, expected)
503
+
504
+ @pytest.mark.parametrize("method", ["pad", "backfill"])
505
+ def test_fillna_preserves_tz(self, method):
506
+ dti = pd.date_range("2000-01-01", periods=5, freq="D", tz="US/Central")
507
+ arr = DatetimeArray._from_sequence(dti, copy=True)
508
+ arr[2] = pd.NaT
509
+
510
+ fill_val = dti[1] if method == "pad" else dti[3]
511
+ expected = DatetimeArray._from_sequence(
512
+ [dti[0], dti[1], fill_val, dti[3], dti[4]],
513
+ dtype=DatetimeTZDtype(tz="US/Central"),
514
+ )
515
+
516
+ result = arr._pad_or_backfill(method=method)
517
+ tm.assert_extension_array_equal(result, expected)
518
+
519
+ # assert that arr and dti were not modified in-place
520
+ assert arr[2] is pd.NaT
521
+ assert dti[2] == pd.Timestamp("2000-01-03", tz="US/Central")
522
+
523
+ def test_fillna_2d(self):
524
+ dti = pd.date_range("2016-01-01", periods=6, tz="US/Pacific")
525
+ dta = dti._data.reshape(3, 2).copy()
526
+ dta[0, 1] = pd.NaT
527
+ dta[1, 0] = pd.NaT
528
+
529
+ res1 = dta._pad_or_backfill(method="pad")
530
+ expected1 = dta.copy()
531
+ expected1[1, 0] = dta[0, 0]
532
+ tm.assert_extension_array_equal(res1, expected1)
533
+
534
+ res2 = dta._pad_or_backfill(method="backfill")
535
+ expected2 = dta.copy()
536
+ expected2 = dta.copy()
537
+ expected2[1, 0] = dta[2, 0]
538
+ expected2[0, 1] = dta[1, 1]
539
+ tm.assert_extension_array_equal(res2, expected2)
540
+
541
+ # with different ordering for underlying ndarray; behavior should
542
+ # be unchanged
543
+ dta2 = dta._from_backing_data(dta._ndarray.copy(order="F"))
544
+ assert dta2._ndarray.flags["F_CONTIGUOUS"]
545
+ assert not dta2._ndarray.flags["C_CONTIGUOUS"]
546
+ tm.assert_extension_array_equal(dta, dta2)
547
+
548
+ res3 = dta2._pad_or_backfill(method="pad")
549
+ tm.assert_extension_array_equal(res3, expected1)
550
+
551
+ res4 = dta2._pad_or_backfill(method="backfill")
552
+ tm.assert_extension_array_equal(res4, expected2)
553
+
554
+ # test the DataFrame method while we're here
555
+ df = pd.DataFrame(dta)
556
+ res = df.ffill()
557
+ expected = pd.DataFrame(expected1)
558
+ tm.assert_frame_equal(res, expected)
559
+
560
+ res = df.bfill()
561
+ expected = pd.DataFrame(expected2)
562
+ tm.assert_frame_equal(res, expected)
563
+
564
+ def test_array_interface_tz(self):
565
+ tz = "US/Central"
566
+ data = pd.date_range("2017", periods=2, tz=tz)._data
567
+ result = np.asarray(data)
568
+
569
+ expected = np.array(
570
+ [
571
+ pd.Timestamp("2017-01-01T00:00:00", tz=tz),
572
+ pd.Timestamp("2017-01-02T00:00:00", tz=tz),
573
+ ],
574
+ dtype=object,
575
+ )
576
+ tm.assert_numpy_array_equal(result, expected)
577
+
578
+ result = np.asarray(data, dtype=object)
579
+ tm.assert_numpy_array_equal(result, expected)
580
+
581
+ result = np.asarray(data, dtype="M8[ns]")
582
+
583
+ expected = np.array(
584
+ ["2017-01-01T06:00:00", "2017-01-02T06:00:00"], dtype="M8[ns]"
585
+ )
586
+ tm.assert_numpy_array_equal(result, expected)
587
+
588
+ def test_array_interface(self):
589
+ data = pd.date_range("2017", periods=2)._data
590
+ expected = np.array(
591
+ ["2017-01-01T00:00:00", "2017-01-02T00:00:00"], dtype="datetime64[ns]"
592
+ )
593
+
594
+ result = np.asarray(data)
595
+ tm.assert_numpy_array_equal(result, expected)
596
+
597
+ result = np.asarray(data, dtype=object)
598
+ expected = np.array(
599
+ [pd.Timestamp("2017-01-01T00:00:00"), pd.Timestamp("2017-01-02T00:00:00")],
600
+ dtype=object,
601
+ )
602
+ tm.assert_numpy_array_equal(result, expected)
603
+
604
+ @pytest.mark.parametrize("index", [True, False])
605
+ def test_searchsorted_different_tz(self, index):
606
+ data = np.arange(10, dtype="i8") * 24 * 3600 * 10**9
607
+ arr = pd.DatetimeIndex(data, freq="D")._data.tz_localize("Asia/Tokyo")
608
+ if index:
609
+ arr = pd.Index(arr)
610
+
611
+ expected = arr.searchsorted(arr[2])
612
+ result = arr.searchsorted(arr[2].tz_convert("UTC"))
613
+ assert result == expected
614
+
615
+ expected = arr.searchsorted(arr[2:6])
616
+ result = arr.searchsorted(arr[2:6].tz_convert("UTC"))
617
+ tm.assert_equal(result, expected)
618
+
619
+ @pytest.mark.parametrize("index", [True, False])
620
+ def test_searchsorted_tzawareness_compat(self, index):
621
+ data = np.arange(10, dtype="i8") * 24 * 3600 * 10**9
622
+ arr = pd.DatetimeIndex(data, freq="D")._data
623
+ if index:
624
+ arr = pd.Index(arr)
625
+
626
+ mismatch = arr.tz_localize("Asia/Tokyo")
627
+
628
+ msg = "Cannot compare tz-naive and tz-aware datetime-like objects"
629
+ with pytest.raises(TypeError, match=msg):
630
+ arr.searchsorted(mismatch[0])
631
+ with pytest.raises(TypeError, match=msg):
632
+ arr.searchsorted(mismatch)
633
+
634
+ with pytest.raises(TypeError, match=msg):
635
+ mismatch.searchsorted(arr[0])
636
+ with pytest.raises(TypeError, match=msg):
637
+ mismatch.searchsorted(arr)
638
+
639
+ @pytest.mark.parametrize(
640
+ "other",
641
+ [
642
+ 1,
643
+ np.int64(1),
644
+ 1.0,
645
+ np.timedelta64("NaT"),
646
+ pd.Timedelta(days=2),
647
+ "invalid",
648
+ np.arange(10, dtype="i8") * 24 * 3600 * 10**9,
649
+ np.arange(10).view("timedelta64[ns]") * 24 * 3600 * 10**9,
650
+ pd.Timestamp("2021-01-01").to_period("D"),
651
+ ],
652
+ )
653
+ @pytest.mark.parametrize("index", [True, False])
654
+ def test_searchsorted_invalid_types(self, other, index):
655
+ data = np.arange(10, dtype="i8") * 24 * 3600 * 10**9
656
+ arr = pd.DatetimeIndex(data, freq="D")._data
657
+ if index:
658
+ arr = pd.Index(arr)
659
+
660
+ msg = "|".join(
661
+ [
662
+ "searchsorted requires compatible dtype or scalar",
663
+ "value should be a 'Timestamp', 'NaT', or array of those. Got",
664
+ ]
665
+ )
666
+ with pytest.raises(TypeError, match=msg):
667
+ arr.searchsorted(other)
668
+
669
+ def test_shift_fill_value(self):
670
+ dti = pd.date_range("2016-01-01", periods=3)
671
+
672
+ dta = dti._data
673
+ expected = DatetimeArray._from_sequence(np.roll(dta._ndarray, 1))
674
+
675
+ fv = dta[-1]
676
+ for fill_value in [fv, fv.to_pydatetime(), fv.to_datetime64()]:
677
+ result = dta.shift(1, fill_value=fill_value)
678
+ tm.assert_datetime_array_equal(result, expected)
679
+
680
+ dta = dta.tz_localize("UTC")
681
+ expected = expected.tz_localize("UTC")
682
+ fv = dta[-1]
683
+ for fill_value in [fv, fv.to_pydatetime()]:
684
+ result = dta.shift(1, fill_value=fill_value)
685
+ tm.assert_datetime_array_equal(result, expected)
686
+
687
+ def test_shift_value_tzawareness_mismatch(self):
688
+ dti = pd.date_range("2016-01-01", periods=3)
689
+
690
+ dta = dti._data
691
+
692
+ fv = dta[-1].tz_localize("UTC")
693
+ for invalid in [fv, fv.to_pydatetime()]:
694
+ with pytest.raises(TypeError, match="Cannot compare"):
695
+ dta.shift(1, fill_value=invalid)
696
+
697
+ dta = dta.tz_localize("UTC")
698
+ fv = dta[-1].tz_localize(None)
699
+ for invalid in [fv, fv.to_pydatetime(), fv.to_datetime64()]:
700
+ with pytest.raises(TypeError, match="Cannot compare"):
701
+ dta.shift(1, fill_value=invalid)
702
+
703
+ def test_shift_requires_tzmatch(self):
704
+ # pre-2.0 we required exact tz match, in 2.0 we require just
705
+ # matching tzawareness
706
+ dti = pd.date_range("2016-01-01", periods=3, tz="UTC")
707
+ dta = dti._data
708
+
709
+ fill_value = pd.Timestamp("2020-10-18 18:44", tz="US/Pacific")
710
+
711
+ result = dta.shift(1, fill_value=fill_value)
712
+ expected = dta.shift(1, fill_value=fill_value.tz_convert("UTC"))
713
+ tm.assert_equal(result, expected)
714
+
715
+ def test_tz_localize_t2d(self):
716
+ dti = pd.date_range("1994-05-12", periods=12, tz="US/Pacific")
717
+ dta = dti._data.reshape(3, 4)
718
+ result = dta.tz_localize(None)
719
+
720
+ expected = dta.ravel().tz_localize(None).reshape(dta.shape)
721
+ tm.assert_datetime_array_equal(result, expected)
722
+
723
+ roundtrip = expected.tz_localize("US/Pacific")
724
+ tm.assert_datetime_array_equal(roundtrip, dta)
725
+
726
+ easts = ["US/Eastern", "dateutil/US/Eastern"]
727
+ if ZoneInfo is not None:
728
+ try:
729
+ tz = ZoneInfo("US/Eastern")
730
+ except KeyError:
731
+ # no tzdata
732
+ pass
733
+ else:
734
+ # Argument 1 to "append" of "list" has incompatible type "ZoneInfo";
735
+ # expected "str"
736
+ easts.append(tz) # type: ignore[arg-type]
737
+
738
+ @pytest.mark.parametrize("tz", easts)
739
+ def test_iter_zoneinfo_fold(self, tz):
740
+ # GH#49684
741
+ utc_vals = np.array(
742
+ [1320552000, 1320555600, 1320559200, 1320562800], dtype=np.int64
743
+ )
744
+ utc_vals *= 1_000_000_000
745
+
746
+ dta = DatetimeArray._from_sequence(utc_vals).tz_localize("UTC").tz_convert(tz)
747
+
748
+ left = dta[2]
749
+ right = list(dta)[2]
750
+ assert str(left) == str(right)
751
+ # previously there was a bug where with non-pytz right would be
752
+ # Timestamp('2011-11-06 01:00:00-0400', tz='US/Eastern')
753
+ # while left would be
754
+ # Timestamp('2011-11-06 01:00:00-0500', tz='US/Eastern')
755
+ # The .value's would match (so they would compare as equal),
756
+ # but the folds would not
757
+ assert left.utcoffset() == right.utcoffset()
758
+
759
+ # The same bug in ints_to_pydatetime affected .astype, so we test
760
+ # that here.
761
+ right2 = dta.astype(object)[2]
762
+ assert str(left) == str(right2)
763
+ assert left.utcoffset() == right2.utcoffset()
764
+
765
+ @pytest.mark.parametrize(
766
+ "freq, freq_depr",
767
+ [
768
+ ("2ME", "2M"),
769
+ ("2SME", "2SM"),
770
+ ("2SME", "2sm"),
771
+ ("2QE", "2Q"),
772
+ ("2QE-SEP", "2Q-SEP"),
773
+ ("1YE", "1Y"),
774
+ ("2YE-MAR", "2Y-MAR"),
775
+ ("1YE", "1A"),
776
+ ("2YE-MAR", "2A-MAR"),
777
+ ("2ME", "2m"),
778
+ ("2QE-SEP", "2q-sep"),
779
+ ("2YE-MAR", "2a-mar"),
780
+ ("2YE", "2y"),
781
+ ],
782
+ )
783
+ def test_date_range_frequency_M_Q_Y_A_deprecated(self, freq, freq_depr):
784
+ # GH#9586, GH#54275
785
+ depr_msg = f"'{freq_depr[1:]}' is deprecated and will be removed "
786
+ f"in a future version, please use '{freq[1:]}' instead."
787
+
788
+ expected = pd.date_range("1/1/2000", periods=4, freq=freq)
789
+ with tm.assert_produces_warning(FutureWarning, match=depr_msg):
790
+ result = pd.date_range("1/1/2000", periods=4, freq=freq_depr)
791
+ tm.assert_index_equal(result, expected)
792
+
793
+ @pytest.mark.parametrize("freq_depr", ["2H", "2CBH", "2MIN", "2S", "2mS", "2Us"])
794
+ def test_date_range_uppercase_frequency_deprecated(self, freq_depr):
795
+ # GH#9586, GH#54939
796
+ depr_msg = f"'{freq_depr[1:]}' is deprecated and will be removed in a "
797
+ f"future version. Please use '{freq_depr.lower()[1:]}' instead."
798
+
799
+ expected = pd.date_range("1/1/2000", periods=4, freq=freq_depr.lower())
800
+ with tm.assert_produces_warning(FutureWarning, match=depr_msg):
801
+ result = pd.date_range("1/1/2000", periods=4, freq=freq_depr)
802
+ tm.assert_index_equal(result, expected)
803
+
804
+ @pytest.mark.parametrize(
805
+ "freq_depr",
806
+ [
807
+ "2ye-mar",
808
+ "2ys",
809
+ "2qe",
810
+ "2qs-feb",
811
+ "2bqs",
812
+ "2sms",
813
+ "2bms",
814
+ "2cbme",
815
+ "2me",
816
+ "2w",
817
+ ],
818
+ )
819
+ def test_date_range_lowercase_frequency_deprecated(self, freq_depr):
820
+ # GH#9586, GH#54939
821
+ depr_msg = f"'{freq_depr[1:]}' is deprecated and will be removed in a "
822
+ f"future version, please use '{freq_depr.upper()[1:]}' instead."
823
+
824
+ expected = pd.date_range("1/1/2000", periods=4, freq=freq_depr.upper())
825
+ with tm.assert_produces_warning(FutureWarning, match=depr_msg):
826
+ result = pd.date_range("1/1/2000", periods=4, freq=freq_depr)
827
+ tm.assert_index_equal(result, expected)
828
+
829
+
830
+ def test_factorize_sort_without_freq():
831
+ dta = DatetimeArray._from_sequence([0, 2, 1], dtype="M8[ns]")
832
+
833
+ msg = r"call pd.factorize\(obj, sort=True\) instead"
834
+ with pytest.raises(NotImplementedError, match=msg):
835
+ dta.factorize(sort=True)
836
+
837
+ # Do TimedeltaArray while we're here
838
+ tda = dta - dta[0]
839
+ with pytest.raises(NotImplementedError, match=msg):
840
+ tda.factorize(sort=True)
shared/package-files/16/1683c7bf59595992d349a2ec8f44c0b79dda3f3d8025182985606f4dfdf908d0/RECORD ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __pycache__/decorator.cpython-39.pyc,,
2
+ decorator-5.1.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
3
+ decorator-5.1.1.dist-info/LICENSE.txt,sha256=_RFmDKvwUyCCxFcGhi-vwpSQfsf44heBgkCkmZgGeC4,1309
4
+ decorator-5.1.1.dist-info/METADATA,sha256=r0bdLx4epfmFZuREMw4PIw5OLJyT6AFcqgbu3kltdE4,3981
5
+ decorator-5.1.1.dist-info/RECORD,,
6
+ decorator-5.1.1.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ decorator-5.1.1.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
8
+ decorator-5.1.1.dist-info/direct_url.json,sha256=CVNnDpADImKNn_BZqCgqAqnbqyfNWfT2QzSNzLFgANM,83
9
+ decorator-5.1.1.dist-info/pbr.json,sha256=AL84oUUWQHwkd8OCPhLRo2NJjU5MDdmXMqRHv-posqs,47
10
+ decorator-5.1.1.dist-info/top_level.txt,sha256=Kn6eQjo83ctWxXVyBMOYt0_YpjRjBznKYVuNyuC_DSI,10
11
+ decorator.py,sha256=el5cAEgoTEpRQN65tOxGhElue-CccMv0xol-J2MwOc0,16752
shared/package-files/16/1685386a11e4259ebb7705977abe455cb8e38deb0a2a0fb0d89ab55f56c7ca60/arrayterator.pyi ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Any
2
+ import numpy as np
3
+
4
+ AR_i8: np.ndarray[Any, np.dtype[np.int64]]
5
+ ar_iter = np.lib.Arrayterator(AR_i8)
6
+
7
+ np.lib.Arrayterator(np.int64()) # E: incompatible type
8
+ ar_iter.shape = (10, 5) # E: is read-only
9
+ ar_iter[None] # E: Invalid index type
10
+ ar_iter[None, 1] # E: Invalid index type
11
+ ar_iter[np.intp()] # E: Invalid index type
12
+ ar_iter[np.intp(), ...] # E: Invalid index type
13
+ ar_iter[AR_i8] # E: Invalid index type
14
+ ar_iter[AR_i8, :] # E: Invalid index type
shared/package-files/16/16868dbe4198217ac3eb198179dac99a6fe854b31ab6a6c6097734dbb0ae8244/spawnbase.py ADDED
@@ -0,0 +1,525 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from io import StringIO, BytesIO
2
+ import codecs
3
+ import os
4
+ import sys
5
+ import re
6
+ import errno
7
+ from .exceptions import ExceptionPexpect, EOF, TIMEOUT
8
+ from .expect import Expecter, searcher_string, searcher_re
9
+
10
+ PY3 = (sys.version_info[0] >= 3)
11
+ text_type = str if PY3 else unicode
12
+
13
+ class _NullCoder(object):
14
+ """Pass bytes through unchanged."""
15
+ @staticmethod
16
+ def encode(b, final=False):
17
+ return b
18
+
19
+ @staticmethod
20
+ def decode(b, final=False):
21
+ return b
22
+
23
+ class SpawnBase(object):
24
+ """A base class providing the backwards-compatible spawn API for Pexpect.
25
+
26
+ This should not be instantiated directly: use :class:`pexpect.spawn` or
27
+ :class:`pexpect.fdpexpect.fdspawn`.
28
+ """
29
+ encoding = None
30
+ pid = None
31
+ flag_eof = False
32
+
33
+ def __init__(self, timeout=30, maxread=2000, searchwindowsize=None,
34
+ logfile=None, encoding=None, codec_errors='strict'):
35
+ self.stdin = sys.stdin
36
+ self.stdout = sys.stdout
37
+ self.stderr = sys.stderr
38
+
39
+ self.searcher = None
40
+ self.ignorecase = False
41
+ self.before = None
42
+ self.after = None
43
+ self.match = None
44
+ self.match_index = None
45
+ self.terminated = True
46
+ self.exitstatus = None
47
+ self.signalstatus = None
48
+ # status returned by os.waitpid
49
+ self.status = None
50
+ # the child file descriptor is initially closed
51
+ self.child_fd = -1
52
+ self.timeout = timeout
53
+ self.delimiter = EOF
54
+ self.logfile = logfile
55
+ # input from child (read_nonblocking)
56
+ self.logfile_read = None
57
+ # output to send (send, sendline)
58
+ self.logfile_send = None
59
+ # max bytes to read at one time into buffer
60
+ self.maxread = maxread
61
+ # Data before searchwindowsize point is preserved, but not searched.
62
+ self.searchwindowsize = searchwindowsize
63
+ # Delay used before sending data to child. Time in seconds.
64
+ # Set this to None to skip the time.sleep() call completely.
65
+ self.delaybeforesend = 0.05
66
+ # Used by close() to give kernel time to update process status.
67
+ # Time in seconds.
68
+ self.delayafterclose = 0.1
69
+ # Used by terminate() to give kernel time to update process status.
70
+ # Time in seconds.
71
+ self.delayafterterminate = 0.1
72
+ # Delay in seconds to sleep after each call to read_nonblocking().
73
+ # Set this to None to skip the time.sleep() call completely: that
74
+ # would restore the behavior from pexpect-2.0 (for performance
75
+ # reasons or because you don't want to release Python's global
76
+ # interpreter lock).
77
+ self.delayafterread = 0.0001
78
+ self.softspace = False
79
+ self.name = '<' + repr(self) + '>'
80
+ self.closed = True
81
+
82
+ # Unicode interface
83
+ self.encoding = encoding
84
+ self.codec_errors = codec_errors
85
+ if encoding is None:
86
+ # bytes mode (accepts some unicode for backwards compatibility)
87
+ self._encoder = self._decoder = _NullCoder()
88
+ self.string_type = bytes
89
+ self.buffer_type = BytesIO
90
+ self.crlf = b'\r\n'
91
+ if PY3:
92
+ self.allowed_string_types = (bytes, str)
93
+ self.linesep = os.linesep.encode('ascii')
94
+ def write_to_stdout(b):
95
+ try:
96
+ return sys.stdout.buffer.write(b)
97
+ except AttributeError:
98
+ # If stdout has been replaced, it may not have .buffer
99
+ return sys.stdout.write(b.decode('ascii', 'replace'))
100
+ self.write_to_stdout = write_to_stdout
101
+ else:
102
+ self.allowed_string_types = (basestring,) # analysis:ignore
103
+ self.linesep = os.linesep
104
+ self.write_to_stdout = sys.stdout.write
105
+ else:
106
+ # unicode mode
107
+ self._encoder = codecs.getincrementalencoder(encoding)(codec_errors)
108
+ self._decoder = codecs.getincrementaldecoder(encoding)(codec_errors)
109
+ self.string_type = text_type
110
+ self.buffer_type = StringIO
111
+ self.crlf = u'\r\n'
112
+ self.allowed_string_types = (text_type, )
113
+ if PY3:
114
+ self.linesep = os.linesep
115
+ else:
116
+ self.linesep = os.linesep.decode('ascii')
117
+ # This can handle unicode in both Python 2 and 3
118
+ self.write_to_stdout = sys.stdout.write
119
+ # storage for async transport
120
+ self.async_pw_transport = None
121
+ # This is the read buffer. See maxread.
122
+ self._buffer = self.buffer_type()
123
+ # The buffer may be trimmed for efficiency reasons. This is the
124
+ # untrimmed buffer, used to create the before attribute.
125
+ self._before = self.buffer_type()
126
+
127
+ def _log(self, s, direction):
128
+ if self.logfile is not None:
129
+ self.logfile.write(s)
130
+ self.logfile.flush()
131
+ second_log = self.logfile_send if (direction=='send') else self.logfile_read
132
+ if second_log is not None:
133
+ second_log.write(s)
134
+ second_log.flush()
135
+
136
+ # For backwards compatibility, in bytes mode (when encoding is None)
137
+ # unicode is accepted for send and expect. Unicode mode is strictly unicode
138
+ # only.
139
+ def _coerce_expect_string(self, s):
140
+ if self.encoding is None and not isinstance(s, bytes):
141
+ return s.encode('ascii')
142
+ return s
143
+
144
+ def _coerce_send_string(self, s):
145
+ if self.encoding is None and not isinstance(s, bytes):
146
+ return s.encode('utf-8')
147
+ return s
148
+
149
+ def _get_buffer(self):
150
+ return self._buffer.getvalue()
151
+
152
+ def _set_buffer(self, value):
153
+ self._buffer = self.buffer_type()
154
+ self._buffer.write(value)
155
+
156
+ # This property is provided for backwards compatability (self.buffer used
157
+ # to be a string/bytes object)
158
+ buffer = property(_get_buffer, _set_buffer)
159
+
160
+ def read_nonblocking(self, size=1, timeout=None):
161
+ """This reads data from the file descriptor.
162
+
163
+ This is a simple implementation suitable for a regular file. Subclasses using ptys or pipes should override it.
164
+
165
+ The timeout parameter is ignored.
166
+ """
167
+
168
+ try:
169
+ s = os.read(self.child_fd, size)
170
+ except OSError as err:
171
+ if err.args[0] == errno.EIO:
172
+ # Linux-style EOF
173
+ self.flag_eof = True
174
+ raise EOF('End Of File (EOF). Exception style platform.')
175
+ raise
176
+ if s == b'':
177
+ # BSD-style EOF
178
+ self.flag_eof = True
179
+ raise EOF('End Of File (EOF). Empty string style platform.')
180
+
181
+ s = self._decoder.decode(s, final=False)
182
+ self._log(s, 'read')
183
+ return s
184
+
185
+ def _pattern_type_err(self, pattern):
186
+ raise TypeError('got {badtype} ({badobj!r}) as pattern, must be one'
187
+ ' of: {goodtypes}, pexpect.EOF, pexpect.TIMEOUT'\
188
+ .format(badtype=type(pattern),
189
+ badobj=pattern,
190
+ goodtypes=', '.join([str(ast)\
191
+ for ast in self.allowed_string_types])
192
+ )
193
+ )
194
+
195
+ def compile_pattern_list(self, patterns):
196
+ '''This compiles a pattern-string or a list of pattern-strings.
197
+ Patterns must be a StringType, EOF, TIMEOUT, SRE_Pattern, or a list of
198
+ those. Patterns may also be None which results in an empty list (you
199
+ might do this if waiting for an EOF or TIMEOUT condition without
200
+ expecting any pattern).
201
+
202
+ This is used by expect() when calling expect_list(). Thus expect() is
203
+ nothing more than::
204
+
205
+ cpl = self.compile_pattern_list(pl)
206
+ return self.expect_list(cpl, timeout)
207
+
208
+ If you are using expect() within a loop it may be more
209
+ efficient to compile the patterns first and then call expect_list().
210
+ This avoid calls in a loop to compile_pattern_list()::
211
+
212
+ cpl = self.compile_pattern_list(my_pattern)
213
+ while some_condition:
214
+ ...
215
+ i = self.expect_list(cpl, timeout)
216
+ ...
217
+ '''
218
+
219
+ if patterns is None:
220
+ return []
221
+ if not isinstance(patterns, list):
222
+ patterns = [patterns]
223
+
224
+ # Allow dot to match \n
225
+ compile_flags = re.DOTALL
226
+ if self.ignorecase:
227
+ compile_flags = compile_flags | re.IGNORECASE
228
+ compiled_pattern_list = []
229
+ for idx, p in enumerate(patterns):
230
+ if isinstance(p, self.allowed_string_types):
231
+ p = self._coerce_expect_string(p)
232
+ compiled_pattern_list.append(re.compile(p, compile_flags))
233
+ elif p is EOF:
234
+ compiled_pattern_list.append(EOF)
235
+ elif p is TIMEOUT:
236
+ compiled_pattern_list.append(TIMEOUT)
237
+ elif isinstance(p, type(re.compile(''))):
238
+ compiled_pattern_list.append(p)
239
+ else:
240
+ self._pattern_type_err(p)
241
+ return compiled_pattern_list
242
+
243
+ def expect(self, pattern, timeout=-1, searchwindowsize=-1, async_=False, **kw):
244
+ '''This seeks through the stream until a pattern is matched. The
245
+ pattern is overloaded and may take several types. The pattern can be a
246
+ StringType, EOF, a compiled re, or a list of any of those types.
247
+ Strings will be compiled to re types. This returns the index into the
248
+ pattern list. If the pattern was not a list this returns index 0 on a
249
+ successful match. This may raise exceptions for EOF or TIMEOUT. To
250
+ avoid the EOF or TIMEOUT exceptions add EOF or TIMEOUT to the pattern
251
+ list. That will cause expect to match an EOF or TIMEOUT condition
252
+ instead of raising an exception.
253
+
254
+ If you pass a list of patterns and more than one matches, the first
255
+ match in the stream is chosen. If more than one pattern matches at that
256
+ point, the leftmost in the pattern list is chosen. For example::
257
+
258
+ # the input is 'foobar'
259
+ index = p.expect(['bar', 'foo', 'foobar'])
260
+ # returns 1('foo') even though 'foobar' is a "better" match
261
+
262
+ Please note, however, that buffering can affect this behavior, since
263
+ input arrives in unpredictable chunks. For example::
264
+
265
+ # the input is 'foobar'
266
+ index = p.expect(['foobar', 'foo'])
267
+ # returns 0('foobar') if all input is available at once,
268
+ # but returns 1('foo') if parts of the final 'bar' arrive late
269
+
270
+ When a match is found for the given pattern, the class instance
271
+ attribute *match* becomes an re.MatchObject result. Should an EOF
272
+ or TIMEOUT pattern match, then the match attribute will be an instance
273
+ of that exception class. The pairing before and after class
274
+ instance attributes are views of the data preceding and following
275
+ the matching pattern. On general exception, class attribute
276
+ *before* is all data received up to the exception, while *match* and
277
+ *after* attributes are value None.
278
+
279
+ When the keyword argument timeout is -1 (default), then TIMEOUT will
280
+ raise after the default value specified by the class timeout
281
+ attribute. When None, TIMEOUT will not be raised and may block
282
+ indefinitely until match.
283
+
284
+ When the keyword argument searchwindowsize is -1 (default), then the
285
+ value specified by the class maxread attribute is used.
286
+
287
+ A list entry may be EOF or TIMEOUT instead of a string. This will
288
+ catch these exceptions and return the index of the list entry instead
289
+ of raising the exception. The attribute 'after' will be set to the
290
+ exception type. The attribute 'match' will be None. This allows you to
291
+ write code like this::
292
+
293
+ index = p.expect(['good', 'bad', pexpect.EOF, pexpect.TIMEOUT])
294
+ if index == 0:
295
+ do_something()
296
+ elif index == 1:
297
+ do_something_else()
298
+ elif index == 2:
299
+ do_some_other_thing()
300
+ elif index == 3:
301
+ do_something_completely_different()
302
+
303
+ instead of code like this::
304
+
305
+ try:
306
+ index = p.expect(['good', 'bad'])
307
+ if index == 0:
308
+ do_something()
309
+ elif index == 1:
310
+ do_something_else()
311
+ except EOF:
312
+ do_some_other_thing()
313
+ except TIMEOUT:
314
+ do_something_completely_different()
315
+
316
+ These two forms are equivalent. It all depends on what you want. You
317
+ can also just expect the EOF if you are waiting for all output of a
318
+ child to finish. For example::
319
+
320
+ p = pexpect.spawn('/bin/ls')
321
+ p.expect(pexpect.EOF)
322
+ print p.before
323
+
324
+ If you are trying to optimize for speed then see expect_list().
325
+
326
+ On Python 3.4, or Python 3.3 with asyncio installed, passing
327
+ ``async_=True`` will make this return an :mod:`asyncio` coroutine,
328
+ which you can yield from to get the same result that this method would
329
+ normally give directly. So, inside a coroutine, you can replace this code::
330
+
331
+ index = p.expect(patterns)
332
+
333
+ With this non-blocking form::
334
+
335
+ index = yield from p.expect(patterns, async_=True)
336
+ '''
337
+ if 'async' in kw:
338
+ async_ = kw.pop('async')
339
+ if kw:
340
+ raise TypeError("Unknown keyword arguments: {}".format(kw))
341
+
342
+ compiled_pattern_list = self.compile_pattern_list(pattern)
343
+ return self.expect_list(compiled_pattern_list,
344
+ timeout, searchwindowsize, async_)
345
+
346
+ def expect_list(self, pattern_list, timeout=-1, searchwindowsize=-1,
347
+ async_=False, **kw):
348
+ '''This takes a list of compiled regular expressions and returns the
349
+ index into the pattern_list that matched the child output. The list may
350
+ also contain EOF or TIMEOUT(which are not compiled regular
351
+ expressions). This method is similar to the expect() method except that
352
+ expect_list() does not recompile the pattern list on every call. This
353
+ may help if you are trying to optimize for speed, otherwise just use
354
+ the expect() method. This is called by expect().
355
+
356
+
357
+ Like :meth:`expect`, passing ``async_=True`` will make this return an
358
+ asyncio coroutine.
359
+ '''
360
+ if timeout == -1:
361
+ timeout = self.timeout
362
+ if 'async' in kw:
363
+ async_ = kw.pop('async')
364
+ if kw:
365
+ raise TypeError("Unknown keyword arguments: {}".format(kw))
366
+
367
+ exp = Expecter(self, searcher_re(pattern_list), searchwindowsize)
368
+ if async_:
369
+ from ._async import expect_async
370
+ return expect_async(exp, timeout)
371
+ else:
372
+ return exp.expect_loop(timeout)
373
+
374
+ def expect_exact(self, pattern_list, timeout=-1, searchwindowsize=-1,
375
+ async_=False, **kw):
376
+
377
+ '''This is similar to expect(), but uses plain string matching instead
378
+ of compiled regular expressions in 'pattern_list'. The 'pattern_list'
379
+ may be a string; a list or other sequence of strings; or TIMEOUT and
380
+ EOF.
381
+
382
+ This call might be faster than expect() for two reasons: string
383
+ searching is faster than RE matching and it is possible to limit the
384
+ search to just the end of the input buffer.
385
+
386
+ This method is also useful when you don't want to have to worry about
387
+ escaping regular expression characters that you want to match.
388
+
389
+ Like :meth:`expect`, passing ``async_=True`` will make this return an
390
+ asyncio coroutine.
391
+ '''
392
+ if timeout == -1:
393
+ timeout = self.timeout
394
+ if 'async' in kw:
395
+ async_ = kw.pop('async')
396
+ if kw:
397
+ raise TypeError("Unknown keyword arguments: {}".format(kw))
398
+
399
+ if (isinstance(pattern_list, self.allowed_string_types) or
400
+ pattern_list in (TIMEOUT, EOF)):
401
+ pattern_list = [pattern_list]
402
+
403
+ def prepare_pattern(pattern):
404
+ if pattern in (TIMEOUT, EOF):
405
+ return pattern
406
+ if isinstance(pattern, self.allowed_string_types):
407
+ return self._coerce_expect_string(pattern)
408
+ self._pattern_type_err(pattern)
409
+
410
+ try:
411
+ pattern_list = iter(pattern_list)
412
+ except TypeError:
413
+ self._pattern_type_err(pattern_list)
414
+ pattern_list = [prepare_pattern(p) for p in pattern_list]
415
+
416
+ exp = Expecter(self, searcher_string(pattern_list), searchwindowsize)
417
+ if async_:
418
+ from ._async import expect_async
419
+ return expect_async(exp, timeout)
420
+ else:
421
+ return exp.expect_loop(timeout)
422
+
423
+ def expect_loop(self, searcher, timeout=-1, searchwindowsize=-1):
424
+ '''This is the common loop used inside expect. The 'searcher' should be
425
+ an instance of searcher_re or searcher_string, which describes how and
426
+ what to search for in the input.
427
+
428
+ See expect() for other arguments, return value and exceptions. '''
429
+
430
+ exp = Expecter(self, searcher, searchwindowsize)
431
+ return exp.expect_loop(timeout)
432
+
433
+ def read(self, size=-1):
434
+ '''This reads at most "size" bytes from the file (less if the read hits
435
+ EOF before obtaining size bytes). If the size argument is negative or
436
+ omitted, read all data until EOF is reached. The bytes are returned as
437
+ a string object. An empty string is returned when EOF is encountered
438
+ immediately. '''
439
+
440
+ if size == 0:
441
+ return self.string_type()
442
+ if size < 0:
443
+ # delimiter default is EOF
444
+ self.expect(self.delimiter)
445
+ return self.before
446
+
447
+ # I could have done this more directly by not using expect(), but
448
+ # I deliberately decided to couple read() to expect() so that
449
+ # I would catch any bugs early and ensure consistent behavior.
450
+ # It's a little less efficient, but there is less for me to
451
+ # worry about if I have to later modify read() or expect().
452
+ # Note, it's OK if size==-1 in the regex. That just means it
453
+ # will never match anything in which case we stop only on EOF.
454
+ cre = re.compile(self._coerce_expect_string('.{%d}' % size), re.DOTALL)
455
+ # delimiter default is EOF
456
+ index = self.expect([cre, self.delimiter])
457
+ if index == 0:
458
+ ### FIXME self.before should be ''. Should I assert this?
459
+ return self.after
460
+ return self.before
461
+
462
+ def readline(self, size=-1):
463
+ '''This reads and returns one entire line. The newline at the end of
464
+ line is returned as part of the string, unless the file ends without a
465
+ newline. An empty string is returned if EOF is encountered immediately.
466
+ This looks for a newline as a CR/LF pair (\\r\\n) even on UNIX because
467
+ this is what the pseudotty device returns. So contrary to what you may
468
+ expect you will receive newlines as \\r\\n.
469
+
470
+ If the size argument is 0 then an empty string is returned. In all
471
+ other cases the size argument is ignored, which is not standard
472
+ behavior for a file-like object. '''
473
+
474
+ if size == 0:
475
+ return self.string_type()
476
+ # delimiter default is EOF
477
+ index = self.expect([self.crlf, self.delimiter])
478
+ if index == 0:
479
+ return self.before + self.crlf
480
+ else:
481
+ return self.before
482
+
483
+ def __iter__(self):
484
+ '''This is to support iterators over a file-like object.
485
+ '''
486
+ return iter(self.readline, self.string_type())
487
+
488
+ def readlines(self, sizehint=-1):
489
+ '''This reads until EOF using readline() and returns a list containing
490
+ the lines thus read. The optional 'sizehint' argument is ignored.
491
+ Remember, because this reads until EOF that means the child
492
+ process should have closed its stdout. If you run this method on
493
+ a child that is still running with its stdout open then this
494
+ method will block until it timesout.'''
495
+
496
+ lines = []
497
+ while True:
498
+ line = self.readline()
499
+ if not line:
500
+ break
501
+ lines.append(line)
502
+ return lines
503
+
504
+ def fileno(self):
505
+ '''Expose file descriptor for a file-like interface
506
+ '''
507
+ return self.child_fd
508
+
509
+ def flush(self):
510
+ '''This does nothing. It is here to support the interface for a
511
+ File-like object. '''
512
+ pass
513
+
514
+ def isatty(self):
515
+ """Overridden in subclass using tty"""
516
+ return False
517
+
518
+ # For 'with spawn(...) as child:'
519
+ def __enter__(self):
520
+ return self
521
+
522
+ def __exit__(self, etype, evalue, tb):
523
+ # We rely on subclasses to implement close(). If they don't, it's not
524
+ # clear what a context manager should do.
525
+ self.close()
shared/package-files/16/1686c73611bd08031e07f00e129ad4b3eed741d3e873562f7e65e1a330d9f293/test_vertex_cover.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import networkx as nx
2
+ from networkx.algorithms.approximation import min_weighted_vertex_cover
3
+
4
+
5
+ def is_cover(G, node_cover):
6
+ return all({u, v} & node_cover for u, v in G.edges())
7
+
8
+
9
+ class TestMWVC:
10
+ """Unit tests for the approximate minimum weighted vertex cover
11
+ function,
12
+ :func:`~networkx.algorithms.approximation.vertex_cover.min_weighted_vertex_cover`.
13
+
14
+ """
15
+
16
+ def test_unweighted_directed(self):
17
+ # Create a star graph in which half the nodes are directed in
18
+ # and half are directed out.
19
+ G = nx.DiGraph()
20
+ G.add_edges_from((0, v) for v in range(1, 26))
21
+ G.add_edges_from((v, 0) for v in range(26, 51))
22
+ cover = min_weighted_vertex_cover(G)
23
+ assert 1 == len(cover)
24
+ assert is_cover(G, cover)
25
+
26
+ def test_unweighted_undirected(self):
27
+ # create a simple star graph
28
+ size = 50
29
+ sg = nx.star_graph(size)
30
+ cover = min_weighted_vertex_cover(sg)
31
+ assert 1 == len(cover)
32
+ assert is_cover(sg, cover)
33
+
34
+ def test_weighted(self):
35
+ wg = nx.Graph()
36
+ wg.add_node(0, weight=10)
37
+ wg.add_node(1, weight=1)
38
+ wg.add_node(2, weight=1)
39
+ wg.add_node(3, weight=1)
40
+ wg.add_node(4, weight=1)
41
+
42
+ wg.add_edge(0, 1)
43
+ wg.add_edge(0, 2)
44
+ wg.add_edge(0, 3)
45
+ wg.add_edge(0, 4)
46
+
47
+ wg.add_edge(1, 2)
48
+ wg.add_edge(2, 3)
49
+ wg.add_edge(3, 4)
50
+ wg.add_edge(4, 1)
51
+
52
+ cover = min_weighted_vertex_cover(wg, weight="weight")
53
+ csum = sum(wg.nodes[node]["weight"] for node in cover)
54
+ assert 4 == csum
55
+ assert is_cover(wg, cover)
56
+
57
+ def test_unweighted_self_loop(self):
58
+ slg = nx.Graph()
59
+ slg.add_node(0)
60
+ slg.add_node(1)
61
+ slg.add_node(2)
62
+
63
+ slg.add_edge(0, 1)
64
+ slg.add_edge(2, 2)
65
+
66
+ cover = min_weighted_vertex_cover(slg)
67
+ assert 2 == len(cover)
68
+ assert is_cover(slg, cover)
shared/package-files/16/16901795632d1d5adca028f544c09b78354f03a7e93bea43958fad6ecef79325/win32.py ADDED
@@ -0,0 +1,683 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import sys
4
+
5
+ assert sys.platform == "win32"
6
+
7
+ import os
8
+ from ctypes import ArgumentError, byref, c_char, c_long, c_uint, c_ulong, pointer
9
+ from ctypes.wintypes import DWORD, HANDLE
10
+ from typing import Callable, TextIO, TypeVar
11
+
12
+ from prompt_toolkit.cursor_shapes import CursorShape
13
+ from prompt_toolkit.data_structures import Size
14
+ from prompt_toolkit.styles import ANSI_COLOR_NAMES, Attrs
15
+ from prompt_toolkit.utils import get_cwidth
16
+ from prompt_toolkit.win32_types import (
17
+ CONSOLE_SCREEN_BUFFER_INFO,
18
+ COORD,
19
+ SMALL_RECT,
20
+ STD_INPUT_HANDLE,
21
+ STD_OUTPUT_HANDLE,
22
+ )
23
+
24
+ from ..utils import SPHINX_AUTODOC_RUNNING
25
+ from .base import Output
26
+ from .color_depth import ColorDepth
27
+
28
+ # Do not import win32-specific stuff when generating documentation.
29
+ # Otherwise RTD would be unable to generate docs for this module.
30
+ if not SPHINX_AUTODOC_RUNNING:
31
+ from ctypes import windll
32
+
33
+
34
+ __all__ = [
35
+ "Win32Output",
36
+ ]
37
+
38
+
39
+ def _coord_byval(coord: COORD) -> c_long:
40
+ """
41
+ Turns a COORD object into a c_long.
42
+ This will cause it to be passed by value instead of by reference. (That is what I think at least.)
43
+
44
+ When running ``ptipython`` is run (only with IPython), we often got the following error::
45
+
46
+ Error in 'SetConsoleCursorPosition'.
47
+ ArgumentError("argument 2: <class 'TypeError'>: wrong type",)
48
+ argument 2: <class 'TypeError'>: wrong type
49
+
50
+ It was solved by turning ``COORD`` parameters into a ``c_long`` like this.
51
+
52
+ More info: http://msdn.microsoft.com/en-us/library/windows/desktop/ms686025(v=vs.85).aspx
53
+ """
54
+ return c_long(coord.Y * 0x10000 | coord.X & 0xFFFF)
55
+
56
+
57
+ #: If True: write the output of the renderer also to the following file. This
58
+ #: is very useful for debugging. (e.g.: to see that we don't write more bytes
59
+ #: than required.)
60
+ _DEBUG_RENDER_OUTPUT = False
61
+ _DEBUG_RENDER_OUTPUT_FILENAME = r"prompt-toolkit-windows-output.log"
62
+
63
+
64
+ class NoConsoleScreenBufferError(Exception):
65
+ """
66
+ Raised when the application is not running inside a Windows Console, but
67
+ the user tries to instantiate Win32Output.
68
+ """
69
+
70
+ def __init__(self) -> None:
71
+ # Are we running in 'xterm' on Windows, like git-bash for instance?
72
+ xterm = "xterm" in os.environ.get("TERM", "")
73
+
74
+ if xterm:
75
+ message = (
76
+ "Found %s, while expecting a Windows console. "
77
+ 'Maybe try to run this program using "winpty" '
78
+ "or run it in cmd.exe instead. Or otherwise, "
79
+ "in case of Cygwin, use the Python executable "
80
+ "that is compiled for Cygwin." % os.environ["TERM"]
81
+ )
82
+ else:
83
+ message = "No Windows console found. Are you running cmd.exe?"
84
+ super().__init__(message)
85
+
86
+
87
+ _T = TypeVar("_T")
88
+
89
+
90
+ class Win32Output(Output):
91
+ """
92
+ I/O abstraction for rendering to Windows consoles.
93
+ (cmd.exe and similar.)
94
+ """
95
+
96
+ def __init__(
97
+ self,
98
+ stdout: TextIO,
99
+ use_complete_width: bool = False,
100
+ default_color_depth: ColorDepth | None = None,
101
+ ) -> None:
102
+ self.use_complete_width = use_complete_width
103
+ self.default_color_depth = default_color_depth
104
+
105
+ self._buffer: list[str] = []
106
+ self.stdout: TextIO = stdout
107
+ self.hconsole = HANDLE(windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE))
108
+
109
+ self._in_alternate_screen = False
110
+ self._hidden = False
111
+
112
+ self.color_lookup_table = ColorLookupTable()
113
+
114
+ # Remember the default console colors.
115
+ info = self.get_win32_screen_buffer_info()
116
+ self.default_attrs = info.wAttributes if info else 15
117
+
118
+ if _DEBUG_RENDER_OUTPUT:
119
+ self.LOG = open(_DEBUG_RENDER_OUTPUT_FILENAME, "ab")
120
+
121
+ def fileno(self) -> int:
122
+ "Return file descriptor."
123
+ return self.stdout.fileno()
124
+
125
+ def encoding(self) -> str:
126
+ "Return encoding used for stdout."
127
+ return self.stdout.encoding
128
+
129
+ def write(self, data: str) -> None:
130
+ if self._hidden:
131
+ data = " " * get_cwidth(data)
132
+
133
+ self._buffer.append(data)
134
+
135
+ def write_raw(self, data: str) -> None:
136
+ "For win32, there is no difference between write and write_raw."
137
+ self.write(data)
138
+
139
+ def get_size(self) -> Size:
140
+ info = self.get_win32_screen_buffer_info()
141
+
142
+ # We take the width of the *visible* region as the size. Not the width
143
+ # of the complete screen buffer. (Unless use_complete_width has been
144
+ # set.)
145
+ if self.use_complete_width:
146
+ width = info.dwSize.X
147
+ else:
148
+ width = info.srWindow.Right - info.srWindow.Left
149
+
150
+ height = info.srWindow.Bottom - info.srWindow.Top + 1
151
+
152
+ # We avoid the right margin, windows will wrap otherwise.
153
+ maxwidth = info.dwSize.X - 1
154
+ width = min(maxwidth, width)
155
+
156
+ # Create `Size` object.
157
+ return Size(rows=height, columns=width)
158
+
159
+ def _winapi(self, func: Callable[..., _T], *a: object, **kw: object) -> _T:
160
+ """
161
+ Flush and call win API function.
162
+ """
163
+ self.flush()
164
+
165
+ if _DEBUG_RENDER_OUTPUT:
166
+ self.LOG.write(("%r" % func.__name__).encode("utf-8") + b"\n")
167
+ self.LOG.write(
168
+ b" " + ", ".join(["%r" % i for i in a]).encode("utf-8") + b"\n"
169
+ )
170
+ self.LOG.write(
171
+ b" "
172
+ + ", ".join(["%r" % type(i) for i in a]).encode("utf-8")
173
+ + b"\n"
174
+ )
175
+ self.LOG.flush()
176
+
177
+ try:
178
+ return func(*a, **kw)
179
+ except ArgumentError as e:
180
+ if _DEBUG_RENDER_OUTPUT:
181
+ self.LOG.write((f" Error in {func.__name__!r} {e!r} {e}\n").encode())
182
+
183
+ raise
184
+
185
+ def get_win32_screen_buffer_info(self) -> CONSOLE_SCREEN_BUFFER_INFO:
186
+ """
187
+ Return Screen buffer info.
188
+ """
189
+ # NOTE: We don't call the `GetConsoleScreenBufferInfo` API through
190
+ # `self._winapi`. Doing so causes Python to crash on certain 64bit
191
+ # Python versions. (Reproduced with 64bit Python 2.7.6, on Windows
192
+ # 10). It is not clear why. Possibly, it has to do with passing
193
+ # these objects as an argument, or through *args.
194
+
195
+ # The Python documentation contains the following - possibly related - warning:
196
+ # ctypes does not support passing unions or structures with
197
+ # bit-fields to functions by value. While this may work on 32-bit
198
+ # x86, it's not guaranteed by the library to work in the general
199
+ # case. Unions and structures with bit-fields should always be
200
+ # passed to functions by pointer.
201
+
202
+ # Also see:
203
+ # - https://github.com/ipython/ipython/issues/10070
204
+ # - https://github.com/jonathanslenders/python-prompt-toolkit/issues/406
205
+ # - https://github.com/jonathanslenders/python-prompt-toolkit/issues/86
206
+
207
+ self.flush()
208
+ sbinfo = CONSOLE_SCREEN_BUFFER_INFO()
209
+ success = windll.kernel32.GetConsoleScreenBufferInfo(
210
+ self.hconsole, byref(sbinfo)
211
+ )
212
+
213
+ # success = self._winapi(windll.kernel32.GetConsoleScreenBufferInfo,
214
+ # self.hconsole, byref(sbinfo))
215
+
216
+ if success:
217
+ return sbinfo
218
+ else:
219
+ raise NoConsoleScreenBufferError
220
+
221
+ def set_title(self, title: str) -> None:
222
+ """
223
+ Set terminal title.
224
+ """
225
+ self._winapi(windll.kernel32.SetConsoleTitleW, title)
226
+
227
+ def clear_title(self) -> None:
228
+ self._winapi(windll.kernel32.SetConsoleTitleW, "")
229
+
230
+ def erase_screen(self) -> None:
231
+ start = COORD(0, 0)
232
+ sbinfo = self.get_win32_screen_buffer_info()
233
+ length = sbinfo.dwSize.X * sbinfo.dwSize.Y
234
+
235
+ self.cursor_goto(row=0, column=0)
236
+ self._erase(start, length)
237
+
238
+ def erase_down(self) -> None:
239
+ sbinfo = self.get_win32_screen_buffer_info()
240
+ size = sbinfo.dwSize
241
+
242
+ start = sbinfo.dwCursorPosition
243
+ length = (size.X - size.X) + size.X * (size.Y - sbinfo.dwCursorPosition.Y)
244
+
245
+ self._erase(start, length)
246
+
247
+ def erase_end_of_line(self) -> None:
248
+ """"""
249
+ sbinfo = self.get_win32_screen_buffer_info()
250
+ start = sbinfo.dwCursorPosition
251
+ length = sbinfo.dwSize.X - sbinfo.dwCursorPosition.X
252
+
253
+ self._erase(start, length)
254
+
255
+ def _erase(self, start: COORD, length: int) -> None:
256
+ chars_written = c_ulong()
257
+
258
+ self._winapi(
259
+ windll.kernel32.FillConsoleOutputCharacterA,
260
+ self.hconsole,
261
+ c_char(b" "),
262
+ DWORD(length),
263
+ _coord_byval(start),
264
+ byref(chars_written),
265
+ )
266
+
267
+ # Reset attributes.
268
+ sbinfo = self.get_win32_screen_buffer_info()
269
+ self._winapi(
270
+ windll.kernel32.FillConsoleOutputAttribute,
271
+ self.hconsole,
272
+ sbinfo.wAttributes,
273
+ length,
274
+ _coord_byval(start),
275
+ byref(chars_written),
276
+ )
277
+
278
+ def reset_attributes(self) -> None:
279
+ "Reset the console foreground/background color."
280
+ self._winapi(
281
+ windll.kernel32.SetConsoleTextAttribute, self.hconsole, self.default_attrs
282
+ )
283
+ self._hidden = False
284
+
285
+ def set_attributes(self, attrs: Attrs, color_depth: ColorDepth) -> None:
286
+ (
287
+ fgcolor,
288
+ bgcolor,
289
+ bold,
290
+ underline,
291
+ strike,
292
+ italic,
293
+ blink,
294
+ reverse,
295
+ hidden,
296
+ ) = attrs
297
+ self._hidden = bool(hidden)
298
+
299
+ # Start from the default attributes.
300
+ win_attrs: int = self.default_attrs
301
+
302
+ if color_depth != ColorDepth.DEPTH_1_BIT:
303
+ # Override the last four bits: foreground color.
304
+ if fgcolor:
305
+ win_attrs = win_attrs & ~0xF
306
+ win_attrs |= self.color_lookup_table.lookup_fg_color(fgcolor)
307
+
308
+ # Override the next four bits: background color.
309
+ if bgcolor:
310
+ win_attrs = win_attrs & ~0xF0
311
+ win_attrs |= self.color_lookup_table.lookup_bg_color(bgcolor)
312
+
313
+ # Reverse: swap these four bits groups.
314
+ if reverse:
315
+ win_attrs = (
316
+ (win_attrs & ~0xFF)
317
+ | ((win_attrs & 0xF) << 4)
318
+ | ((win_attrs & 0xF0) >> 4)
319
+ )
320
+
321
+ self._winapi(windll.kernel32.SetConsoleTextAttribute, self.hconsole, win_attrs)
322
+
323
+ def disable_autowrap(self) -> None:
324
+ # Not supported by Windows.
325
+ pass
326
+
327
+ def enable_autowrap(self) -> None:
328
+ # Not supported by Windows.
329
+ pass
330
+
331
+ def cursor_goto(self, row: int = 0, column: int = 0) -> None:
332
+ pos = COORD(X=column, Y=row)
333
+ self._winapi(
334
+ windll.kernel32.SetConsoleCursorPosition, self.hconsole, _coord_byval(pos)
335
+ )
336
+
337
+ def cursor_up(self, amount: int) -> None:
338
+ sr = self.get_win32_screen_buffer_info().dwCursorPosition
339
+ pos = COORD(X=sr.X, Y=sr.Y - amount)
340
+ self._winapi(
341
+ windll.kernel32.SetConsoleCursorPosition, self.hconsole, _coord_byval(pos)
342
+ )
343
+
344
+ def cursor_down(self, amount: int) -> None:
345
+ self.cursor_up(-amount)
346
+
347
+ def cursor_forward(self, amount: int) -> None:
348
+ sr = self.get_win32_screen_buffer_info().dwCursorPosition
349
+ # assert sr.X + amount >= 0, 'Negative cursor position: x=%r amount=%r' % (sr.X, amount)
350
+
351
+ pos = COORD(X=max(0, sr.X + amount), Y=sr.Y)
352
+ self._winapi(
353
+ windll.kernel32.SetConsoleCursorPosition, self.hconsole, _coord_byval(pos)
354
+ )
355
+
356
+ def cursor_backward(self, amount: int) -> None:
357
+ self.cursor_forward(-amount)
358
+
359
+ def flush(self) -> None:
360
+ """
361
+ Write to output stream and flush.
362
+ """
363
+ if not self._buffer:
364
+ # Only flush stdout buffer. (It could be that Python still has
365
+ # something in its buffer. -- We want to be sure to print that in
366
+ # the correct color.)
367
+ self.stdout.flush()
368
+ return
369
+
370
+ data = "".join(self._buffer)
371
+
372
+ if _DEBUG_RENDER_OUTPUT:
373
+ self.LOG.write(("%r" % data).encode("utf-8") + b"\n")
374
+ self.LOG.flush()
375
+
376
+ # Print characters one by one. This appears to be the best solution
377
+ # in order to avoid traces of vertical lines when the completion
378
+ # menu disappears.
379
+ for b in data:
380
+ written = DWORD()
381
+
382
+ retval = windll.kernel32.WriteConsoleW(
383
+ self.hconsole, b, 1, byref(written), None
384
+ )
385
+ assert retval != 0
386
+
387
+ self._buffer = []
388
+
389
+ def get_rows_below_cursor_position(self) -> int:
390
+ info = self.get_win32_screen_buffer_info()
391
+ return info.srWindow.Bottom - info.dwCursorPosition.Y + 1
392
+
393
+ def scroll_buffer_to_prompt(self) -> None:
394
+ """
395
+ To be called before drawing the prompt. This should scroll the console
396
+ to left, with the cursor at the bottom (if possible).
397
+ """
398
+ # Get current window size
399
+ info = self.get_win32_screen_buffer_info()
400
+ sr = info.srWindow
401
+ cursor_pos = info.dwCursorPosition
402
+
403
+ result = SMALL_RECT()
404
+
405
+ # Scroll to the left.
406
+ result.Left = 0
407
+ result.Right = sr.Right - sr.Left
408
+
409
+ # Scroll vertical
410
+ win_height = sr.Bottom - sr.Top
411
+ if 0 < sr.Bottom - cursor_pos.Y < win_height - 1:
412
+ # no vertical scroll if cursor already on the screen
413
+ result.Bottom = sr.Bottom
414
+ else:
415
+ result.Bottom = max(win_height, cursor_pos.Y)
416
+ result.Top = result.Bottom - win_height
417
+
418
+ # Scroll API
419
+ self._winapi(
420
+ windll.kernel32.SetConsoleWindowInfo, self.hconsole, True, byref(result)
421
+ )
422
+
423
+ def enter_alternate_screen(self) -> None:
424
+ """
425
+ Go to alternate screen buffer.
426
+ """
427
+ if not self._in_alternate_screen:
428
+ GENERIC_READ = 0x80000000
429
+ GENERIC_WRITE = 0x40000000
430
+
431
+ # Create a new console buffer and activate that one.
432
+ handle = HANDLE(
433
+ self._winapi(
434
+ windll.kernel32.CreateConsoleScreenBuffer,
435
+ GENERIC_READ | GENERIC_WRITE,
436
+ DWORD(0),
437
+ None,
438
+ DWORD(1),
439
+ None,
440
+ )
441
+ )
442
+
443
+ self._winapi(windll.kernel32.SetConsoleActiveScreenBuffer, handle)
444
+ self.hconsole = handle
445
+ self._in_alternate_screen = True
446
+
447
+ def quit_alternate_screen(self) -> None:
448
+ """
449
+ Make stdout again the active buffer.
450
+ """
451
+ if self._in_alternate_screen:
452
+ stdout = HANDLE(
453
+ self._winapi(windll.kernel32.GetStdHandle, STD_OUTPUT_HANDLE)
454
+ )
455
+ self._winapi(windll.kernel32.SetConsoleActiveScreenBuffer, stdout)
456
+ self._winapi(windll.kernel32.CloseHandle, self.hconsole)
457
+ self.hconsole = stdout
458
+ self._in_alternate_screen = False
459
+
460
+ def enable_mouse_support(self) -> None:
461
+ ENABLE_MOUSE_INPUT = 0x10
462
+
463
+ # This `ENABLE_QUICK_EDIT_MODE` flag needs to be cleared for mouse
464
+ # support to work, but it's possible that it was already cleared
465
+ # before.
466
+ ENABLE_QUICK_EDIT_MODE = 0x0040
467
+
468
+ handle = HANDLE(windll.kernel32.GetStdHandle(STD_INPUT_HANDLE))
469
+
470
+ original_mode = DWORD()
471
+ self._winapi(windll.kernel32.GetConsoleMode, handle, pointer(original_mode))
472
+ self._winapi(
473
+ windll.kernel32.SetConsoleMode,
474
+ handle,
475
+ (original_mode.value | ENABLE_MOUSE_INPUT) & ~ENABLE_QUICK_EDIT_MODE,
476
+ )
477
+
478
+ def disable_mouse_support(self) -> None:
479
+ ENABLE_MOUSE_INPUT = 0x10
480
+ handle = HANDLE(windll.kernel32.GetStdHandle(STD_INPUT_HANDLE))
481
+
482
+ original_mode = DWORD()
483
+ self._winapi(windll.kernel32.GetConsoleMode, handle, pointer(original_mode))
484
+ self._winapi(
485
+ windll.kernel32.SetConsoleMode,
486
+ handle,
487
+ original_mode.value & ~ENABLE_MOUSE_INPUT,
488
+ )
489
+
490
+ def hide_cursor(self) -> None:
491
+ pass
492
+
493
+ def show_cursor(self) -> None:
494
+ pass
495
+
496
+ def set_cursor_shape(self, cursor_shape: CursorShape) -> None:
497
+ pass
498
+
499
+ def reset_cursor_shape(self) -> None:
500
+ pass
501
+
502
+ @classmethod
503
+ def win32_refresh_window(cls) -> None:
504
+ """
505
+ Call win32 API to refresh the whole Window.
506
+
507
+ This is sometimes necessary when the application paints background
508
+ for completion menus. When the menu disappears, it leaves traces due
509
+ to a bug in the Windows Console. Sending a repaint request solves it.
510
+ """
511
+ # Get console handle
512
+ handle = HANDLE(windll.kernel32.GetConsoleWindow())
513
+
514
+ RDW_INVALIDATE = 0x0001
515
+ windll.user32.RedrawWindow(handle, None, None, c_uint(RDW_INVALIDATE))
516
+
517
+ def get_default_color_depth(self) -> ColorDepth:
518
+ """
519
+ Return the default color depth for a windows terminal.
520
+
521
+ Contrary to the Vt100 implementation, this doesn't depend on a $TERM
522
+ variable.
523
+ """
524
+ if self.default_color_depth is not None:
525
+ return self.default_color_depth
526
+
527
+ return ColorDepth.DEPTH_4_BIT
528
+
529
+
530
+ class FOREGROUND_COLOR:
531
+ BLACK = 0x0000
532
+ BLUE = 0x0001
533
+ GREEN = 0x0002
534
+ CYAN = 0x0003
535
+ RED = 0x0004
536
+ MAGENTA = 0x0005
537
+ YELLOW = 0x0006
538
+ GRAY = 0x0007
539
+ INTENSITY = 0x0008 # Foreground color is intensified.
540
+
541
+
542
+ class BACKGROUND_COLOR:
543
+ BLACK = 0x0000
544
+ BLUE = 0x0010
545
+ GREEN = 0x0020
546
+ CYAN = 0x0030
547
+ RED = 0x0040
548
+ MAGENTA = 0x0050
549
+ YELLOW = 0x0060
550
+ GRAY = 0x0070
551
+ INTENSITY = 0x0080 # Background color is intensified.
552
+
553
+
554
+ def _create_ansi_color_dict(
555
+ color_cls: type[FOREGROUND_COLOR] | type[BACKGROUND_COLOR],
556
+ ) -> dict[str, int]:
557
+ "Create a table that maps the 16 named ansi colors to their Windows code."
558
+ return {
559
+ "ansidefault": color_cls.BLACK,
560
+ "ansiblack": color_cls.BLACK,
561
+ "ansigray": color_cls.GRAY,
562
+ "ansibrightblack": color_cls.BLACK | color_cls.INTENSITY,
563
+ "ansiwhite": color_cls.GRAY | color_cls.INTENSITY,
564
+ # Low intensity.
565
+ "ansired": color_cls.RED,
566
+ "ansigreen": color_cls.GREEN,
567
+ "ansiyellow": color_cls.YELLOW,
568
+ "ansiblue": color_cls.BLUE,
569
+ "ansimagenta": color_cls.MAGENTA,
570
+ "ansicyan": color_cls.CYAN,
571
+ # High intensity.
572
+ "ansibrightred": color_cls.RED | color_cls.INTENSITY,
573
+ "ansibrightgreen": color_cls.GREEN | color_cls.INTENSITY,
574
+ "ansibrightyellow": color_cls.YELLOW | color_cls.INTENSITY,
575
+ "ansibrightblue": color_cls.BLUE | color_cls.INTENSITY,
576
+ "ansibrightmagenta": color_cls.MAGENTA | color_cls.INTENSITY,
577
+ "ansibrightcyan": color_cls.CYAN | color_cls.INTENSITY,
578
+ }
579
+
580
+
581
+ FG_ANSI_COLORS = _create_ansi_color_dict(FOREGROUND_COLOR)
582
+ BG_ANSI_COLORS = _create_ansi_color_dict(BACKGROUND_COLOR)
583
+
584
+ assert set(FG_ANSI_COLORS) == set(ANSI_COLOR_NAMES)
585
+ assert set(BG_ANSI_COLORS) == set(ANSI_COLOR_NAMES)
586
+
587
+
588
+ class ColorLookupTable:
589
+ """
590
+ Inspired by pygments/formatters/terminal256.py
591
+ """
592
+
593
+ def __init__(self) -> None:
594
+ self._win32_colors = self._build_color_table()
595
+
596
+ # Cache (map color string to foreground and background code).
597
+ self.best_match: dict[str, tuple[int, int]] = {}
598
+
599
+ @staticmethod
600
+ def _build_color_table() -> list[tuple[int, int, int, int, int]]:
601
+ """
602
+ Build an RGB-to-256 color conversion table
603
+ """
604
+ FG = FOREGROUND_COLOR
605
+ BG = BACKGROUND_COLOR
606
+
607
+ return [
608
+ (0x00, 0x00, 0x00, FG.BLACK, BG.BLACK),
609
+ (0x00, 0x00, 0xAA, FG.BLUE, BG.BLUE),
610
+ (0x00, 0xAA, 0x00, FG.GREEN, BG.GREEN),
611
+ (0x00, 0xAA, 0xAA, FG.CYAN, BG.CYAN),
612
+ (0xAA, 0x00, 0x00, FG.RED, BG.RED),
613
+ (0xAA, 0x00, 0xAA, FG.MAGENTA, BG.MAGENTA),
614
+ (0xAA, 0xAA, 0x00, FG.YELLOW, BG.YELLOW),
615
+ (0x88, 0x88, 0x88, FG.GRAY, BG.GRAY),
616
+ (0x44, 0x44, 0xFF, FG.BLUE | FG.INTENSITY, BG.BLUE | BG.INTENSITY),
617
+ (0x44, 0xFF, 0x44, FG.GREEN | FG.INTENSITY, BG.GREEN | BG.INTENSITY),
618
+ (0x44, 0xFF, 0xFF, FG.CYAN | FG.INTENSITY, BG.CYAN | BG.INTENSITY),
619
+ (0xFF, 0x44, 0x44, FG.RED | FG.INTENSITY, BG.RED | BG.INTENSITY),
620
+ (0xFF, 0x44, 0xFF, FG.MAGENTA | FG.INTENSITY, BG.MAGENTA | BG.INTENSITY),
621
+ (0xFF, 0xFF, 0x44, FG.YELLOW | FG.INTENSITY, BG.YELLOW | BG.INTENSITY),
622
+ (0x44, 0x44, 0x44, FG.BLACK | FG.INTENSITY, BG.BLACK | BG.INTENSITY),
623
+ (0xFF, 0xFF, 0xFF, FG.GRAY | FG.INTENSITY, BG.GRAY | BG.INTENSITY),
624
+ ]
625
+
626
+ def _closest_color(self, r: int, g: int, b: int) -> tuple[int, int]:
627
+ distance = 257 * 257 * 3 # "infinity" (>distance from #000000 to #ffffff)
628
+ fg_match = 0
629
+ bg_match = 0
630
+
631
+ for r_, g_, b_, fg_, bg_ in self._win32_colors:
632
+ rd = r - r_
633
+ gd = g - g_
634
+ bd = b - b_
635
+
636
+ d = rd * rd + gd * gd + bd * bd
637
+
638
+ if d < distance:
639
+ fg_match = fg_
640
+ bg_match = bg_
641
+ distance = d
642
+ return fg_match, bg_match
643
+
644
+ def _color_indexes(self, color: str) -> tuple[int, int]:
645
+ indexes = self.best_match.get(color, None)
646
+ if indexes is None:
647
+ try:
648
+ rgb = int(str(color), 16)
649
+ except ValueError:
650
+ rgb = 0
651
+
652
+ r = (rgb >> 16) & 0xFF
653
+ g = (rgb >> 8) & 0xFF
654
+ b = rgb & 0xFF
655
+ indexes = self._closest_color(r, g, b)
656
+ self.best_match[color] = indexes
657
+ return indexes
658
+
659
+ def lookup_fg_color(self, fg_color: str) -> int:
660
+ """
661
+ Return the color for use in the
662
+ `windll.kernel32.SetConsoleTextAttribute` API call.
663
+
664
+ :param fg_color: Foreground as text. E.g. 'ffffff' or 'red'
665
+ """
666
+ # Foreground.
667
+ if fg_color in FG_ANSI_COLORS:
668
+ return FG_ANSI_COLORS[fg_color]
669
+ else:
670
+ return self._color_indexes(fg_color)[0]
671
+
672
+ def lookup_bg_color(self, bg_color: str) -> int:
673
+ """
674
+ Return the color for use in the
675
+ `windll.kernel32.SetConsoleTextAttribute` API call.
676
+
677
+ :param bg_color: Background as text. E.g. 'ffffff' or 'red'
678
+ """
679
+ # Background.
680
+ if bg_color in BG_ANSI_COLORS:
681
+ return BG_ANSI_COLORS[bg_color]
682
+ else:
683
+ return self._color_indexes(bg_color)[1]
shared/package-files/16/1695a2bbaee4805aaccc8441eb85c1c1dcb301736c3dc6a58a858266f0ad455d/norm_compositeexplicitautograd_dispatch.h ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+ // @generated by torchgen/gen.py from DispatchKeyFunction.h
3
+
4
+ // NB: The implementing C++ file is RegisterDispatchKey.cpp
5
+
6
+ // The only #includes we need are for custom classes that have defaults in the C++ API
7
+ #include <c10/core/MemoryFormat.h>
8
+ #include <c10/core/Scalar.h>
9
+ #include <ATen/core/Reduction.h>
10
+
11
+ // Forward declarations of any types needed in the operator signatures.
12
+ // We can't directly include these classes because it will cause circular include dependencies.
13
+ // This file is included by TensorBody.h, which defines the Tensor class.
14
+ #include <ATen/core/ATen_fwd.h>
15
+
16
+ namespace at {
17
+
18
+ namespace compositeexplicitautograd {
19
+
20
+ TORCH_API at::Tensor norm(const at::Tensor & self, const c10::optional<at::Scalar> & p, at::ScalarType dtype);
21
+ TORCH_API at::Tensor & norm_out(at::Tensor & out, const at::Tensor & self, const c10::optional<at::Scalar> & p, at::ScalarType dtype);
22
+ TORCH_API at::Tensor & norm_outf(const at::Tensor & self, const c10::optional<at::Scalar> & p, at::ScalarType dtype, at::Tensor & out);
23
+ TORCH_API at::Tensor norm(const at::Tensor & self, const at::Scalar & p=2);
24
+ TORCH_API at::Tensor & norm_out(at::Tensor & out, const at::Tensor & self, const at::Scalar & p=2);
25
+ TORCH_API at::Tensor & norm_outf(const at::Tensor & self, const at::Scalar & p, at::Tensor & out);
26
+
27
+ } // namespace compositeexplicitautograd
28
+ } // namespace at
shared/package-files/16/1695bf5062546ea28711f9bc4b9e1c34442c7a82b26b87916d9e74c843904d0a/__init__.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates
2
+ from .embedding_ops import * # noqa: F403
3
+ from .matrix_ops import * # noqa: F403
4
+ from .math_ops import * # noqa: F403
5
+ from .tensor_ops import * # noqa: F403
6
+ from .pointwise_ops import * # noqa: F403
7
+ from .random_ops import * # noqa: F403
8
+ from .view_ops import * # noqa: F403
9
+ from .conv_ops import * # noqa: F403
10
+ from .experimental_ops import * # noqa: F403