Skip to content

Commit 95bf435

Browse files
committed
private docstrings for builtin.atoms to pytests
1 parent 1c8c249 commit 95bf435

File tree

6 files changed

+280
-202
lines changed

6 files changed

+280
-202
lines changed

mathics/builtin/atomic/numbers.py

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,6 @@ class IntegerLength(Builtin):
320320
'0' is a special case:
321321
>> IntegerLength[0]
322322
= 0
323-
324-
#> IntegerLength /@ (10 ^ Range[100] - 1) == Range[1, 100]
325-
= True
326323
"""
327324

328325
attributes = A_LISTABLE | A_PROTECTED
@@ -414,39 +411,9 @@ class RealDigits(Builtin):
414411
>> RealDigits[123.45, 10, 18]
415412
= {{1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Indeterminate, Indeterminate}, 3}
416413
417-
#> RealDigits[-1.25, -1]
418-
: Base -1 is not a real number greater than 1.
419-
= RealDigits[-1.25, -1]
420-
421414
Return 25 digits of in base 10:
422415
>> RealDigits[Pi, 10, 25]
423416
= {{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}
424-
425-
#> RealDigits[-Pi]
426-
: The number of digits to return cannot be determined.
427-
= RealDigits[-Pi]
428-
429-
#> RealDigits[I, 7]
430-
: The value I is not a real number.
431-
= RealDigits[I, 7]
432-
433-
#> RealDigits[Pi]
434-
: The number of digits to return cannot be determined.
435-
= RealDigits[Pi]
436-
437-
#> RealDigits[3 + 4 I]
438-
: The value 3 + 4 I is not a real number.
439-
= RealDigits[3 + 4 I]
440-
441-
442-
#> RealDigits[3.14, 10, 1.5]
443-
: Non-negative machine-sized integer expected at position 3 in RealDigits[3.14, 10, 1.5].
444-
= RealDigits[3.14, 10, 1.5]
445-
446-
#> RealDigits[3.14, 10, 1, 1.5]
447-
: Machine-sized integer expected at position 4 in RealDigits[3.14, 10, 1, 1.5].
448-
= RealDigits[3.14, 10, 1, 1.5]
449-
450417
"""
451418

452419
attributes = A_LISTABLE | A_PROTECTED
@@ -662,28 +629,6 @@ class MaxPrecision(Predefined):
662629
>> N[Pi, 11]
663630
: Requested precision 11 is larger than $MaxPrecision. Using current $MaxPrecision of 10. instead. $MaxPrecision = Infinity specifies that any precision should be allowed.
664631
= 3.141592654
665-
666-
#> N[Pi, 10]
667-
= 3.141592654
668-
669-
#> $MaxPrecision = x
670-
: Cannot set $MaxPrecision to x; value must be a positive number or Infinity.
671-
= x
672-
#> $MaxPrecision = -Infinity
673-
: Cannot set $MaxPrecision to -Infinity; value must be a positive number or Infinity.
674-
= -Infinity
675-
#> $MaxPrecision = 0
676-
: Cannot set $MaxPrecision to 0; value must be a positive number or Infinity.
677-
= 0
678-
#> $MaxPrecision = Infinity;
679-
680-
#> $MinPrecision = 15;
681-
#> $MaxPrecision = 10
682-
: Cannot set $MaxPrecision such that $MaxPrecision < $MinPrecision.
683-
= 10
684-
#> $MaxPrecision
685-
= Infinity
686-
#> $MinPrecision = 0;
687632
"""
688633

689634
is_numeric = False
@@ -765,12 +710,6 @@ class MachinePrecision(Predefined):
765710
= 15.9546
766711
>> N[MachinePrecision, 30]
767712
= 15.9545897701910033463281614204
768-
769-
#> N[E, MachinePrecision]
770-
= 2.71828
771-
772-
#> Round[MachinePrecision]
773-
= 16
774713
"""
775714

776715
is_numeric = True
@@ -802,28 +741,6 @@ class MinPrecision(Builtin):
802741
>> N[Pi, 9]
803742
: Requested precision 9 is smaller than $MinPrecision. Using current $MinPrecision of 10. instead.
804743
= 3.141592654
805-
806-
#> N[Pi, 10]
807-
= 3.141592654
808-
809-
#> $MinPrecision = x
810-
: Cannot set $MinPrecision to x; value must be a non-negative number.
811-
= x
812-
#> $MinPrecision = -Infinity
813-
: Cannot set $MinPrecision to -Infinity; value must be a non-negative number.
814-
= -Infinity
815-
#> $MinPrecision = -1
816-
: Cannot set $MinPrecision to -1; value must be a non-negative number.
817-
= -1
818-
#> $MinPrecision = 0;
819-
820-
#> $MaxPrecision = 10;
821-
#> $MinPrecision = 15
822-
: Cannot set $MinPrecision such that $MaxPrecision < $MinPrecision.
823-
= 15
824-
#> $MinPrecision
825-
= 0
826-
#> $MaxPrecision = Infinity;
827744
"""
828745

829746
messages = {

mathics/builtin/atomic/strings.py

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -439,10 +439,6 @@ class LetterNumber(Builtin):
439439
>> LetterNumber[{"P", "Pe", "P1", "eck"}]
440440
= {16, {16, 5}, {16, 0}, {5, 3, 11}}
441441
442-
#> LetterNumber[4]
443-
: The argument 4 is not a string.
444-
= LetterNumber[4]
445-
446442
>> LetterNumber["\[Beta]", "Greek"]
447443
= 2
448444
@@ -720,63 +716,12 @@ class StringContainsQ(Builtin):
720716
>> StringContainsQ["mathics", "a" ~~ __ ~~ "m"]
721717
= False
722718
723-
#> StringContainsQ["Hello", "o"]
724-
= True
725-
726-
#> StringContainsQ["a"]["abcd"]
727-
= True
728-
729-
#> StringContainsQ["Mathics", "ma", IgnoreCase -> False]
730-
= False
731-
732-
>> StringContainsQ["Mathics", "MA" , IgnoreCase -> True]
733-
= True
734-
735-
#> StringContainsQ["", "Empty String"]
736-
= False
737-
738-
#> StringContainsQ["", ___]
739-
= True
740-
741-
#> StringContainsQ["Empty Pattern", ""]
742-
= True
743-
744-
#> StringContainsQ[notastring, "n"]
745-
: String or list of strings expected at position 1 in StringContainsQ[notastring, n].
746-
= StringContainsQ[notastring, n]
747-
748-
#> StringContainsQ["Welcome", notapattern]
749-
: Element notapattern is not a valid string or pattern element in notapattern.
750-
= StringContainsQ[Welcome, notapattern]
751-
752719
>> StringContainsQ[{"g", "a", "laxy", "universe", "sun"}, "u"]
753720
= {False, False, False, True, True}
754721
755-
#> StringContainsQ[{}, "list of string is empty"]
756-
= {}
757722
758723
>> StringContainsQ["e" ~~ ___ ~~ "u"] /@ {"The Sun", "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"}
759724
= {True, True, True, False, False, False, False, False, True}
760-
761-
## special cases, Mathematica allows list of patterns
762-
#> StringContainsQ[{"A", "Galaxy", "Far", "Far", "Away"}, {"F" ~~ __ ~~ "r", "aw" ~~ ___}]
763-
= {False, False, True, True, False}
764-
765-
#> StringContainsQ[{"A", "Galaxy", "Far", "Far", "Away"}, {"F" ~~ __ ~~ "r", "aw" ~~ ___}, IgnoreCase -> True]
766-
= {False, False, True, True, True}
767-
768-
#> StringContainsQ[{"A", "Galaxy", "Far", "Far", "Away"}, {}]
769-
= {False, False, False, False, False}
770-
771-
#> StringContainsQ[{"A", Galaxy, "Far", "Far", Away}, {"F" ~~ __ ~~ "r", "aw" ~~ ___}]
772-
: String or list of strings expected at position 1 in StringContainsQ[{A, Galaxy, Far, Far, Away}, {F ~~ __ ~~ r, aw ~~ ___}].
773-
= StringContainsQ[{A, Galaxy, Far, Far, Away}, {F ~~ __ ~~ r, aw ~~ ___}]
774-
775-
#> StringContainsQ[{"A", "Galaxy", "Far", "Far", "Away"}, {F ~~ __ ~~ "r", aw ~~ ___}]
776-
: Element F ~~ __ ~~ r is not a valid string or pattern element in {F ~~ __ ~~ r, aw ~~ ___}.
777-
= StringContainsQ[{A, Galaxy, Far, Far, Away}, {F ~~ __ ~~ r, aw ~~ ___}]
778-
## Mathematica can detemine correct invalid element in the pattern, it reports error:
779-
## Element F is not a valid string or pattern element in {F ~~ __ ~~ r, aw ~~ ___}.
780725
"""
781726

782727
messages = {
@@ -843,10 +788,6 @@ class StringRepeat(Builtin):
843788
844789
>> StringRepeat["abc", 10, 7]
845790
= abcabca
846-
847-
#> StringRepeat["x", 0]
848-
: A positive integer is expected at position 2 in StringRepeat[x, 0].
849-
= StringRepeat[x, 0]
850791
"""
851792

852793
messages = {
@@ -937,17 +878,6 @@ class ToExpression(Builtin):
937878
second-line value.
938879
>> ToExpression["2\[NewLine]3"]
939880
= 3
940-
941-
#> ToExpression["log(x)", InputForm]
942-
= log x
943-
944-
#> ToExpression["1+"]
945-
: Incomplete expression; more input is needed (line 1 of "ToExpression['1+']").
946-
= $Failed
947-
948-
#> ToExpression[]
949-
: ToExpression called with 0 arguments; between 1 and 3 arguments are expected.
950-
= ToExpression[]
951881
"""
952882

953883
# TODO: Other forms
@@ -956,8 +886,6 @@ class ToExpression(Builtin):
956886
= Log[x]
957887
>> ToExpression["log(x)", TraditionalForm]
958888
= Log[x]
959-
#> ToExpression["log(x)", StandardForm]
960-
= log x
961889
"""
962890
attributes = A_LISTABLE | A_PROTECTED
963891

mathics/builtin/atomic/symbols.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -111,21 +111,6 @@ class Context(Builtin):
111111
112112
>> InputForm[Context[]]
113113
= "Global`"
114-
115-
## placeholder for general context-related tests
116-
#> x === Global`x
117-
= True
118-
#> `x === Global`x
119-
= True
120-
#> a`x === Global`x
121-
= False
122-
#> a`x === a`x
123-
= True
124-
#> a`x === b`x
125-
= False
126-
## awkward parser cases
127-
#> FullForm[a`b_]
128-
= Pattern[a`b, Blank[]]
129114
"""
130115

131116
attributes = A_HOLD_FIRST | A_PROTECTED
@@ -431,25 +416,6 @@ class Information(PrefixOperator):
431416
'Information' does not print information for 'ReadProtected' symbols.
432417
433418
'Information' uses 'InputForm' to format values.
434-
435-
#> a = 2;
436-
#> Information[a]
437-
| a = 2
438-
.
439-
= Null
440-
441-
#> f[x_] := x ^ 2;
442-
#> g[f] ^:= 2;
443-
#> f::usage = "f[x] returns the square of x";
444-
#> Information[f]
445-
| f[x] returns the square of x
446-
.
447-
. f[x_] = x ^ 2
448-
.
449-
. g[f] ^= 2
450-
.
451-
= Null
452-
453419
"""
454420

455421
attributes = A_HOLD_ALL | A_SEQUENCE_HOLD | A_PROTECTED | A_READ_PROTECTED
@@ -620,9 +586,6 @@ class Names(Builtin):
620586
The number of built-in symbols:
621587
>> Length[Names["System`*"]]
622588
= ...
623-
624-
#> Length[Names["System`*"]] > 350
625-
= True
626589
"""
627590

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

703663
attributes = A_LOCKED | A_PROTECTED
@@ -735,9 +695,6 @@ class SymbolName(Builtin):
735695
736696
>> SymbolName[x] // InputForm
737697
= "x"
738-
739-
#> SymbolName[a`b`x] // InputForm
740-
= "x"
741698
"""
742699

743700
summary_text = "give the name of a symbol as a string"
@@ -785,9 +742,6 @@ class ValueQ(Builtin):
785742
>> x = 1;
786743
>> ValueQ[x]
787744
= True
788-
789-
#> ValueQ[True]
790-
= False
791745
"""
792746

793747
attributes = A_HOLD_FIRST | A_PROTECTED

0 commit comments

Comments
 (0)