Skip to content

Commit

Permalink
Merge branch 'master' into add-FileNameDrop
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatera authored Oct 21, 2024
2 parents 5465977 + 712337b commit 84227ab
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 66 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
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
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
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
5 changes: 5 additions & 0 deletions mathics/builtin/numbers/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,3 +756,8 @@ class Underflow(Builtin):
instance = cls(expression=False)
val = instance.get_constant()
NUMERICAL_CONSTANTS[instance.symbol] = MachineReal(val.value)

# Remove these variables to prevent errors in the SYMBOL_MANIFEST check.
del cls
del instance
del val

0 comments on commit 84227ab

Please sign in to comment.