Skip to content

Commit f1eb359

Browse files
Lowercase kwargs everywhere
1 parent 5221b2c commit f1eb359

19 files changed

Lines changed: 158 additions & 146 deletions

File tree

docs/pictures/to-table.tex

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,39 @@
1010
\begin{document}
1111

1212
\begin{tabular}{l|c|c|c|c|c|c|c|c|c|c|c}
13-
&
14-
\rotatebox{90}{\texttt{Congruence}} &
15-
\rotatebox{90}{\texttt{FroidurePin}} &
16-
\rotatebox{90}{\texttt{InversePresentation}} &
17-
\rotatebox{90}{\texttt{Kambites}} &
18-
\rotatebox{90}{\texttt{KnuthBendix}} &
19-
\rotatebox{90}{\texttt{Konieczny}} &
20-
\rotatebox{90}{\texttt{Presentation}} &
21-
\rotatebox{90}{\texttt{SchreierSims}} &
22-
\rotatebox{90}{\texttt{Stephen}} &
23-
\rotatebox{90}{\texttt{ToddCoxeter}}
24-
\\
25-
\midrule
26-
\texttt{to(*args, Return=Congruence)} & \xmark & \cmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark \\\hline
27-
\texttt{to(*args, Return=FroidurePin)} & \cmark & \xmark & \xmark & \cmark & \cmark & \xmark & \xmark & \xmark & \xmark & \cmark \\\hline
28-
\texttt{to(*args, Return=InversePresentation)} & \xmark & \xmark & \cmark & \xmark & \xmark & \xmark & \cmark & \xmark & \xmark & \xmark \\\hline
29-
\texttt{to(*args, Return=Kambites)} & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark \\\hline
30-
\texttt{to(*args, Return=KnuthBendix)} & \xmark & \cmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \cmark \\\hline
31-
\texttt{to(*args, Return=Konieczny)} & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark \\\hline
32-
\texttt{to(*args, Return=Presentation)} & \xmark & \cmark & \xmark & \xmark & \cmark & \xmark & \cmark & \xmark & \xmark & \xmark \\\hline
33-
\texttt{to(*args, Return=SchreierSims)} & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark \\\hline
34-
\texttt{to(*args, Return=Stephen)} & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark \\\hline
35-
\texttt{to(*args, Return=ToddCoxeter)} & \xmark & \cmark & \xmark & \xmark & \cmark & \xmark & \xmark & \xmark & \xmark & \xmark \\
13+
&
14+
\rotatebox{90}{\texttt{Congruence}} &
15+
\rotatebox{90}{\texttt{FroidurePin}} &
16+
\rotatebox{90}{\texttt{InversePresentation}} &
17+
\rotatebox{90}{\texttt{Kambites}} &
18+
\rotatebox{90}{\texttt{KnuthBendix}} &
19+
\rotatebox{90}{\texttt{Konieczny}} &
20+
\rotatebox{90}{\texttt{Presentation}} &
21+
\rotatebox{90}{\texttt{SchreierSims}} &
22+
\rotatebox{90}{\texttt{Stephen}} &
23+
\rotatebox{90}{\texttt{ToddCoxeter}}
24+
\\
25+
\midrule
26+
\texttt{to(*args, rtype=Congruence)} & \xmark & \cmark &
27+
\xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark \\\hline
28+
\texttt{to(*args, rtype=FroidurePin)} & \cmark & \xmark &
29+
\xmark & \cmark & \cmark & \xmark & \xmark & \xmark & \xmark & \cmark \\\hline
30+
\texttt{to(*args, rtype=InversePresentation)} & \xmark & \xmark &
31+
\cmark & \xmark & \xmark & \xmark & \cmark & \xmark & \xmark & \xmark \\\hline
32+
\texttt{to(*args, rtype=Kambites)} & \xmark & \xmark &
33+
\xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark \\\hline
34+
\texttt{to(*args, rtype=KnuthBendix)} & \xmark & \cmark &
35+
\xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \cmark \\\hline
36+
\texttt{to(*args, rtype=Konieczny)} & \xmark & \xmark &
37+
\xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark \\\hline
38+
\texttt{to(*args, rtype=Presentation)} & \xmark & \cmark &
39+
\xmark & \xmark & \cmark & \xmark & \cmark & \xmark & \xmark & \xmark \\\hline
40+
\texttt{to(*args, rtype=SchreierSims)} & \xmark & \xmark &
41+
\xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark \\\hline
42+
\texttt{to(*args, rtype=Stephen)} & \xmark & \xmark &
43+
\xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark \\\hline
44+
\texttt{to(*args, rtype=ToddCoxeter)} & \xmark & \cmark &
45+
\xmark & \xmark & \cmark & \xmark & \xmark & \xmark & \xmark & \xmark \\
3646
\end{tabular}
3747
% \cmark = implemented, \xmark = not yet implemented, -
3848
% = not applicable

docs/source/data-structures/presentations/to-inverse-present.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ This function throws a :any:`LibsemigroupsError` if
7373
>>> presentation.add_rule(p, 'aaa', 'b')
7474
>>> presentation.add_rule(p, 'bac', 'cab')
7575

76-
>>> ip = to(p, Return=(InversePresentation,))
76+
>>> ip = to(p, rtype=(InversePresentation,))
7777
>>> ip.alphabet()
7878
'abcdef'
7979
>>> ip.inverses()
@@ -139,10 +139,10 @@ not the same as that specified in *Return* and
139139
>>> presentation.add_rule(ip, 'aaa', 'b')
140140
>>> presentation.add_rule(ip, 'bac', 'cab')
141141

142-
>>> ip == to(ip, Return=(InversePresentation, str))
142+
>>> ip == to(ip, rtype=(InversePresentation, str))
143143
True
144144

145-
>>> iq = to(ip, Return=(InversePresentation, list[int]))
145+
>>> iq = to(ip, rtype=(InversePresentation, list[int]))
146146
>>> iq.alphabet()
147147
[0, 1, 2]
148148
>>> iq.inverses()
@@ -204,7 +204,7 @@ type of word specified in *Return*.
204204
>>> iq = to(
205205
... ip, # ip
206206
... lambda x: chr(ord(x) + 11), # f
207-
... Return=(InversePresentation, str)
207+
... rtype=(InversePresentation, str)
208208
... )
209209
>>> iq.alphabet()
210210
'lmn'

docs/source/data-structures/presentations/to-present.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,16 @@ not the same as that specified in *Return*, and
8787
>>> p.rules
8888
['ae', 'e', 'ea', 'e', 'be', 'e', 'eb', 'e', 'ce', 'e', 'ec', 'e', 'de', 'e', 'ed', 'e', 'ee', 'e', 'fe', 'e', 'ef', 'e']
8989

90-
>>> p == to(p, Return=(Presentation, str))
90+
>>> p == to(p, rtype=(Presentation, str))
9191
True
9292

93-
>>> q = to(p, Return=(Presentation, list[int]))
93+
>>> q = to(p, rtype=(Presentation, list[int]))
9494
>>> q.alphabet()
9595
[0, 1, 2, 3, 4, 5]
9696
>>> q.rules
9797
[[0, 4], [4], [4, 0], [4], [1, 4], [4], [4, 1], [4], [2, 4], [4], [4, 2], [4], [3, 4], [4], [4, 3], [4], [4, 4], [4], [5, 4], [4], [4, 5], [4]]
9898

99-
>>> p == to(q, Return=(Presentation, str))
99+
>>> p == to(q, rtype=(Presentation, str))
100100
True
101101

102102
.. _presentation-and-function-to-presentation:
@@ -147,7 +147,7 @@ specified in *Return*.
147147
>>> q = to(
148148
... p, # p
149149
... double, # f
150-
... Return=(Presentation, list[int])
150+
... rtype=(Presentation, list[int])
151151
... )
152152
>>> q.alphabet()
153153
[0, 4, 8, 12]
@@ -205,7 +205,7 @@ enumerates *kb*) prior to calling this function.
205205

206206
>>> kb = KnuthBendix(congruence_kind.twosided, p1)
207207
>>> kb.run()
208-
>>> p2 = to(kb, Return=(Presentation,))
208+
>>> p2 = to(kb, rtype=(Presentation,))
209209
>>> for p in [p1, p2]:
210210
... presentation.sort_each_rule(p)
211211
... presentation.sort_rules(p)
@@ -261,6 +261,6 @@ to calling this function.
261261
>>> b4 = Bipartition([[1, 2], [3, -3], [4, -4], [-1, -2]])
262262
>>> S = FroidurePin(b1, b2, b3, b4)
263263

264-
>>> p = to(S, Return=(Presentation, str))
264+
>>> p = to(S, rtype=(Presentation, str))
265265
>>> len(p.alphabet()) == 4
266266
True

docs/source/data-structures/to-function.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ This page contains links to the documentation of the uses of the function
1515
to another type. These mostly only apply to the types implementing the main
1616
algorithms in ``libsemigroups_pybind11``.
1717

18-
For example, to convert a :any:`ToddCoxeter` ``tc`` object to a
19-
:any:`FroidurePin` object, you can simply do ``to(tc, Return=(FroidurePin,))``.
18+
For example, to convert a :any:`ToddCoxeter` object ``tc`` to a
19+
:any:`FroidurePin` object, you can simply do ``to(tc, rtype=(FroidurePin,))``.
2020

2121
A summary of the possible conversions available in ``libsemigroups_pybind11`` of
22-
``to(FromType, Return=(ToType,))`` are given below, where the rows correspond to
22+
``to(FromType, rtype=(ToType,))`` are given below, where the rows correspond to
2323
``ToType`` and the columns to ``FromType``:
2424

2525
.. image:: ../../pictures/to-table.svg

docs/source/main-algorithms/congruence/to-cong.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ This will throw a :any:`LibsemigroupsError` if *wg* is not the
8181
... congruence_kind.twosided, # knd
8282
... S, # fpb
8383
... S.right_cayley_graph(), # wg
84-
... Return=(Congruence, str),
84+
... rtype=(Congruence, str),
8585
... )
8686

8787
>>> cong.run()

docs/source/main-algorithms/froidure-pin/to-froidure-pin.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ This function throws a :any:`LibsemigroupsError` if ``cong.kind`` is not
7272
>>> presentation.add_rule(p, [1, 1], [1])
7373

7474
>>> cong = Congruence(congruence_kind.twosided, p)
75-
>>> fp = to(cong, Return=(FroidurePin,))
75+
>>> fp = to(cong, rtype=(FroidurePin,))
7676
>>> fp.run()
7777

7878
>>> fp.size() == cong.number_of_classes()
@@ -121,7 +121,7 @@ This function throws a :any:`LibsemigroupsError` if the
121121
>>> presentation.add_rule(p, 'ef', 'dg')
122122

123123
>>> k = Kambites(congruence_kind.twosided, p)
124-
>>> fp = to(k, Return=(FroidurePin,))
124+
>>> fp = to(k, rtype=(FroidurePin,))
125125
>>> fp.enumerate(100)
126126

127127
>>> fp.current_size() == 8205
@@ -165,7 +165,7 @@ This function throws a :any:`LibsemigroupsError` if ``kb.kind()`` is not
165165
>>> presentation.add_rule(p, [1, 1], [1])
166166

167167
>>> kb = KnuthBendix(congruence_kind.twosided, p)
168-
>>> fp = to(kb, Return=(FroidurePin,))
168+
>>> fp = to(kb, rtype=(FroidurePin,))
169169
>>> fp.run()
170170

171171
>>> fp.size() == kb.number_of_classes()
@@ -209,7 +209,7 @@ This function throws a :any:`LibsemigroupsError` if ``tc.kind()`` is not
209209
>>> presentation.add_rule(p, [1, 1], [1])
210210

211211
>>> tc = ToddCoxeter(congruence_kind.twosided, p)
212-
>>> fp = to(tc, Return=(FroidurePin,))
212+
>>> fp = to(tc, rtype=(FroidurePin,))
213213
>>> fp.run()
214214

215215
>>> fp.size() == tc.number_of_classes()
@@ -286,7 +286,7 @@ corresponding :math:`f`.
286286
... w, # wg
287287
... 1, # first
288288
... 2, # last
289-
... Return=(FroidurePin,)
289+
... rtype=(FroidurePin,)
290290
... )
291291
>>> fp.run()
292292

docs/source/main-algorithms/knuth-bendix/to-knuth-bendix.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ the semigroup defined by *tc*.
7777
>>> kb = to(
7878
... congruence_kind.twosided, # knd
7979
... tc, # tc
80-
... Return=(KnuthBendix,)
80+
... rtype=(KnuthBendix,)
8181
... )
8282
>>> kb.run()
8383

@@ -132,7 +132,7 @@ the semigroup defined by *tc*.
132132
>>> kb = to(
133133
... congruence_kind.twosided, # knd
134134
... tc, # tc
135-
... Return=(KnuthBendix, 'RewriteFromLeft')
135+
... rtype=(KnuthBendix, 'RewriteFromLeft')
136136
... )
137137
>>> kb.run()
138138

@@ -169,7 +169,7 @@ Additionally, specify one of the following for *Return*:
169169

170170
This function converts a :any:`FroidurePin` object *fpb* to a :any:`KnuthBendix`
171171
object with the word type and rewriter as specified above. This is done using
172-
the presentation obtained from ``to(fpb, Return=(Presentation, Word)`` where
172+
the presentation obtained from ``to(fpb, rtype=(Presentation, Word)`` where
173173
``Word`` is either ``str`` or ``list[int]``.
174174

175175
This returned :any:`KnuthBendix` object represents the trivial congruence over
@@ -196,7 +196,7 @@ the semigroup defined by *fpb*.
196196
>>> kb = to(
197197
... congruence_kind.twosided, # knd
198198
... S, # tc
199-
... Return=(KnuthBendix, list[int], 'RewriteFromLeft')
199+
... rtype=(KnuthBendix, list[int], 'RewriteFromLeft')
200200
... )
201201
>>> kb.run()
202202

docs/source/main-algorithms/todd-coxeter/to-todd-coxeter.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ This will throw a :any:`LibsemigroupsError` if *wg* is not the
8383
... congruence_kind.twosided, # knd
8484
... S, # fpb
8585
... S.right_cayley_graph(), # wg
86-
... Return=(ToddCoxeter, str),
86+
... rtype=(ToddCoxeter, str),
8787
... )
8888

8989
>>> tc.run()
@@ -141,7 +141,7 @@ This will throw a :any:`LibsemigroupsError` if either:
141141
>>> tc = to(
142142
... congruence_kind.twosided, # knd
143143
... kb, # kb
144-
... Return=(ToddCoxeter,)
144+
... rtype=(ToddCoxeter,)
145145
... )
146146
>>> tc.run()
147147

src/libsemigroups_pybind11/detail/congruence_common.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(self: Self, *args, wrong_num_args_msg="", **kwargs) -> None:
3232
# super().__init__ checks if there are unexpected kwargs, sets up
3333
# _cxx_type_to_py_template_params, and sets _cxx_obj if
3434
# the unique argument is a cxx_obj of type in _all_wrapped_cxx_types
35-
super().__init__(*args, optional_kwargs="Word")
35+
super().__init__(*args, optional_kwargs=("word",), **kwargs)
3636
if _to_cxx(self) is not None:
3737
# constructed from args[0] of type belonging to _all_wrapped_cxx_types
3838
return
@@ -44,17 +44,17 @@ def __init__(self: Self, *args, wrong_num_args_msg="", **kwargs) -> None:
4444
if len(args) != 0 and len(kwargs) != 0:
4545
if len(wrong_num_args_msg) == 0:
4646
wrong_num_args_msg = (
47-
'expected 2 positional arguments or 1 keyword arguments ("Word") '
47+
'expected 2 positional arguments or 1 keyword arguments ("word",) '
4848
f"but found {len(args)} and {len(kwargs)}"
4949
)
5050
raise TypeError(wrong_num_args_msg)
5151
if len(args) == 0:
52-
if kwargs["Word"] not in (str, list[int]):
52+
if kwargs["word"] not in (str, list[int]):
5353
raise ValueError(
54-
'expected the keyword argument "Word" to be "str" or "list[int]" '
55-
f"but found {kwargs['Word']}"
54+
'expected the keyword argument "word" to be "str" or "list[int]" '
55+
f"but found {kwargs['word']}"
5656
)
57-
self.py_template_params = (kwargs["Word"],)
57+
self.py_template_params = (kwargs["word"],)
5858
elif not isinstance(args[0], _congruence_kind):
5959
raise TypeError(
6060
f"expected the 1st argument to be congruence_kind but found {type(args[0])}"

src/libsemigroups_pybind11/knuth_bendix.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class KnuthBendix(_CongruenceCommon): # pylint: disable=missing-class-docstring
5252
__doc__ = _KnuthBendixStringRewriteTrie.__doc__
5353

5454
_py_template_params_to_cxx_type = {
55+
(list[int],): _KnuthBendixWordRewriteTrie,
56+
(str,): _KnuthBendixStringRewriteTrie,
5557
(list[int], "RewriteTrie"): _KnuthBendixWordRewriteTrie,
5658
(str, "RewriteTrie"): _KnuthBendixStringRewriteTrie,
5759
(list[int], "RewriteFromLeft"): _KnuthBendixWordRewriteFromLeft,
@@ -70,17 +72,17 @@ class KnuthBendix(_CongruenceCommon): # pylint: disable=missing-class-docstring
7072
options = _KnuthBendixStringRewriteTrie.options
7173

7274
@_copydoc(_KnuthBendixStringRewriteTrie.__init__)
73-
def __init__(self, *args, Rewriter="RewriteTrie", **kwargs) -> None:
74-
if Rewriter not in ("RewriteFromLeft", "RewriteTrie"):
75+
def __init__(self, *args, rewriter="RewriteTrie", **kwargs) -> None:
76+
if rewriter not in ("RewriteFromLeft", "RewriteTrie"):
7577
raise TypeError(
76-
f'expected the keyword argument "Rewriter" to be '
77-
f'"RewriteFromLeft" or "RewriteTrie", but found "{Rewriter}"'
78+
f'expected the keyword argument "rewriter" to be '
79+
f'"RewriteFromLeft" or "RewriteTrie", but found "{rewriter}"'
7880
)
7981

8082
msg = f"""expected either:
8183
1) 2 positional arguments of types congruence_kind and Presentation; or
82-
2) 0 positional arguments and the keyword argument "Word"
83-
(and possibly the keyword argument "Rewriter").
84+
2) 0 positional arguments and the keyword argument "word"
85+
(and possibly the keyword argument "rewriter").
8486
Found {len(args)} positional arguments and keyword arguments
8587
{list(kwargs.keys())}!"""
8688

@@ -90,7 +92,7 @@ def __init__(self, *args, Rewriter="RewriteTrie", **kwargs) -> None:
9092
if len(args) == 2:
9193
if isinstance(args[1], _Presentation):
9294
self.py_template_params = args[1].py_template_params + (
93-
Rewriter,
95+
rewriter,
9496
)
9597
else:
9698
raise TypeError(

0 commit comments

Comments
 (0)