Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Place options 'All' and 'None' in correct section #770

Merged
merged 1 commit into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 1 addition & 30 deletions mathics/builtin/lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Functions here will eventually get moved to more suitable subsections.
"""

from mathics.builtin.base import Builtin, Predefined, Test
from mathics.builtin.base import Builtin, Test
from mathics.builtin.box.layout import RowBox
from mathics.core.attributes import A_LOCKED, A_PROTECTED
from mathics.core.exceptions import InvalidLevelspecError
Expand All @@ -14,21 +14,6 @@
from mathics.eval.parts import python_levelspec


class All(Predefined):
"""
<url>
:WMA link:
https://reference.wolfram.com/language/ref/All.html</url>

<dl>
<dt>'All'
<dd>is a possible option value for 'Span', 'Quiet', 'Part' and related functions. 'All' specifies all parts at a particular level.
</dl>
"""

summary_text = "all the parts in the level"


class LevelQ(Test):
"""
<url>
Expand Down Expand Up @@ -99,20 +84,6 @@ def eval_makeboxes(self, items, f, evaluation):
return RowBox(*list_boxes(items, f, evaluation, "{", "}"))


class None_(Predefined):
"""
<url>:WMA link:https://reference.wolfram.com/language/ref/None.html</url>

<dl>
<dt>'None'
<dd>is a possible value for 'Span' and 'Quiet'.
</dl>
"""

name = "None"
summary_text = "not any part"


class NotListQ(Test):
"""
<url>:WMA link:https://reference.wolfram.com/language/ref/NotListQ.html</url>
Expand Down
71 changes: 70 additions & 1 deletion mathics/builtin/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
https://reference.wolfram.com/language/guide/OptionsManagement.html</url>
"""

from mathics.builtin.base import Builtin, Test, get_option
from mathics.builtin.base import Builtin, Predefined, Test, get_option
from mathics.builtin.image.base import Image
from mathics.core.atoms import String
from mathics.core.evaluation import Evaluation
Expand All @@ -22,6 +22,52 @@
from mathics.eval.patterns import Matcher


class All(Predefined):
"""
<url>
:WMA link:
https://reference.wolfram.com/language/ref/All.html</url>

<dl>
<dt>'All'
<dd>is an option value for a number of functions indicating to include everything.
</dl>


In list functions, it indicates all levels of the list.

For example, in <url>
:Part:
/doc/reference-of-built-in-symbols/list-functions/elements-of-lists/part</url>, \
'All', extracts into a first column vector the first element of each of the list elements:

>> {{1, 3}, {5, 7}}[[All, 1]]
= {1, 5}

while in <url>
:Take:
/doc/reference-of-built-in-symbols/list-functions/elements-of-lists/part</url>, \
'All' extracts as a column matrix the first element as a list for each of the list elements:

>> Take[{{1, 3}, {5, 7}}, All, {1}]
= {{1}, {5}}

In <url>
:Plot:
/doc/reference-of-built-in-symbols/graphics-and-drawing/plotting-data/plot</url> \
</url>, setting the <url>
:Mesh:
/doc/reference-of-built-in-symbols/drawing-options-and-option-values/mesh</url> \
option to 'All' will show the specific plot points:

>> Plot[x^2, {x, -1, 1}, MaxRecursion->5, Mesh->All]
= -Graphics-

"""

summary_text = "option value that specify using everything"


class Default(Builtin):
"""
<url>
Expand Down Expand Up @@ -121,6 +167,29 @@ def matched():
return ListExpression(*list(matched()))


class None_(Predefined):
"""
<url>:WMA link:https://reference.wolfram.com/language/ref/None.html</url>

<dl>
<dt>'None'
<dd>is a setting value for many options.
</dl>

Plot3D shows the mesh grid between computed points by default. This the <url>
:Mesh:
/doc/reference-of-built-in-symbols/drawing-option-and-values/mesh</url> option.

However, you hide the mesh by setting thes 'Mesh' option value to 'None':

>> Plot3D[{x^2 + y^2, -x^2 - y^2}, {x, -2, 2}, {y, -2, 2}, BoxRatios-> Automatic, Mesh->None]
= -Graphics3D-
"""

name = "None"
summary_text = "option value that disables the option"


# Has this been removed from WL? I cannot find a WMA link.
class NotOptionQ(Test):
"""
Expand Down