summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2020-09-16 13:08:11 +0100
committerEric Wieser <wieser.eric@gmail.com>2020-09-16 15:09:11 +0100
commit5c3f10061f39a7858a5f2c6cd48773abe3252e48 (patch)
tree38b7e4ef1a47a4dedb1160a56b486271a2338079
parent3a06142f5e26c6294ffd5fa24cd450addef45e13 (diff)
downloadnumpy-5c3f10061f39a7858a5f2c6cd48773abe3252e48.tar.gz
DOC: Fix broken references and make the tables a little clearer
`types.BooleanType` and similar names were python2 things that no longer exist `unicode` also no longer exists, and is now `str`
-rw-r--r--doc/source/reference/arrays.scalars.rst55
-rw-r--r--numpy/core/numerictypes.py2
2 files changed, 30 insertions, 27 deletions
diff --git a/doc/source/reference/arrays.scalars.rst b/doc/source/reference/arrays.scalars.rst
index f57a11724..46d2bb8fa 100644
--- a/doc/source/reference/arrays.scalars.rst
+++ b/doc/source/reference/arrays.scalars.rst
@@ -29,7 +29,7 @@ an array scalar object. Alternatively, what kind of array scalar is
present can be determined using other members of the data type
hierarchy. Thus, for example ``isinstance(val, np.complexfloating)``
will return :py:data:`True` if *val* is a complex valued type, while
-:const:`isinstance(val, np.flexible)` will return true if *val* is one
+``isinstance(val, np.flexible)`` will return true if *val* is one
of the flexible itemsize array types (:class:`string`,
:class:`unicode`, :class:`void`).
@@ -65,19 +65,22 @@ Some of the scalar types are essentially equivalent to fundamental
Python types and therefore inherit from them as well as from the
generic array scalar type:
-==================== ================================
-Array scalar type Related Python type
-==================== ================================
-:class:`int_` :class:`IntType` (Python 2 only)
-:class:`float_` :class:`FloatType`
-:class:`complex_` :class:`ComplexType`
-:class:`bytes_` :class:`BytesType`
-:class:`unicode_` :class:`UnicodeType`
-==================== ================================
+==================== =========================== =============
+Array scalar type Related Python type Inherits?
+==================== =========================== =============
+:class:`int_` :class:`int` Python 2 only
+:class:`float_` :class:`float` yes
+:class:`complex_` :class:`complex` yes
+:class:`bytes_` :class:`bytes` yes
+:class:`str_` :class:`str` yes
+:class:`bool_` :class:`bool` no
+:class:`datetime64` :class:`datetime.datetime` no
+:class:`timedelta64` :class:`datetime.timedelta` no
+==================== =========================== =============
The :class:`bool_` data type is very similar to the Python
-:class:`BooleanType` but does not inherit from it because Python's
-:class:`BooleanType` does not allow itself to be inherited from, and
+:class:`bool` but does not inherit from it because Python's
+:class:`bool` does not allow itself to be inherited from, and
on the C-level the size of the actual bool data is not the same as a
Python Boolean scalar.
@@ -86,7 +89,7 @@ Python Boolean scalar.
The :class:`bool_` type is not a subclass of the :class:`int_` type
(the :class:`bool_` is not even a number type). This is different
than Python's default implementation of :class:`bool` as a
- sub-class of int.
+ sub-class of :class:`int`.
.. warning::
@@ -113,11 +116,11 @@ Type Remarks Character code
Integers:
=================== ============================= ===============
-:class:`byte` compatible: C char ``'b'``
-:class:`short` compatible: C short ``'h'``
-:class:`intc` compatible: C int ``'i'``
-:class:`int_` compatible: Python int ``'l'``
-:class:`longlong` compatible: C long long ``'q'``
+:class:`byte` compatible: C ``char`` ``'b'``
+:class:`short` compatible: C ``short`` ``'h'``
+:class:`intc` compatible: C ``int`` ``'i'``
+:class:`int_` compatible: C ``long`` ``'l'``
+:class:`longlong` compatible: C ``long long`` ``'q'``
:class:`intp` large enough to fit a pointer ``'p'``
:class:`int8` 8 bits
:class:`int16` 16 bits
@@ -127,18 +130,18 @@ Integers:
Unsigned integers:
-=================== ============================= ===============
-:class:`ubyte` compatible: C unsigned char ``'B'``
-:class:`ushort` compatible: C unsigned short ``'H'``
-:class:`uintc` compatible: C unsigned int ``'I'``
-:class:`uint` compatible: Python int ``'L'``
-:class:`ulonglong` compatible: C long long ``'Q'``
-:class:`uintp` large enough to fit a pointer ``'P'``
+=================== ================================= ===============
+:class:`ubyte` compatible: C ``unsigned char`` ``'B'``
+:class:`ushort` compatible: C ``unsigned short`` ``'H'``
+:class:`uintc` compatible: C ``unsigned int`` ``'I'``
+:class:`uint` compatible: C ``long`` ``'L'``
+:class:`ulonglong` compatible: C ``long long`` ``'Q'``
+:class:`uintp` large enough to fit a pointer ``'P'``
:class:`uint8` 8 bits
:class:`uint16` 16 bits
:class:`uint32` 32 bits
:class:`uint64` 64 bits
-=================== ============================= ===============
+=================== ================================= ===============
Floating-point numbers:
diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py
index 632f2b8cd..e705dd3ea 100644
--- a/numpy/core/numerictypes.py
+++ b/numpy/core/numerictypes.py
@@ -374,8 +374,8 @@ def issubdtype(arg1, arg2):
See Also
--------
+ :ref:`arrays.scalars` : Overview of the numpy type hierarchy.
issubsctype, issubclass_
- numpy.core.numerictypes : Overview of numpy type hierarchy.
Examples
--------