Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatera committed Dec 12, 2023
1 parent 2cca637 commit 3025fb4
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 1 deletion.
81 changes: 81 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# A GNU Makefile to run various tasks - compatibility for us old-timers.

# Note: This makefile include remake-style target comments.
# These comments before the targets start with #:
# remake --tasks to shows the targets and the comments

GIT2CL ?= admin-tools/git2cl
PYTHON ?= python
PIP ?= $(PYTHON) -m pip
RM ?= rm


.PHONY: all build \
check clean \
develop dist doc doc-data \
pypi-setup \
pytest \
rmChangeLog \
test

#: Default target - same as "develop"
all: develop

#: build everything needed to install
build: pypi-setup
$(PYTHON) ./setup.py build

#: Check Python version, and install PyPI dependencies
pypi-setup:
$(PIP) install -e .

#: Set up to run from the source tree
develop: pypi-setup

#: Make distirbution: wheels, eggs, tarball
dist:
./admin-tools/make-dist.sh

#: Install pymathics.graph
install: pypi-setup
$(PYTHON) setup.py install

# Run tests
test check: pytest doctest

#: Remove derived files
clean: clean-pyc

#: Remove old PYC files
clean-pyc:
@find . -name "*.pyc" -type f -delete

#: Run py.test tests. Use environment variable "o" for pytest options
pytest:
MATHICS_CHARACTER_ENCODING="ASCII" $(PYTHON) -m pytest $(PYTEST_WORKERS) test $o


# #: Create data that is used to in Django docs and to build TeX PDF
# doc-data mathics/doc/tex/data: mathics/builtin/*.py mathics/doc/documentation/*.mdoc mathics/doc/documentation/images/*
# $(PYTHON) mathics/test.py -ot -k

#: Run tests that appear in docstring in the code.
doctest:
MATHICS_CHARACTER_ENCODING="ASCII" $(PYTHON) -m mathics.docpipeline -l pymathics.language -c "Pymathics Language" $o

# #: Make Mathics PDF manual
# doc mathics.pdf: mathics/doc/tex/data
# (cd mathics/doc/tex && $(MAKE) mathics.pdf)

#: Remove ChangeLog
rmChangeLog:
$(RM) ChangeLog || true

#: Create a ChangeLog from git via git log and git2cl
ChangeLog: rmChangeLog
git log --pretty --numstat --summary | $(GIT2CL) >$@


#: Run pytest consistency and style checks
check-consistency-and-style:
MATHICS_LINT=t $(PYTHON) -m pytest test/consistency-and-style
2 changes: 1 addition & 1 deletion pymathics/language/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from typing import List, Optional

from mathics.core.atoms import String
from mathics.core.base import Builtin
from mathics.core.builtin import Builtin
from mathics.core.convert.expression import to_mathics_list

availableLocales = Locale.getAvailableLocales()
Expand Down
24 changes: 24 additions & 0 deletions test/test_language.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-

from mathics.core.load_builtin import import_and_load_builtins
from mathics.session import MathicsSession

import_and_load_builtins()

session = MathicsSession(character_encoding="ASCII")


def check_evaluation(str_expr: str, expected: str, message=""):
"""Helper function to test that a Mathics expression against
its results"""
result = session.evaluate(str_expr).value

if message:
assert result == expected, f"{message}: got: {result}"
else:
assert result == expected


def test_hello():
session.evaluate('LoadModule["pymathics.language"]') == "pymathics.language"
check_evaluation('Alphabet["es"]//Length', 33)

0 comments on commit 3025fb4

Please # to comment.