-
Notifications
You must be signed in to change notification settings - Fork 0
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
Bringup of Rubi section 1 Algebraic functions
#2
Conversation
3413208
to
be0b6d7
Compare
…rn matching library.
@rocky Unfortunately, I think we're ready to execute the whole suit now. Some tests will still fail and need to be fixed. Identifying these failing tests will aid with the fix. |
I think we will be able to fix or address this, but I would like more detail and clarification about this comment. I don't fully understand what you mean. I just spent some time running In the log I see timeout exceptions like:
It is not clear to me though that this is a In Python, an exception can occur at a place where Python is not in a position to be able to handle it. This is called an "unraisable exception". See the second paragraph in https://vstinner.github.io/sys-unraisablehook-python38.html:
And this seems to be what appears here. Notice the mention of deleting a weak reference.
If this is going to take days, then why do this instead of running on some small set, fix those problems, and then iterate?
I have been following along what has been going on and I am very impressed and thankful for this work. Very few times do we have people using Mathics3 programs to get large projects done. But the best way for the code to improve is for us to do more activity like this. I have tried to write WMA/Mathics3 code, but my WMA skills are seriously lacking. I see that you've been working around existing bugs, such as for ReadList, or Select. To the extent this helps progress, this is good. And it is possible that we could put the workaround code into Mathics-core. What I'd ask though is to create bug tickets for each bug you have worked around. And it would be good to keep track of what should happen or be undone when a bug is fixed in Mathics core. If something is seriously blocking progress on Rubi, then mark it as such. If there is a workaround, the issue has a section to describe that. We should try to prioritize the bugs since there are likely to be many of these. One other thing, we should consider merging the branch into master. Having branches with lots of commits is not a good idea unless this is a major refactor of existing working code. Here, there was no existing working code. Again thanks for undertaking this. |
Thank you very much for the kind words and the details on the inner workings of Python. Below, I'll try to explain the issue with
On my PC, the following does not abort and return after In[1]:= << Rubi.m
In[2]:= << Test.m
In[3]:= TimeConstrained[Int[(a + b*x)^5/x^1, x], 30, 0] However, smaller timeout values such as |
Ok - thanks for the more detailed explanation. I will look at this when I am able to, and let you know what we might be able to do. |
I haven't started tracking down what's up with TimeConstrained timeout signals yet. However, in preparation for this, I've modified the Mathics3 debugger (now called I used this to find out what's happening with the delay in Not surprisingly , I am seeing a lot of time in the pattern-matching part of Mathics3, specifically, in walk_levels. Speeding up pattern matching is one of the 6 or so big things we need to correct in Mathics3. |
Here is what's happening. While in the middle of one With short timeouts, the chance of hitting another One could conceive of keeping track of all the pending time-constrained evaluations along with their due dates, adjusting deadline times, as new requests that come in based on the ones that already exist. But that is a bit more than I think we want to undertake right now . Branch at-most-one-TimeConstrained has code that I think you can use. I believe Rubi code embraces the idea that TimeConstrained[] evaluation is nice to have, but not strictly necessary. In other words, any evaluation that wraps TimeConstrained is allowed to fail, which we will do on those requests after the first one. The whole TimeConstrained notion is probably the main source of Rubi indeterminacy of solutions - on faster computers, more searching is done. |
Perfect! Thank you, I'll try the branch now and merge this PR as soon as I have the first full run (along with raising other issues, etc.)
I fully agree. After Rubi, I'd like to implement missing linear algebra functions (my field) and also work on the half-done Jupyter plugin. Soon after, I'll take a look at pattern matching again. Eventually, I want to implement Matrix Calculus on Mathics. It's a grand plan and I'll also be a bit constrained on time as soon as I begin my new job. But, I'll keep contributing! |
Open Items
|
Unprotect[With]; | |
With[vars_, Verbatim[Condition][expr_, wcond_]] := Condition[With[vars, expr], With[vars, wcond]]; | |
With[vars_, Verbatim[Condition][expr_, wcond_]] := Condition[Indeterminate, Not[With[vars, wcond]]]; | |
Protect[With]; |
pattern.py
. Without the fix, Inderminate
results are returned.
Increment
and friends
Increment
and friendsInfinite recursion when the input is undefined.
TraceEvaluation
after hitting $RecusionLimit
TraceEvaluation
after hitting $RecusionLimit
In[1]:= f[x_] := x + f[x-1]
Out[1]= None
In[2]:= f[0] = 0
Out[2]= 0
In[3]:= f[201] // TraceEvaluation
Evaluating: Global`f[201]
Evaluating: Global`f
. . .
$RecursionLimit::reclim: Recursion depth of 200 exceeded.
Out[3]= $Aborted
In[7]:= 1+2
Evaluating: System`Plus[1, 2]
Evaluating: System`Plus
Out[7]= 3
Tracing continues for 1+2
.
TraceEvaluation
not printing the first level
TraceEvaluation
not printing the first levelTraceEvaluation
does not print the first level if reevaluate
is False
.
(Note: not a good idea. Hence, do not fix.)
Select
with empty sets and three arguments
Select
with empty sets and three argumentsThis should address the problem seen via Rubi testing where TraceEvalution was called and we hit a recursion limit. See Mathics3/Mathics3-Rubi#2 (comment) --------- Co-authored-by: Aravindh Krishnamoorthy <[email protected]>
See the `ReadList[]` example in Mathics3/Mathics3-Rubi#2 --------- Co-authored-by: Aravindh Krishnamoorthy <[email protected]>
I think this will be ready and merged in a day or two. |
@aravindh-krishnamoorthy Note that some misfeatures around TraceEvaluation, Select, ReadList, and Increment/Decrement have been addressed. So if those workarounds are removed and Rubi is less modified, that would be good. If there is a Mathics3 code-based workaround for Mathics3/mathics-core#1209 that would be nice to add. But see also Finally, it would be nice to have issues logged in mathics core for the empty sets with 3 args, the specific kinds of problems with TimedConstrained and ReplaceParts with 3 args. In the issue please add reproducible test cases that demonstrate the specific kinds problems you encountered and can be used to demonstrate that those problems were fixed. Thanks for doing this and for working on Rubi. |
Definitely! I will complete the items on the checklist before finalising this. I'll also have to update the |
* Add 3-argument Select, by adding a parameter inside Structure's filter function. * Go over Structure class: remove duplication of filter() and add the count functionality needed by Select[] * Update Select doctests for 3 arg form. Move error checking to pytest where it belongs. `Select[]` count-parameter issue is mentioned in Mathics3/Mathics3-Rubi#2
Goal
Implement the first section of Rubi
1 Algebraic functions
with minimal (ideally zero) changes to the Rubi rules (for easy future upgrade and to demonstrate top compatibility with Mathematica).Howto
Commit: 049d301
Note: Some progress, but still a long way to go.
Full Test Suite Results for
1 Algebraic functions
TBD
Open Items
These items must be fixed in
mathics-core
before completing this PR.See #2 (comment) for the list.
Resolved
With
evaluates the expression but returns unevaluated result.With
: Return evaluated result mathics-core#1194ReadList[]
when reading comment-only lines.ReadList[]
handlingNull
andHold[]
expressions mathics-core#1203TraceEvaluation
is not reset after hitting the recursion limit.TraceEvaluation[]
params on an exception mathics-core#1204Increment
and related functions hit the recursion limit if the input is undefined.Increment
and related functions hit the recursion limit when the input is undefined mathics-core#1205Condition
within scoping blocks forSetDelayed
does not bind tolhs
With
and other scoping environments is disregarded mathics-core#1206DownValues[f]//FullForm
different from Mathematica causing issues inFixIntRules[]
DownValues[f]//FullForm
is different from Mathematica's mathics-core#1209Select[]
with empty sets.Refine[]
Refine[]
mathics-core#1230