Skip to content

Commit

Permalink
Add operator tables (#67)
Browse files Browse the repository at this point in the history
* Administrivia and bump version
* First cut at creating an operator table
* Comment out fields that don't YAML parse easily (yet)
* Add program to convert operator CSV to YAML
* Spelling corrections
* Add program to create operator table from YAML
* Need to use special branch to test... And we'll have to remove this later when it gets merged to master. Sigh.
* CI woes
* Another attempt at packaging
  • Loading branch information
rocky authored Aug 29, 2024
1 parent e187a1b commit d627f29
Show file tree
Hide file tree
Showing 15 changed files with 9,163 additions and 25 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/mathics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9]
python-version: ['3.11']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install OS dependencies
Expand All @@ -31,7 +31,10 @@ jobs:
- name: Test Mathics3
run: |
# Until next Mathics3/mathics-core release is out...
python -m pip install -e git+https://github.com/Mathics3/mathics-core#egg=Mathics3[full]
(cd src/mathics3 && ./admin-tools/make-op-tables.sh )
git clone https://github.com/Mathics3/mathics-core.git
cd mathics-core/
git checkout table-driven-operator-precedence
make PIP_INSTALL_OPTS='[full]'
# pip install Mathics3[full]
cd ..
MATHICS_CHARACTER_ENCODING="ASCII" make check-mathics
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
/.python-version
/Mathics_Scanner.egg-info
ChangeLog
ChangeLog.orig
ChangeLog.rej
Documents/
Homepage/
Test/
_Copies_/
_Database_/
build/
/mathics_scanner/data/characters.json
/mathics_scanner/data/operators.json
dist/
tmp
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ GIT2CL ?= admin-tools/git2cl
PYTHON ?= python
PIP ?= pip3
RM ?= rm
PIP_INSTALL_OPTS ?=

.PHONY: all build \
check check-full check-mathics clean \
Expand All @@ -25,19 +26,23 @@ mathics_scanner/data/characters.json: mathics_scanner/data/named-characters.yml
$(PIP) install -r requirements-dev.txt
$(PYTHON) mathics_scanner/generate/build_tables.py

mathics_scanner/data/operators.json: mathics_scanner/data/operators.yml
$(PIP) install -r requirements-dev.txt
$(PYTHON) mathics_scanner/generate/build_operator_tables.py

#: build everything needed to install
build: mathics_scanner/data/characters.json
$(PYTHON) ./setup.py build

#: Set up to run from the source tree
develop: mathics_scanner/data/characters.json
$(PIP) install -e .
develop: mathics_scanner/data/characters.json mathics_scanner/data/operators.json
$(PIP) install -e .$(PIP_INSTALL_OPTS)

#: Build distribution
dist: admin-tools/make-dist.sh
$(SHELL) admin-tools/make-dist.sh

#: Install mathics
#: Install mathics-scanner
install: build
$(PYTHON) setup.py install

Expand All @@ -57,7 +62,7 @@ doc: mathics_scanner/data/characters.json
#: Remove derived files
clean:
@find . -name *.pyc -type f -delete; \
$(RM) -f mathics_scanner/data/characters.json || true
$(RM) -f mathics_scanner/data/characters.json mathics_scanner/data/operators.json || true

#: Run py.test tests. Use environment variable "o" for pytest options
pytest: mathics_scanner/data/characters.json
Expand Down
7 changes: 4 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ To regenerate JSON-format tables run:

::

$ mathics-generate-json-table
$ mathics3-generate-json-table
$ mathics3-operator-json-table

Without options ``mathics-generate-json-table`` produces the maximum set of correspondences.
Without options ``mathics3-generate-json-table`` produces the maximum set of correspondences.

In most applications though you may need just a few of these. The
``--field`` option can be used to narrow the list of entries to output in JSON. Run
``mathics-generate-json-table --help`` for a full list of fields.
``mathics3-generate-json-table --help`` for a full list of fields.


Implementation
Expand Down
5 changes: 3 additions & 2 deletions admin-tools/check-versions.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash
function finish {
cd $owd
cd $mathics_scanner_owd
}

# FIXME put some of the below in a common routine
owd=$(pwd)
mathics_scanner_owd=$(pwd)
trap finish EXIT

cd $(dirname ${BASH_SOURCE[0]})
Expand All @@ -24,3 +24,4 @@ for version in $PYVERSIONS; do
fi
echo === $version ===
done
finish
6 changes: 3 additions & 3 deletions admin-tools/make-dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ PACKAGE=mathics-scanner

# FIXME put some of the below in a common routine
function finish {
cd $owd
cd $mathics_scanner_owd
}

cd $(dirname ${BASH_SOURCE[0]})
owd=$(pwd)
mathics_scanner_owd=$(pwd)
trap finish EXIT

if ! source ./pyenv-versions ; then
Expand All @@ -25,9 +25,9 @@ for pyversion in $PYVERSIONS; do
# pip bdist_egg create too-general wheels. So
# we narrow that by moving the generated wheel.

# Pick out first two number of version, e.g. 3.7.9 -> 37
rm -fr build
python setup.py bdist_egg
done
python setup.py bdist_wheel
python ./setup.py sdist
finish
1 change: 1 addition & 0 deletions admin-tools/make-tables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ PYTHON=${PYTHON:-python}

cd $mydir/../mathics_scanner/data
$PYTHON ../generate/build_tables.py -o characters.json
$PYTHON ../generate/build_operator_tables.py -o operators.json
Loading

0 comments on commit d627f29

Please sign in to comment.