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

Support Refine[] #1230

Open
aravindh-krishnamoorthy opened this issue Dec 15, 2024 · 8 comments
Open

Support Refine[] #1230

aravindh-krishnamoorthy opened this issue Dec 15, 2024 · 8 comments
Labels
New Builtin Function or Variable Add a new Mathics Bultin Variable or Function

Comments

@aravindh-krishnamoorthy
Copy link
Collaborator

Support Refine[] Wolfram language function described here: Refine.

Refine[] is different and (usually) lightweight compared to Simplify[] and FullSimplify[] and only performs reductions based on global assumptions and those passed to the function.

Is your feature request related to a problem? Please describe.
Refine[] is used in Rubi (https://github.com/Mathics3/Mathics3-Rubi/).

Describe the solution you'd like
Support Refine[] Wolfram language function described here: Refine.

Describe alternatives you've considered
In Rubi, Refine[] is currently equated to Simplify[].

Additional context
Sympy version of Refine[] is here: https://docs.sympy.org/latest/modules/assumptions/refine.html, which might likely be of help to the implementor.

@ricor07
Copy link

ricor07 commented Dec 28, 2024

Hello, I'd like to join the project by working on this issue.

@rocky
Copy link
Member

rocky commented Dec 28, 2024

Hi @ricor07 . I would love for you to help by working on this issue.

I wrote https://mathics-development-guide.readthedocs.io/en/latest/extending/developing-code/extending/tutorial.html hoping to help people get started in this kind of activity. Please read that and the broader section on extending Mathics3.

If you have any questions or problems as you go along, let me know.

@rocky rocky added the New Builtin Function or Variable Add a new Mathics Bultin Variable or Function label Dec 28, 2024
@rocky
Copy link
Member

rocky commented Dec 29, 2024

@ricor07 As a warmup to doing this function, you might consider doing #1187. I believe this is a straightforward process of wrapping a SymPy function into a Mathics3 function. In doing this, you'd practice the boilerplate part of what is needed to add a new builtin function. And this too will eventually be needed by Rubi.

@ricor07
Copy link

ricor07 commented Dec 29, 2024

Good morning. I can't use your repo. After running this commands:

cd mathics-core
python -m venv venv
venv\Scripts\activate
pip install -e .
mathics```

This is what I get:

Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 196, in _run_module_as_main
return run_code(code, main_globals, None,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 86, in run_code
exec(code, run_globals)
File "C:\Users\angel\mathics-core\venv\Scripts\mathics.exe_main
.py", line 4, in
File "C:\Users\angel\mathics-core\mathics\main.py", line 24, in
from mathics.builtin.trace import TraceBuiltins, traced_apply_function
File "C:\Users\angel\mathics-core\mathics\builtin\trace.py", line 28, in
from mathics.core.builtin import Builtin
File "C:\Users\angel\mathics-core\mathics\core\builtin.py", line 32, in
import mathics.core.parser.operators
File "C:\Users\angel\mathics-core\mathics\core\parser_init
.py", line 21, in
from mathics.core.parser.operators import all_operator_names
File "C:\Users\angel\mathics-core\mathics\core\parser\operators.py", line 25, in
assert osp.exists(
AssertionError: Internal error: Mathics3 Operator information are missing; expected to be in C:\Users\angel\mathics-core\mathics\data\operator-tables.json


I am on Windows.

@rocky
Copy link
Member

rocky commented Dec 29, 2024

When building from git source in the master branch, we now need to generate JSON operator tables. This is done on POSIX systems that have bash using admin-tools/make-op-tables. But this is just running some Python programs that should be installed when you install mathics-scanner. These programs are mathics3-generate-json-table and mathics3-generate-operator-json-table.

To run from a command line:

chdir <place where mathics/data exists>
mathics3-generate-json-table \
    --field=ascii-operator-to-symbol \
    --field=ascii-operator-to-unicode \
    --field=ascii-operator-to-wl-unicode \
    --field=operator-to-ascii \
    --field=operator-to-unicode \
    -o op-tables.json
mathics3-generate-operator-json-table -o operator-tables.json

Oh, and by the way, use pip install -e .[dev] when installing from git so you get the packages needed for testing, i.e. pytest.

I will try to update https://mathics-development-guide.readthedocs.io/en/latest/installing.html#install-from-the-mathics3-github-organization, but if you want to make corrections to that repository, please do.

@ricor07
Copy link

ricor07 commented Dec 29, 2024

Are you sure these are windows commands? Command prompt does not recognize mathics3-generate-json-table and so on

@rocky
Copy link
Member

rocky commented Dec 29, 2024

Are you sure these are windows commands? Command prompt does not recognize mathics3-generate-json-table and so on

Ah, you have to also install mathics-scanner from github sources. Occasionally as we improve things, the API (or here the information in files that passes between the scanner and mathics core) changes. And when that happens, you have to build both from source.

mathics3-generate-json-table and mathics3-generate-json-table are new scripts that are installed when you install mathics-scanner from the github master branch.

@rocky
Copy link
Member

rocky commented Dec 29, 2024

And BTW when Mathics3/mathics-scanner#111 goes in, additional information in the JSON tables will be added and so this process will be needed to be done again.

One of the reasons we haven't made a new release, is that we want to minimize this kind of stuff for non-developers. So when we break the API as we do here, we try to batch in all the breaking changes to reduce this kind of annoyance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Builtin Function or Variable Add a new Mathics Bultin Variable or Function
Projects
None yet
Development

No branches or pull requests

3 participants