From 1ee7eeab9fa5f652caff40c7d17e11bb2a0df1fd Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 27 Jul 2026 21:40:44 -0400 Subject: [PATCH 1/6] Add Import for WL files. It works the same as Get, but has the Import interface. --- mathics/Data/ExampleData/HelloWorld.wl | 2 ++ mathics/SystemFiles/Formats/WL/Import.wl | 17 +++++++++++ mathics/builtin/fileformats/wlformat.py | 28 +++++++++++++++++++ .../import_export/test_importexport.py | 7 +++++ 4 files changed, 54 insertions(+) create mode 100644 mathics/Data/ExampleData/HelloWorld.wl create mode 100644 mathics/SystemFiles/Formats/WL/Import.wl create mode 100644 mathics/builtin/fileformats/wlformat.py diff --git a/mathics/Data/ExampleData/HelloWorld.wl b/mathics/Data/ExampleData/HelloWorld.wl new file mode 100644 index 000000000..bd83ab015 --- /dev/null +++ b/mathics/Data/ExampleData/HelloWorld.wl @@ -0,0 +1,2 @@ +(* An example of a Wolfram Language/Mathics3 program that can be used for testing. *) +"Hello, " <> "World!" diff --git a/mathics/SystemFiles/Formats/WL/Import.wl b/mathics/SystemFiles/Formats/WL/Import.wl new file mode 100644 index 000000000..32794e48c --- /dev/null +++ b/mathics/SystemFiles/Formats/WL/Import.wl @@ -0,0 +1,17 @@ +(* ::Package:: *) + +(* Note: this is stripped down a lot from what WMA handles. *) + +Begin["System`Convert`WLDump`"]; + + +ImportExport`RegisterImport[ + "WL", (* WMA mime-type name *) + WLDump`ImportWL (* Default Function name that handles this. *), + {}, + "AvailableElements" -> {"Get", "Script"}, + "DefaultElement" -> "Get" +]; + + +End[]; diff --git a/mathics/builtin/fileformats/wlformat.py b/mathics/builtin/fileformats/wlformat.py new file mode 100644 index 000000000..b80de04ed --- /dev/null +++ b/mathics/builtin/fileformats/wlformat.py @@ -0,0 +1,28 @@ +""" +WL File Format + +WL and Mathics3 importer +""" + +from mathics.core.builtin import Builtin, String +from mathics.core.evaluation import Evaluation +from mathics.eval.fileformats.wlformat import eval_WLImport + + +class ImportWL(Builtin): + """ + :WMA link:https://reference.wolfram.com/language/ref/format/WL.html + +
+
'WLDump`ImportWL[$path$]' +
Read $path$ as a Wolfram package and 'Get' it. +
+ + """ + + context = "WLDump`" + summary_text = "import WL file" + + def eval(self, path: String, evaluation: Evaluation): + "WLDump`ImportWL[path_String]" + return eval_WLImport(path, evaluation) diff --git a/test/builtin/import_export/test_importexport.py b/test/builtin/import_export/test_importexport.py index c016a193e..7d929ce97 100644 --- a/test/builtin/import_export/test_importexport.py +++ b/test/builtin/import_export/test_importexport.py @@ -232,6 +232,13 @@ def test_export(): "0.88, 0.60, 0.94\n.076, 0.19, .51\n0.97, 0.04, .26", None, ), + # WL + ( + 'Import["ExampleData/HelloWorld.wl"]', + None, + "Hello, World!", + None, + ), # FIXME: the below out is incorrect and does not match WMA, # due to a lame homegrown implementation of # CSV. The data below will change when we use Python's CSV library. From 29e16e80c29019b145a679f4eb51ce454514687e Mon Sep 17 00:00:00 2001 From: rocky Date: Tue, 28 Jul 2026 12:30:44 -0400 Subject: [PATCH 2/6] Promote a 'WLFormat' pytest to doctests and demonstrate explanation of 'WLFormat' vs. 'Import' and 'Get' --- mathics/builtin/fileformats/wlformat.py | 24 +++++++++++++++++++ .../import_export/test_importexport.py | 7 ------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/mathics/builtin/fileformats/wlformat.py b/mathics/builtin/fileformats/wlformat.py index b80de04ed..199b70320 100644 --- a/mathics/builtin/fileformats/wlformat.py +++ b/mathics/builtin/fileformats/wlformat.py @@ -18,6 +18,30 @@ class ImportWL(Builtin):
Read $path$ as a Wolfram package and 'Get' it. + This command is hooked into the 'Import' command via \ + 'SystemFiles/Formats/WL/Import.wl'. + + When running this command directly, a list of rules is returned: + + >> WLDump`ImportWL["ExampleData/HelloWorld.wl"] + = {Get -> Hello, World!, Script -> Hello, World!} + + The left-hand side is a element name that can be provided to 'Import', \ + and the right-hand side is the value associated with that element. Here it \ + represents the last evaluation value when evaluating the contents of the file. + + When an 'Import' is done and the file mentioned is a Mathics3 or a \ + Wolfram-Language file, this command is run underneath selecting value of the \ + "Get" element: + + >> Import["ExampleData/HelloWorld.wl"] + = Hello, World! + + All of this is the same as just running a simple 'Get': + >> << "ExampleData/HelloWorld.wl" + = Hello, World! + + In sum, the built-in provides the glue to the 'Import' accees mechanism for 'Get'. """ context = "WLDump`" diff --git a/test/builtin/import_export/test_importexport.py b/test/builtin/import_export/test_importexport.py index 7d929ce97..c016a193e 100644 --- a/test/builtin/import_export/test_importexport.py +++ b/test/builtin/import_export/test_importexport.py @@ -232,13 +232,6 @@ def test_export(): "0.88, 0.60, 0.94\n.076, 0.19, .51\n0.97, 0.04, .26", None, ), - # WL - ( - 'Import["ExampleData/HelloWorld.wl"]', - None, - "Hello, World!", - None, - ), # FIXME: the below out is incorrect and does not match WMA, # due to a lame homegrown implementation of # CSV. The data below will change when we use Python's CSV library. From d29be8cb6996d0c0ba502a309bdba151949c4ce4 Mon Sep 17 00:00:00 2001 From: Juan Mauricio Matera Date: Tue, 28 Jul 2026 20:31:40 -0300 Subject: [PATCH 3/6] fix doctests to pass without ascii (#1879) Last adjustments to make tests transparent to the system encoding --- Makefile | 4 ++-- mathics/builtin/atomic/symbols.py | 2 +- mathics/builtin/functional/apply_fns_to_lists.py | 4 ++-- mathics/builtin/layout.py | 2 +- mathics/builtin/numbers/algebra.py | 6 +++--- mathics/doc/documentation/1-Manual.mdoc | 10 +++++----- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 58d7915e2..105ac61a6 100644 --- a/Makefile +++ b/Makefile @@ -134,7 +134,7 @@ mypy: mypy --install-types --ignore-missing-imports --non-interactive mathics plot-detailed-tests: - MATHICS_CHARACTER_ENCODING="ASCII" MATHICS_PLOT_DETAILED_TESTS="1" $(PYTHON) -m pytest -x $(PYTEST_OPTIONS) test/builtin/drawing/test_plot_detail.py + MATHICS_PLOT_DETAILED_TESTS="1" $(PYTHON) -m pytest -x $(PYTEST_OPTIONS) test/builtin/drawing/test_plot_detail.py #: Run pytest tests. Use environment variable "PYTEST_OPTIONS" for pytest options pytest: @@ -156,7 +156,7 @@ latex-doctest-data: mathics/builtin/*.py mathics/doc/documentation/*.mdoc mathic #: Run tests that appear in docstring in the code. Use environment variable "DOCTEST_OPTIONS" for doctest options doctest: - MATHICS_CHARACTER_ENCODING="ASCII" MATHICS3_SANDBOX=$(MATHICS3_SANDBOX) $(PYTHON) mathics/docpipeline.py $(DOCTEST_OPTIONS) + MATHICS3_SANDBOX=$(MATHICS3_SANDBOX) $(PYTHON) mathics/docpipeline.py $(DOCTEST_OPTIONS) #: Run tests that appear in docstring in the code, stopping on the first error. doctest-x: diff --git a/mathics/builtin/atomic/symbols.py b/mathics/builtin/atomic/symbols.py index c576905a2..f541b5bbf 100644 --- a/mathics/builtin/atomic/symbols.py +++ b/mathics/builtin/atomic/symbols.py @@ -422,7 +422,7 @@ class FormatValues(Builtin): The replacement pattern on the right in the delayed rule is formatted according to the top-level form. To see the rule input, we can use 'InputForm': >> FormatValues[F] //InputForm - = {HoldPattern[Format[F[x_], OutputForm]] ⧴ Subscript[x, F]} + = {HoldPattern[Format[F[x_], OutputForm]] :> Subscript[x, F]} """ summary_text = ( diff --git a/mathics/builtin/functional/apply_fns_to_lists.py b/mathics/builtin/functional/apply_fns_to_lists.py index f5e0529cd..1eeed7b38 100644 --- a/mathics/builtin/functional/apply_fns_to_lists.py +++ b/mathics/builtin/functional/apply_fns_to_lists.py @@ -224,11 +224,11 @@ class MapAt(Builtin): Map $f$ onto at the second position of an association: >> MapAt[f, <|"a" -> 1, "b" -> 2, "c" -> 3, "d" -> 4|>, 2] - = <|a -> 1, b -> f[2], c -> 3, d -> 4|> + = <|a ⇾ 1, b ⇾ f[2], c ⇾ 3, d ⇾ 4|> Same as above, but select the second-from-the-end position: >> MapAt[f, <|"a" -> 1, "b" -> 2, "c" -> 3, "d" -> 4|>, -2] - = <|a -> 1, b -> 2, c -> f[3], d -> 4|> + = <|a ⇾ 1, b ⇾ 2, c ⇾ f[3], d ⇾ 4|> """ diff --git a/mathics/builtin/layout.py b/mathics/builtin/layout.py index d246705ef..4f1ae83f0 100644 --- a/mathics/builtin/layout.py +++ b/mathics/builtin/layout.py @@ -100,7 +100,7 @@ class Format(Builtin): Mathics3 input: >> Format[{a -> Integrate[F[x], x]}, StandardForm] //InputForm - = Format[{a ⇾ Integrate[F[x], x]}, StandardForm] + = Format[{a -> Integrate[F[x], x]}, StandardForm] In WMA, you might not get something that can be used as input. diff --git a/mathics/builtin/numbers/algebra.py b/mathics/builtin/numbers/algebra.py index 36f3ab273..c5cc00c70 100644 --- a/mathics/builtin/numbers/algebra.py +++ b/mathics/builtin/numbers/algebra.py @@ -135,7 +135,7 @@ class Apart(Builtin): = Sin[1 / (x ^ 2 - y ^ 2)] >> a == "A" // Apart // InputForm - = a ⩵ "A" + = a == "A" """ attributes = A_LISTABLE | A_PROTECTED @@ -175,7 +175,7 @@ class Cancel(Builtin): But it does not touch other expressions: >> a == "A" // Cancel // InputForm - = a ⩵ "A" + = a == "A" """ attributes = A_LISTABLE | A_PROTECTED @@ -976,7 +976,7 @@ class Factor(Builtin): But it does not touch other expressions: >> a == "A" // Factor // InputForm - = a ⩵ "A" + = a == "A" """ attributes = A_LISTABLE | A_PROTECTED diff --git a/mathics/doc/documentation/1-Manual.mdoc b/mathics/doc/documentation/1-Manual.mdoc index 4b7f03726..be91db740 100644 --- a/mathics/doc/documentation/1-Manual.mdoc +++ b/mathics/doc/documentation/1-Manual.mdoc @@ -1233,15 +1233,15 @@ A dice object shall be displayed as a rectangle with the given number of points #> Definition[Dice] = Attributes[Dice] = {Orderless} . - . Format[Dice[n_Integer ? (1 ≤ #1 ≤ 6&)], MathMLForm] = Block[{p = 0.2, r = 0.05}, Graphics[{EdgeForm[Black], White, Rectangle[], Black, EdgeForm[], If[OddQ[n], Disk[{0.5, 0.5}, r]], If[MemberQ[{2, 3, 4, 5, 6}, n], Disk[{p, p}, r]], If[MemberQ[{2, 3, 4, 5, 6}, n], Disk[{1 - p, 1 - p}, r]], If[MemberQ[{4, 5, 6}, n], Disk[{p, 1 - p}, r]], If[MemberQ[{4, 5, 6}, n], Disk[{1 - p, p}, r]], If[n === 6, {Disk[{p, 0.5}, r], Disk[{1 - p, 0.5}, r]}]}, ImageSize ⇾ Tiny]] + . Format[Dice[n_Integer ? (1 <= #1 <= 6&)], MathMLForm] = Block[{p = 0.2, r = 0.05}, Graphics[{EdgeForm[Black], White, Rectangle[], Black, EdgeForm[], If[OddQ[n], Disk[{0.5, 0.5}, r]], If[MemberQ[{2, 3, 4, 5, 6}, n], Disk[{p, p}, r]], If[MemberQ[{2, 3, 4, 5, 6}, n], Disk[{1 - p, 1 - p}, r]], If[MemberQ[{4, 5, 6}, n], Disk[{p, 1 - p}, r]], If[MemberQ[{4, 5, 6}, n], Disk[{1 - p, p}, r]], If[n === 6, {Disk[{p, 0.5}, r], Disk[{1 - p, 0.5}, r]}]}, ImageSize -> Tiny]] . - . Format[Dice[n_Integer ? (1 ≤ #1 ≤ 6&)], OutputForm] = Block[{p = 0.2, r = 0.05}, Graphics[{EdgeForm[Black], White, Rectangle[], Black, EdgeForm[], If[OddQ[n], Disk[{0.5, 0.5}, r]], If[MemberQ[{2, 3, 4, 5, 6}, n], Disk[{p, p}, r]], If[MemberQ[{2, 3, 4, 5, 6}, n], Disk[{1 - p, 1 - p}, r]], If[MemberQ[{4, 5, 6}, n], Disk[{p, 1 - p}, r]], If[MemberQ[{4, 5, 6}, n], Disk[{1 - p, p}, r]], If[n === 6, {Disk[{p, 0.5}, r], Disk[{1 - p, 0.5}, r]}]}, ImageSize ⇾ Tiny]] + . Format[Dice[n_Integer ? (1 <= #1 <= 6&)], OutputForm] = Block[{p = 0.2, r = 0.05}, Graphics[{EdgeForm[Black], White, Rectangle[], Black, EdgeForm[], If[OddQ[n], Disk[{0.5, 0.5}, r]], If[MemberQ[{2, 3, 4, 5, 6}, n], Disk[{p, p}, r]], If[MemberQ[{2, 3, 4, 5, 6}, n], Disk[{1 - p, 1 - p}, r]], If[MemberQ[{4, 5, 6}, n], Disk[{p, 1 - p}, r]], If[MemberQ[{4, 5, 6}, n], Disk[{1 - p, p}, r]], If[n === 6, {Disk[{p, 0.5}, r], Disk[{1 - p, 0.5}, r]}]}, ImageSize -> Tiny]] . - . Format[Dice[n_Integer ? (1 ≤ #1 ≤ 6&)], StandardForm] = Block[{p = 0.2, r = 0.05}, Graphics[{EdgeForm[Black], White, Rectangle[], Black, EdgeForm[], If[OddQ[n], Disk[{0.5, 0.5}, r]], If[MemberQ[{2, 3, 4, 5, 6}, n], Disk[{p, p}, r]], If[MemberQ[{2, 3, 4, 5, 6}, n], Disk[{1 - p, 1 - p}, r]], If[MemberQ[{4, 5, 6}, n], Disk[{p, 1 - p}, r]], If[MemberQ[{4, 5, 6}, n], Disk[{1 - p, p}, r]], If[n === 6, {Disk[{p, 0.5}, r], Disk[{1 - p, 0.5}, r]}]}, ImageSize ⇾ Tiny]] + . Format[Dice[n_Integer ? (1 <= #1 <= 6&)], StandardForm] = Block[{p = 0.2, r = 0.05}, Graphics[{EdgeForm[Black], White, Rectangle[], Black, EdgeForm[], If[OddQ[n], Disk[{0.5, 0.5}, r]], If[MemberQ[{2, 3, 4, 5, 6}, n], Disk[{p, p}, r]], If[MemberQ[{2, 3, 4, 5, 6}, n], Disk[{1 - p, 1 - p}, r]], If[MemberQ[{4, 5, 6}, n], Disk[{p, 1 - p}, r]], If[MemberQ[{4, 5, 6}, n], Disk[{1 - p, p}, r]], If[n === 6, {Disk[{p, 0.5}, r], Disk[{1 - p, 0.5}, r]}]}, ImageSize -> Tiny]] . - . Format[Dice[n_Integer ? (1 ≤ #1 ≤ 6&)], TeXForm] = Block[{p = 0.2, r = 0.05}, Graphics[{EdgeForm[Black], White, Rectangle[], Black, EdgeForm[], If[OddQ[n], Disk[{0.5, 0.5}, r]], If[MemberQ[{2, 3, 4, 5, 6}, n], Disk[{p, p}, r]], If[MemberQ[{2, 3, 4, 5, 6}, n], Disk[{1 - p, 1 - p}, r]], If[MemberQ[{4, 5, 6}, n], Disk[{p, 1 - p}, r]], If[MemberQ[{4, 5, 6}, n], Disk[{1 - p, p}, r]], If[n === 6, {Disk[{p, 0.5}, r], Disk[{1 - p, 0.5}, r]}]}, ImageSize ⇾ Tiny]] + . Format[Dice[n_Integer ? (1 <= #1 <= 6&)], TeXForm] = Block[{p = 0.2, r = 0.05}, Graphics[{EdgeForm[Black], White, Rectangle[], Black, EdgeForm[], If[OddQ[n], Disk[{0.5, 0.5}, r]], If[MemberQ[{2, 3, 4, 5, 6}, n], Disk[{p, p}, r]], If[MemberQ[{2, 3, 4, 5, 6}, n], Disk[{1 - p, 1 - p}, r]], If[MemberQ[{4, 5, 6}, n], Disk[{p, 1 - p}, r]], If[MemberQ[{4, 5, 6}, n], Disk[{1 - p, p}, r]], If[n === 6, {Disk[{p, 0.5}, r], Disk[{1 - p, 0.5}, r]}]}, ImageSize -> Tiny]] . - . Format[Dice[n_Integer ? (1 ≤ #1 ≤ 6&)], TraditionalForm] = Block[{p = 0.2, r = 0.05}, Graphics[{EdgeForm[Black], White, Rectangle[], Black, EdgeForm[], If[OddQ[n], Disk[{0.5, 0.5}, r]], If[MemberQ[{2, 3, 4, 5, 6}, n], Disk[{p, p}, r]], If[MemberQ[{2, 3, 4, 5, 6}, n], Disk[{1 - p, 1 - p}, r]], If[MemberQ[{4, 5, 6}, n], Disk[{p, 1 - p}, r]], If[MemberQ[{4, 5, 6}, n], Disk[{1 - p, p}, r]], If[n === 6, {Disk[{p, 0.5}, r], Disk[{1 - p, 0.5}, r]}]}, ImageSize ⇾ Tiny]] + . Format[Dice[n_Integer ? (1 <= #1 <= 6&)], TraditionalForm] = Block[{p = 0.2, r = 0.05}, Graphics[{EdgeForm[Black], White, Rectangle[], Black, EdgeForm[], If[OddQ[n], Disk[{0.5, 0.5}, r]], If[MemberQ[{2, 3, 4, 5, 6}, n], Disk[{p, p}, r]], If[MemberQ[{2, 3, 4, 5, 6}, n], Disk[{1 - p, 1 - p}, r]], If[MemberQ[{4, 5, 6}, n], Disk[{p, 1 - p}, r]], If[MemberQ[{4, 5, 6}, n], Disk[{1 - p, p}, r]], If[n === 6, {Disk[{p, 0.5}, r], Disk[{1 - p, 0.5}, r]}]}, ImageSize -> Tiny]] The empty series of dice shall be displayed as an empty dice: >> Format[Dice[]] := Graphics[{EdgeForm[Black], White, Rectangle[]}, ImageSize -> Tiny] From 70159ed111b88321de2b9835b6f1302825b8a4f5 Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 27 Jul 2026 21:40:44 -0400 Subject: [PATCH 4/6] Add Import for WL files. It works the same as Get, but has the Import interface. --- mathics/Data/ExampleData/HelloWorld.wl | 2 ++ mathics/SystemFiles/Formats/WL/Import.wl | 17 +++++++++++ mathics/builtin/fileformats/wlformat.py | 28 +++++++++++++++++++ .../import_export/test_importexport.py | 7 +++++ 4 files changed, 54 insertions(+) create mode 100644 mathics/Data/ExampleData/HelloWorld.wl create mode 100644 mathics/SystemFiles/Formats/WL/Import.wl create mode 100644 mathics/builtin/fileformats/wlformat.py diff --git a/mathics/Data/ExampleData/HelloWorld.wl b/mathics/Data/ExampleData/HelloWorld.wl new file mode 100644 index 000000000..bd83ab015 --- /dev/null +++ b/mathics/Data/ExampleData/HelloWorld.wl @@ -0,0 +1,2 @@ +(* An example of a Wolfram Language/Mathics3 program that can be used for testing. *) +"Hello, " <> "World!" diff --git a/mathics/SystemFiles/Formats/WL/Import.wl b/mathics/SystemFiles/Formats/WL/Import.wl new file mode 100644 index 000000000..32794e48c --- /dev/null +++ b/mathics/SystemFiles/Formats/WL/Import.wl @@ -0,0 +1,17 @@ +(* ::Package:: *) + +(* Note: this is stripped down a lot from what WMA handles. *) + +Begin["System`Convert`WLDump`"]; + + +ImportExport`RegisterImport[ + "WL", (* WMA mime-type name *) + WLDump`ImportWL (* Default Function name that handles this. *), + {}, + "AvailableElements" -> {"Get", "Script"}, + "DefaultElement" -> "Get" +]; + + +End[]; diff --git a/mathics/builtin/fileformats/wlformat.py b/mathics/builtin/fileformats/wlformat.py new file mode 100644 index 000000000..b80de04ed --- /dev/null +++ b/mathics/builtin/fileformats/wlformat.py @@ -0,0 +1,28 @@ +""" +WL File Format + +WL and Mathics3 importer +""" + +from mathics.core.builtin import Builtin, String +from mathics.core.evaluation import Evaluation +from mathics.eval.fileformats.wlformat import eval_WLImport + + +class ImportWL(Builtin): + """ + :WMA link:https://reference.wolfram.com/language/ref/format/WL.html + +
+
'WLDump`ImportWL[$path$]' +
Read $path$ as a Wolfram package and 'Get' it. +
+ + """ + + context = "WLDump`" + summary_text = "import WL file" + + def eval(self, path: String, evaluation: Evaluation): + "WLDump`ImportWL[path_String]" + return eval_WLImport(path, evaluation) diff --git a/test/builtin/import_export/test_importexport.py b/test/builtin/import_export/test_importexport.py index c016a193e..7d929ce97 100644 --- a/test/builtin/import_export/test_importexport.py +++ b/test/builtin/import_export/test_importexport.py @@ -232,6 +232,13 @@ def test_export(): "0.88, 0.60, 0.94\n.076, 0.19, .51\n0.97, 0.04, .26", None, ), + # WL + ( + 'Import["ExampleData/HelloWorld.wl"]', + None, + "Hello, World!", + None, + ), # FIXME: the below out is incorrect and does not match WMA, # due to a lame homegrown implementation of # CSV. The data below will change when we use Python's CSV library. From c6328f11a6ba26a45dde87a8ee4e0afb3ffd9169 Mon Sep 17 00:00:00 2001 From: rocky Date: Tue, 28 Jul 2026 12:30:44 -0400 Subject: [PATCH 5/6] Promote a 'WLFormat' pytest to doctests and demonstrate explanation of 'WLFormat' vs. 'Import' and 'Get' --- mathics/builtin/fileformats/wlformat.py | 24 +++++++++++++++++++ .../import_export/test_importexport.py | 7 ------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/mathics/builtin/fileformats/wlformat.py b/mathics/builtin/fileformats/wlformat.py index b80de04ed..199b70320 100644 --- a/mathics/builtin/fileformats/wlformat.py +++ b/mathics/builtin/fileformats/wlformat.py @@ -18,6 +18,30 @@ class ImportWL(Builtin):
Read $path$ as a Wolfram package and 'Get' it. + This command is hooked into the 'Import' command via \ + 'SystemFiles/Formats/WL/Import.wl'. + + When running this command directly, a list of rules is returned: + + >> WLDump`ImportWL["ExampleData/HelloWorld.wl"] + = {Get -> Hello, World!, Script -> Hello, World!} + + The left-hand side is a element name that can be provided to 'Import', \ + and the right-hand side is the value associated with that element. Here it \ + represents the last evaluation value when evaluating the contents of the file. + + When an 'Import' is done and the file mentioned is a Mathics3 or a \ + Wolfram-Language file, this command is run underneath selecting value of the \ + "Get" element: + + >> Import["ExampleData/HelloWorld.wl"] + = Hello, World! + + All of this is the same as just running a simple 'Get': + >> << "ExampleData/HelloWorld.wl" + = Hello, World! + + In sum, the built-in provides the glue to the 'Import' accees mechanism for 'Get'. """ context = "WLDump`" diff --git a/test/builtin/import_export/test_importexport.py b/test/builtin/import_export/test_importexport.py index 7d929ce97..c016a193e 100644 --- a/test/builtin/import_export/test_importexport.py +++ b/test/builtin/import_export/test_importexport.py @@ -232,13 +232,6 @@ def test_export(): "0.88, 0.60, 0.94\n.076, 0.19, .51\n0.97, 0.04, .26", None, ), - # WL - ( - 'Import["ExampleData/HelloWorld.wl"]', - None, - "Hello, World!", - None, - ), # FIXME: the below out is incorrect and does not match WMA, # due to a lame homegrown implementation of # CSV. The data below will change when we use Python's CSV library. From b5da01770943f9ce9c5406e170dae6371598c7c7 Mon Sep 17 00:00:00 2001 From: rocky Date: Tue, 28 Jul 2026 20:11:02 -0400 Subject: [PATCH 6/6] Track recent encoding change --- mathics/builtin/fileformats/wlformat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mathics/builtin/fileformats/wlformat.py b/mathics/builtin/fileformats/wlformat.py index 199b70320..4fd5e2e94 100644 --- a/mathics/builtin/fileformats/wlformat.py +++ b/mathics/builtin/fileformats/wlformat.py @@ -24,7 +24,7 @@ class ImportWL(Builtin): When running this command directly, a list of rules is returned: >> WLDump`ImportWL["ExampleData/HelloWorld.wl"] - = {Get -> Hello, World!, Script -> Hello, World!} + = {Get ⇾ Hello, World!, Script ⇾ Hello, World!} The left-hand side is a element name that can be provided to 'Import', \ and the right-hand side is the value associated with that element. Here it \