Skip to content

Commit

Permalink
Moving modules from mathics.algorithm to mathics.eval (#922)
Browse files Browse the repository at this point in the history
From the discussion in PR #918
(#918 (comment)),
I remembered that this was something pendant for a while, so I started
moving these modules to follow the new organization of the code.
  • Loading branch information
mmatera authored Sep 20, 2023
1 parent 0cdc458 commit 6318023
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 22 deletions.
2 changes: 1 addition & 1 deletion mathics/builtin/atomic/numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
SymbolRound,
)
from mathics.eval.nevaluator import eval_N
from mathics.eval.numbers import eval_Accuracy, eval_Precision
from mathics.eval.numbers.numbers import eval_Accuracy, eval_Precision

SymbolIntegerDigits = Symbol("IntegerDigits")
SymbolIntegerExponent = Symbol("IntegerExponent")
Expand Down
4 changes: 2 additions & 2 deletions mathics/builtin/numbers/algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import sympy

from mathics.algorithm.simplify import default_complexity_function
from mathics.builtin.inference import evaluate_predicate
from mathics.builtin.options import options_to_rules
from mathics.builtin.scoping import dynamic_scoping
Expand Down Expand Up @@ -64,7 +63,8 @@
SymbolTable,
SymbolTanh,
)
from mathics.eval.numbers import cancel, sympy_factor
from mathics.eval.numbers.algebra.simplify import default_complexity_function
from mathics.eval.numbers.numbers import cancel, sympy_factor
from mathics.eval.parts import walk_parts
from mathics.eval.patterns import match

Expand Down
34 changes: 18 additions & 16 deletions mathics/builtin/numbers/calculus.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@
import numpy as np
import sympy

from mathics.algorithm.integrators import (
_fubini,
_internal_adaptative_simpsons_rule,
decompose_domain,
eval_D_to_Integral,
)
from mathics.algorithm.series import (
build_series,
series_derivative,
series_plus_series,
series_times_series,
)
from mathics.builtin.scoping import dynamic_scoping
from mathics.core.atoms import (
Atom,
Expand Down Expand Up @@ -90,6 +78,18 @@
)
from mathics.eval.makeboxes import format_element
from mathics.eval.nevaluator import eval_N
from mathics.eval.numbers.calculus.integrators import (
_fubini,
_internal_adaptative_simpsons_rule,
decompose_domain,
eval_D_to_Integral,
)
from mathics.eval.numbers.calculus.series import (
build_series,
series_derivative,
series_plus_series,
series_times_series,
)

# These should be used in lower-level formatting
SymbolDifferentialD = Symbol("System`DifferentialD")
Expand Down Expand Up @@ -748,7 +748,9 @@ class FindMaximum(_BaseFinder):
messages = _BaseFinder.messages.copy()
summary_text = "local maximum optimization"
try:
from mathics.algorithm.optimizers import native_local_optimizer_methods
from mathics.eval.numbers.calculus.optimizers import (
native_local_optimizer_methods,
)

methods.update(native_local_optimizer_methods)
except Exception:
Expand Down Expand Up @@ -797,7 +799,7 @@ class FindMinimum(_BaseFinder):
messages = _BaseFinder.messages.copy()
summary_text = "local minimum optimization"
try:
from mathics.algorithm.optimizers import (
from mathics.eval.numbers.calculus.optimizers import (
native_local_optimizer_methods,
native_optimizer_messages,
)
Expand Down Expand Up @@ -883,7 +885,7 @@ class FindRoot(_BaseFinder):
)

try:
from mathics.algorithm.optimizers import (
from mathics.eval.numbers.calculus.optimizers import (
native_findroot_messages,
native_findroot_methods,
)
Expand Down Expand Up @@ -1349,7 +1351,7 @@ class NIntegrate(Builtin):

try:
# builtin integrators
from mathics.algorithm.integrators import (
from mathics.eval.numbers.calculus.integrators import (
integrator_messages,
integrator_methods,
)
Expand Down
2 changes: 1 addition & 1 deletion mathics/core/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
SymbolSequence,
)
from mathics.eval.arithmetic import eval_mpmath_function
from mathics.eval.numbers import cancel
from mathics.eval.numbers.numbers import cancel
from mathics.eval.numerify import numerify
from mathics.eval.scoping import dynamic_scoping

Expand Down
4 changes: 4 additions & 0 deletions mathics/eval/numbers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
"""
Implementation of mathics.builtin.numbers
"""
4 changes: 4 additions & 0 deletions mathics/eval/numbers/algebra/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
"""
Implementation of mathics.builtin.numbers.algebra
"""
File renamed without changes.
4 changes: 4 additions & 0 deletions mathics/eval/numbers/calculus/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
"""
Implementation of mathics.builtin.numbers.calculus
"""
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-

"""
Implementation of builtin function integrators.
"""
import numpy as np

from mathics.core.atoms import Integer, Integer0, Number
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-

"""
Implementation of builtin optimizers.
"""
from typing import Optional

from mathics.builtin.scoping import dynamic_scoping
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# -*- coding: utf-8 -*-
"""
Implementation of Series handling functions.
"""
from mathics.core.atoms import Integer, Integer0, Rational
from mathics.core.convert.expression import to_mathics_list
from mathics.core.expression import Expression
Expand Down
5 changes: 5 additions & 0 deletions mathics/eval/numbers.py → mathics/eval/numbers/numbers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# -*- coding: utf-8 -*-
"""
Implementation of numbers handling functions.
"""

from typing import Optional

import mpmath
Expand Down

0 comments on commit 6318023

Please sign in to comment.