Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fa423e3
fix cleanup after loading autoload definitions
mmatera Nov 6, 2022
53c511f
Merge remote-tracking branch 'origin/master' into fix_definition_auto…
mmatera Nov 7, 2022
be0fb71
improving comment
mmatera Nov 7, 2022
8dbbe6e
improving clarity in Builtin.contribute
mmatera Nov 7, 2022
513bfc5
adding comments. adding tests
mmatera Nov 8, 2022
e92da0f
fix test for SetDelayed. Move special case for Set with LHS a list aw…
mmatera Nov 8, 2022
a728701
more on modularize assignment. assign_elementary->assign
mmatera Nov 8, 2022
d88ab76
Merge pull request #600 from Mathics3/fix_contribute
rocky Nov 13, 2022
ad6b87a
Merge pull request #601 from Mathics3/documenting_assignment
rocky Nov 13, 2022
92e6b0c
fix OneIdentity
mmatera Nov 10, 2022
cd74aa9
remove comment
mmatera Nov 10, 2022
cb2ca92
Handle optional with a first element that is not a Pattern[]
mmatera Nov 11, 2022
afcf467
Update examples in OneIdentity
rocky Nov 12, 2022
454bbaa
More pervasive use of Symbols
rocky Nov 12, 2022
21a4080
Pattern_create -> Pattern.create
rocky Nov 12, 2022
d33ca93
Add function signature; straighten import issue
rocky Nov 12, 2022
318a2b8
Put test_rules_patterns tests where they belong
rocky Nov 12, 2022
de5bbbe
Add note to add skipped example as a doctest ...
rocky Nov 13, 2022
cdd8e6a
Merge pull request #602 from Mathics3/fix_one_identity
rocky Nov 13, 2022
f4eb4ce
Add SetAttributes length check and ...
rocky Nov 13, 2022
069deea
Merge pull request #615 from Mathics3/SetAttribute-arg-check
rocky Nov 13, 2022
1e5d97b
Merge branch 'fix_definition_autoload_to_builtin' into HEAD
mmatera Nov 14, 2022
592f1a0
modifiying the code to promote Definitions.builtin as a class attribute
mmatera Nov 15, 2022
aa9cc93
Merge branch 'fix_definition_autoload_to_builtin' into add_builtin_ju…
mmatera Nov 15, 2022
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
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. contents::
.. contents::

CHANGES
=======
Expand Down Expand Up @@ -41,6 +41,8 @@ Internals
#. Operator name to unicode or ASCII comes from Mathics scanner character tables.
#. ``eval*`` methods in `Builtin` classes are considerer as synonyms of ``apply*`` methods.
#. Modularize and improve the way in which `Builtin` classes are selected to have an associated `Definition`.
#. `_SetOperator.assign_elementary` was renamed as `_SetOperator.assign`. All the special cases are not handled by the `_SetOperator.special_cases` dict.



Bugs
Expand Down
3 changes: 2 additions & 1 deletion mathics/builtin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
PatternObject,
)

from mathics.core.pattern import pattern_objects

from mathics.settings import ENABLE_FILES_MODULE
from mathics.version import __version__ # noqa used in loading to check consistency.

Expand Down Expand Up @@ -267,7 +269,6 @@ def sanity_check(cls, module):
mathics_to_python = {} # here we have: name -> string
sympy_to_mathics = {}

pattern_objects = {}
builtins_precedence = {}

new_builtins = _builtins
Expand Down
26 changes: 24 additions & 2 deletions mathics/builtin/assignments/assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,30 @@ class SetDelayed(Set):
= 2 / 3
>> F[-3, 2]
= -2 / 3
We can use conditional delayed assignments to define \
symbols with values conditioned to the context. For example,
>> ClearAll[a,b]; a/; b>0:= 3
Set $a$ to have a value of $3$ if certain variable $b$ is positive.\
So, if this variable is not set, $a$ stays unevaluated:
>> a
= a
If now we assign a positive value to $b$, then $a$ is evaluated:
>> b=2; a
= 3
"""

# I WMA, if we assign a value without a condition on the LHS,
# conditional values are never reached. So,
#
# Notice however that if we assign an unconditional value to $a$, \
# this overrides the condition:
# >> a:=0; a/; b>1:= 3
# >> a
# = 0
#
# In Mathics, this last line would return 3
# """

operator = ":="
attributes = A_HOLD_ALL | A_PROTECTED | A_SEQUENCE_HOLD

Expand Down Expand Up @@ -203,7 +225,7 @@ def apply(self, f, lhs, rhs, evaluation):
return

rhs = rhs.evaluate(evaluation)
self.assign_elementary(lhs, rhs, evaluation, tags=[name])
self.assign(lhs, rhs, evaluation, tags=[name])
return rhs


Expand All @@ -228,7 +250,7 @@ def apply(self, f, lhs, rhs, evaluation):
evaluation.message(self.get_name(), "sym", f, 1)
return

if self.assign_elementary(lhs, rhs, evaluation, tags=[name]):
if self.assign(lhs, rhs, evaluation, tags=[name]):
return SymbolNull
else:
return SymbolFailed
Expand Down
24 changes: 15 additions & 9 deletions mathics/builtin/assignments/clear.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,20 @@
Atom,
Symbol,
SymbolNull,
system_symbols,
symbol_set,
)

from mathics.core.systemsymbols import (
SymbolContext,
SymbolContextPath,
SymbolDownValues,
SymbolFailed,
SymbolMessages,
SymbolNValues,
SymbolOptions,
SymbolOwnValues,
SymbolSubValues,
SymbolUpValues,
)

from mathics.core.atoms import String
Expand Down Expand Up @@ -320,12 +326,12 @@ def apply(self, expr, evaluation):
return SymbolNull


SYSTEM_SYMBOL_VALUES = system_symbols(
"OwnValues",
"DownValues",
"SubValues",
"UpValues",
"NValues",
"Options",
"Messages",
SYSTEM_SYMBOL_VALUES = symbol_set(
SymbolDownValues,
SymbolMessages,
SymbolNValues,
SymbolOptions,
SymbolOwnValues,
SymbolSubValues,
SymbolUpValues,
)
Loading