You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 30, 2023. It is now read-only.
Internal function for use error messages when constructing encoders and decoders.
18
+
19
+
EXAMPLES::
20
+
21
+
sage: from sage.coding.linear_code import _explain_constructor, LinearCodeSyndromeDecoder
22
+
sage: cl = LinearCodeSyndromeDecoder
23
+
sage: _explain_constructor(cl)
24
+
"The constructor requires no arguments.\nIt takes the optional arguments ['maximum_error_weight'].\nSee the documentation of sage.coding.linear_code.LinearCodeSyndromeDecoder for more details."
25
+
26
+
sage: from sage.coding.information_set_decoder import LinearCodeInformationSetDecoder
27
+
sage: cl = LinearCodeInformationSetDecoder
28
+
sage: _explain_constructor(cl)
29
+
"The constructor requires the arguments ['number_errors'].\nIt takes the optional arguments ['algorithm'].\nIt accepts unspecified arguments as well.\nSee the documentation of sage.coding.information_set_decoder.LinearCodeInformationSetDecoder for more details."
30
+
"""
31
+
ifinspect.isclass(cl):
32
+
argspec=sage_getargspec(cl.__init__)
33
+
skip=2# skip the self and code arguments
34
+
else:
35
+
# Not a class, assume it's a factory function posing as a class
36
+
argspec=sage_getargspec(cl)
37
+
skip=1# skip code argument
38
+
ifargspec.defaults:
39
+
args=argspec.args[skip:-len(argspec.defaults)]
40
+
kwargs=argspec.args[-len(argspec.defaults):]
41
+
opts="It takes the optional arguments {}.".format(kwargs)
42
+
else:
43
+
args=argspec.args[skip:]
44
+
opts="It takes no optional arguments."
45
+
ifargs:
46
+
reqs="The constructor requires the arguments {}.".format(args)
47
+
else:
48
+
reqs="The constructor requires no arguments."
49
+
ifargspec.varargsorargspec.keywords:
50
+
var="It accepts unspecified arguments as well.\n"
51
+
else:
52
+
var=""
53
+
return("{}\n{}\n{}See the documentation of {}.{} for more details."\
54
+
.format(reqs, opts, var, cl.__module__, cl.__name__))
0 commit comments