Skip to content

Commit

Permalink
Docfixes part2 (#1300)
Browse files Browse the repository at this point in the history
Doctest corrections for Arg, FilenameDrop and SetEnvironment. 

SetEnvironment return value corrected.
  • Loading branch information
rocky authored Jan 18, 2025
1 parent 483e301 commit 3f1fb46
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
6 changes: 3 additions & 3 deletions mathics/builtin/arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ class Arg(MPMathFunction):
>> Arg[-3]
= Pi
Same as above using sympy's method:
Same as above, but using SymPy's method:
>> Arg[-3, Method->"sympy"]
= Pi
>> Arg[1-I]
= -Pi / 4
Arg evaluate the direction of DirectedInfinity quantities by
the Arg of they arguments:
'Arg' evaluates the direction of 'DirectedInfinity' quantities by \
the 'Arg' of its arguments:
>> Arg[DirectedInfinity[1+I]]
= Pi / 4
>> Arg[DirectedInfinity[]]
Expand Down
2 changes: 1 addition & 1 deletion mathics/builtin/file_operations/path_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class FileNameDrop(Builtin):
<dd>drops the last path elements in the file name $path$.
</dl>
>> path = FileNameJoin{"a","b","c"}
>> path = FileNameJoin[{"a","b","c"}]
= ...
>> FileNameDrop[path, -1]
Expand Down
14 changes: 5 additions & 9 deletions mathics/builtin/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from mathics.core.evaluation import Evaluation
from mathics.core.expression import Expression
from mathics.core.list import ListExpression
from mathics.core.symbols import SymbolNull
from mathics.core.systemsymbols import (
SymbolFailed,
SymbolNone,
Expand Down Expand Up @@ -569,7 +570,6 @@ class SetEnvironment(Builtin):
Set a single environment variable:
S> SetEnvironment["FOO" -> "bar"]
= SetEnvironment[FOO -> bar]
See that the environment variable has changed:
S> GetEnvironment["FOO"]
Expand All @@ -587,18 +587,14 @@ class SetEnvironment(Builtin):
S> SetEnvironment["FOO" -> 5]
: 5 must be a string or None.
= SetEnvironment[FOO -> 5]
= $Failed
S> GetEnvironment["FOO"]
= FOO -> baz
If the environment name is not a string, the evaluation fails without a message.
S> SetEnvironment[FOO -> "bar"]
= SetEnvironment[FOO -> bar]
S> GetEnvironment["FOO"]
= FOO -> baz
S> SetEnvironment[1 -> "bar"]
See also <url>
:'Environment':
Expand All @@ -615,14 +611,14 @@ def eval(self, rule, evaluation):
env_var_name, env_var_value = rule.elements
if not (env_var_value is SymbolNone or isinstance(env_var_value, String)):
evaluation.message("SetEnvironment", "value", env_var_value)
return None
return SymbolFailed

if isinstance(env_var_name, String):
# WMA does not give an error message if env_var_name is not a String - weird.
os.environ[env_var_name.value] = (
None if None is SymbolNone else env_var_value.value
)
return None
return SymbolNull

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

0 comments on commit 3f1fb46

Please sign in to comment.