From 8a6f500d4ef8ad2f744db66efb1d93ff6f9ad6ef Mon Sep 17 00:00:00 2001 From: Juan Mauricio Matera Date: Sat, 18 Jan 2025 09:37:15 -0300 Subject: [PATCH] Lint two pytests (#1299) * New tests in `test.builtin.arithfns.test_basic` * fix `mathics.builtin.arithfns.basic` formatting rules for Plus and Times. --------- Co-authored-by: R. Bernstein --- mathics/builtin/arithfns/basic.py | 20 ++-- mathics/builtin/arithmetic.py | 18 +-- mathics/builtin/files_io/importexport.py | 2 +- .../builtin/functional/apply_fns_to_lists.py | 8 +- .../equality_inequality.py | 2 +- mathics/builtin/trace.py | 2 +- mathics/core/builtin.py | 2 +- mathics/doc/documentation/1-Manual.mdoc | 113 +++++++++--------- mathics/doc/latex/Makefile | 7 +- mathics/docpipeline.py | 9 +- test/builtin/arithmetic/test_basic.py | 10 ++ test/builtin/test_evaluation.py | 1 - 12 files changed, 104 insertions(+), 90 deletions(-) diff --git a/mathics/builtin/arithfns/basic.py b/mathics/builtin/arithfns/basic.py index 288071587..5bb8f6a81 100644 --- a/mathics/builtin/arithfns/basic.py +++ b/mathics/builtin/arithfns/basic.py @@ -287,16 +287,16 @@ def format_plus(self, items, evaluation): "Plus[items__]" def negate(item): # -> Expression (see FIXME below) - if item.has_form("Times", 1, None): + if item.has_form("Times", 2, None): if isinstance(item.elements[0], Number): - neg = -item.elements[0] - if neg.sameQ(Integer1): - if len(item.elements) == 1: - return neg - else: - return Expression(SymbolTimes, *item.elements[1:]) - else: - return Expression(SymbolTimes, neg, *item.elements[1:]) + first, *rest = item.elements + first = -first + if first.sameQ(Integer1): + if len(rest) == 1: + return rest[0] + return Expression(SymbolTimes, *rest) + + return Expression(SymbolTimes, first, *rest) else: return Expression(SymbolTimes, IntegerM1, *item.elements) elif isinstance(item, Number): @@ -632,6 +632,8 @@ def inverse(item): return item items = items.get_sequence() + if len(items) < 2: + return positive = [] negative = [] for item in items: diff --git a/mathics/builtin/arithmetic.py b/mathics/builtin/arithmetic.py index 94a306c42..f952017ca 100644 --- a/mathics/builtin/arithmetic.py +++ b/mathics/builtin/arithmetic.py @@ -627,7 +627,7 @@ class I_(Predefined, SympyObject): name = "I" sympy_name = "I" sympy_obj = sympy.I - summary_text = "imaginary unit" + summary_text = "imaginary unit number Sqrt[-1]" python_equivalent = 1j def is_constant(self) -> bool: @@ -658,7 +658,7 @@ class Im(SympyFunction): = -Graphics- """ - summary_text = "imaginary part" + summary_text = "imaginary part of a complex number" attributes = A_LISTABLE | A_NUMERIC_FUNCTION | A_PROTECTED def eval_complex(self, number, evaluation: Evaluation): @@ -817,10 +817,14 @@ class Re(SympyFunction): = -Graphics- """ - summary_text = "real part" + summary_text = "real part of a complex number" attributes = A_LISTABLE | A_NUMERIC_FUNCTION | A_PROTECTED sympy_name = "re" + def eval(self, number, evaluation: Evaluation): + "Re[number_]" + return from_sympy(sympy.re(number.to_sympy().expand(complex=True))) + def eval_complex(self, number, evaluation: Evaluation): "Re[number_Complex]" if isinstance(number, Complex): @@ -831,10 +835,6 @@ def eval_number(self, number, evaluation: Evaluation): return number - def eval(self, number, evaluation: Evaluation): - "Re[number_]" - return from_sympy(sympy.re(number.to_sympy().expand(complex=True))) - class Real_(Builtin): """ @@ -987,8 +987,8 @@ class Sum(IterationFunction, SympyFunction): } ) - def get_result(self, items): - return Expression(SymbolPlus, *items) + def get_result(self, elements) -> Expression: + return Expression(SymbolPlus, *elements) def to_sympy(self, expr, **kwargs) -> Optional[SympyExpression]: """ diff --git a/mathics/builtin/files_io/importexport.py b/mathics/builtin/files_io/importexport.py index 08750a998..e91f20179 100644 --- a/mathics/builtin/files_io/importexport.py +++ b/mathics/builtin/files_io/importexport.py @@ -1327,7 +1327,7 @@ class Import(Builtin):
imports the specified elements from a file.
'Import["$file$", {"$fmt$", $elements$}]' -
imports the specified elements from a file asuming the specified file format. +
imports the specified elements from a file assuming the specified file format.
'Import["http://$url$", ...]' and 'Import["ftp://$url$", ...]'
imports from a URL. diff --git a/mathics/builtin/functional/apply_fns_to_lists.py b/mathics/builtin/functional/apply_fns_to_lists.py index d9ba0a05e..b6c2b3ff1 100644 --- a/mathics/builtin/functional/apply_fns_to_lists.py +++ b/mathics/builtin/functional/apply_fns_to_lists.py @@ -173,21 +173,21 @@ class MapAt(Builtin):
applies $f$ to the part of $expr$ at position {$i$, $j$, ...}.
'MapAt[$f$, $pos$]' -
represents an operator form of MapAt that can be applied to an expression. +
represents an operator form of 'MapAt' that can be applied to an expression. Map function $f$ to the second element of an simple flat list: >> MapAt[f, {a, b, c}, 2] = {a, f[b], c} - Above we specified a simple integer value 2. In general, the expression can an arbitrary vector. + Above, we specified a simple integer value 2. In general, the expression can an arbitrary vector. Using 'MapAt' with 'Function[0]', we can zero a value or values in a vector: >> MapAt[0&, {{1, 1}, {1, 1}}, {2, 1}] = {{1, 1}, {0, 1}} - When the dimension of the replacment expression is less than the vector, \ + When the dimension of the replacement expression is less than the vector, \ that element's dimension changes: >> MapAt[0&, {{0, 1}, {1, 0}}, 2] @@ -396,7 +396,7 @@ class Scan(Builtin):
'Scan[$f$, $expr$]'
applies $f$ to each element of $expr$ and returns 'Null'. -
'Scan[$f$, $expr$, $levelspec$] +
'Scan[$f$, $expr$, $levelspec$]'
applies $f$ to each level specified by $levelspec$ of $expr$. diff --git a/mathics/builtin/testing_expressions/equality_inequality.py b/mathics/builtin/testing_expressions/equality_inequality.py index 40d1def63..86a253f5c 100644 --- a/mathics/builtin/testing_expressions/equality_inequality.py +++ b/mathics/builtin/testing_expressions/equality_inequality.py @@ -349,7 +349,7 @@ class Between(Builtin):
'Between'[$x$, {$min$, $max$}]
equivalent to $min$ <= $x$ <= $max$.
'Between[$x$, { {$min1$, $max1$}, {$min2$, $max2$}, ...]' -
equivalent to $min1$ <= $x$ <= $max1$' || $min2$ <= $x$ <= $max2$ ... +
equivalent to $min1$ <= $x$ <= $max1$ || $min2$ <= $x$ <= $max2$ ...
'Between[$range$]'
operator form that yields 'Between'[$x$, $range$] when applied to expression $x$. diff --git a/mathics/builtin/trace.py b/mathics/builtin/trace.py index 559ee96e6..2e314f6dd 100644 --- a/mathics/builtin/trace.py +++ b/mathics/builtin/trace.py @@ -153,7 +153,7 @@ class Stacktrace(_TraceBase):
'Stacktrace[]' -
Print Mathics3 stack trace of evalutations leading to this point +
Print Mathics3 stack trace of evaluations leading to this point
To show the Mathics3 evaluation stack at the \ diff --git a/mathics/core/builtin.py b/mathics/core/builtin.py index 9dff13357..616b3a699 100644 --- a/mathics/core/builtin.py +++ b/mathics/core/builtin.py @@ -933,7 +933,7 @@ class IterationFunction(Builtin, ABC): allow_loopcontrol = False throw_iterb = True - def get_result(self, elements) -> ListExpression: + def get_result(self, elements) -> Expression: raise NotImplementedError def eval_symbol(self, expr, iterator, evaluation): diff --git a/mathics/doc/documentation/1-Manual.mdoc b/mathics/doc/documentation/1-Manual.mdoc index ac38bb2c0..f2a989e31 100644 --- a/mathics/doc/documentation/1-Manual.mdoc +++ b/mathics/doc/documentation/1-Manual.mdoc @@ -1,31 +1,30 @@ -\Mathics is a :computer algebra -system:https://en.wikipedia.org/wiki/Computer_algebra_system. It is a free, open-source alternative to \Mathematica or the \Wolfram Language. However, \Mathics builds around and on top of the Python ecosystem of libraries and tools. So in a sense, you can think of it as a WMA front-end to the Python ecosystem of tools. +\Mathics is a :computer algebra system:https://en.wikipedia.org/wiki/Computer_algebra_system. It is a free, open-source alternative to \Mathematica or the \Wolfram Language. However, \Mathics builds around and on top of the Python ecosystem of libraries and tools. So in a sense, you can think of it as a WMA front-end to the Python ecosystem of tools. -\Mathics is free both as in "free beer" but also, more importantly, as in "freedom". \Mathics can be run locally. But to facilitate installation of the vast amount of software needed to run this, there is a :docker image available on dockerhub: https://hub.docker.com/r/mathicsorg/mathics. +\Mathics is free both as in "free beer", but more importantly, as in "freedom". \Mathics can be run locally. To facilitate installation of the vast amount of software needed to run this, there is a :docker image available on dockerhub: https://hub.docker.com/r/mathicsorg/mathics. -The programming language and built-in functions of \Mathics tries to match the \Wolfram Language, which is continually evolving changing. +The programming language and built-in functions of \Mathics try to match the \Wolfram Language, which is continually evolving. \Mathics is in no way affiliated or supported by \Wolfram. \Mathics will probably never have the power to compete with \Mathematica in industrial applications; it is a free alternative though. It also invites community development at all levels. -See the :installation instructions: https://mathics-development-guide.readthedocs.io/en/latest/installing/index.html for the most recent instructions for installing from PyPI, or the source. +See the :installation instructions:https://mathics-development-guide.readthedocs.io/en/latest/installing.html for the most recent instructions for installing from PyPI, or the source. -For implementation details, please refer to the :Developers Guide:https://mathics-development-guide.readthedocs.io/en/latest/. +For implementation details, please refer to the :Developers Guide:https://mathics-development-guide.readthedocs.io/en/latest.
-\Mathematica is great, but it a couple of disadvantages. +\Mathematica is great, but it has a couple of disadvantages.
  • It is not open source. -
  • Its development is tightly controlled and centralized, and as such -
  • it can't hook into different kinds open-source packages that have independently developed algorithms and methods +
  • Its development is tightly controlled and centralized and as such +
  • It can't hook into different kinds of open-source packages that have independently developed algorithms and methods
-The second point some may find and advantage. +The second point some may find an advantage. -However, even if you are willing to pay hundreds of dollars for the software, you would will not be able to see what\'s going on "inside" the program if that is your interest. That\'s what free, open-source, and community-supported software is for! +However, even if you are willing to pay hundreds of dollars for the software, you would not be able to see what\'s going on "inside" the program if that is your interest. That\'s what free, open-source, and community-supported software is for! \Mathics combines the beauty of \Mathematica implemented in an open-source environment written in Python. The Python ecosystem includes libraries and tools like: @@ -36,19 +35,19 @@ However, even if you are willing to pay hundreds of dollars for the software, yo
  • :SciPy: https://www.scipy.org/ for Scientific calculations. -Performance of \Mathics is not, right now, practical in large-scale projects and calculations. However can be used as a tool for exploration and education. +Performance of \Mathics is not, right now, practical in large-scale projects and calculations. However, it can be used as a tool for exploration and education. There is promise that it can provide better debugging.
  • -Because \Mathics is compatible with Wolfram-Language kernel within the +Because \Mathics is compatible with the Wolfram-Language kernel within the confines of the Python ecosystem, it is a powerful functional programming language, driven by pattern matching and rule application. Primitive types include rationals, complex numbers, and arbitrary-precision numbers. Other primitive types such as images or graphs, or NLP come from the various Python libraries that \Mathics uses. -Outside of the "core" \Mathics kernel (which has a only primitive command-line interface), in separate github projects, as add-ons, there is: +Outside of the "core" \Mathics kernel (which has only a primitive command-line interface), in separate GitHub projects, as add-ons, there are:
    • a :command-line interface:https://pypi.org/project/mathicsscript/ using either :prompt-toolkit:https://python-prompt-toolkit.readthedocs.io/en/master/, or GNU Readline @@ -61,7 +60,7 @@ Outside of the "core" \Mathics kernel (which has a only primitive command-line i
    -The first alpha versions of \Mathics were done in 2011 by Jan Pöschko. He worked on it for a couple of years to about the v0.5 release in 2012. By then, it had 386 built-in symbols. Currently there are over a 1,000 and even more when \Mathics modules are included. +The first alpha versions of \Mathics were done in 2011 by Jan Pöschko. He worked on it for a couple of years to about the v0.5 release in 2012. By then, it had 386 built-in symbols. Currently there are over a 1,000, and even more when \Mathics modules are included. After that, Angus Griffith took over primary leadership and rewrote the parser to pretty much the stage it is in now. He and later Ben Jones worked on it from 2013 to about 2017 to the v1.0 release. Towards the end of this period, Bernhard Liebl worked on this, mostly focused on graphics. @@ -75,13 +74,13 @@ https://github.com/Mathics3/mathics-core/blob/master/AUTHORS.txt file.
    -There are lots of ways in which \Mathics could still be improved. :FUTURE.rst: https://github.com/Mathics-3/mathics/blob/master/FUTURE.txt has the current roadmap. +There are lots of ways in which \Mathics could still be improved. :FUTURE.rst: https://github.com/Mathics3/mathics-core/blob/master/FUTURE.rst has the current roadmap. We always could use help in Python programming and improving the documentation. But there are other ways to help. For example:
      -
    • Ensure this document is complete and accurate. We could use help to ensure all of the Builtin functions described properly and fully, and that they have link to corresponding Wiki, Sympy, WMA and/or mpath links. -Make sure the builtin summaries and examples clear and useful.
    • +
    • Ensure this document is complete and accurate. We could use help to ensure all of the Builtin functions are described properly and fully, and that they have a link to corresponding Wiki, SymPy, WMA and/or mpath links. +Make sure the builtin summaries and examples are clear and useful.
    • We could use help in LaTeX styling, and going over this document to remove overfull boxes and things of that nature. We could also use help and our use of Asymptote. The are some graphics primitives such as for polyhedra that haven't been implemented. Similar graphics options are sometimes missing in Asymptote that we have available in other graphics backends.
    • add another graphics backend: it could be a javascript library like jsfiddle
    • @@ -97,9 +96,9 @@ See :The Mathics3 Developer Guide:https://mathics-development-guide.readthe -The following sections are introductions to the basic principles of the language of \Mathics. A few examples and functions are presented. Only their most common usages are listed; for a full description of a Symbols possible arguments, options, etc., see its entry in the Reference of Built-in Symbols. +The following sections are introductions to the basic principles of the language of \Mathics. A few examples and functions are presented. Only their most common usages are listed; for a full description of a Symbol's possible arguments, options, etc., see its entry in the Reference of Built-in Symbols. -However if you google for "Mathematica Tutorials" you will find easily dozens of other tutorials which are applicable. For example, see :An Elementary Introduction to the Wolfram Language:https://www.wolfram.com/language/elementary-introduction/. In the :docker image that we supply:https://hub.docker.com/r/mathicsorg/mathics, you can load "workspaces" containing the examples described in the chapters of this introduction. +However, if you google for "Mathematica Tutorials" you will find easily dozens of other tutorials that are applicable. For example, see :An Elementary Introduction to the Wolfram Language:https://www.wolfram.com/language/elementary-introduction/. In the :docker image that we supply:https://hub.docker.com/r/mathicsorg/mathics, you can load "workspaces" containing the examples described in the chapters of this introduction. Be warned though that \Mathics does not yet offer the full range and features and capabilities of \Mathematica. @@ -179,7 +178,7 @@ Of course, \Mathics has complex numbers: >> 55! (* Also known as Factorial[55] *) = 12696403353658275925965100847566516959580321051449436762275840000000000000 -We could easily increase use a number larger than 55, but the digits will just run off the page. +We could easily use a number larger than 55, but the digits will just run off the page. The precision of numerical evaluation can be set: @@ -231,7 +230,7 @@ The result of the previous query to \Mathics can be accessed by '%': >> 3.1416`3 = 3.14 -Above, two decimal places are shown in output after the decimal point, but three places of precision are stored. +Above, two decimal places are shown in the output after the decimal point, but three places of precision are stored. The relative uncertainty of '3.1416`3' is 10^-3. It is numerically equivalent, in three places after the decimal point, to 3.1413`4: @@ -244,12 +243,12 @@ We can get the precision of the number by using the \Mathics Built-in function < >> Precision[3.1413`4] = 4. -While 3.1419 not the closest approximation to Pi in 4 digits after the decimal point (or with precision 4), for 3 digits of precision it is: +While 3.1419 is not the closest approximation to Pi in 4 digits after the decimal point (or with precision 4), for 3 digits of precision it is: >> Pi == 3.141987654321`3 = True -The absolute accuracy of a number, is set by adding a two RawBackquotes '``' and the number digits. +The absolute accuracy of a number is set by adding two RawBackquotes '``' and the number digits. For example: @@ -669,7 +668,7 @@ This can be used to get all subsequences of a list, for instance: >> ReplaceAll[{a, b, c}, {___, x__, ___} -> {x}] = {a} -In addition to defining functions as rules for certain patterns, there are pure functions that can be defined using the '&' postfix operator, where everything before it is treated as the function body and '#' can be used as argument placeholder: +In addition to defining functions as rules for certain patterns, there are pure functions that can be defined using the '&' postfix operator, where everything before it is treated as the function body, and '#' can be used as argument placeholder: >> h = # ^ 2 &; >> h[3] @@ -735,7 +734,7 @@ Compound statements can be entered with ';'. The result of a compound expression = 3 >> 1; 2; 3; -Inside 'For', 'While', and 'Do' loops, 'Break[]' exits the loop and 'Continue[]' continues to the next iteration. +Inside 'For', 'While', and 'Do' loops, 'Break[]' exits the loop, and 'Continue[]' continues to the next iteration. >> For[i = 1, i <= 5, i++, If[i == 4, Break[]]; Print[i]] | 1 @@ -754,13 +753,14 @@ However, sometimes "local" variables are needed in order not to disturb the glob
    • dynamic scoping by 'Block'.
    -
    'Module[{$vars$}, $expr$]' -
    localizes variables by giving them a temporary name of the form - 'name$number', where number is the current value of '$ModuleNumber'. Each time a module - is evaluated, '$ModuleNumber' is incremented. -
    'Block[{$vars$}, $expr$]' -
    temporarily stores the definitions of certain variables, evaluates - $expr$ with reset values and restores the original definitions afterwards. +
    'Module[{$vars$}, $expr$]' +
    localizes variables by giving them a temporary name of the form + 'name$number', where number is the current value of '$ModuleNumber'. Each time a module + is evaluated, '$ModuleNumber' is incremented. + +
    'Block[{$vars$}, $expr$]' +
    temporarily stores the definitions of certain variables, evaluates + $expr$ with reset values and restores the original definitions afterward.
    Both scoping constructs shield inner variables from affecting outer ones: @@ -814,7 +814,7 @@ It is common to use scoping constructs for function definitions with local varia
    -The way results are formatted for output in \Mathics is rather sophisticated, as compatibility to the way \Mathematica does things is one of the design goals. It can be summed up in the following procedure: +The way results are formatted for output in \Mathics is rather sophisticated, compatibility with \Mathematica is one of the design goals. It can be summed up in the following procedure:
    1. The result of the query is calculated.
    2. The result is stored in 'Out' (which '%' is a shortcut for). @@ -885,7 +885,7 @@ If you want even more low-level control over expression display, override 'MakeB >> b = b -## this will be displayed as c in the browser and LaTeX documentation +## This will be displayed as c in the browser and LaTeX documentation. This will even apply to 'TeXForm', because 'TeXForm' implies 'StandardForm': >> b // TeXForm = c @@ -1341,7 +1341,7 @@ A pop-up menu should appear with the list of saved worksheets with an option to
      -We have a number of examples showing off briefly some of the capabilities of the system. These are run when you hit hit the button that looks like this: +We have a number of examples showing off briefly some of the capabilities of the system. These are run when you hit the button that looks like this: @@ -1351,17 +1351,17 @@ It is also shown in the pop-up text that appears when Mathics3 is first run.
      -When you use the Django-based Web interface of \Mathics, a browser session is created. Cookies have to be enabled to allow this. Your session holds a key which is used to access your definitions that are stored in a database on the server. As long as you don\'t clear the cookies in your browser, your definitions will remain even when you close and re-open the browser. +When you use the Django-based Web interface of \Mathics, a browser session is created. Cookies have to be enabled to allow this. Your session holds a key that is used to access your definitions that are stored in a database on the server. As long as you don\'t clear the cookies in your browser, your definitions will remain even when you close and re-open the browser. This implies that you should not store sensitive, private information in \Mathics variables when using the online Web interface. In addition to their values being stored in a database on the server, your queries might be saved for debugging purposes. However, the fact that they are transmitted over plain HTTP should make you aware that you should not transmit any sensitive information. When you want to do calculations with that kind of stuff, simply install \Mathics locally! If you are using a public terminal, to erase all your definitions and close the browser window. When you use \Mathics in a browser, use the command Quit[] or its alias, Exit[]. -When you reload the current page in a browser using the default URL, e.g http:localhost:8000, all of the previous input and output disappears. +When you reload the current page in a browser using the default URL, e.g., http:localhost:8000, all of the previous input and output disappears. On the other hand, Definitions as described above do not, unless Quit[] or Exit[] is entered as described above. -If you want a URL that will that records the input entered the Generate Input Hash button does this. The button looks like this: +If you want a URL that records the input entered, the Generate Input Hash button does this. The button looks like this: @@ -1376,25 +1376,30 @@ Of course, what the value of this is when evaluated depends on whether x -
      'Shift+Return'
      -
      This evaluates the current cell (the most important one, for sure). On the right-hand side you may also see an "=" button which can be clicked to do the same thing.
      -
      'Ctrl+D'
      -
      This moves the cursor over to the documentation pane on the right-hand side. From here you can perform a search for a pre-defined \Mathics function, or symbol. Clicking on the "?" symbol on the right-hand side does the same thing.
      -
      'Ctrl+C'
      -
      This moves the cursor back to document code pane area where you type \Mathics expressions
      -
      'Ctrl+S'
      -
      Save worksheet
      -
      'Ctrl+O'
      -
      Open worksheet
      -
      'Right Click' on MathML output
      -
      Opens MathJax Menu
      +
      'Shift+Return'
      +
      This evaluates the current cell (the most important one, for sure). On the right-hand side, you may also see an "=" button which can be clicked to do the same thing.
      + +
      'Ctrl+D'
      +
      This moves the cursor over to the documentation pane on the right-hand side. From here you can perform a search for a pre-defined \Mathics function, or symbol. Clicking on the "?" symbol on the right-hand side does the same thing.
      + +
      'Ctrl+C'
      +
      This moves the cursor back to the document code pane area where you type \Mathics expressions
      + +
      'Ctrl+S'
      +
      Save worksheet
      + +
      'Ctrl+O'
      +
      Open worksheet
      + +
      'Right Click' on MathML output
      +
      Opens MathJax Menu
      -Of special note is the last item on the list: right-click to open the MathJax menu. Under "Math Setting"/"Zoom Trigger", if the zoom trigger is set to a value other then "No Zoom", then when that trigger is applied on MathML formatted output, the MathML formula pop up a window for the formula. The window can show the formula larger. Also, this is a way to see output that is too large to fit on the display since the window allows for scrolling. +Of special note is the last item on the list: right-click to open the MathJax menu. Under "Math Setting"/"Zoom Trigger", if the zoom trigger is set to a value other than "No Zoom", then when that trigger is applied to MathML-formatted output, the MathML formula pops up a window for the formula. The window can show the formula larger. Also, this is a way to see output that is too large to fit on the display since the window allows for scrolling. -Keyboard commands behavior depends the browser used, the operating system, desktop settings, and customization. We hook into the desktop "Open the current document" and "Save the current document" functions that many desktops provide. For example see: :Finding keyboard shortcuts: https://help.ubuntu.com/community/KeyboardShortcuts#Finding_keyboard_shortcuts +Keyboard command behavior depends on the browser used, the operating system, desktop settings, and customization. We hook into the desktop "Open the current document" and "Save the current document" functions that many desktops provide. For example see: :Finding keyboard shortcuts: https://help.ubuntu.com/community/KeyboardShortcuts#Finding_keyboard_shortcuts -Often, these shortcut keyboard command are only recognized when a text field has focus; otherwise,the browser might do some browser-specific actions, like setting a bookmark etc. +Often, these shortcut keyboard commands are only recognized when a text field has focus; otherwise, the browser might do some browser-specific actions, like setting a bookmark etc.
      diff --git a/mathics/doc/latex/Makefile b/mathics/doc/latex/Makefile index 9ceff7ebb..45e567727 100644 --- a/mathics/doc/latex/Makefile +++ b/mathics/doc/latex/Makefile @@ -10,7 +10,7 @@ BASH ?= /bin/bash DOCTEST_LATEX_DATA_PCL ?= $(HOME)/.local/var/mathics/doctest_latex_data.pcl # Variable indicating Mathics3 Modules you have available on your system, in latex2doc option format -MATHICS3_MODULE_OPTION ?=--load-module pymathics.graph,pymathics.natlang +MATHICS3_MODULE_OPTION ?=--load-module pymathics.trepan,pymathics.graph,pymathics.natlang #: Default target: Make everything all doc texdoc: mathics.pdf @@ -22,7 +22,10 @@ doc-data $(DOCTEST_LATEX_DATA_PCL): mathics-title.pdf: cp mathics-title.pdf-src mathics-title.pdf -#: Build mathics PDF +#: Build somewhat incomplete mathics DVI +mathics.dvi: mathics.tex documentation.tex + $(LATEXMK) -dvi -f --verbose mathics + mathics.pdf: mathics.tex documentation.tex mathics-title.pdf logo-text-nodrop.pdf logo-heptatom.pdf version-info.tex $(DOCTEST_LATEX_DATA_PCL) $(LATEXMK) --verbose -f -pdf -pdflatex="$(XETEX) -halt-on-error" mathics diff --git a/mathics/docpipeline.py b/mathics/docpipeline.py index 4448c99b8..c7b16d839 100644 --- a/mathics/docpipeline.py +++ b/mathics/docpipeline.py @@ -670,7 +670,8 @@ def show_report(test_pipeline): "(not all tests are accounted for due to --)", ) test_pipeline.print_and_log("Failed:") - for part, chapter, section in sorted(test_status.failed_sections): + for part, chapter, *section in sorted(test_status.failed_sections): + section = "/".join(section) test_pipeline.print_and_log(f" - {section} in {part} / {chapter}") if test_parameters.data_path is not None and ( @@ -731,12 +732,6 @@ def save_doctest_data(doctest_pipeline: DocTestPipeline): doctest_pipeline.print_and_log( f"Writing internal document data to {doctest_latex_data_path}" ) - i = 0 - for key in output_data: - i = i + 1 - doctest_pipeline.print_and_log(f"{key}, {output_data[key]}") - if i > 9: - break with open(doctest_latex_data_path, "wb") as output_file: pickle.dump(output_data, output_file, 4) diff --git a/test/builtin/arithmetic/test_basic.py b/test/builtin/arithmetic/test_basic.py index 07e83f1be..65892c162 100644 --- a/test/builtin/arithmetic/test_basic.py +++ b/test/builtin/arithmetic/test_basic.py @@ -109,6 +109,16 @@ def test_exponential(str_expr, str_expected): "ComplexInfinity", "Goes to the previous case because of the rule in Power", ), + ( + "HoldForm[Times[]]", + "Times[]", + "Times without arguments is not formatted", + ), + ( + "HoldForm[Times[x]]", + "Times[x]", + "Times with a single argument is not formatted", + ), ], ) def test_multiply(str_expr, str_expected, msg): diff --git a/test/builtin/test_evaluation.py b/test/builtin/test_evaluation.py index 3068054b4..219942cae 100644 --- a/test/builtin/test_evaluation.py +++ b/test/builtin/test_evaluation.py @@ -62,7 +62,6 @@ None, ), ("ClearAll[f];", None, None, None), - ("HoldForm[Times[]]", None, "Times[]", None), ], ) def test_private_doctests_evaluation(str_expr, msgs, str_expected, fail_msg):