Skip to content

Commit

Permalink
Merge branch 'master' into builtins
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatera authored Oct 22, 2024
2 parents f459556 + 8c472bd commit 2823f73
Show file tree
Hide file tree
Showing 19 changed files with 151 additions and 166 deletions.
1 change: 1 addition & 0 deletions .github/workflows/consistency-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ jobs:
- name: Test Mathics Consistency and Style
run: |
make check-consistency-and-style
make check-builtin-manifest
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ API incompatibility
-------------------

* ``Matcher`` now requires an additional ``evaluation`` parameter
* ``Romberg`` removed as an ``NIntegrate[]`` method. It is depcrecated in SciPy and is to be removed by SciPy 1.15.


Bugs
Expand Down
30 changes: 26 additions & 4 deletions SYMBOLS_MANIFEST.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CombinatoricaOld`BinarySearch
HTML`DataImport
HTML`FullDataImport
HTML`HyperlinksImport
Expand Down Expand Up @@ -40,6 +39,7 @@ System`$Machine
System`$MachineEpsilon
System`$MachineName
System`$MachinePrecision
System`$MaxLengthIntStringConversion
System`$MaxMachineNumber
System`$MaxPrecision
System`$MinMachineNumber
Expand Down Expand Up @@ -105,7 +105,6 @@ System`Apart
System`Append
System`AppendTo
System`Apply
System`ApplyLevel
System`ArcCos
System`ArcCosh
System`ArcCot
Expand Down Expand Up @@ -134,10 +133,12 @@ System`Attributes
System`Automatic
System`Axes
System`Axis
System`Background
System`BarChart
System`BaseForm
System`Begin
System`BeginPackage
System`BellB
System`BernoulliB
System`BernsteinBasis
System`BesselI
Expand Down Expand Up @@ -197,6 +198,7 @@ System`ChartLegends
System`ChebyshevT
System`ChebyshevU
System`Check
System`CheckAbort
System`ChessboardDistance
System`Chop
System`Circle
Expand Down Expand Up @@ -238,6 +240,7 @@ System`ConditionalExpression
System`Cone
System`Cone3DBox
System`Conjugate
System`ConjugateTranspose
System`Constant
System`ConstantArray
System`ContainsOnly
Expand Down Expand Up @@ -322,6 +325,8 @@ System`Dispatch
System`Divide
System`DivideBy
System`Divisible
System`DivisorSigma
System`DivisorSum
System`Divisors
System`Do
System`Dodecahedron
Expand Down Expand Up @@ -355,12 +360,14 @@ System`Erf
System`Erfc
System`Erosion
System`EuclideanDistance
System`EulerE
System`EulerGamma
System`EulerPhi
System`Evaluate
System`EvenQ
System`ExactNumberQ
System`Except
System`Exit
System`Exp
System`ExpIntegralE
System`ExpIntegralEi
Expand Down Expand Up @@ -526,6 +533,8 @@ System`Integer
System`IntegerDigits
System`IntegerExponent
System`IntegerLength
System`IntegerPart
System`IntegerPartitions
System`IntegerQ
System`IntegerReverse
System`IntegerString
Expand All @@ -543,6 +552,7 @@ System`InverseGudermannian
System`InverseHaversine
System`JaccardDissimilarity
System`JacobiP
System`JacobiSymbol
System`Join
System`Joined
System`KelvinBei
Expand All @@ -554,6 +564,7 @@ System`Keys
System`Khinchin
System`KnownUnitQ
System`KroneckerProduct
System`KroneckerSymbol
System`Kurtosis
System`LABColor
System`LCHColor
Expand All @@ -574,9 +585,9 @@ System`LessEqual
System`LetterCharacter
System`LetterNumber
System`LetterQ
System`LeviCivitaTensor
System`Level
System`LevelQ
System`LeviCivitaTensor
System`LightBlue
System`LightBrown
System`LightCyan
Expand All @@ -600,6 +611,7 @@ System`ListLinePlot
System`ListLogPlot
System`ListPlot
System`ListQ
System`ListStepPlot
System`Listable
System`LoadModule
System`Locked
Expand All @@ -612,13 +624,15 @@ System`LogisticSigmoid
System`Longest
System`Lookup
System`LowerCaseQ
System`LucasL
System`MachineNumberQ
System`MachinePrecision
System`Magenta
System`MakeBoxes
System`ManhattanDistance
System`MantissaExponent
System`Map
System`MapApply
System`MapAt
System`MapIndexed
System`MapThread
Expand All @@ -642,6 +656,7 @@ System`Medium
System`MemberQ
System`MemoryAvailable
System`MemoryInUse
System`MersennePrimeExponent
System`Mesh
System`Message
System`MessageName
Expand All @@ -655,6 +670,7 @@ System`Missing
System`Mod
System`ModularInverse
System`Module
System`MoebiusMu
System`MorphologicalComponents
System`Most
System`Multinomial
Expand Down Expand Up @@ -760,6 +776,7 @@ System`PolyGamma
System`Polygon
System`Polygon3DBox
System`PolygonBox
System`PolygonalNumber
System`PolynomialQ
System`Position
System`Positive
Expand All @@ -768,6 +785,7 @@ System`Postfix
System`Power
System`PowerExpand
System`PowerMod
System`PowersRepresentations
System`PreDecrement
System`PreIncrement
System`Precedence
Expand All @@ -793,6 +811,7 @@ System`PseudoInverse
System`Purple
System`Put
System`PutAppend
System`PythonCProfileEvaluation
System`PythonForm
System`QRDecomposition
System`Quantile
Expand Down Expand Up @@ -827,8 +846,8 @@ System`ReadProtected
System`Real
System`RealAbs
System`RealDigits
System`RealNumberQ
System`RealSign
System`RealValuedNumberQ
System`Reals
System`Reap
System`Record
Expand All @@ -855,6 +874,7 @@ System`ResetDirectory
System`Rest
System`Return
System`Reverse
System`ReverseSort
System`Riffle
System`Right
System`RogersTanimotoDissimilarity
Expand Down Expand Up @@ -886,6 +906,7 @@ System`Set
System`SetAttributes
System`SetDelayed
System`SetDirectory
System`SetEnvironment
System`SetFileDate
System`SetOptions
System`SetStreamPosition
Expand Down Expand Up @@ -925,6 +946,7 @@ System`SplitBy
System`Sqrt
System`SqrtBox
System`SquaredEuclideanDistance
System`SquaresR
System`StandardDeviation
System`StandardForm
System`StartOfLine
Expand Down
4 changes: 2 additions & 2 deletions admin-tools/build_and_check_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from mathics.core.builtin import Builtin
from mathics.core.load_builtin import (
import_and_load_builtins,
modules,
mathics3_builtins_modules,
name_is_builtin_symbol,
)

Expand All @@ -15,7 +15,7 @@
def generate_available_builtins_names():
msg = ""
builtins_by_name = {}
for module in modules:
for module in mathics3_builtins_modules:
vars = dir(module)
for name in vars:
var = name_is_builtin_symbol(module, name)
Expand Down
2 changes: 1 addition & 1 deletion mathics/builtin/arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import sympy

from mathics.builtin.inference import get_assumptions_list
from mathics.builtin.numeric import Abs
from mathics.builtin.scoping import dynamic_scoping
from mathics.core.atoms import (
Expand Down Expand Up @@ -72,6 +71,7 @@
SymbolUndefined,
)
from mathics.eval.arithmetic import eval_Sign
from mathics.eval.inference import get_assumptions_list
from mathics.eval.nevaluator import eval_N

# This tells documentation how to sort this module
Expand Down
8 changes: 5 additions & 3 deletions mathics/builtin/atomic/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,14 +411,16 @@ class HexadecimalCharacter(Builtin):

# This isn't your normal Box class. We'll keep this here rather than
# in mathics.builtin.box for now.
class InterpretationBox(PrefixOperator):
# mmatera commenct: This does not even exist in WMA. \! should be associated
# to `ToExpression`, but it was not properly implemented by now...
class InterpretedBox(PrefixOperator):
r"""
<url>
:WMA link:
https://reference.wolfram.com/language/ref/InterpretationBox.html</url>
<dl>
<dt>'InterpretationBox[$box$]'
<dt>'InterpretedBox[$box$]'
<dd>is the ad hoc fullform for \! $box$. just for internal use...
</dl>
Expand All @@ -430,7 +432,7 @@ class InterpretationBox(PrefixOperator):
summary_text = "interpret boxes as an expression"

def eval(self, boxes, evaluation: Evaluation):
"""InterpretationBox[boxes_]"""
"""InterpretedBox[boxes_]"""
# TODO: the following is a very raw and dummy way to
# handle these expressions.
# In the first place, this should handle different kind
Expand Down
2 changes: 1 addition & 1 deletion mathics/builtin/drawing/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def eval(self, points, evaluation: Evaluation, options: dict):
all_points = (
points.value
if hasattr(points, "value") and points.value is not None
else eval_N(points, evaluation).to_python()
else eval_N(points, evaluation).to_python() # TODO: force tuple-ness?
)

# FIXME: arrange for self to have a .symbolname property or attribute
Expand Down
57 changes: 0 additions & 57 deletions mathics/builtin/files_io/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,63 +346,6 @@ def eval(self, evaluation: Evaluation):
return String(result)


class DirectoryName(Builtin):
"""
<url>:WMA link:https://reference.wolfram.com/language/ref/DirectoryName.html</url>
<dl>
<dt>'DirectoryName["$name$"]'
<dd>extracts the directory name from a filename.
</dl>
>> DirectoryName["a/b/c"]
= a/b
>> DirectoryName["a/b/c", 2]
= a
"""

messages = {
"string": "String expected at position 1 in `1`.",
"intpm": ("Positive machine-sized integer expected at " "position 2 in `1`."),
}

options = {
"OperatingSystem": "$OperatingSystem",
}
summary_text = "directory part of a filename"

def eval_with_n(self, name, n, evaluation: Evaluation, options: dict):
"DirectoryName[name_, n_, OptionsPattern[DirectoryName]]"

if n is None:
expr = to_expression("DirectoryName", name)
py_n = 1
else:
expr = to_expression("DirectoryName", name, n)
py_n = n.to_python()

if not (isinstance(py_n, int) and py_n > 0):
evaluation.message("DirectoryName", "intpm", expr)
return

py_name = name.to_python()
if not (isinstance(py_name, str) and py_name[0] == py_name[-1] == '"'):
evaluation.message("DirectoryName", "string", expr)
return
py_name = py_name[1:-1]

result = py_name
for i in range(py_n):
(result, tmp) = osp.split(result)

return String(result)

def eval(self, name, evaluation: Evaluation, options: dict):
"DirectoryName[name_, OptionsPattern[DirectoryName]]"
return self.eval_with_n(name, None, evaluation, options)


class DirectoryStack(Builtin):
"""
<url>:WMA link:https://reference.wolfram.com/language/ref/DirectoryStack.html</url>
Expand Down
Loading

0 comments on commit 2823f73

Please sign in to comment.