Mailing List Archive

bpo-44072: fix Complex, Integral docs for `**` (GH-25986)
https://github.com/python/cpython/commit/4aa63d65a9971d14f1a2131b989dca0dab514a9d
commit: 4aa63d65a9971d14f1a2131b989dca0dab514a9d
branch: main
author: Rory Yorke <rory.yorke@gmail.com>
committer: terryjreedy <tjreedy@udel.edu>
date: 2021-05-14T18:01:48-04:00
summary:

bpo-44072: fix Complex, Integral docs for `**` (GH-25986)

In numbers module docstrings and docs.

files:
A Misc/NEWS.d/next/Documentation/2021-05-08-09-48-05.bpo-44072.fb2x5I.rst
M Doc/library/numbers.rst
M Lib/numbers.py

diff --git a/Doc/library/numbers.rst b/Doc/library/numbers.rst
index 1b594952ead724..d37123c35476a7 100644
--- a/Doc/library/numbers.rst
+++ b/Doc/library/numbers.rst
@@ -27,8 +27,8 @@ The numeric tower
Subclasses of this type describe complex numbers and include the operations
that work on the built-in :class:`complex` type. These are: conversions to
:class:`complex` and :class:`bool`, :attr:`.real`, :attr:`.imag`, ``+``,
- ``-``, ``*``, ``/``, :func:`abs`, :meth:`conjugate`, ``==``, and ``!=``. All
- except ``-`` and ``!=`` are abstract.
+ ``-``, ``*``, ``/``, ``**``, :func:`abs`, :meth:`conjugate`, ``==``, and
+ ``!=``. All except ``-`` and ``!=`` are abstract.

.. attribute:: real

@@ -76,8 +76,9 @@ The numeric tower

Subtypes :class:`Rational` and adds a conversion to :class:`int`. Provides
defaults for :func:`float`, :attr:`~Rational.numerator`, and
- :attr:`~Rational.denominator`. Adds abstract methods for ``**`` and
- bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``, ``~``.
+ :attr:`~Rational.denominator`. Adds abstract methods for :func:`pow` with
+ modulus and bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``,
+ ``~``.


Notes for type implementors
diff --git a/Lib/numbers.py b/Lib/numbers.py
index ed815ef41ebe12..5b98e642083b36 100644
--- a/Lib/numbers.py
+++ b/Lib/numbers.py
@@ -33,7 +33,7 @@ class Complex(Number):
"""Complex defines the operations that work on the builtin complex type.

In short, those are: a conversion to complex, .real, .imag, +, -,
- *, /, abs(), .conjugate, ==, and !=.
+ *, /, **, abs(), .conjugate, ==, and !=.

If it is given heterogeneous arguments, and doesn't have special
knowledge about them, it should fall back to the builtin complex
@@ -292,7 +292,11 @@ def __float__(self):


class Integral(Rational):
- """Integral adds a conversion to int and the bit-string operations."""
+ """Integral adds methods that work on integral numbers.
+
+ In short, these are conversion to int, pow with modulus, and the
+ bit-string operations.
+ """

__slots__ = ()

diff --git a/Misc/NEWS.d/next/Documentation/2021-05-08-09-48-05.bpo-44072.fb2x5I.rst b/Misc/NEWS.d/next/Documentation/2021-05-08-09-48-05.bpo-44072.fb2x5I.rst
new file mode 100644
index 00000000000000..a5b0c95d85e66e
--- /dev/null
+++ b/Misc/NEWS.d/next/Documentation/2021-05-08-09-48-05.bpo-44072.fb2x5I.rst
@@ -0,0 +1,2 @@
+Correct where in the numeric ABC hierarchy ``**`` support is added, i.e., in
+numbers.Complex, not numbers.Integral.

_______________________________________________
Python-checkins mailing list
Python-checkins@python.org
https://mail.python.org/mailman/listinfo/python-checkins
bpo-44072: fix Complex, Integral docs for `**` (GH-25986) [ In reply to ]
https://github.com/python/cpython/commit/2e99869f64bbd3c6590cb5ceaf9cf59e63689d63
commit: 2e99869f64bbd3c6590cb5ceaf9cf59e63689d63
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
committer: miss-islington <31488909+miss-islington@users.noreply.github.com>
date: 2021-05-14T15:22:45-07:00
summary:

bpo-44072: fix Complex, Integral docs for `**` (GH-25986)


In numbers module docstrings and docs.
(cherry picked from commit 4aa63d65a9971d14f1a2131b989dca0dab514a9d)

Co-authored-by: Rory Yorke <rory.yorke@gmail.com>

files:
A Misc/NEWS.d/next/Documentation/2021-05-08-09-48-05.bpo-44072.fb2x5I.rst
M Doc/library/numbers.rst
M Lib/numbers.py

diff --git a/Doc/library/numbers.rst b/Doc/library/numbers.rst
index 1b594952ead724..d37123c35476a7 100644
--- a/Doc/library/numbers.rst
+++ b/Doc/library/numbers.rst
@@ -27,8 +27,8 @@ The numeric tower
Subclasses of this type describe complex numbers and include the operations
that work on the built-in :class:`complex` type. These are: conversions to
:class:`complex` and :class:`bool`, :attr:`.real`, :attr:`.imag`, ``+``,
- ``-``, ``*``, ``/``, :func:`abs`, :meth:`conjugate`, ``==``, and ``!=``. All
- except ``-`` and ``!=`` are abstract.
+ ``-``, ``*``, ``/``, ``**``, :func:`abs`, :meth:`conjugate`, ``==``, and
+ ``!=``. All except ``-`` and ``!=`` are abstract.

.. attribute:: real

@@ -76,8 +76,9 @@ The numeric tower

Subtypes :class:`Rational` and adds a conversion to :class:`int`. Provides
defaults for :func:`float`, :attr:`~Rational.numerator`, and
- :attr:`~Rational.denominator`. Adds abstract methods for ``**`` and
- bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``, ``~``.
+ :attr:`~Rational.denominator`. Adds abstract methods for :func:`pow` with
+ modulus and bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``,
+ ``~``.


Notes for type implementors
diff --git a/Lib/numbers.py b/Lib/numbers.py
index ed815ef41ebe12..5b98e642083b36 100644
--- a/Lib/numbers.py
+++ b/Lib/numbers.py
@@ -33,7 +33,7 @@ class Complex(Number):
"""Complex defines the operations that work on the builtin complex type.

In short, those are: a conversion to complex, .real, .imag, +, -,
- *, /, abs(), .conjugate, ==, and !=.
+ *, /, **, abs(), .conjugate, ==, and !=.

If it is given heterogeneous arguments, and doesn't have special
knowledge about them, it should fall back to the builtin complex
@@ -292,7 +292,11 @@ def __float__(self):


class Integral(Rational):
- """Integral adds a conversion to int and the bit-string operations."""
+ """Integral adds methods that work on integral numbers.
+
+ In short, these are conversion to int, pow with modulus, and the
+ bit-string operations.
+ """

__slots__ = ()

diff --git a/Misc/NEWS.d/next/Documentation/2021-05-08-09-48-05.bpo-44072.fb2x5I.rst b/Misc/NEWS.d/next/Documentation/2021-05-08-09-48-05.bpo-44072.fb2x5I.rst
new file mode 100644
index 00000000000000..a5b0c95d85e66e
--- /dev/null
+++ b/Misc/NEWS.d/next/Documentation/2021-05-08-09-48-05.bpo-44072.fb2x5I.rst
@@ -0,0 +1,2 @@
+Correct where in the numeric ABC hierarchy ``**`` support is added, i.e., in
+numbers.Complex, not numbers.Integral.

_______________________________________________
Python-checkins mailing list
Python-checkins@python.org
https://mail.python.org/mailman/listinfo/python-checkins
bpo-44072: fix Complex, Integral docs for `**` (GH-25986) [ In reply to ]
https://github.com/python/cpython/commit/fa9de0c383581936de3338c8dc6b58c10a6e27b8
commit: fa9de0c383581936de3338c8dc6b58c10a6e27b8
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
committer: miss-islington <31488909+miss-islington@users.noreply.github.com>
date: 2021-05-14T15:25:43-07:00
summary:

bpo-44072: fix Complex, Integral docs for `**` (GH-25986)


In numbers module docstrings and docs.
(cherry picked from commit 4aa63d65a9971d14f1a2131b989dca0dab514a9d)

Co-authored-by: Rory Yorke <rory.yorke@gmail.com>

files:
A Misc/NEWS.d/next/Documentation/2021-05-08-09-48-05.bpo-44072.fb2x5I.rst
M Doc/library/numbers.rst
M Lib/numbers.py

diff --git a/Doc/library/numbers.rst b/Doc/library/numbers.rst
index 1b594952ead724..d37123c35476a7 100644
--- a/Doc/library/numbers.rst
+++ b/Doc/library/numbers.rst
@@ -27,8 +27,8 @@ The numeric tower
Subclasses of this type describe complex numbers and include the operations
that work on the built-in :class:`complex` type. These are: conversions to
:class:`complex` and :class:`bool`, :attr:`.real`, :attr:`.imag`, ``+``,
- ``-``, ``*``, ``/``, :func:`abs`, :meth:`conjugate`, ``==``, and ``!=``. All
- except ``-`` and ``!=`` are abstract.
+ ``-``, ``*``, ``/``, ``**``, :func:`abs`, :meth:`conjugate`, ``==``, and
+ ``!=``. All except ``-`` and ``!=`` are abstract.

.. attribute:: real

@@ -76,8 +76,9 @@ The numeric tower

Subtypes :class:`Rational` and adds a conversion to :class:`int`. Provides
defaults for :func:`float`, :attr:`~Rational.numerator`, and
- :attr:`~Rational.denominator`. Adds abstract methods for ``**`` and
- bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``, ``~``.
+ :attr:`~Rational.denominator`. Adds abstract methods for :func:`pow` with
+ modulus and bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``,
+ ``~``.


Notes for type implementors
diff --git a/Lib/numbers.py b/Lib/numbers.py
index ed815ef41ebe12..5b98e642083b36 100644
--- a/Lib/numbers.py
+++ b/Lib/numbers.py
@@ -33,7 +33,7 @@ class Complex(Number):
"""Complex defines the operations that work on the builtin complex type.

In short, those are: a conversion to complex, .real, .imag, +, -,
- *, /, abs(), .conjugate, ==, and !=.
+ *, /, **, abs(), .conjugate, ==, and !=.

If it is given heterogeneous arguments, and doesn't have special
knowledge about them, it should fall back to the builtin complex
@@ -292,7 +292,11 @@ def __float__(self):


class Integral(Rational):
- """Integral adds a conversion to int and the bit-string operations."""
+ """Integral adds methods that work on integral numbers.
+
+ In short, these are conversion to int, pow with modulus, and the
+ bit-string operations.
+ """

__slots__ = ()

diff --git a/Misc/NEWS.d/next/Documentation/2021-05-08-09-48-05.bpo-44072.fb2x5I.rst b/Misc/NEWS.d/next/Documentation/2021-05-08-09-48-05.bpo-44072.fb2x5I.rst
new file mode 100644
index 00000000000000..a5b0c95d85e66e
--- /dev/null
+++ b/Misc/NEWS.d/next/Documentation/2021-05-08-09-48-05.bpo-44072.fb2x5I.rst
@@ -0,0 +1,2 @@
+Correct where in the numeric ABC hierarchy ``**`` support is added, i.e., in
+numbers.Complex, not numbers.Integral.

_______________________________________________
Python-checkins mailing list
Python-checkins@python.org
https://mail.python.org/mailman/listinfo/python-checkins