-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
patch #639
patch #639
Changes from all commits
530e147
da8580c
6436065
c01508c
b5d5c5d
37bffec
f1ccc6d
53300f5
be591cd
c914823
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
import importlib | ||
import re | ||
|
||
from functools import lru_cache, total_ordering | ||
from itertools import chain | ||
from typing import Any, Callable, Dict, Iterable, List, Optional, Union, cast | ||
|
@@ -191,7 +192,12 @@ def __new__(cls, *args, **kwargs): | |
# mathics.builtin.inout | ||
|
||
if kwargs.get("expression", None) is not False: | ||
return to_expression(cls.get_name(), *args) | ||
try: | ||
return to_expression(cls.get_name(), *args) | ||
except: | ||
from trepan.api import debug | ||
|
||
debug() | ||
else: | ||
instance = super().__new__(cls) | ||
if not instance.formats: | ||
|
@@ -286,7 +292,13 @@ def check_options(options_to_check, evaluation): | |
) | ||
|
||
box_rules = [] | ||
# FIXME: Why a special case for System`MakeBoxes? Remove this | ||
|
||
# System`MakeBoxes comes first because all the other symbols contribute to it. | ||
# Then, a definition of this symbol must be available from the begining. | ||
# Probably, this is not a good approach, since it makes that MakeBoxes has | ||
# a very large number of inespecific rules. A better approach would imply at least | ||
# to store the rules as upvalues of the symbols associated to these rules. | ||
# | ||
if name != "System`MakeBoxes": | ||
new_rules = [] | ||
for rule in rules: | ||
|
@@ -384,13 +396,32 @@ def contextify_form_name(f): | |
) | ||
if is_pymodule: | ||
definitions.pymathics[name] = definition | ||
try: | ||
makeboxes_def = definitions.pymathics["System`MakeBoxes"] | ||
except KeyError: | ||
builtin_mb_def = definitions.builtin["System`MakeBoxes"] | ||
makeboxes_def = Definition( | ||
"System`MakeBoxes", | ||
builtin=builtin_mb_def.builtin, | ||
attributes=builtin_mb_def.attributes, | ||
is_numeric=builtin_mb_def.is_numeric, | ||
) | ||
definitions.pymathics["System`MakeBoxes"] = makeboxes_def | ||
else: | ||
definitions.builtin[name] = definition | ||
makeboxes_def = definitions.builtin["System`MakeBoxes"] | ||
|
||
makeboxes_def = definitions.builtin["System`MakeBoxes"] | ||
for rule in box_rules: | ||
makeboxes_def.add_rule(rule) | ||
|
||
# If a pymathics module was loaded, then there are at least two | ||
# definitions for MakeBoxes, the builtin, the pymathics, and the | ||
# cached from combining the former two. Rules are added to one of | ||
# both, which are not going to be in the cached version that | ||
# Definitions.get_definition provides. To make the new rules | ||
# accesible, we need to clear the definitions cache. | ||
definitions.clear_cache("System`MakeBoxes") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is only needed when pymathics modules are loaded, then why isn't this only in the branch of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But then, I should duplicate lines 414 and 415 in both branches. |
||
|
||
@classmethod | ||
def get_name(cls, short=False) -> str: | ||
if cls.name is None: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was my bad - should be removed.