Skip to content

Commit a7d4335

Browse files
committed
Deploying to gh-pages from @ b813391 🚀
1 parent 192dcff commit a7d4335

File tree

531 files changed

+4326
-4215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

531 files changed

+4326
-4215
lines changed

.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: 9c491100fe29bc5f8522a86d74577c4d
3+
config: 44c8d32fa1c843401cafd8ed3755058f
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

_sources/library/concurrent.futures.rst.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,22 @@ Executor Objects
3939
future = executor.submit(pow, 323, 1235)
4040
print(future.result())
4141

42-
.. method:: map(func, *iterables, timeout=None, chunksize=1)
42+
.. method:: map(fn, *iterables, timeout=None, chunksize=1)
4343

44-
Similar to :func:`map(func, *iterables) <map>` except:
44+
Similar to :func:`map(fn, *iterables) <map>` except:
4545

4646
* the *iterables* are collected immediately rather than lazily;
4747

48-
* *func* is executed asynchronously and several calls to
49-
*func* may be made concurrently.
48+
* *fn* is executed asynchronously and several calls to
49+
*fn* may be made concurrently.
5050

5151
The returned iterator raises a :exc:`TimeoutError`
5252
if :meth:`~iterator.__next__` is called and the result isn't available
5353
after *timeout* seconds from the original call to :meth:`Executor.map`.
5454
*timeout* can be an int or a float. If *timeout* is not specified or
5555
``None``, there is no limit to the wait time.
5656

57-
If a *func* call raises an exception, then that exception will be
57+
If a *fn* call raises an exception, then that exception will be
5858
raised when its value is retrieved from the iterator.
5959

6060
When using :class:`ProcessPoolExecutor`, this method chops *iterables*

_sources/library/dataclasses.rst.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,10 @@ class :meth:`~object.__init__` methods. If the base class has an :meth:`~object.
534534
that has to be called, it is common to call this method in a
535535
:meth:`__post_init__` method::
536536

537-
@dataclass
538537
class Rectangle:
539-
height: float
540-
width: float
538+
def __init__(self, height, width):
539+
self.height = height
540+
self.width = width
541541

542542
@dataclass
543543
class Square(Rectangle):

_sources/library/fnmatch.rst.txt

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ Also note that :func:`functools.lru_cache` with the *maxsize* of 32768 is used t
5050
cache the compiled regex patterns in the following functions: :func:`fnmatch`,
5151
:func:`fnmatchcase`, :func:`.filter`.
5252

53-
.. function:: fnmatch(filename, pattern)
53+
.. function:: fnmatch(name, pat)
5454

55-
Test whether the *filename* string matches the *pattern* string, returning
56-
:const:`True` or :const:`False`. Both parameters are case-normalized
55+
Test whether the filename string *name* matches the pattern string *pat*,
56+
returning ``True`` or ``False``. Both parameters are case-normalized
5757
using :func:`os.path.normcase`. :func:`fnmatchcase` can be used to perform a
5858
case-sensitive comparison, regardless of whether that's standard for the
5959
operating system.
@@ -69,22 +69,24 @@ cache the compiled regex patterns in the following functions: :func:`fnmatch`,
6969
print(file)
7070

7171

72-
.. function:: fnmatchcase(filename, pattern)
72+
.. function:: fnmatchcase(name, pat)
7373

74-
Test whether *filename* matches *pattern*, returning :const:`True` or
75-
:const:`False`; the comparison is case-sensitive and does not apply
76-
:func:`os.path.normcase`.
74+
Test whether the filename string *name* matches the pattern string *pat*,
75+
returning ``True`` or ``False``;
76+
the comparison is case-sensitive and does not apply :func:`os.path.normcase`.
7777

7878

79-
.. function:: filter(names, pattern)
79+
.. function:: filter(names, pat)
8080

81-
Construct a list from those elements of the iterable *names* that match *pattern*. It is the same as
82-
``[n for n in names if fnmatch(n, pattern)]``, but implemented more efficiently.
81+
Construct a list from those elements of the :term:`iterable` *names*
82+
that match pattern *pat*.
83+
It is the same as ``[n for n in names if fnmatch(n, pat)]``,
84+
but implemented more efficiently.
8385

8486

85-
.. function:: translate(pattern)
87+
.. function:: translate(pat)
8688

87-
Return the shell-style *pattern* converted to a regular expression for
89+
Return the shell-style pattern *pat* converted to a regular expression for
8890
using with :func:`re.match`.
8991

9092
Example:

_sources/library/multiprocessing.shared_memory.rst.txt

Lines changed: 78 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ and management of shared memory to be accessed by one or more processes
2020
on a multicore or symmetric multiprocessor (SMP) machine. To assist with
2121
the life-cycle management of shared memory especially across distinct
2222
processes, a :class:`~multiprocessing.managers.BaseManager` subclass,
23-
:class:`SharedMemoryManager`, is also provided in the
24-
``multiprocessing.managers`` module.
23+
:class:`~multiprocessing.managers.SharedMemoryManager`, is also provided in the
24+
:mod:`multiprocessing.managers` module.
2525

2626
In this module, shared memory refers to "System V style" shared memory blocks
2727
(though is not necessarily implemented explicitly as such) and does not refer
@@ -38,7 +38,8 @@ copying of data.
3838

3939
.. class:: SharedMemory(name=None, create=False, size=0)
4040

41-
Creates a new shared memory block or attaches to an existing shared
41+
Create an instance of the :class:`!SharedMemory` class for either
42+
creating a new shared memory block or attaching to an existing shared
4243
memory block. Each shared memory block is assigned a unique name.
4344
In this way, one process can create a shared memory block with a
4445
particular name and a different process can attach to that same shared
@@ -47,43 +48,48 @@ copying of data.
4748
As a resource for sharing data across processes, shared memory blocks
4849
may outlive the original process that created them. When one process
4950
no longer needs access to a shared memory block that might still be
50-
needed by other processes, the :meth:`close()` method should be called.
51+
needed by other processes, the :meth:`close` method should be called.
5152
When a shared memory block is no longer needed by any process, the
52-
:meth:`unlink()` method should be called to ensure proper cleanup.
53-
54-
*name* is the unique name for the requested shared memory, specified as
55-
a string. When creating a new shared memory block, if ``None`` (the
56-
default) is supplied for the name, a novel name will be generated.
57-
58-
*create* controls whether a new shared memory block is created (``True``)
59-
or an existing shared memory block is attached (``False``).
60-
61-
*size* specifies the requested number of bytes when creating a new shared
62-
memory block. Because some platforms choose to allocate chunks of memory
63-
based upon that platform's memory page size, the exact size of the shared
64-
memory block may be larger or equal to the size requested. When attaching
65-
to an existing shared memory block, the ``size`` parameter is ignored.
53+
:meth:`unlink` method should be called to ensure proper cleanup.
54+
55+
:param name:
56+
The unique name for the requested shared memory, specified as a string.
57+
When creating a new shared memory block, if ``None`` (the default)
58+
is supplied for the name, a novel name will be generated.
59+
:type name: str | None
60+
61+
:param bool create:
62+
Control whether a new shared memory block is created (``True``)
63+
or an existing shared memory block is attached (``False``).
64+
65+
:param int size:
66+
The requested number of bytes when creating a new shared memory block.
67+
Because some platforms choose to allocate chunks of memory
68+
based upon that platform's memory page size, the exact size of the shared
69+
memory block may be larger or equal to the size requested.
70+
When attaching to an existing shared memory block,
71+
the *size* parameter is ignored.
6672

6773
.. method:: close()
6874

69-
Closes access to the shared memory from this instance. In order to
75+
Close access to the shared memory from this instance. In order to
7076
ensure proper cleanup of resources, all instances should call
71-
``close()`` once the instance is no longer needed. Note that calling
72-
``close()`` does not cause the shared memory block itself to be
77+
:meth:`close` once the instance is no longer needed. Note that calling
78+
:meth:`!close` does not cause the shared memory block itself to be
7379
destroyed.
7480

7581
.. method:: unlink()
7682

77-
Requests that the underlying shared memory block be destroyed. In
78-
order to ensure proper cleanup of resources, ``unlink()`` should be
83+
Request that the underlying shared memory block be destroyed. In
84+
order to ensure proper cleanup of resources, :meth:`unlink` should be
7985
called once (and only once) across all processes which have need
8086
for the shared memory block. After requesting its destruction, a
8187
shared memory block may or may not be immediately destroyed and
8288
this behavior may differ across platforms. Attempts to access data
83-
inside the shared memory block after ``unlink()`` has been called may
89+
inside the shared memory block after :meth:`!unlink` has been called may
8490
result in memory access errors. Note: the last process relinquishing
85-
its hold on a shared memory block may call ``unlink()`` and
86-
:meth:`close()` in either order.
91+
its hold on a shared memory block may call :meth:`!unlink` and
92+
:meth:`close` in either order.
8793

8894
.. attribute:: buf
8995

@@ -126,7 +132,7 @@ instances::
126132

127133
The following example demonstrates a practical use of the :class:`SharedMemory`
128134
class with `NumPy arrays <https://numpy.org/>`_, accessing the
129-
same ``numpy.ndarray`` from two distinct Python shells:
135+
same :class:`!numpy.ndarray` from two distinct Python shells:
130136

131137
.. doctest::
132138
:options: +SKIP
@@ -178,43 +184,43 @@ same ``numpy.ndarray`` from two distinct Python shells:
178184
.. class:: SharedMemoryManager([address[, authkey]])
179185
:module: multiprocessing.managers
180186

181-
A subclass of :class:`~multiprocessing.managers.BaseManager` which can be
187+
A subclass of :class:`multiprocessing.managers.BaseManager` which can be
182188
used for the management of shared memory blocks across processes.
183189

184190
A call to :meth:`~multiprocessing.managers.BaseManager.start` on a
185-
:class:`SharedMemoryManager` instance causes a new process to be started.
191+
:class:`!SharedMemoryManager` instance causes a new process to be started.
186192
This new process's sole purpose is to manage the life cycle
187193
of all shared memory blocks created through it. To trigger the release
188194
of all shared memory blocks managed by that process, call
189-
:meth:`~multiprocessing.managers.BaseManager.shutdown()` on the instance.
190-
This triggers a :meth:`SharedMemory.unlink()` call on all of the
191-
:class:`SharedMemory` objects managed by that process and then
192-
stops the process itself. By creating ``SharedMemory`` instances
193-
through a ``SharedMemoryManager``, we avoid the need to manually track
195+
:meth:`~multiprocessing.managers.BaseManager.shutdown` on the instance.
196+
This triggers a :meth:`~multiprocessing.shared_memory.SharedMemory.unlink` call
197+
on all of the :class:`SharedMemory` objects managed by that process and then
198+
stops the process itself. By creating :class:`!SharedMemory` instances
199+
through a :class:`!SharedMemoryManager`, we avoid the need to manually track
194200
and trigger the freeing of shared memory resources.
195201

196202
This class provides methods for creating and returning :class:`SharedMemory`
197203
instances and for creating a list-like object (:class:`ShareableList`)
198204
backed by shared memory.
199205

200-
Refer to :class:`multiprocessing.managers.BaseManager` for a description
206+
Refer to :class:`~multiprocessing.managers.BaseManager` for a description
201207
of the inherited *address* and *authkey* optional input arguments and how
202-
they may be used to connect to an existing ``SharedMemoryManager`` service
208+
they may be used to connect to an existing :class:`!SharedMemoryManager` service
203209
from other processes.
204210

205211
.. method:: SharedMemory(size)
206212

207213
Create and return a new :class:`SharedMemory` object with the
208-
specified ``size`` in bytes.
214+
specified *size* in bytes.
209215

210216
.. method:: ShareableList(sequence)
211217

212218
Create and return a new :class:`ShareableList` object, initialized
213-
by the values from the input ``sequence``.
219+
by the values from the input *sequence*.
214220

215221

216222
The following example demonstrates the basic mechanisms of a
217-
:class:`SharedMemoryManager`:
223+
:class:`~multiprocessing.managers.SharedMemoryManager`:
218224

219225
.. doctest::
220226
:options: +SKIP
@@ -232,9 +238,9 @@ The following example demonstrates the basic mechanisms of a
232238
>>> smm.shutdown() # Calls unlink() on sl, raw_shm, and another_sl
233239

234240
The following example depicts a potentially more convenient pattern for using
235-
:class:`SharedMemoryManager` objects via the :keyword:`with` statement to
236-
ensure that all shared memory blocks are released after they are no longer
237-
needed:
241+
:class:`~multiprocessing.managers.SharedMemoryManager` objects via the
242+
:keyword:`with` statement to ensure that all shared memory blocks are released
243+
after they are no longer needed:
238244

239245
.. doctest::
240246
:options: +SKIP
@@ -250,38 +256,46 @@ needed:
250256
... p2.join() # Wait for all work to complete in both processes
251257
... total_result = sum(sl) # Consolidate the partial results now in sl
252258

253-
When using a :class:`SharedMemoryManager` in a :keyword:`with` statement, the
254-
shared memory blocks created using that manager are all released when the
255-
:keyword:`with` statement's code block finishes execution.
259+
When using a :class:`~multiprocessing.managers.SharedMemoryManager`
260+
in a :keyword:`with` statement, the shared memory blocks created using that
261+
manager are all released when the :keyword:`!with` statement's code block
262+
finishes execution.
263+
264+
265+
.. class:: ShareableList(sequence=None, *, name=None)
256266

267+
Provide a mutable list-like object where all values stored within are
268+
stored in a shared memory block.
269+
This constrains storable values to the following built-in data types:
257270

258-
.. class:: ShareableList(sequence=None, \*, name=None)
271+
* :class:`int` (signed 64-bit)
272+
* :class:`float`
273+
* :class:`bool`
274+
* :class:`str` (less than 10M bytes each when encoded as UTF-8)
275+
* :class:`bytes` (less than 10M bytes each)
276+
* ``None``
259277

260-
Provides a mutable list-like object where all values stored within are
261-
stored in a shared memory block. This constrains storable values to
262-
only the ``int`` (signed 64-bit), ``float``, ``bool``, ``str`` (less
263-
than 10M bytes each when encoded as utf-8), ``bytes`` (less than 10M
264-
bytes each), and ``None`` built-in data types. It also notably
265-
differs from the built-in ``list`` type in that these lists can not
266-
change their overall length (i.e. no append, insert, etc.) and do not
267-
support the dynamic creation of new :class:`ShareableList` instances
278+
It also notably differs from the built-in :class:`list` type
279+
in that these lists can not change their overall length
280+
(i.e. no :meth:`!append`, :meth:`!insert`, etc.) and do not
281+
support the dynamic creation of new :class:`!ShareableList` instances
268282
via slicing.
269283

270-
*sequence* is used in populating a new ``ShareableList`` full of values.
284+
*sequence* is used in populating a new :class:`!ShareableList` full of values.
271285
Set to ``None`` to instead attach to an already existing
272-
``ShareableList`` by its unique shared memory name.
286+
:class:`!ShareableList` by its unique shared memory name.
273287

274288
*name* is the unique name for the requested shared memory, as described
275289
in the definition for :class:`SharedMemory`. When attaching to an
276-
existing ``ShareableList``, specify its shared memory block's unique
277-
name while leaving ``sequence`` set to ``None``.
290+
existing :class:`!ShareableList`, specify its shared memory block's unique
291+
name while leaving *sequence* set to ``None``.
278292

279293
.. note::
280294

281295
A known issue exists for :class:`bytes` and :class:`str` values.
282296
If they end with ``\x00`` nul bytes or characters, those may be
283297
*silently stripped* when fetching them by index from the
284-
:class:`ShareableList`. This ``.rstrip(b'\x00')`` behavior is
298+
:class:`!ShareableList`. This ``.rstrip(b'\x00')`` behavior is
285299
considered a bug and may go away in the future. See :gh:`106939`.
286300

287301
For applications where rstripping of trailing nulls is a problem,
@@ -307,12 +321,12 @@ shared memory blocks created using that manager are all released when the
307321

308322
.. method:: count(value)
309323

310-
Returns the number of occurrences of ``value``.
324+
Return the number of occurrences of *value*.
311325

312326
.. method:: index(value)
313327

314-
Returns first index position of ``value``. Raises :exc:`ValueError` if
315-
``value`` is not present.
328+
Return first index position of *value*.
329+
Raise :exc:`ValueError` if *value* is not present.
316330

317331
.. attribute:: format
318332

@@ -372,8 +386,8 @@ behind it:
372386
>>> c.shm.close()
373387
>>> c.shm.unlink()
374388

375-
The following examples demonstrates that ``ShareableList``
376-
(and underlying ``SharedMemory``) objects
389+
The following examples demonstrates that :class:`ShareableList`
390+
(and underlying :class:`SharedMemory`) objects
377391
can be pickled and unpickled if needed.
378392
Note, that it will still be the same shared object.
379393
This happens, because the deserialized object has

_sources/library/pathlib.rst.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,10 @@ call fails (for example because the path doesn't exist).
916916
PosixPath('setup.py'),
917917
PosixPath('test_pathlib.py')]
918918

919+
This method calls :meth:`Path.is_dir` on the top-level directory and
920+
propagates any :exc:`OSError` exception that is raised. Subsequent
921+
:exc:`OSError` exceptions from scanning directories are suppressed.
922+
919923
By default, or when the *case_sensitive* keyword-only argument is set to
920924
``None``, this method matches paths using platform-specific casing rules:
921925
typically, case-sensitive on POSIX, and case-insensitive on Windows.

_sources/library/statistics.rst.txt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,17 +1094,15 @@ from a fixed number of discrete samples.
10941094
The basic idea is to smooth the data using `a kernel function such as a
10951095
normal distribution, triangular distribution, or uniform distribution
10961096
<https://en.wikipedia.org/wiki/Kernel_(statistics)#Kernel_functions_in_common_use>`_.
1097-
The degree of smoothing is controlled by a single
1098-
parameter, ``h``, representing the variance of the kernel function.
1097+
The degree of smoothing is controlled by a scaling parameter, ``h``,
1098+
which is called the *bandwidth*.
10991099

11001100
.. testcode::
11011101

1102-
import math
1103-
11041102
def kde_normal(sample, h):
11051103
"Create a continuous probability density function from a sample."
1106-
# Smooth the sample with a normal distribution of variance h.
1107-
kernel_h = NormalDist(0.0, math.sqrt(h)).pdf
1104+
# Smooth the sample with a normal distribution kernel scaled by h.
1105+
kernel_h = NormalDist(0.0, h).pdf
11081106
n = len(sample)
11091107
def pdf(x):
11101108
return sum(kernel_h(x - x_i) for x_i in sample) / n
@@ -1118,7 +1116,7 @@ a probability density function estimated from a small sample:
11181116
.. doctest::
11191117

11201118
>>> sample = [-2.1, -1.3, -0.4, 1.9, 5.1, 6.2]
1121-
>>> f_hat = kde_normal(sample, h=2.25)
1119+
>>> f_hat = kde_normal(sample, h=1.5)
11221120
>>> xarr = [i/100 for i in range(-750, 1100)]
11231121
>>> yarr = [f_hat(x) for x in xarr]
11241122

0 commit comments

Comments
 (0)