Skip to content

Commit 3f1fb46

Browse files
authored
Docfixes part2 (#1300)
Doctest corrections for Arg, FilenameDrop and SetEnvironment. SetEnvironment return value corrected.
1 parent 483e301 commit 3f1fb46

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

mathics/builtin/arithmetic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,15 @@ class Arg(MPMathFunction):
122122
>> Arg[-3]
123123
= Pi
124124
125-
Same as above using sympy's method:
125+
Same as above, but using SymPy's method:
126126
>> Arg[-3, Method->"sympy"]
127127
= Pi
128128
129129
>> Arg[1-I]
130130
= -Pi / 4
131131
132-
Arg evaluate the direction of DirectedInfinity quantities by
133-
the Arg of they arguments:
132+
'Arg' evaluates the direction of 'DirectedInfinity' quantities by \
133+
the 'Arg' of its arguments:
134134
>> Arg[DirectedInfinity[1+I]]
135135
= Pi / 4
136136
>> Arg[DirectedInfinity[]]

mathics/builtin/file_operations/path_operations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class FileNameDrop(Builtin):
3434
<dd>drops the last path elements in the file name $path$.
3535
</dl>
3636
37-
>> path = FileNameJoin{"a","b","c"}
37+
>> path = FileNameJoin[{"a","b","c"}]
3838
= ...
3939
4040
>> FileNameDrop[path, -1]

mathics/builtin/system.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from mathics.core.evaluation import Evaluation
2121
from mathics.core.expression import Expression
2222
from mathics.core.list import ListExpression
23+
from mathics.core.symbols import SymbolNull
2324
from mathics.core.systemsymbols import (
2425
SymbolFailed,
2526
SymbolNone,
@@ -569,7 +570,6 @@ class SetEnvironment(Builtin):
569570
570571
Set a single environment variable:
571572
S> SetEnvironment["FOO" -> "bar"]
572-
= SetEnvironment[FOO -> bar]
573573
574574
See that the environment variable has changed:
575575
S> GetEnvironment["FOO"]
@@ -587,18 +587,14 @@ class SetEnvironment(Builtin):
587587
588588
S> SetEnvironment["FOO" -> 5]
589589
: 5 must be a string or None.
590-
= SetEnvironment[FOO -> 5]
590+
= $Failed
591591
592592
S> GetEnvironment["FOO"]
593593
= FOO -> baz
594594
595595
If the environment name is not a string, the evaluation fails without a message.
596596
597-
S> SetEnvironment[FOO -> "bar"]
598-
= SetEnvironment[FOO -> bar]
599-
600-
S> GetEnvironment["FOO"]
601-
= FOO -> baz
597+
S> SetEnvironment[1 -> "bar"]
602598
603599
See also <url>
604600
:'Environment':
@@ -615,14 +611,14 @@ def eval(self, rule, evaluation):
615611
env_var_name, env_var_value = rule.elements
616612
if not (env_var_value is SymbolNone or isinstance(env_var_value, String)):
617613
evaluation.message("SetEnvironment", "value", env_var_value)
618-
return None
614+
return SymbolFailed
619615

620616
if isinstance(env_var_name, String):
621617
# WMA does not give an error message if env_var_name is not a String - weird.
622618
os.environ[env_var_name.value] = (
623619
None if None is SymbolNone else env_var_value.value
624620
)
625-
return None
621+
return SymbolNull
626622

627623
def eval_list(self, rules: Expression, evaluation: Evaluation):
628624
"SetEnvironment[{rules__}]"

0 commit comments

Comments
 (0)