Skip to content

Commit 533ab95

Browse files
doc: constants page final form
1 parent a931406 commit 533ab95

3 files changed

Lines changed: 79 additions & 27 deletions

File tree

docs/source/data-structures/constants/index.rst

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,59 @@
55

66
The full license is in the file LICENSE, distributed with this software.
77

8-
.. currentmodule:: _libsemigroups_pybind11
8+
.. currentmodule:: libsemigroups_pybind11
99

1010
Constants
1111
=========
1212

1313
This page describes some of the constants used in ``libsemigroups_pybind11``.
1414

15+
Constant types
16+
--------------
1517

16-
.. autodata:: UNDEFINED
18+
.. autoclass:: LimitMax
1719

18-
This variable is used to indicate that a value is undefined.
19-
:any:`UNDEFINED` is comparable with any integral value (signed or
20-
unsigned) or constant via ``==`` and ``!=`` but not via ``<`` or ``>``.
20+
.. autoclass:: NegativeInfinity
2121

22+
.. autoclass:: PositiveInfinity
2223

23-
.. autodata:: POSITIVE_INFINITY
24+
.. autoclass:: Undefined
2425

25-
This variable of type :class:`_libsemigroups_pybind11.PositiveInfinity`
26-
represents :math:`\infty`. :any:`POSITIVE_INFINITY` is comparable via
27-
``==``, ``!=``, ``<``, ``>`` with any integral value (signed or
28-
unsigned) and with :any:`NEGATIVE_INFINITY`, and is comparable to any
29-
other constant via ``==`` and ``!=``, but not by ``<`` and ``>``.
26+
Constant values
27+
---------------
3028

29+
.. py:data:: LIMIT_MAX
3130
32-
.. autodata:: LIMIT_MAX
31+
This value represents the maximum value that certain function parameters
32+
can have. This value has type :any:`LimitMax`.
3333

34-
This variable represents the maximum value that certain function
35-
parameters can have. :any:`LIMIT_MAX` is comparable via ``==``, ``!=``,
36-
``<``, ``>`` with any integral value (signed or unsigned), and is
37-
comparable to any other constant via ``==`` and ``!=``, but not by ``<``
38-
and ``>``.
34+
:any:`LIMIT_MAX` is comparable via ``==``, ``!=``, ``<``, ``>``
35+
with any integral value, and is comparable to any other constant via ``==``
36+
and ``!=``, but not by ``<`` and ``>``.
3937

38+
.. py:data:: NEGATIVE_INFINITY
39+
:value: -∞
4040

41-
.. autodata:: NEGATIVE_INFINITY
41+
This value represents :math:`-\infty` and has type :any:`NegativeInfinity`.
4242

43-
This variable represents :math:`-\infty`. :any:`NEGATIVE_INFINITY` is
44-
comparable via ``==``, ``!=``, ``<``, ``>`` with any signed integral
45-
value and with :any:`POSITIVE_INFINITY`, and is comparable to any other
46-
constant via ``==`` and ``!=``.
43+
:any:`NEGATIVE_INFINITY` is comparable via ``==``, ``!=``, ``<``, ``>``
44+
with any integer and with :any:`POSITIVE_INFINITY`, and is comparable to
45+
any other constant via ``==`` and ``!=``.
46+
47+
.. py:data:: POSITIVE_INFINITY
48+
:value: +∞
49+
50+
This value represents :math:`+\infty` and has type :any:`PositiveInfinity`.
51+
52+
:any:`POSITIVE_INFINITY` is comparable via ``==``, ``!=``, ``<``, ``>``
53+
with any integral and with :any:`NEGATIVE_INFINITY`, and is comparable to
54+
any other constant via ``==`` and ``!=``, but not by ``<`` and ``>``.
55+
56+
.. py:data:: UNDEFINED
57+
58+
This value is used to indicate that a value is undefined and is of type
59+
:any:`Undefined`.
60+
61+
This value is comparable with other constants via ``==`` and ``!=``, and to
62+
itself by ``<`` and ``>`` but is not comparable to any other types using
63+
``<`` or ``>``.

src/constants.cpp

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,23 @@ namespace libsemigroups {
3333
// Undefined
3434
////////////////////////////////////////////////////////////////////////
3535

36-
py::class_<Undefined>(m, "Undefined")
36+
py::class_<Undefined>(m, "Undefined", R"pbdoc(
37+
The type of :any:`UNDEFINED`.
38+
39+
This class is the type of the constant value :any:`UNDEFINED`, and appears as
40+
such in type annotations in ``libsemigroups_pybind11``.
41+
)pbdoc")
3742
.def("__repr__",
3843
[](Undefined const& val) -> std::string { return "UNDEFINED"; })
3944
.def(py::self < Undefined())
45+
// TODO doesn't yet exist .def(py::self <= Undefined())
4046
.def(
4147
"__eq__",
4248
[](Undefined const& lhop, Undefined const& rhop) -> bool {
4349
return true;
4450
},
4551
py::is_operator())
46-
.def("__hash__", [](Undefined const& op) -> int {
52+
.def("__hash__", [](Undefined const& op) {
4753
return std::hash<uint64_t>{}(static_cast<uint64_t>(op));
4854
});
4955

@@ -53,15 +59,26 @@ namespace libsemigroups {
5359
// PositiveInfinity
5460
////////////////////////////////////////////////////////////////////////
5561

56-
py::class_<PositiveInfinity>(m, "PositiveInfinity")
62+
py::class_<PositiveInfinity>(m,
63+
"PositiveInfinity",
64+
R"pbdoc(
65+
The type of :any:`POSITIVE_INFINITY`.
66+
67+
This class is the type of the constant value :any:`POSITIVE_INFINITY`, and appears as
68+
such in type annotations in ``libsemigroups_pybind11``.
69+
)pbdoc")
5770
.def("__repr__",
5871
[](PositiveInfinity const& val) -> std::string {
5972
return u8"+\u221E";
6073
})
6174
.def(pybind11::self < PositiveInfinity())
75+
// .def(pybind11::self <= PositiveInfinity())
6276
.def(pybind11::self < NegativeInfinity())
77+
// .def(pybind11::self <= NegativeInfinity()) TODO not implemented
6378
.def(pybind11::self < int())
79+
// .def(pybind11::self <= int()) TODO not implemented
6480
.def(int() < pybind11::self)
81+
// .def(int() <= pybind11::self) TODO not implemented
6582
.def(
6683
"__eq__",
6784
[](PositiveInfinity const& lhop,
@@ -82,7 +99,14 @@ namespace libsemigroups {
8299
// NegativeInfinity
83100
////////////////////////////////////////////////////////////////////////
84101

85-
py::class_<NegativeInfinity>(m, "NegativeInfinity")
102+
py::class_<NegativeInfinity>(m,
103+
"NegativeInfinity",
104+
R"pbdoc(
105+
The type of :any:`NEGATIVE_INFINITY`.
106+
107+
This class is the type of the constant value :any:`NEGATIVE_INFINITY`, and appears as
108+
such in type annotations in ``libsemigroups_pybind11``.
109+
)pbdoc")
86110
.def("__repr__",
87111
[](NegativeInfinity const& val) -> std::string {
88112
return u8"-\u221E";
@@ -106,7 +130,14 @@ namespace libsemigroups {
106130
// LimitMax
107131
////////////////////////////////////////////////////////////////////////
108132

109-
py::class_<LimitMax>(m, "LimitMax")
133+
py::class_<LimitMax>(m,
134+
"LimitMax",
135+
R"pbdoc(
136+
The type of :any:`LIMIT_MAX`.
137+
138+
This class is the type of the constant value :any:`LIMIT_MAX`, and appears as
139+
such in type annotations in ``libsemigroups_pybind11``.
140+
)pbdoc")
110141
.def("__repr__",
111142
[](LimitMax const& val) -> std::string { return "LIMIT_MAX"; })
112143
.def(pybind11::self < LimitMax())

src/libsemigroups_pybind11/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,22 @@
6060
Joiner,
6161
LIMIT_MAX,
6262
LibsemigroupsError,
63+
LimitMax,
6364
Meeter,
6465
NEGATIVE_INFINITY,
66+
NegativeInfinity,
6567
Order,
6668
PBR,
6769
POSITIVE_INFINITY,
6870
Paths,
71+
PositiveInfinity,
6972
ReportGuard,
7073
StringRange,
7174
ToString,
7275
ToWord,
7376
UNDEFINED,
7477
Ukkonen,
78+
Undefined,
7579
WordGraph,
7680
WordRange,
7781
congruence_kind,

0 commit comments

Comments
 (0)