Skip to content

Commit

Permalink
Merge branch 'master' into fix_unevaluated
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatera committed Dec 31, 2022
2 parents cb699f8 + e74438c commit ae0ac51
Show file tree
Hide file tree
Showing 267 changed files with 11,157 additions and 8,384 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Othewrwise, Black is run and its changes are committed back to the incoming pull request.
# https://github.com/cclauss/autoblack

name: autoblack
name: isort and black check
on: [pull_request]
jobs:
build:
Expand All @@ -14,11 +14,11 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install click
run: pip install 'click==8.0.4'
- name: Install Black
run: pip install 'black==22.3.0'
- name: Run black --check .
- name: Install click, black and isort
run: pip install 'click==8.0.4' 'black==22.3.0' 'isort==5.10.1'
- name: Run isort --check .
run: isort --check .
- name: Run isort --check .
run: black --check .
- name: If needed, commit black changes to the pull request
if: failure()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
set LLVM_DIR="C:\Program Files\LLVM"
# We can comment out after next Mathics-Scanner release
python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
make develop
make develop-full
- name: Install Mathics
run: |
python setup.py install
Expand Down
10 changes: 10 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[settings]
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
line_length = 88
sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
default_section = THIRDPARTY
combine_as_imports = 1
profile = black
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ repos:
stages: [commit]
- id: end-of-file-fixer
stages: [commit]
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
stages: [commit]
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
Expand Down
34 changes: 29 additions & 5 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,34 @@ CHANGES
5.0.3dev0
---------

API
+++

#. New function ``mathics.system_info.python_implementation()`` shows the Python Implementation, e.g. CPython, PyPy, Pyston that is running Python. This is included in the information ``mathics.system_info.mathics_system__system_info()`` returns and is used in ``$PythonImplementation``
#. A list of optional software can be found in ``mathics.optional_software``. Versions of that software are included in ``mathics.version_info``.


Package update
..............

#. SymPy 1.11.1 accepted
#. Numpy 1.24.0 accepted


New Builtins
+++++++++++

#. ``$BoxForms``
#. ``$OutputForms``
#. ``$PrintForms``
#. ``$PythonImplementation``
#. ``Accuracy``
#. ``ClebschGordan``
#. ``Curl`` (2-D and 3-D vector forms only)
#. ``DiscretePlot``
#. ``Kurtosis``
#. ``ListLogPlot``
#. ``LogPlot``
#. ``PauliMatrix``
#. ``Remove``
#. ``SetOptions``
Expand All @@ -31,25 +49,31 @@ Documentation
#. "Exponential Functional" split out from "Trigonometry Functions"
#. A new section on "Accuracy and Precision" was included in the manual.
#. "Forms of Input and Output" is its own section
#. All Builtins have links to WMA pages.
#. More url links to Wiki pages added; more internal cross links added.
#. Image has been split off from Graphics and Drawing. There are now subsections for Image

Internals
+++++++++

#. ``boxes_to_`` methods are now optional for ``BoxElement`` subclasses. Most of the code is now moved to the ``mathics.format`` submodule, and implemented in a more scalable way.
#. ``mathics.builtin.inout`` was splitted in several modules (``inout``, ``messages``, ``layout``, ``makeboxes``) in order to improve the documentation.
#. `from_mpmath` conversion supports a new parameter ``acc`` to set the accuracy of the number.
#. ``from_mpmath`` conversion supports a new parameter ``acc`` to set the accuracy of the number.
#. Operator name to unicode or ASCII comes from Mathics scanner character tables.
#. ``eval*`` methods in `Builtin` classes are considerer as synonyms of ``apply*`` methods.
#. Modularize and improve the way in which `Builtin` classes are selected to have an associated `Definition`.
#. `_SetOperator.assign_elementary` was renamed as `_SetOperator.assign`. All the special cases are not handled by the `_SetOperator.special_cases` dict.

#. Builtin instance methods that start ``apply`` are considered rule matching and function application; the use of the name ``apply``is deprecated, when ``eval`` is intended.
#. Modularize and improve the way in which ``Builtin`` classes are selected to have an associated ``Definition``.
#. ``_SetOperator.assign_elementary`` was renamed as ``_SetOperator.assign``. All the special cases are not handled by the ``_SetOperator.special_cases`` dict.
#. ``isort`` run over all Python files. More type annotations and docstrings on functions added.
#. caching on immutable atoms like, ``String``, ``Integer``, ``Real``, etc. was improved; the ``__hash__()`` function was sped up. There is a small speedup overall from this at the expense of increased memory.


Bugs
++++

# ``0`` with a given precision (like in ```0`3```) is now parsed as ``0``, an integer number.
#. ``RandomSample`` with one list argument now returns a random ordering of the list items. Previously it would return just one item.
#. Origin placement corrected on ``ListPlot`` and ``LinePlot``.
#. Fix long-standing bugs in Image handling


Enhancements
Expand Down
7 changes: 5 additions & 2 deletions SYMBOLS_MANIFEST.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ System`$PreRead
System`$PrintForms
System`$ProcessID
System`$ProcessorType
System`$PythonImplementation
System`$RandomState
System`$RecursionLimit
System`$RootDirectory
Expand Down Expand Up @@ -244,7 +245,6 @@ System`Continue
System`ContinuedFraction
System`Convert`B64Dump`B64Decode
System`Convert`B64Dump`B64Encode
System`Convert`CommonDump`RemoveLinearSyntax
System`ConvertersDump`$extensionMappings
System`ConvertersDump`$formatMappings
System`CoprimeQ
Expand Down Expand Up @@ -311,6 +311,7 @@ System`DirectoryName
System`DirectoryQ
System`DirectoryStack
System`DiscreteLimit
System`DiscretePlot
System`DisjointQ
System`Disk
System`DiskBox
Expand Down Expand Up @@ -462,7 +463,7 @@ System`Hash
System`Haversine
System`Head
System`HermiteH
System`HexidecimalCharacter
System`HexadecimalCharacter
System`Histogram
System`Hold
System`HoldAll
Expand Down Expand Up @@ -592,6 +593,7 @@ System`LinearModelFit
System`LinearSolve
System`List
System`ListLinePlot
System`ListLogPlot
System`ListPlot
System`ListQ
System`Listable
Expand All @@ -601,6 +603,7 @@ System`Log
System`Log10
System`Log2
System`LogGamma
System`LogPlot
System`LogisticSigmoid
System`Longest
System`Lookup
Expand Down
9 changes: 5 additions & 4 deletions admin-tools/build_and_check_manifest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env python

from mathics.builtin import name_is_builtin_symbol, modules, Builtin
import sys

from mathics.builtin import Builtin, modules, name_is_builtin_symbol

def generate_avaliable_builtins_names():

def generate_available_builtins_names():
msg = ""
builtins_by_name = {}
for module in modules:
Expand Down Expand Up @@ -37,15 +38,15 @@ def generate_avaliable_builtins_names():


def build_builtin_manifest():
builtins_by_name = generate_avaliable_builtins_names()
builtins_by_name = generate_available_builtins_names()
with open("SYMBOLS_MANIFEST.txt", "w") as f_out:
for key in sorted(key for key in builtins_by_name):
f_out.write(key + "\n")


def check_manifest():
status_OK = True
builtins_by_name = generate_avaliable_builtins_names()
builtins_by_name = generate_available_builtins_names()
with open("SYMBOLS_MANIFEST.txt", "r") as f_in:
manifest_symbols = {name[:-1]: "OK" for name in f_in.readlines()}
# Check that all the Symbols in the manifest are available
Expand Down
3 changes: 2 additions & 1 deletion admin-tools/time-mathmp-sympy-fns.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
Program to time mpmath pi vs sympy pi
"""

import math
from timeit import timeit

import mpmath
import math
import sympy

PRECISION = 100
Expand Down
42 changes: 32 additions & 10 deletions mathics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,50 @@
# -*- coding: utf-8 -*-

import sys
import platform
import sympy
import sys
from importlib import import_module
from typing import Dict

import mpmath
import numpy
import sympy

from mathics.version import __version__

version_info = {
# version_info contains a list of Python packages
# and the versions infsalled or "Not installed"
# if the package is not installed and "No version information"
# if we can't get version infomation.
version_info: Dict[str, str] = {
"mathics": __version__,
"sympy": sympy.__version__,
"mpmath": mpmath.__version__,
"numpy": numpy.__version__,
"python": platform.python_implementation() + " " + sys.version.split("\n")[0],
"sympy": sympy.__version__,
}

try:
import cython
except ImportError:
pass
else:
version_info["cython"] = cython.__version__

# optional_software contains a list of Python packages
# that add functionality but are optional
optional_software: Dict[str, str] = (
"cython",
"lxml",
"networkx",
"nltk",
"psutil",
"scikit-image",
"scipy",
"wordcloud",
)

for package in optional_software:
try:
mod = import_module(package)
package_version = mod.__dict__.get("__version__", "No version information")
except ImportError:
package_version = "Not installed"

version_info[package] = package_version

version_string = """Mathics {mathics}
on {python}
Expand Down
4 changes: 2 additions & 2 deletions mathics/algorithm/clusters.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-


import random
from itertools import chain, islice
import bisect
import math
import random
from itertools import chain, islice

from mpmath import fsum

Expand Down
11 changes: 2 additions & 9 deletions mathics/algorithm/integrators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,11 @@

import numpy as np

from mathics.core.number import machine_epsilon
from mathics.core.atoms import Integer, Integer0, Number
from mathics.core.expression import Expression
from mathics.core.atoms import (
Integer,
Integer0,
Number,
)

from mathics.core.list import ListExpression
from mathics.core.number import machine_epsilon
from mathics.core.symbols import Symbol, SymbolPlus, SymbolSequence, SymbolTimes


from mathics.core.systemsymbols import (
SymbolBlank,
SymbolComplex,
Expand Down
2 changes: 1 addition & 1 deletion mathics/algorithm/introselect.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ def introselect(a, k): # changes a


if __name__ == "__main__":
import random
import itertools
import random

def test_algorithm(l, r_max, name, f):
a = [random.randint(-r_max, r_max) for _ in range(l)]
Expand Down
16 changes: 4 additions & 12 deletions mathics/algorithm/optimizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,22 @@
from typing import Optional

from mathics.builtin.scoping import dynamic_scoping


from mathics.core.atoms import (
String,
Integer,
Integer0,
IntegerM1,
Integer1,
Integer2,
Integer3,
Integer10,
IntegerM1,
Number,
Real,
String,
)
from mathics.core.convert.python import from_python
from mathics.core.evaluation import Evaluation
from mathics.eval.nevaluator import eval_N
from mathics.core.expression import Expression
from mathics.core.symbols import (
BaseElement,
SymbolPlus,
SymbolTimes,
SymbolTrue,
)

from mathics.core.symbols import BaseElement, SymbolPlus, SymbolTimes, SymbolTrue
from mathics.core.systemsymbols import (
SymbolAutomatic,
SymbolD,
Expand All @@ -37,6 +28,7 @@
SymbolLog,
SymbolNone,
)
from mathics.eval.nevaluator import eval_N


def find_minimum_newton1d(f, x0, x, opts, evaluation) -> (Number, bool):
Expand Down
3 changes: 1 addition & 2 deletions mathics/algorithm/parts.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
)
from mathics.core.expression import Expression
from mathics.core.list import ListExpression
from mathics.core.subexpression import SubExpression
from mathics.core.symbols import Atom, Symbol, SymbolList
from mathics.core.systemsymbols import SymbolDirectedInfinity, SymbolInfinity
from mathics.core.subexpression import SubExpression


SymbolNothing = Symbol("Nothing")

Expand Down
Loading

0 comments on commit ae0ac51

Please sign in to comment.