Skip to content

Commit

Permalink
private docstrings for builtin.atoms to pytests
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatera committed Aug 14, 2023
1 parent 1c8c249 commit 95bf435
Show file tree
Hide file tree
Showing 6 changed files with 280 additions and 202 deletions.
83 changes: 0 additions & 83 deletions mathics/builtin/atomic/numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,6 @@ class IntegerLength(Builtin):
'0' is a special case:
>> IntegerLength[0]
= 0
#> IntegerLength /@ (10 ^ Range[100] - 1) == Range[1, 100]
= True
"""

attributes = A_LISTABLE | A_PROTECTED
Expand Down Expand Up @@ -414,39 +411,9 @@ class RealDigits(Builtin):
>> RealDigits[123.45, 10, 18]
= {{1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Indeterminate, Indeterminate}, 3}
#> RealDigits[-1.25, -1]
: Base -1 is not a real number greater than 1.
= RealDigits[-1.25, -1]
Return 25 digits of in base 10:
>> RealDigits[Pi, 10, 25]
= {{3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3}, 1}
#> RealDigits[-Pi]
: The number of digits to return cannot be determined.
= RealDigits[-Pi]
#> RealDigits[I, 7]
: The value I is not a real number.
= RealDigits[I, 7]
#> RealDigits[Pi]
: The number of digits to return cannot be determined.
= RealDigits[Pi]
#> RealDigits[3 + 4 I]
: The value 3 + 4 I is not a real number.
= RealDigits[3 + 4 I]
#> RealDigits[3.14, 10, 1.5]
: Non-negative machine-sized integer expected at position 3 in RealDigits[3.14, 10, 1.5].
= RealDigits[3.14, 10, 1.5]
#> RealDigits[3.14, 10, 1, 1.5]
: Machine-sized integer expected at position 4 in RealDigits[3.14, 10, 1, 1.5].
= RealDigits[3.14, 10, 1, 1.5]
"""

attributes = A_LISTABLE | A_PROTECTED
Expand Down Expand Up @@ -662,28 +629,6 @@ class MaxPrecision(Predefined):
>> N[Pi, 11]
: Requested precision 11 is larger than $MaxPrecision. Using current $MaxPrecision of 10. instead. $MaxPrecision = Infinity specifies that any precision should be allowed.
= 3.141592654
#> N[Pi, 10]
= 3.141592654
#> $MaxPrecision = x
: Cannot set $MaxPrecision to x; value must be a positive number or Infinity.
= x
#> $MaxPrecision = -Infinity
: Cannot set $MaxPrecision to -Infinity; value must be a positive number or Infinity.
= -Infinity
#> $MaxPrecision = 0
: Cannot set $MaxPrecision to 0; value must be a positive number or Infinity.
= 0
#> $MaxPrecision = Infinity;
#> $MinPrecision = 15;
#> $MaxPrecision = 10
: Cannot set $MaxPrecision such that $MaxPrecision < $MinPrecision.
= 10
#> $MaxPrecision
= Infinity
#> $MinPrecision = 0;
"""

is_numeric = False
Expand Down Expand Up @@ -765,12 +710,6 @@ class MachinePrecision(Predefined):
= 15.9546
>> N[MachinePrecision, 30]
= 15.9545897701910033463281614204
#> N[E, MachinePrecision]
= 2.71828
#> Round[MachinePrecision]
= 16
"""

is_numeric = True
Expand Down Expand Up @@ -802,28 +741,6 @@ class MinPrecision(Builtin):
>> N[Pi, 9]
: Requested precision 9 is smaller than $MinPrecision. Using current $MinPrecision of 10. instead.
= 3.141592654
#> N[Pi, 10]
= 3.141592654
#> $MinPrecision = x
: Cannot set $MinPrecision to x; value must be a non-negative number.
= x
#> $MinPrecision = -Infinity
: Cannot set $MinPrecision to -Infinity; value must be a non-negative number.
= -Infinity
#> $MinPrecision = -1
: Cannot set $MinPrecision to -1; value must be a non-negative number.
= -1
#> $MinPrecision = 0;
#> $MaxPrecision = 10;
#> $MinPrecision = 15
: Cannot set $MinPrecision such that $MaxPrecision < $MinPrecision.
= 15
#> $MinPrecision
= 0
#> $MaxPrecision = Infinity;
"""

messages = {
Expand Down
72 changes: 0 additions & 72 deletions mathics/builtin/atomic/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,6 @@ class LetterNumber(Builtin):
>> LetterNumber[{"P", "Pe", "P1", "eck"}]
= {16, {16, 5}, {16, 0}, {5, 3, 11}}
#> LetterNumber[4]
: The argument 4 is not a string.
= LetterNumber[4]
>> LetterNumber["\[Beta]", "Greek"]
= 2
Expand Down Expand Up @@ -720,63 +716,12 @@ class StringContainsQ(Builtin):
>> StringContainsQ["mathics", "a" ~~ __ ~~ "m"]
= False
#> StringContainsQ["Hello", "o"]
= True
#> StringContainsQ["a"]["abcd"]
= True
#> StringContainsQ["Mathics", "ma", IgnoreCase -> False]
= False
>> StringContainsQ["Mathics", "MA" , IgnoreCase -> True]
= True
#> StringContainsQ["", "Empty String"]
= False
#> StringContainsQ["", ___]
= True
#> StringContainsQ["Empty Pattern", ""]
= True
#> StringContainsQ[notastring, "n"]
: String or list of strings expected at position 1 in StringContainsQ[notastring, n].
= StringContainsQ[notastring, n]
#> StringContainsQ["Welcome", notapattern]
: Element notapattern is not a valid string or pattern element in notapattern.
= StringContainsQ[Welcome, notapattern]
>> StringContainsQ[{"g", "a", "laxy", "universe", "sun"}, "u"]
= {False, False, False, True, True}
#> StringContainsQ[{}, "list of string is empty"]
= {}
>> StringContainsQ["e" ~~ ___ ~~ "u"] /@ {"The Sun", "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"}
= {True, True, True, False, False, False, False, False, True}
## special cases, Mathematica allows list of patterns
#> StringContainsQ[{"A", "Galaxy", "Far", "Far", "Away"}, {"F" ~~ __ ~~ "r", "aw" ~~ ___}]
= {False, False, True, True, False}
#> StringContainsQ[{"A", "Galaxy", "Far", "Far", "Away"}, {"F" ~~ __ ~~ "r", "aw" ~~ ___}, IgnoreCase -> True]
= {False, False, True, True, True}
#> StringContainsQ[{"A", "Galaxy", "Far", "Far", "Away"}, {}]
= {False, False, False, False, False}
#> StringContainsQ[{"A", Galaxy, "Far", "Far", Away}, {"F" ~~ __ ~~ "r", "aw" ~~ ___}]
: String or list of strings expected at position 1 in StringContainsQ[{A, Galaxy, Far, Far, Away}, {F ~~ __ ~~ r, aw ~~ ___}].
= StringContainsQ[{A, Galaxy, Far, Far, Away}, {F ~~ __ ~~ r, aw ~~ ___}]
#> StringContainsQ[{"A", "Galaxy", "Far", "Far", "Away"}, {F ~~ __ ~~ "r", aw ~~ ___}]
: Element F ~~ __ ~~ r is not a valid string or pattern element in {F ~~ __ ~~ r, aw ~~ ___}.
= StringContainsQ[{A, Galaxy, Far, Far, Away}, {F ~~ __ ~~ r, aw ~~ ___}]
## Mathematica can detemine correct invalid element in the pattern, it reports error:
## Element F is not a valid string or pattern element in {F ~~ __ ~~ r, aw ~~ ___}.
"""

messages = {
Expand Down Expand Up @@ -843,10 +788,6 @@ class StringRepeat(Builtin):
>> StringRepeat["abc", 10, 7]
= abcabca
#> StringRepeat["x", 0]
: A positive integer is expected at position 2 in StringRepeat[x, 0].
= StringRepeat[x, 0]
"""

messages = {
Expand Down Expand Up @@ -937,17 +878,6 @@ class ToExpression(Builtin):
second-line value.
>> ToExpression["2\[NewLine]3"]
= 3
#> ToExpression["log(x)", InputForm]
= log x
#> ToExpression["1+"]
: Incomplete expression; more input is needed (line 1 of "ToExpression['1+']").
= $Failed
#> ToExpression[]
: ToExpression called with 0 arguments; between 1 and 3 arguments are expected.
= ToExpression[]
"""

# TODO: Other forms
Expand All @@ -956,8 +886,6 @@ class ToExpression(Builtin):
= Log[x]
>> ToExpression["log(x)", TraditionalForm]
= Log[x]
#> ToExpression["log(x)", StandardForm]
= log x
"""
attributes = A_LISTABLE | A_PROTECTED

Expand Down
46 changes: 0 additions & 46 deletions mathics/builtin/atomic/symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,6 @@ class Context(Builtin):
>> InputForm[Context[]]
= "Global`"
## placeholder for general context-related tests
#> x === Global`x
= True
#> `x === Global`x
= True
#> a`x === Global`x
= False
#> a`x === a`x
= True
#> a`x === b`x
= False
## awkward parser cases
#> FullForm[a`b_]
= Pattern[a`b, Blank[]]
"""

attributes = A_HOLD_FIRST | A_PROTECTED
Expand Down Expand Up @@ -431,25 +416,6 @@ class Information(PrefixOperator):
'Information' does not print information for 'ReadProtected' symbols.
'Information' uses 'InputForm' to format values.
#> a = 2;
#> Information[a]
| a = 2
.
= Null
#> f[x_] := x ^ 2;
#> g[f] ^:= 2;
#> f::usage = "f[x] returns the square of x";
#> Information[f]
| f[x] returns the square of x
.
. f[x_] = x ^ 2
.
. g[f] ^= 2
.
= Null
"""

attributes = A_HOLD_ALL | A_SEQUENCE_HOLD | A_PROTECTED | A_READ_PROTECTED
Expand Down Expand Up @@ -620,9 +586,6 @@ class Names(Builtin):
The number of built-in symbols:
>> Length[Names["System`*"]]
= ...
#> Length[Names["System`*"]] > 350
= True
"""

summary_text = "find a list of symbols with names matching a pattern"
Expand Down Expand Up @@ -695,9 +658,6 @@ class Symbol_(Builtin):
You can use 'Symbol' to create symbols from strings:
>> Symbol["x"] + Symbol["x"]
= 2 x
#> {\\[Eta], \\[CapitalGamma]\\[Beta], Z\\[Infinity], \\[Angle]XYZ, \\[FilledSquare]r, i\\[Ellipsis]j}
= {\u03b7, \u0393\u03b2, Z\u221e, \u2220XYZ, \u25a0r, i\u2026j}
"""

attributes = A_LOCKED | A_PROTECTED
Expand Down Expand Up @@ -735,9 +695,6 @@ class SymbolName(Builtin):
>> SymbolName[x] // InputForm
= "x"
#> SymbolName[a`b`x] // InputForm
= "x"
"""

summary_text = "give the name of a symbol as a string"
Expand Down Expand Up @@ -785,9 +742,6 @@ class ValueQ(Builtin):
>> x = 1;
>> ValueQ[x]
= True
#> ValueQ[True]
= False
"""

attributes = A_HOLD_FIRST | A_PROTECTED
Expand Down
Loading

0 comments on commit 95bf435

Please sign in to comment.