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

bark when a rule in Builtin.rules cannot be loaded #1006

Merged
merged 16 commits into from
Oct 3, 2024

Conversation

mmatera
Copy link
Contributor

@mmatera mmatera commented Feb 9, 2024

This is related to #1000. There are some rules included in the Builtin.rules property that cannot be loaded. With this PR, it this happens, a warning is printed. In any case, the idea is to fix these cases before merging this PR.

@mmatera
Copy link
Contributor Author

mmatera commented Feb 9, 2024

These are the rules that cannot be loaded and must be fixed:

  • System`Set[System`Pattern[System`lhs, System`Blank[]], System`Pattern[System`rhs, System`Blank[]]] could not be associated to System`$TimeZone

  • System`Set[System`Pattern[System`lhs, System`Blank[]], `System`Pattern[System`rhs, System`Blank[]]] could not be associated to System`$TimeZone

  • System`Exit[System`Pattern[System`n, System`BlankNullSequence[]]] could not be associated to System`Quit

  • System`Normal[System`Pattern[System`dispatch, System`Blank[System`Dispatch]]] could not be associated to System`Dispatch

  • System`Normal[System`Pattern[System`dispatch, System`Blank[System`Dispatch]]] could not be associated to System`Dispatch

  • System`Read[System`Pattern[System`arg1, System`Blank[]], `System`Pattern[System`arg2, System`Blank[]]] could not be associated to System`Find

  • System`Read[System`Pattern[System`arg1, System`Blank[]], System`Pattern[System`arg2, System`Blank[]]] could not be associated to System`Find

  • System`Read[System`Pattern[System`stream, System`Blank[]]] could not be associated to System`Find

  • System`Read[System`Pattern[System`arg1, System`Blank[]], System`Pattern[System`arg2, System`Blank[]]] could not be associated to System`ReadList

  • System`Read[System`Pattern[System`arg1, System`Blank[]], System`Pattern[System`arg2, System`Blank[]]] could not be associated to

  • System`ReadList

  • System`Read[System`Pattern[System`arg1, System`Blank[]], System`Pattern[System`arg2, System`Blank[]]] could not be associated to System`Skip

  • System`Read[System`Pattern[System`arg1, System`Blank[]], System`Pattern[System`arg2, System`Blank[]]] could not be associated to System`Skip

  • System`Parition[System`Pattern[System`list, System`Blank[]], SystemPattern[Systemn, SystemBlank[]], SystemPattern[Systemd, SystemBlank[]], Systemk]``` could not be associated to ```SystemPartition```

  • System`DisplayForm[System`Pattern[System`boxexpr, System`Blank[System`IntepretationBox]]] could not be associated to System`InterpretationBox

  • System`ToExpression[System`Pattern[System`boxexpr, System`Blank[System`IntepretationBox]], System`Pattern[System`form, System`BlankNullSequence[]]] could not be associated to System`InterpretationBox

  • System`DisplayForm[System`Pattern[System`boxexpr, System`Blank[System`IntepretationBox]]] could not be associated to System`InterpretationBox

  • System`ToExpression[System`Pattern[System`boxexpr, System`Blank[System`IntepretationBox]], System`Pattern[System`form, System`BlankNullSequence[]]] could not be associated to System`InterpretationBox

* Improve ``mathics.core.definitions.get_tag_position`` to support more complex rules
* Add a pytest to check different cases of ``get_tag_position``
* Restore ``mathics.docpipeline`` from master~3, because the current one is not properly working.
@mmatera mmatera marked this pull request as ready for review March 13, 2024 19:59
@mmatera
Copy link
Contributor Author

mmatera commented Oct 3, 2024

@rocky, when you have the chance, please look at this old PR. This fixes the load of some rules and prevents the include dead rules in the future.

@rocky
Copy link
Member

rocky commented Oct 3, 2024

@rocky, when you have the chance, please look at this old PR. This fixes the load of some rules and prevents the include dead rules in the future.

@mmatera Thanks for pointing this out. I will do after finishing trying an going over the more-patterns branch today.

@rocky rocky mentioned this pull request Oct 3, 2024
"System`BlankNullSequence",
)

def strip_pattern_name_and_condition(pat):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add annotations:

strip_pattern_name_and_condition(pat: ExpressionPattern) -> ExpressionPattern

this will be in PR bark_if_builtin_rule_cannot_be_stored-more

This function strips it to ensure that
``pat`` does not have that form.
"""
if pat.get_head_name() == "System`Condition":
Copy link
Member

@rocky rocky Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use SymbolCondition and SymbolPattern below. Again, this will be in a PR for your review.

We have to use get_head_name() for testing on System`Condition because pat can either SymbolCondition or an <AtomPattern: System`Condition> and in the latter case, comparing to SymbolCondition is not sufficient.

return strip_pattern_name_and_condition(pat.elements[1])
return pat

def check_is_subvalue(pattern_sv, name_sv):
Copy link
Member

@rocky rocky Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add annotation for function signature:

def check_is_subvalue(pattern_sv: ExpressionPattern, name_sv: str) -> bool:

the function name check_is_subvalue() is a poor name. First, for functions returning boolean values we use is_xxx not check_is_xxx. Second what is a subvalue?

In the PR that will appear I have changed the docstring to:

"""Determines if ``pattern_sv`` or any of its alternates is a pattern with name `name_sv`"""

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the PR I have changed the function name to "is_pattern_a_kind_of".

@rocky
Copy link
Member

rocky commented Oct 3, 2024

LGTM

@rocky rocky merged commit e44ab00 into master Oct 3, 2024
11 checks passed
@rocky rocky deleted the bark_if_builtin_rule_cannot_be_stored branch October 3, 2024 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants