Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- ScaleDF_rebuttal/python_dedup_pkgs/sympy-1.14.0.data/data/share/man/man1/isympy.1 +188 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy-1.14.0.dist-info/METADATA +319 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy-1.14.0.dist-info/RECORD +0 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy-1.14.0.dist-info/WHEEL +5 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy-1.14.0.dist-info/entry_points.txt +2 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy-1.14.0.dist-info/licenses/AUTHORS +1379 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy-1.14.0.dist-info/licenses/LICENSE +153 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy-1.14.0.dist-info/top_level.txt +2 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/autolev/test-examples/pydy-example-repo/chaos_pendulum.py +55 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/autolev/test-examples/pydy-example-repo/double_pendulum.al +25 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/autolev/test-examples/pydy-example-repo/double_pendulum.py +39 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/autolev/test-examples/pydy-example-repo/mass_spring_damper.al +19 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/autolev/test-examples/pydy-example-repo/mass_spring_damper.py +31 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/autolev/test-examples/pydy-example-repo/non_min_pendulum.al +20 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/autolev/test-examples/pydy-example-repo/non_min_pendulum.py +36 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/c/__init__.py +1 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/c/c_parser.py +1059 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/fortran/__init__.py +1 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/fortran/fortran_parser.py +347 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/LICENSE.txt +21 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/LaTeX.g4 +312 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/__init__.py +204 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/_antlr/__init__.py +9 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/_antlr/latexlexer.py +512 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/_antlr/latexparser.py +0 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/_build_latex_antlr.py +91 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/_parse_latex_antlr.py +607 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/errors.py +2 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/lark/__init__.py +2 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/lark/grammar/greek_symbols.lark +28 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/lark/grammar/latex.lark +403 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/lark/latex_parser.py +145 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/lark/transformer.py +730 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/__init__.py +0 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_ast_parser.py +25 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_autolev.py +178 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_c_parser.py +0 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_custom_latex.py +69 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_fortran_parser.py +406 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_implicit_multiplication_application.py +195 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_latex.py +358 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_latex_deps.py +16 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_latex_lark.py +872 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_mathematica.py +280 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_maxima.py +50 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_sym_expr.py +209 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_sympy_parser.py +371 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/physics/__init__.py +12 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/physics/biomechanics/__init__.py +53 -0
- ScaleDF_rebuttal/python_dedup_pkgs/sympy/physics/biomechanics/_mixin.py +53 -0
ScaleDF_rebuttal/python_dedup_pkgs/sympy-1.14.0.data/data/share/man/man1/isympy.1
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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TH isympy 1 2007-10-8 "" ""
|
| 9 |
+
.SH NAME
|
| 10 |
+
isympy \- interactive shell for SymPy
|
| 11 |
+
.SH SYNOPSIS
|
| 12 |
+
'nh
|
| 13 |
+
.fi
|
| 14 |
+
.ad l
|
| 15 |
+
\fBisympy\fR \kx
|
| 16 |
+
.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
|
| 17 |
+
'in \n(.iu+\nxu
|
| 18 |
+
[\fB-c\fR | \fB--console\fR] [\fB-p\fR ENCODING | \fB--pretty\fR ENCODING] [\fB-t\fR TYPE | \fB--types\fR TYPE] [\fB-o\fR ORDER | \fB--order\fR ORDER] [\fB-q\fR | \fB--quiet\fR] [\fB-d\fR | \fB--doctest\fR] [\fB-C\fR | \fB--no-cache\fR] [\fB-a\fR | \fB--auto\fR] [\fB-D\fR | \fB--debug\fR] [
|
| 19 |
+
-- | PYTHONOPTIONS]
|
| 20 |
+
'in \n(.iu-\nxu
|
| 21 |
+
.ad b
|
| 22 |
+
'hy
|
| 23 |
+
'nh
|
| 24 |
+
.fi
|
| 25 |
+
.ad l
|
| 26 |
+
\fBisympy\fR \kx
|
| 27 |
+
.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
|
| 28 |
+
'in \n(.iu+\nxu
|
| 29 |
+
[
|
| 30 |
+
{\fB-h\fR | \fB--help\fR}
|
| 31 |
+
|
|
| 32 |
+
{\fB-v\fR | \fB--version\fR}
|
| 33 |
+
]
|
| 34 |
+
'in \n(.iu-\nxu
|
| 35 |
+
.ad b
|
| 36 |
+
'hy
|
| 37 |
+
.SH DESCRIPTION
|
| 38 |
+
isympy is a Python shell for SymPy. It is just a normal python shell
|
| 39 |
+
(ipython shell if you have the ipython package installed) that executes
|
| 40 |
+
the following commands so that you don't have to:
|
| 41 |
+
.PP
|
| 42 |
+
.nf
|
| 43 |
+
\*(T<
|
| 44 |
+
>>> from __future__ import division
|
| 45 |
+
>>> from sympy import *
|
| 46 |
+
>>> x, y, z = symbols("x,y,z")
|
| 47 |
+
>>> k, m, n = symbols("k,m,n", integer=True)
|
| 48 |
+
\*(T>
|
| 49 |
+
.fi
|
| 50 |
+
.PP
|
| 51 |
+
So starting isympy is equivalent to starting python (or ipython) and
|
| 52 |
+
executing the above commands by hand. It is intended for easy and quick
|
| 53 |
+
experimentation with SymPy. For more complicated programs, it is recommended
|
| 54 |
+
to write a script and import things explicitly (using the "from sympy
|
| 55 |
+
import sin, log, Symbol, ..." idiom).
|
| 56 |
+
.SH OPTIONS
|
| 57 |
+
.TP
|
| 58 |
+
\*(T<\fB\-c \fR\*(T>\fISHELL\fR, \*(T<\fB\-\-console=\fR\*(T>\fISHELL\fR
|
| 59 |
+
Use the specified shell (python or ipython) as
|
| 60 |
+
console backend instead of the default one (ipython
|
| 61 |
+
if present or python otherwise).
|
| 62 |
+
|
| 63 |
+
Example: isympy -c python
|
| 64 |
+
|
| 65 |
+
\fISHELL\fR could be either
|
| 66 |
+
\&'ipython' or 'python'
|
| 67 |
+
.TP
|
| 68 |
+
\*(T<\fB\-p \fR\*(T>\fIENCODING\fR, \*(T<\fB\-\-pretty=\fR\*(T>\fIENCODING\fR
|
| 69 |
+
Setup pretty printing in SymPy. By default, the most pretty, unicode
|
| 70 |
+
printing is enabled (if the terminal supports it). You can use less
|
| 71 |
+
pretty ASCII printing instead or no pretty printing at all.
|
| 72 |
+
|
| 73 |
+
Example: isympy -p no
|
| 74 |
+
|
| 75 |
+
\fIENCODING\fR must be one of 'unicode',
|
| 76 |
+
\&'ascii' or 'no'.
|
| 77 |
+
.TP
|
| 78 |
+
\*(T<\fB\-t \fR\*(T>\fITYPE\fR, \*(T<\fB\-\-types=\fR\*(T>\fITYPE\fR
|
| 79 |
+
Setup the ground types for the polys. By default, gmpy ground types
|
| 80 |
+
are used if gmpy2 or gmpy is installed, otherwise it falls back to python
|
| 81 |
+
ground types, which are a little bit slower. You can manually
|
| 82 |
+
choose python ground types even if gmpy is installed (e.g., for testing purposes).
|
| 83 |
+
|
| 84 |
+
Note that sympy ground types are not supported, and should be used
|
| 85 |
+
only for experimental purposes.
|
| 86 |
+
|
| 87 |
+
Note that the gmpy1 ground type is primarily intended for testing; it the
|
| 88 |
+
use of gmpy even if gmpy2 is available.
|
| 89 |
+
|
| 90 |
+
This is the same as setting the environment variable
|
| 91 |
+
SYMPY_GROUND_TYPES to the given ground type (e.g.,
|
| 92 |
+
SYMPY_GROUND_TYPES='gmpy')
|
| 93 |
+
|
| 94 |
+
The ground types can be determined interactively from the variable
|
| 95 |
+
sympy.polys.domains.GROUND_TYPES inside the isympy shell itself.
|
| 96 |
+
|
| 97 |
+
Example: isympy -t python
|
| 98 |
+
|
| 99 |
+
\fITYPE\fR must be one of 'gmpy',
|
| 100 |
+
\&'gmpy1' or 'python'.
|
| 101 |
+
.TP
|
| 102 |
+
\*(T<\fB\-o \fR\*(T>\fIORDER\fR, \*(T<\fB\-\-order=\fR\*(T>\fIORDER\fR
|
| 103 |
+
Setup the ordering of terms for printing. The default is lex, which
|
| 104 |
+
orders terms lexicographically (e.g., x**2 + x + 1). You can choose
|
| 105 |
+
other orderings, such as rev-lex, which will use reverse
|
| 106 |
+
lexicographic ordering (e.g., 1 + x + x**2).
|
| 107 |
+
|
| 108 |
+
Note that for very large expressions, ORDER='none' may speed up
|
| 109 |
+
printing considerably, with the tradeoff that the order of the terms
|
| 110 |
+
in the printed expression will have no canonical order
|
| 111 |
+
|
| 112 |
+
Example: isympy -o rev-lax
|
| 113 |
+
|
| 114 |
+
\fIORDER\fR must be one of 'lex', 'rev-lex', 'grlex',
|
| 115 |
+
\&'rev-grlex', 'grevlex', 'rev-grevlex', 'old', or 'none'.
|
| 116 |
+
.TP
|
| 117 |
+
\*(T<\fB\-q\fR\*(T>, \*(T<\fB\-\-quiet\fR\*(T>
|
| 118 |
+
Print only Python's and SymPy's versions to stdout at startup, and nothing else.
|
| 119 |
+
.TP
|
| 120 |
+
\*(T<\fB\-d\fR\*(T>, \*(T<\fB\-\-doctest\fR\*(T>
|
| 121 |
+
Use the same format that should be used for doctests. This is
|
| 122 |
+
equivalent to '\fIisympy -c python -p no\fR'.
|
| 123 |
+
.TP
|
| 124 |
+
\*(T<\fB\-C\fR\*(T>, \*(T<\fB\-\-no\-cache\fR\*(T>
|
| 125 |
+
Disable the caching mechanism. Disabling the cache may slow certain
|
| 126 |
+
operations down considerably. This is useful for testing the cache,
|
| 127 |
+
or for benchmarking, as the cache can result in deceptive benchmark timings.
|
| 128 |
+
|
| 129 |
+
This is the same as setting the environment variable SYMPY_USE_CACHE
|
| 130 |
+
to 'no'.
|
| 131 |
+
.TP
|
| 132 |
+
\*(T<\fB\-a\fR\*(T>, \*(T<\fB\-\-auto\fR\*(T>
|
| 133 |
+
Automatically create missing symbols. Normally, typing a name of a
|
| 134 |
+
Symbol that has not been instantiated first would raise NameError,
|
| 135 |
+
but with this option enabled, any undefined name will be
|
| 136 |
+
automatically created as a Symbol. This only works in IPython 0.11.
|
| 137 |
+
|
| 138 |
+
Note that this is intended only for interactive, calculator style
|
| 139 |
+
usage. In a script that uses SymPy, Symbols should be instantiated
|
| 140 |
+
at the top, so that it's clear what they are.
|
| 141 |
+
|
| 142 |
+
This will not override any names that are already defined, which
|
| 143 |
+
includes the single character letters represented by the mnemonic
|
| 144 |
+
QCOSINE (see the "Gotchas and Pitfalls" document in the
|
| 145 |
+
documentation). You can delete existing names by executing "del
|
| 146 |
+
name" in the shell itself. You can see if a name is defined by typing
|
| 147 |
+
"'name' in globals()".
|
| 148 |
+
|
| 149 |
+
The Symbols that are created using this have default assumptions.
|
| 150 |
+
If you want to place assumptions on symbols, you should create them
|
| 151 |
+
using symbols() or var().
|
| 152 |
+
|
| 153 |
+
Finally, this only works in the top level namespace. So, for
|
| 154 |
+
example, if you define a function in isympy with an undefined
|
| 155 |
+
Symbol, it will not work.
|
| 156 |
+
.TP
|
| 157 |
+
\*(T<\fB\-D\fR\*(T>, \*(T<\fB\-\-debug\fR\*(T>
|
| 158 |
+
Enable debugging output. This is the same as setting the
|
| 159 |
+
environment variable SYMPY_DEBUG to 'True'. The debug status is set
|
| 160 |
+
in the variable SYMPY_DEBUG within isympy.
|
| 161 |
+
.TP
|
| 162 |
+
-- \fIPYTHONOPTIONS\fR
|
| 163 |
+
These options will be passed on to \fIipython (1)\fR shell.
|
| 164 |
+
Only supported when ipython is being used (standard python shell not supported).
|
| 165 |
+
|
| 166 |
+
Two dashes (--) are required to separate \fIPYTHONOPTIONS\fR
|
| 167 |
+
from the other isympy options.
|
| 168 |
+
|
| 169 |
+
For example, to run iSymPy without startup banner and colors:
|
| 170 |
+
|
| 171 |
+
isympy -q -c ipython -- --colors=NoColor
|
| 172 |
+
.TP
|
| 173 |
+
\*(T<\fB\-h\fR\*(T>, \*(T<\fB\-\-help\fR\*(T>
|
| 174 |
+
Print help output and exit.
|
| 175 |
+
.TP
|
| 176 |
+
\*(T<\fB\-v\fR\*(T>, \*(T<\fB\-\-version\fR\*(T>
|
| 177 |
+
Print isympy version information and exit.
|
| 178 |
+
.SH FILES
|
| 179 |
+
.TP
|
| 180 |
+
\*(T<\fI${HOME}/.sympy\-history\fR\*(T>
|
| 181 |
+
Saves the history of commands when using the python
|
| 182 |
+
shell as backend.
|
| 183 |
+
.SH BUGS
|
| 184 |
+
The upstreams BTS can be found at \(lahttps://github.com/sympy/sympy/issues\(ra
|
| 185 |
+
Please report all bugs that you find in there, this will help improve
|
| 186 |
+
the overall quality of SymPy.
|
| 187 |
+
.SH "SEE ALSO"
|
| 188 |
+
\fBipython\fR(1), \fBpython\fR(1)
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy-1.14.0.dist-info/METADATA
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.4
|
| 2 |
+
Name: sympy
|
| 3 |
+
Version: 1.14.0
|
| 4 |
+
Summary: Computer algebra system (CAS) in Python
|
| 5 |
+
Home-page: https://sympy.org
|
| 6 |
+
Author: SymPy development team
|
| 7 |
+
Author-email: sympy@googlegroups.com
|
| 8 |
+
License: BSD
|
| 9 |
+
Project-URL: Source, https://github.com/sympy/sympy
|
| 10 |
+
Keywords: Math CAS
|
| 11 |
+
Classifier: License :: OSI Approved :: BSD License
|
| 12 |
+
Classifier: Operating System :: OS Independent
|
| 13 |
+
Classifier: Programming Language :: Python
|
| 14 |
+
Classifier: Topic :: Scientific/Engineering
|
| 15 |
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
| 16 |
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
| 17 |
+
Classifier: Programming Language :: Python :: 3
|
| 18 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 19 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 20 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 21 |
+
Classifier: Programming Language :: Python :: 3.12
|
| 22 |
+
Classifier: Programming Language :: Python :: 3.13
|
| 23 |
+
Classifier: Programming Language :: Python :: 3 :: Only
|
| 24 |
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
| 25 |
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
| 26 |
+
Requires-Python: >=3.9
|
| 27 |
+
Description-Content-Type: text/markdown
|
| 28 |
+
License-File: LICENSE
|
| 29 |
+
License-File: AUTHORS
|
| 30 |
+
Requires-Dist: mpmath<1.4,>=1.1.0
|
| 31 |
+
Provides-Extra: dev
|
| 32 |
+
Requires-Dist: pytest>=7.1.0; extra == "dev"
|
| 33 |
+
Requires-Dist: hypothesis>=6.70.0; extra == "dev"
|
| 34 |
+
Dynamic: author
|
| 35 |
+
Dynamic: author-email
|
| 36 |
+
Dynamic: classifier
|
| 37 |
+
Dynamic: description
|
| 38 |
+
Dynamic: description-content-type
|
| 39 |
+
Dynamic: home-page
|
| 40 |
+
Dynamic: keywords
|
| 41 |
+
Dynamic: license
|
| 42 |
+
Dynamic: license-file
|
| 43 |
+
Dynamic: project-url
|
| 44 |
+
Dynamic: provides-extra
|
| 45 |
+
Dynamic: requires-dist
|
| 46 |
+
Dynamic: requires-python
|
| 47 |
+
Dynamic: summary
|
| 48 |
+
|
| 49 |
+
# SymPy
|
| 50 |
+
|
| 51 |
+
[](https://pypi.python.org/pypi/sympy)
|
| 52 |
+
[](https://gitter.im/sympy/sympy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
| 53 |
+
[](https://zenodo.org/badge/latestdoi/18918/sympy/sympy)
|
| 54 |
+
[](https://pepy.tech/project/sympy)
|
| 55 |
+
[](https://github.com/sympy/sympy/issues)
|
| 56 |
+
[](https://git-scm.com/book/en/v2/GitHub-Contributing-to-a-Project)
|
| 57 |
+
[](https://numfocus.org)
|
| 58 |
+
[](https://github.com/sympy/sympy/releases)
|
| 59 |
+
|
| 60 |
+
[](https://sympy.org/)
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
See the [AUTHORS](AUTHORS) file for the list of authors.
|
| 64 |
+
|
| 65 |
+
And many more people helped on the SymPy mailing list, reported bugs,
|
| 66 |
+
helped organize SymPy's participation in the Google Summer of Code, the
|
| 67 |
+
Google Highly Open Participation Contest, Google Code-In, wrote and
|
| 68 |
+
blogged about SymPy...
|
| 69 |
+
|
| 70 |
+
License: New BSD License (see the [LICENSE](LICENSE) file for details) covers all
|
| 71 |
+
files in the sympy repository unless stated otherwise.
|
| 72 |
+
|
| 73 |
+
Our mailing list is at
|
| 74 |
+
<https://groups.google.com/forum/?fromgroups#!forum/sympy>.
|
| 75 |
+
|
| 76 |
+
We have a community chat at [Gitter](https://gitter.im/sympy/sympy). Feel
|
| 77 |
+
free to ask us anything there. We have a very welcoming and helpful
|
| 78 |
+
community.
|
| 79 |
+
|
| 80 |
+
## Download
|
| 81 |
+
|
| 82 |
+
The recommended installation method is through Anaconda,
|
| 83 |
+
<https://www.anaconda.com/products/distribution>
|
| 84 |
+
|
| 85 |
+
You can also get the latest version of SymPy from
|
| 86 |
+
<https://pypi.python.org/pypi/sympy/>
|
| 87 |
+
|
| 88 |
+
To get the git version do
|
| 89 |
+
|
| 90 |
+
$ git clone https://github.com/sympy/sympy.git
|
| 91 |
+
|
| 92 |
+
For other options (tarballs, debs, etc.), see
|
| 93 |
+
<https://docs.sympy.org/dev/install.html>.
|
| 94 |
+
|
| 95 |
+
## Documentation and Usage
|
| 96 |
+
|
| 97 |
+
For in-depth instructions on installation and building the
|
| 98 |
+
documentation, see the [SymPy Documentation Style Guide](https://docs.sympy.org/dev/documentation-style-guide.html).
|
| 99 |
+
|
| 100 |
+
Everything is at:
|
| 101 |
+
|
| 102 |
+
<https://docs.sympy.org/>
|
| 103 |
+
|
| 104 |
+
You can generate everything at the above site in your local copy of
|
| 105 |
+
SymPy by:
|
| 106 |
+
|
| 107 |
+
$ cd doc
|
| 108 |
+
$ make html
|
| 109 |
+
|
| 110 |
+
Then the docs will be in <span class="title-ref">\_build/html</span>. If
|
| 111 |
+
you don't want to read that, here is a short usage:
|
| 112 |
+
|
| 113 |
+
From this directory, start Python and:
|
| 114 |
+
|
| 115 |
+
``` python
|
| 116 |
+
>>> from sympy import Symbol, cos
|
| 117 |
+
>>> x = Symbol('x')
|
| 118 |
+
>>> e = 1/cos(x)
|
| 119 |
+
>>> print(e.series(x, 0, 10))
|
| 120 |
+
1 + x**2/2 + 5*x**4/24 + 61*x**6/720 + 277*x**8/8064 + O(x**10)
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
SymPy also comes with a console that is a simple wrapper around the
|
| 124 |
+
classic python console (or IPython when available) that loads the SymPy
|
| 125 |
+
namespace and executes some common commands for you.
|
| 126 |
+
|
| 127 |
+
To start it, issue:
|
| 128 |
+
|
| 129 |
+
$ bin/isympy
|
| 130 |
+
|
| 131 |
+
from this directory, if SymPy is not installed or simply:
|
| 132 |
+
|
| 133 |
+
$ isympy
|
| 134 |
+
|
| 135 |
+
if SymPy is installed.
|
| 136 |
+
|
| 137 |
+
## Installation
|
| 138 |
+
|
| 139 |
+
To install SymPy using PyPI, run the following command:
|
| 140 |
+
|
| 141 |
+
$ pip install sympy
|
| 142 |
+
|
| 143 |
+
To install SymPy using Anaconda, run the following command:
|
| 144 |
+
|
| 145 |
+
$ conda install -c anaconda sympy
|
| 146 |
+
|
| 147 |
+
To install SymPy from GitHub source, first clone SymPy using `git`:
|
| 148 |
+
|
| 149 |
+
$ git clone https://github.com/sympy/sympy.git
|
| 150 |
+
|
| 151 |
+
Then, in the `sympy` repository that you cloned, simply run:
|
| 152 |
+
|
| 153 |
+
$ pip install .
|
| 154 |
+
|
| 155 |
+
See <https://docs.sympy.org/dev/install.html> for more information.
|
| 156 |
+
|
| 157 |
+
## Contributing
|
| 158 |
+
|
| 159 |
+
We welcome contributions from anyone, even if you are new to open
|
| 160 |
+
source. Please read our [Introduction to Contributing](https://docs.sympy.org/dev/contributing/introduction-to-contributing.html)
|
| 161 |
+
page and the [SymPy Documentation Style Guide](https://docs.sympy.org/dev/documentation-style-guide.html). If you
|
| 162 |
+
are new and looking for some way to contribute, a good place to start is
|
| 163 |
+
to look at the issues tagged [Easy to Fix](https://github.com/sympy/sympy/issues?q=is%3Aopen+is%3Aissue+label%3A%22Easy+to+Fix%22).
|
| 164 |
+
|
| 165 |
+
Please note that all participants in this project are expected to follow
|
| 166 |
+
our Code of Conduct. By participating in this project you agree to abide
|
| 167 |
+
by its terms. See [CODE\_OF\_CONDUCT.md](CODE_OF_CONDUCT.md).
|
| 168 |
+
|
| 169 |
+
## Tests
|
| 170 |
+
|
| 171 |
+
To execute all tests, run:
|
| 172 |
+
|
| 173 |
+
$./setup.py test
|
| 174 |
+
|
| 175 |
+
in the current directory.
|
| 176 |
+
|
| 177 |
+
For the more fine-grained running of tests or doctests, use `bin/test`
|
| 178 |
+
or respectively `bin/doctest`. The master branch is automatically tested
|
| 179 |
+
by GitHub Actions.
|
| 180 |
+
|
| 181 |
+
To test pull requests, use
|
| 182 |
+
[sympy-bot](https://github.com/sympy/sympy-bot).
|
| 183 |
+
|
| 184 |
+
## Regenerate Experimental <span class="title-ref">LaTeX</span> Parser/Lexer
|
| 185 |
+
|
| 186 |
+
The parser and lexer were generated with the [ANTLR4](http://antlr4.org)
|
| 187 |
+
toolchain in `sympy/parsing/latex/_antlr` and checked into the repo.
|
| 188 |
+
Presently, most users should not need to regenerate these files, but
|
| 189 |
+
if you plan to work on this feature, you will need the `antlr4`
|
| 190 |
+
command-line tool (and you must ensure that it is in your `PATH`).
|
| 191 |
+
One way to get it is:
|
| 192 |
+
|
| 193 |
+
$ conda install -c conda-forge antlr=4.11.1
|
| 194 |
+
|
| 195 |
+
Alternatively, follow the instructions on the ANTLR website and download
|
| 196 |
+
the `antlr-4.11.1-complete.jar`. Then export the `CLASSPATH` as instructed
|
| 197 |
+
and instead of creating `antlr4` as an alias, make it an executable file
|
| 198 |
+
with the following contents:
|
| 199 |
+
``` bash
|
| 200 |
+
#!/bin/bash
|
| 201 |
+
java -jar /usr/local/lib/antlr-4.11.1-complete.jar "$@"
|
| 202 |
+
```
|
| 203 |
+
|
| 204 |
+
After making changes to `sympy/parsing/latex/LaTeX.g4`, run:
|
| 205 |
+
|
| 206 |
+
$ ./setup.py antlr
|
| 207 |
+
|
| 208 |
+
## Clean
|
| 209 |
+
|
| 210 |
+
To clean everything (thus getting the same tree as in the repository):
|
| 211 |
+
|
| 212 |
+
$ git clean -Xdf
|
| 213 |
+
|
| 214 |
+
which will clear everything ignored by `.gitignore`, and:
|
| 215 |
+
|
| 216 |
+
$ git clean -df
|
| 217 |
+
|
| 218 |
+
to clear all untracked files. You can revert the most recent changes in
|
| 219 |
+
git with:
|
| 220 |
+
|
| 221 |
+
$ git reset --hard
|
| 222 |
+
|
| 223 |
+
WARNING: The above commands will all clear changes you may have made,
|
| 224 |
+
and you will lose them forever. Be sure to check things with `git
|
| 225 |
+
status`, `git diff`, `git clean -Xn`, and `git clean -n` before doing any
|
| 226 |
+
of those.
|
| 227 |
+
|
| 228 |
+
## Bugs
|
| 229 |
+
|
| 230 |
+
Our issue tracker is at <https://github.com/sympy/sympy/issues>. Please
|
| 231 |
+
report any bugs that you find. Or, even better, fork the repository on
|
| 232 |
+
GitHub and create a pull request. We welcome all changes, big or small,
|
| 233 |
+
and we will help you make the pull request if you are new to git (just
|
| 234 |
+
ask on our mailing list or Gitter Channel). If you further have any queries, you can find answers
|
| 235 |
+
on Stack Overflow using the [sympy](https://stackoverflow.com/questions/tagged/sympy) tag.
|
| 236 |
+
|
| 237 |
+
## Brief History
|
| 238 |
+
|
| 239 |
+
SymPy was started by Ondřej Čertík in 2005, he wrote some code during
|
| 240 |
+
the summer, then he wrote some more code during summer 2006. In February
|
| 241 |
+
2007, Fabian Pedregosa joined the project and helped fix many things,
|
| 242 |
+
contributed documentation, and made it alive again. 5 students (Mateusz
|
| 243 |
+
Paprocki, Brian Jorgensen, Jason Gedge, Robert Schwarz, and Chris Wu)
|
| 244 |
+
improved SymPy incredibly during summer 2007 as part of the Google
|
| 245 |
+
Summer of Code. Pearu Peterson joined the development during the summer
|
| 246 |
+
2007 and he has made SymPy much more competitive by rewriting the core
|
| 247 |
+
from scratch, which has made it from 10x to 100x faster. Jurjen N.E. Bos
|
| 248 |
+
has contributed pretty-printing and other patches. Fredrik Johansson has
|
| 249 |
+
written mpmath and contributed a lot of patches.
|
| 250 |
+
|
| 251 |
+
SymPy has participated in every Google Summer of Code since 2007. You
|
| 252 |
+
can see <https://github.com/sympy/sympy/wiki#google-summer-of-code> for
|
| 253 |
+
full details. Each year has improved SymPy by bounds. Most of SymPy's
|
| 254 |
+
development has come from Google Summer of Code students.
|
| 255 |
+
|
| 256 |
+
In 2011, Ondřej Čertík stepped down as lead developer, with Aaron
|
| 257 |
+
Meurer, who also started as a Google Summer of Code student, taking his
|
| 258 |
+
place. Ondřej Čertík is still active in the community but is too busy
|
| 259 |
+
with work and family to play a lead development role.
|
| 260 |
+
|
| 261 |
+
Since then, a lot more people have joined the development and some
|
| 262 |
+
people have also left. You can see the full list in doc/src/aboutus.rst,
|
| 263 |
+
or online at:
|
| 264 |
+
|
| 265 |
+
<https://docs.sympy.org/dev/aboutus.html#sympy-development-team>
|
| 266 |
+
|
| 267 |
+
The git history goes back to 2007 when development moved from svn to hg.
|
| 268 |
+
To see the history before that point, look at
|
| 269 |
+
<https://github.com/sympy/sympy-old>.
|
| 270 |
+
|
| 271 |
+
You can use git to see the biggest developers. The command:
|
| 272 |
+
|
| 273 |
+
$ git shortlog -ns
|
| 274 |
+
|
| 275 |
+
will show each developer, sorted by commits to the project. The command:
|
| 276 |
+
|
| 277 |
+
$ git shortlog -ns --since="1 year"
|
| 278 |
+
|
| 279 |
+
will show the top developers from the last year.
|
| 280 |
+
|
| 281 |
+
## Citation
|
| 282 |
+
|
| 283 |
+
To cite SymPy in publications use
|
| 284 |
+
|
| 285 |
+
> Meurer A, Smith CP, Paprocki M, Čertík O, Kirpichev SB, Rocklin M,
|
| 286 |
+
> Kumar A, Ivanov S, Moore JK, Singh S, Rathnayake T, Vig S, Granger BE,
|
| 287 |
+
> Muller RP, Bonazzi F, Gupta H, Vats S, Johansson F, Pedregosa F, Curry
|
| 288 |
+
> MJ, Terrel AR, Roučka Š, Saboo A, Fernando I, Kulal S, Cimrman R,
|
| 289 |
+
> Scopatz A. (2017) SymPy: symbolic computing in Python. *PeerJ Computer
|
| 290 |
+
> Science* 3:e103 <https://doi.org/10.7717/peerj-cs.103>
|
| 291 |
+
|
| 292 |
+
A BibTeX entry for LaTeX users is
|
| 293 |
+
|
| 294 |
+
``` bibtex
|
| 295 |
+
@article{10.7717/peerj-cs.103,
|
| 296 |
+
title = {SymPy: symbolic computing in Python},
|
| 297 |
+
author = {Meurer, Aaron and Smith, Christopher P. and Paprocki, Mateusz and \v{C}ert\'{i}k, Ond\v{r}ej and Kirpichev, Sergey B. and Rocklin, Matthew and Kumar, Amit and Ivanov, Sergiu and Moore, Jason K. and Singh, Sartaj and Rathnayake, Thilina and Vig, Sean and Granger, Brian E. and Muller, Richard P. and Bonazzi, Francesco and Gupta, Harsh and Vats, Shivam and Johansson, Fredrik and Pedregosa, Fabian and Curry, Matthew J. and Terrel, Andy R. and Rou\v{c}ka, \v{S}t\v{e}p\'{a}n and Saboo, Ashutosh and Fernando, Isuru and Kulal, Sumith and Cimrman, Robert and Scopatz, Anthony},
|
| 298 |
+
year = 2017,
|
| 299 |
+
month = Jan,
|
| 300 |
+
keywords = {Python, Computer algebra system, Symbolics},
|
| 301 |
+
abstract = {
|
| 302 |
+
SymPy is an open-source computer algebra system written in pure Python. It is built with a focus on extensibility and ease of use, through both interactive and programmatic applications. These characteristics have led SymPy to become a popular symbolic library for the scientific Python ecosystem. This paper presents the architecture of SymPy, a description of its features, and a discussion of select submodules. The supplementary material provides additional examples and further outlines details of the architecture and features of SymPy.
|
| 303 |
+
},
|
| 304 |
+
volume = 3,
|
| 305 |
+
pages = {e103},
|
| 306 |
+
journal = {PeerJ Computer Science},
|
| 307 |
+
issn = {2376-5992},
|
| 308 |
+
url = {https://doi.org/10.7717/peerj-cs.103},
|
| 309 |
+
doi = {10.7717/peerj-cs.103}
|
| 310 |
+
}
|
| 311 |
+
```
|
| 312 |
+
|
| 313 |
+
SymPy is BSD licensed, so you are free to use it whatever you like, be
|
| 314 |
+
it academic, commercial, creating forks or derivatives, as long as you
|
| 315 |
+
copy the BSD statement if you redistribute it (see the LICENSE file for
|
| 316 |
+
details). That said, although not required by the SymPy license, if it
|
| 317 |
+
is convenient for you, please cite SymPy when using it in your work and
|
| 318 |
+
also consider contributing all your changes back, so that we can
|
| 319 |
+
incorporate it and all of us will benefit in the end.
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy-1.14.0.dist-info/RECORD
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy-1.14.0.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: setuptools (79.0.1)
|
| 3 |
+
Root-Is-Purelib: true
|
| 4 |
+
Tag: py3-none-any
|
| 5 |
+
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy-1.14.0.dist-info/entry_points.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[console_scripts]
|
| 2 |
+
isympy = isympy:main
|
ScaleDF_rebuttal/python_dedup_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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
All people who contributed to SymPy by sending at least a patch or
|
| 2 |
+
more (in the order of the date of their first contribution), except
|
| 3 |
+
those who explicitly didn't want to be mentioned. People with a * next
|
| 4 |
+
to their names are not found in the metadata of the git history. This
|
| 5 |
+
file is generated automatically by running `./bin/authors_update.py`.
|
| 6 |
+
|
| 7 |
+
There are a total of 1371 authors.
|
| 8 |
+
|
| 9 |
+
Ondřej Čertík <ondrej@certik.cz>
|
| 10 |
+
Fabian Pedregosa <fabian@fseoane.net>
|
| 11 |
+
Jurjen N.E. Bos <jnebos@gmail.com>
|
| 12 |
+
Mateusz Paprocki <mattpap@gmail.com>
|
| 13 |
+
*Marc-Etienne M.Leveille <protonyc@gmail.com>
|
| 14 |
+
Brian Jorgensen <brian.jorgensen@gmail.com>
|
| 15 |
+
Jason Gedge <inferno1386@gmail.com>
|
| 16 |
+
Robert Schwarz <lethargo@googlemail.com>
|
| 17 |
+
Pearu Peterson <pearu.peterson@gmail.com>
|
| 18 |
+
Fredrik Johansson <fredrik.johansson@gmail.com>
|
| 19 |
+
Chris Wu <chris.wu@gmail.com>
|
| 20 |
+
*Ulrich Hecht <ulrich.hecht@gmail.com>
|
| 21 |
+
Goutham Lakshminarayan <dl.goutham@gmail.com>
|
| 22 |
+
David Lawrence <dmlawrence@gmail.com>
|
| 23 |
+
Jaroslaw Tworek <dev.jrx@gmail.com>
|
| 24 |
+
David Marek <h4wk.cz@gmail.com>
|
| 25 |
+
Bernhard R. Link <brlink@debian.org>
|
| 26 |
+
Andrej Tokarčík <androsis@gmail.com>
|
| 27 |
+
Or Dvory <gidesa@gmail.com>
|
| 28 |
+
Saroj Adhikari <adh.saroj@gmail.com>
|
| 29 |
+
Pauli Virtanen <pav@iki.fi>
|
| 30 |
+
Robert Kern <robert.kern@gmail.com>
|
| 31 |
+
James Aspnes <aspnes@cs.yale.edu>
|
| 32 |
+
Nimish Telang <ntelang@gmail.com>
|
| 33 |
+
Abderrahim Kitouni <a.kitouni@gmail.com>
|
| 34 |
+
Pan Peng <pengpanster@gmail.com>
|
| 35 |
+
Friedrich Hagedorn <friedrich_h@gmx.de>
|
| 36 |
+
Elrond der Elbenfuerst <elrond+sympy.org@samba-tng.org>
|
| 37 |
+
Rizgar Mella <rizgar.mella@gmail.com>
|
| 38 |
+
Felix Kaiser <felix.kaiser@fxkr.net>
|
| 39 |
+
Roberto Nobrega <rwnobrega@gmail.com>
|
| 40 |
+
David Roberts <dvdr18@gmail.com>
|
| 41 |
+
Sebastian Krämer <basti.kr@gmail.com>
|
| 42 |
+
Vinzent Steinberg <vinzent.steinberg@gmail.com>
|
| 43 |
+
Riccardo Gori <goriccardo@gmail.com>
|
| 44 |
+
Case Van Horsen <casevh@gmail.com>
|
| 45 |
+
Stepan Roucka <stepan@roucka.eu>
|
| 46 |
+
Ali Raza Syed <arsyed@gmail.com>
|
| 47 |
+
Stefano Maggiolo <s.maggiolo@gmail.com>
|
| 48 |
+
Robert Cimrman <cimrman3@ntc.zcu.cz>
|
| 49 |
+
Bastian Weber <bastian.weber@gmx-topmail.de>
|
| 50 |
+
Sebastian Krause <sebastian.krause@gmx.de>
|
| 51 |
+
Sebastian Kreft <skreft@gmail.com>
|
| 52 |
+
*Dan <coolg49964@gmail.com>
|
| 53 |
+
Alan Bromborsky <abrombo@verizon.net>
|
| 54 |
+
Boris Timokhin <qoqenator@gmail.com>
|
| 55 |
+
Robert <average.programmer@gmail.com>
|
| 56 |
+
Andy R. Terrel <aterrel@uchicago.edu>
|
| 57 |
+
Hubert Tsang <intsangity@gmail.com>
|
| 58 |
+
Konrad Meyer <konrad.meyer@gmail.com>
|
| 59 |
+
Henrik Johansson <henjo2006@gmail.com>
|
| 60 |
+
Priit Laes <plaes@plaes.org>
|
| 61 |
+
Freddie Witherden <freddie@witherden.org>
|
| 62 |
+
Brian E. Granger <ellisonbg@gmail.com>
|
| 63 |
+
Andrew Straw <strawman@astraw.com>
|
| 64 |
+
Kaifeng Zhu <cafeeee@gmail.com>
|
| 65 |
+
Ted Horst <ted.horst@earthlink.net>
|
| 66 |
+
Andrew Docherty <andrewd@maths.usyd.edu.au>
|
| 67 |
+
Akshay Srinivasan <akshaysrinivasan@gmail.com>
|
| 68 |
+
Aaron Meurer <asmeurer@gmail.com>
|
| 69 |
+
Barry Wardell <barry.wardell@gmail.com>
|
| 70 |
+
Tomasz Buchert <thinred@gmail.com>
|
| 71 |
+
Vinay Kumar <gnulinooks@gmail.com>
|
| 72 |
+
Johann Cohen-Tanugi <johann.cohentanugi@gmail.com>
|
| 73 |
+
Jochen Voss <voss@seehuhn.de>
|
| 74 |
+
Luke Peterson <hazelnusse@gmail.com>
|
| 75 |
+
Chris Smith <smichr@gmail.com>
|
| 76 |
+
Thomas Sidoti <TSidoti@gmail.com>
|
| 77 |
+
Florian Mickler <florian@mickler.org>
|
| 78 |
+
Nicolas Pourcelot <nicolas.pourcelot@gmail.com>
|
| 79 |
+
Ben Goodrich <goodrich.ben@gmail.com>
|
| 80 |
+
Toon Verstraelen <Toon.Verstraelen@UGent.be>
|
| 81 |
+
Ronan Lamy <ronan.lamy@gmail.com>
|
| 82 |
+
James Abbatiello <abbeyj@gmail.com>
|
| 83 |
+
Ryan Krauss <ryanlists@gmail.com>
|
| 84 |
+
Bill Flynn <wflynny@gmail.com>
|
| 85 |
+
Kevin Goodsell <kevin-opensource@omegacrash.net>
|
| 86 |
+
Jorn Baayen <jorn.baayen@gmail.com>
|
| 87 |
+
Eh Tan <tan2tan2@gmail.com>
|
| 88 |
+
Renato Coutinho <renato.coutinho@gmail.com>
|
| 89 |
+
Oscar Benjamin <oscar.j.benjamin@gmail.com>
|
| 90 |
+
Øyvind Jensen <jensen.oyvind@gmail.com>
|
| 91 |
+
Julio Idichekop Filho <idichekop@yahoo.com.br>
|
| 92 |
+
Łukasz Pankowski <lukpank@o2.pl>
|
| 93 |
+
*Chu-Ching Huang <cchuang@mail.cgu.edu.tw>
|
| 94 |
+
Fernando Perez <Fernando.Perez@berkeley.edu>
|
| 95 |
+
Raffaele De Feo <alberthilbert@gmail.com>
|
| 96 |
+
Christian Muise <christian.muise@gmail.com>
|
| 97 |
+
Matt Curry <mattjcurry@gmail.com>
|
| 98 |
+
Kazuo Thow <kazuo.thow@gmail.com>
|
| 99 |
+
Christian Schubert <chr.schubert@gmx.de>
|
| 100 |
+
Jezreel Ng <jezreel@gmail.com>
|
| 101 |
+
James Pearson <xiong.chiamiov@gmail.com>
|
| 102 |
+
Matthew Brett <matthew.brett@gmail.com>
|
| 103 |
+
Addison Cugini <ajcugini@gmail.com>
|
| 104 |
+
Nicholas J.S. Kinar <n.kinar@usask.ca>
|
| 105 |
+
Harold Erbin <harold.erbin@gmail.com>
|
| 106 |
+
Thomas Dixon <thom@thomdixon.org>
|
| 107 |
+
Cristóvão Sousa <crisjss@gmail.com>
|
| 108 |
+
Andre de Fortier Smit <freevryheid@gmail.com>
|
| 109 |
+
Mark Dewing <markdewing@gmail.com>
|
| 110 |
+
Alexey U. Gudchenko <proga@goodok.ru>
|
| 111 |
+
Gary Kerr <gary.kerr@blueyonder.co.uk>
|
| 112 |
+
Sherjil Ozair <sherjilozair@gmail.com>
|
| 113 |
+
Oleksandr Gituliar <gituliar@gmail.com>
|
| 114 |
+
Sean Vig <sean.v.775@gmail.com>
|
| 115 |
+
Prafullkumar P. Tale <hector1618@gmail.com>
|
| 116 |
+
Vladimir Perić <vlada.peric@gmail.com>
|
| 117 |
+
Tom Bachmann <e_mc_h2@web.de>
|
| 118 |
+
Yuri Karadzhov <yuri.karadzhov@gmail.com>
|
| 119 |
+
Vladimir Lagunov <werehuman@gmail.com>
|
| 120 |
+
Matthew Rocklin <mrocklin@cs.uchicago.edu>
|
| 121 |
+
Saptarshi Mandal <sapta.iitkgp@gmail.com>
|
| 122 |
+
Gilbert Gede <gilbertgede@gmail.com>
|
| 123 |
+
Anatolii Koval <weralwolf@gmail.com>
|
| 124 |
+
Tomo Lazovich <lazovich@gmail.com>
|
| 125 |
+
Pavel Fedotov <fedotovp@gmail.com>
|
| 126 |
+
Jack McCaffery <jpmccaffery@gmail.com>
|
| 127 |
+
Jeremias Yehdegho <j.yehdegho@gmail.com>
|
| 128 |
+
Kibeom Kim <kk1674@nyu.edu>
|
| 129 |
+
Gregory Ksionda <ksiondag846@gmail.com>
|
| 130 |
+
Tomáš Bambas <tomas.bambas@gmail.com>
|
| 131 |
+
Raymond Wong <rayman_407@yahoo.com>
|
| 132 |
+
Luca Weihs <astronomicalcuriosity@gmail.com>
|
| 133 |
+
Shai 'Deshe' Wyborski <shaide@cs.huji.ac.il>
|
| 134 |
+
Thomas Wiecki <thomas.wiecki@gmail.com>
|
| 135 |
+
Óscar Nájera <najera.oscar@gmail.com>
|
| 136 |
+
Mario Pernici <mario.pernici@gmail.com>
|
| 137 |
+
Benjamin McDonald <mcdonald.ben@gmail.com>
|
| 138 |
+
Sam Magura <samtheman132@gmail.com>
|
| 139 |
+
Stefan Krastanov <krastanov.stefan@gmail.com>
|
| 140 |
+
Bradley Froehle <brad.froehle@gmail.com>
|
| 141 |
+
Min Ragan-Kelley <benjaminrk@gmail.com>
|
| 142 |
+
Emma Hogan <ehogan@gemini.edu>
|
| 143 |
+
Nikhil Sarda <diff.operator@gmail.com>
|
| 144 |
+
Julien Rioux <julien.rioux@gmail.com>
|
| 145 |
+
Roberto Colistete, Jr. <roberto.colistete@gmail.com>
|
| 146 |
+
Raoul Bourquin <raoulb@bluewin.ch>
|
| 147 |
+
Gert-Ludwig Ingold <gert.ingold@physik.uni-augsburg.de>
|
| 148 |
+
Srinivas Vasudevan <srvasude@gmail.com>
|
| 149 |
+
Jason Moore <moorepants@gmail.com>
|
| 150 |
+
Miha Marolt <tloramus@gmail.com>
|
| 151 |
+
Tim Lahey <tim.lahey@gmail.com>
|
| 152 |
+
Luis Garcia <ppn.online@me.com>
|
| 153 |
+
Matt Rajca <matt.rajca@me.com>
|
| 154 |
+
David Li <l33tnerd.li@gmail.com>
|
| 155 |
+
Alexandr Gudulin <alexandr.gudulin@gmail.com>
|
| 156 |
+
Bilal Akhtar <bilalakhtar@ubuntu.com>
|
| 157 |
+
Grzegorz Świrski <sognat@gmail.com>
|
| 158 |
+
Matt Habel <habelinc@gmail.com>
|
| 159 |
+
David Ju <Sgtmook314@gmail.com>
|
| 160 |
+
Nichita Utiu <nikita.utiu+github@gmail.com>
|
| 161 |
+
Nikolay Lazarov <qwerqwerqwer@abv.bg>
|
| 162 |
+
Steve Anton <anxuiz.nx@gmail.com>
|
| 163 |
+
Imran Ahmed Manzoor <imran.manzoor31@gmail.com>
|
| 164 |
+
Ljubiša Moćić <3rdslasher@gmail.com>
|
| 165 |
+
Piotr Korgul <p.korgul@gmail.com>
|
| 166 |
+
Jim Zhang <Hyriodula@gmail.com>
|
| 167 |
+
Sam Sleight <samuel.sleight@gmail.com>
|
| 168 |
+
tborisova <ts.borisova3@gmail.com>
|
| 169 |
+
Chancellor Arkantos <Chancellor_Arkantos@hotmail.co.uk>
|
| 170 |
+
Stepan Simsa <simsa.st@gmail.com>
|
| 171 |
+
Tobias Lenz <t_lenz94@web.de>
|
| 172 |
+
Siddhanathan Shanmugam <siddhanathan@gmail.com>
|
| 173 |
+
Tiffany Zhu <bubble.wubble.303@gmail.com>
|
| 174 |
+
Tristan Hume <tris.hume@gmail.com>
|
| 175 |
+
Alexey Subach <alexey.subach@gmail.com>
|
| 176 |
+
Joan Creus <joan.creus.c@gmail.com>
|
| 177 |
+
Geoffry Song <goffrie@gmail.com>
|
| 178 |
+
Puneeth Chaganti <punchagan@gmail.com>
|
| 179 |
+
Marcin Kostrzewa <>
|
| 180 |
+
Natalia Nawara <fankalemura@gmail.com>
|
| 181 |
+
vishal <vishal.panjwani15@gmail.com>
|
| 182 |
+
Shruti Mangipudi <shruti2395@gmail.com>
|
| 183 |
+
Davy Mao <e_equals_mass_speed_light_squared@hotmail.com>
|
| 184 |
+
Swapnil Agarwal <swapnilag29@gmail.com>
|
| 185 |
+
Dhia Kennouche <kendhia@gmail.com>
|
| 186 |
+
jerryma1121 <jerryma1121@gmail.com>
|
| 187 |
+
Joachim Durchholz <jo@durchholz.org>
|
| 188 |
+
Martin Povišer <martin.povik@gmail.com>
|
| 189 |
+
Siddhant Jain <getsiddhant@gmail.com>
|
| 190 |
+
Kevin Hunter <hunteke@earlham.edu>
|
| 191 |
+
Michael Mayorov <marchael@kb.csu.ru>
|
| 192 |
+
Nathan Alison <nathan.f.alison@gmail.com>
|
| 193 |
+
Christian Bühler <christian@cbuehler.de>
|
| 194 |
+
Carsten Knoll <CarstenKnoll@gmx.de>
|
| 195 |
+
Bharath M R <catchmrbharath@gmail.com>
|
| 196 |
+
Matthias Toews <mat.toews@googlemail.com>
|
| 197 |
+
Sergiu Ivanov <unlimitedscolobb@gmail.com>
|
| 198 |
+
Jorge E. Cardona <jorgeecardona@gmail.com>
|
| 199 |
+
Sanket Agarwal <sanket@sanketagarwal.com>
|
| 200 |
+
Manoj Babu K. <manoj.babu2378@gmail.com>
|
| 201 |
+
Sai Nikhil <tsnlegend@gmail.com>
|
| 202 |
+
Aleksandar Makelov <amakelov@college.harvard.edu>
|
| 203 |
+
Sachin Irukula <sachin.irukula@gmail.com>
|
| 204 |
+
Raphael Michel <webmaster@raphaelmichel.de>
|
| 205 |
+
Ashwini Oruganti <ashwini.oruganti@gmail.com>
|
| 206 |
+
Andreas Klöckner <inform@tiker.net>
|
| 207 |
+
Prateek Papriwal <papriwalprateek@gmail.com>
|
| 208 |
+
Arpit Goyal <agmps18@gmail.com>
|
| 209 |
+
Angadh Nanjangud <angadh.n@gmail.com>
|
| 210 |
+
Comer Duncan <comer.duncan@gmail.com>
|
| 211 |
+
Jens H. Nielsen <jenshnielsen@gmail.com>
|
| 212 |
+
Joseph Dougherty <Github@JWDougherty.com>
|
| 213 |
+
Elliot Marshall <Marshall2389@gmail.com>
|
| 214 |
+
Guru Devanla <grdvnl@gmail.com>
|
| 215 |
+
George Waksman <waksman@gwax.com>
|
| 216 |
+
Alexandr Popov <alexandr.s.popov@gmail.com>
|
| 217 |
+
Tarun Gaba <tarun.gaba7@gmail.com>
|
| 218 |
+
Takafumi Arakaki <aka.tkf@gmail.com>
|
| 219 |
+
Saurabh Jha <saurabh.jhaa@gmail.com>
|
| 220 |
+
Rom le Clair <jacen.guardian@gmail.com>
|
| 221 |
+
Angus Griffith <16sn6uv@gmail.com>
|
| 222 |
+
Timothy Reluga <treluga@math.psu.edu>
|
| 223 |
+
Brian Stephanik <xoedusk@gmail.com>
|
| 224 |
+
Alexander Eberspächer <alex.eberspaecher@gmail.com>
|
| 225 |
+
Sachin Joglekar <srjoglekar246@gmail.com>
|
| 226 |
+
Tyler Pirtle <teeler@gmail.com>
|
| 227 |
+
Vasily Povalyaev <vapovalyaev@gmail.com>
|
| 228 |
+
Colleen Lee <colleenclee@gmail.com>
|
| 229 |
+
Matthew Hoff <mhoff14@gmail.com>
|
| 230 |
+
Niklas Thörne <notrupertthorne@gmail.com>
|
| 231 |
+
Huijun Mai <m.maihuijun@gmail.com>
|
| 232 |
+
Marek Šuppa <mr@shu.io>
|
| 233 |
+
Ramana Venkata <idlike2dream@gmail.com>
|
| 234 |
+
Prasoon Shukla <prasoon92.iitr@gmail.com>
|
| 235 |
+
Stefen Yin <zqyin@ucdavis.edu>
|
| 236 |
+
Thomas Hisch <t.hisch@gmail.com>
|
| 237 |
+
Madeleine Ball <mpball@gmail.com>
|
| 238 |
+
Mary Clark <mary.spriteling@gmail.com>
|
| 239 |
+
Rishabh Dixit <rishabhdixit11@gmail.com>
|
| 240 |
+
Manoj Kumar <manojkumarsivaraj334@gmail.com>
|
| 241 |
+
Akshit Agarwal <akshit.jiit@gmail.com>
|
| 242 |
+
CJ Carey <perimosocordiae@gmail.com>
|
| 243 |
+
Patrick Lacasse <patrick.m.lacasse@gmail.com>
|
| 244 |
+
Ananya H <ananyaha93@gmail.com>
|
| 245 |
+
Tarang Patel <tarangrockr@gmail.com>
|
| 246 |
+
Christopher Dembia <cld72@cornell.edu>
|
| 247 |
+
Benjamin Fishbein <fishbeinb@gmail.com>
|
| 248 |
+
Sean Ge <seange727@gmail.com>
|
| 249 |
+
Amit Jamadagni <bitsjamadagni@gmail.com>
|
| 250 |
+
Ankit Agrawal <aaaagrawal@iitb.ac.in>
|
| 251 |
+
Björn Dahlgren <bjodah@gmail.com>
|
| 252 |
+
Christophe Saint-Jean <christophe.saint-jean@univ-lr.fr>
|
| 253 |
+
Demian Wassermann <demian@bwh.harvard.edu>
|
| 254 |
+
Khagesh Patel <khageshpatel93@gmail.com>
|
| 255 |
+
Stephen Loo <shikil@yahoo.com>
|
| 256 |
+
hm <hacman0@gmail.com>
|
| 257 |
+
Patrick Poitras <acebulf@gmail.com>
|
| 258 |
+
Katja Sophie Hotz <katja.sophie.hotz@student.tuwien.ac.at>
|
| 259 |
+
Varun Joshi <joshi.142@osu.edu>
|
| 260 |
+
Chetna Gupta <cheta.gup@gmail.com>
|
| 261 |
+
Thilina Rathnayake <thilinarmtb@gmail.com>
|
| 262 |
+
Max Hutchinson <maxhutch@gmail.com>
|
| 263 |
+
Shravas K Rao <shravas@gmail.com>
|
| 264 |
+
Matthew Tadd <matt.tadd@gmail.com>
|
| 265 |
+
Alexander Hirzel <alex@hirzel.us>
|
| 266 |
+
Randy Heydon <randy.heydon@clockworklab.net>
|
| 267 |
+
Oliver Lee <oliverzlee@gmail.com>
|
| 268 |
+
Seshagiri Prabhu <seshagiriprabhu@gmail.com>
|
| 269 |
+
Pradyumna <pradyu1993@gmail.com>
|
| 270 |
+
Erik Welch <erik.n.welch@gmail.com>
|
| 271 |
+
Eric Nelson <eric.the.red.XLII@gmail.com>
|
| 272 |
+
Roland Puntaier <roland.puntaier@chello.at>
|
| 273 |
+
Chris Conley <chrisconley15@gmail.com>
|
| 274 |
+
Tim Swast <tswast@gmail.com>
|
| 275 |
+
Dmitry Batkovich <batya239@gmail.com>
|
| 276 |
+
Francesco Bonazzi <franz.bonazzi@gmail.com>
|
| 277 |
+
Yuriy Demidov <iurii.demidov@gmail.com>
|
| 278 |
+
Rick Muller <rpmuller@gmail.com>
|
| 279 |
+
Manish Gill <gill.manish90@gmail.com>
|
| 280 |
+
Markus Müller <markus.mueller.1.g@googlemail.com>
|
| 281 |
+
Amit Saha <amitsaha.in@gmail.com>
|
| 282 |
+
Jeremy <twobitlogic@gmail.com>
|
| 283 |
+
QuaBoo <kisonchristian@gmail.com>
|
| 284 |
+
Stefan van der Walt <stefan@sun.ac.za>
|
| 285 |
+
David Joyner <wdjoyner@gmail.com>
|
| 286 |
+
Lars Buitinck <larsmans@gmail.com>
|
| 287 |
+
Alkiviadis G. Akritas <akritas@uth.gr>
|
| 288 |
+
Vinit Ravishankar <vinit.ravishankar@gmail.com>
|
| 289 |
+
Michael Boyle <michael.oliver.boyle@gmail.com>
|
| 290 |
+
Heiner Kirchhoffer <Heiner.Kirchhoffer@gmail.com>
|
| 291 |
+
Pablo Puente <ppuedom@gmail.com>
|
| 292 |
+
James Fiedler <jrfiedler@gmail.com>
|
| 293 |
+
Harsh Gupta <mail@hargup.in>
|
| 294 |
+
Tuomas Airaksinen <tuomas.airaksinen@gmail.com>
|
| 295 |
+
Paul Strickland <p.e.strickland@gmail.com>
|
| 296 |
+
James Goppert <james.goppert@gmail.com>
|
| 297 |
+
rathmann <rathmann.os@gmail.com>
|
| 298 |
+
Avichal Dayal <avichal.dayal@gmail.com>
|
| 299 |
+
Paul Scott <paul.scott@nicta.com.au>
|
| 300 |
+
Shipra Banga <bangashipra@gmail.com>
|
| 301 |
+
Pramod Ch <pramodch14@gmail.com>
|
| 302 |
+
Akshay <akshaynukala95@gmail.com>
|
| 303 |
+
Buck Shlegeris <buck2@bruceh15.anu.edu.au>
|
| 304 |
+
Jonathan Miller <jdmiller93@gmail.com>
|
| 305 |
+
Edward Schembor <eschemb1@jhu.edu>
|
| 306 |
+
Rajath Shashidhara <rajaths.rajaths@gmail.com>
|
| 307 |
+
Zamrath Nizam <zamiguy_ni@yahoo.com>
|
| 308 |
+
Aditya Shah <adityashah30@gmail.com>
|
| 309 |
+
Rajat Aggarwal <rajataggarwal1975@gmail.com>
|
| 310 |
+
Sambuddha Basu <sammygamer@live.com>
|
| 311 |
+
Zeel Shah <kshah215@gmail.com>
|
| 312 |
+
Abhinav Chanda <abhinavchanda01@gmail.com>
|
| 313 |
+
Jim Crist <crist042@umn.edu>
|
| 314 |
+
Sudhanshu Mishra <mrsud94@gmail.com>
|
| 315 |
+
Anurag Sharma <anurags92@gmail.com>
|
| 316 |
+
Soumya Dipta Biswas <sdb1323@gmail.com>
|
| 317 |
+
Sushant Hiray <hiraysushant@gmail.com>
|
| 318 |
+
Ben Lucato <ben.lucato@gmail.com>
|
| 319 |
+
Kunal Arora <kunalarora.135@gmail.com>
|
| 320 |
+
Henry Gebhardt <hsggebhardt@gmail.com>
|
| 321 |
+
Dammina Sahabandu <dmsahabandu@gmail.com>
|
| 322 |
+
Manish Shukla <manish.shukla393@gmail>
|
| 323 |
+
Ralph Bean <rbean@redhat.com>
|
| 324 |
+
richierichrawr <richierichrawr@users.noreply.github.com>
|
| 325 |
+
John Connor <john.theman.connor@gmail.com>
|
| 326 |
+
Juan Luis Cano Rodríguez <juanlu001@gmail.com>
|
| 327 |
+
Sahil Shekhawat <sahilshekhawat01@gmail.com>
|
| 328 |
+
Kundan Kumar <kundankumar18581@gmail.com>
|
| 329 |
+
Stas Kelvich <stanconn@gmail.com>
|
| 330 |
+
sevaader <sevaader@gmail.com>
|
| 331 |
+
Dhruvesh Vijay Parikh <parikhdhruvesh1@gmail.com>
|
| 332 |
+
Venkatesh Halli <venkatesh.fatality@gmail.com>
|
| 333 |
+
Lennart Fricke <lennart@die-frickes.eu>
|
| 334 |
+
Vlad Seghete <vlad.seghete@gmail.com>
|
| 335 |
+
Shashank Agarwal <shashank.agarwal94@gmail.com>
|
| 336 |
+
carstimon <carstimon@gmail.com>
|
| 337 |
+
Pierre Haessig <pierre.haessig@crans.org>
|
| 338 |
+
Maciej Baranski <getrox.sc@gmail.com>
|
| 339 |
+
Benjamin Gudehus <hastebrot@gmail.com>
|
| 340 |
+
Faisal Anees <faisal.iiit@gmail.com>
|
| 341 |
+
Mark Shoulson <mark@kli.org>
|
| 342 |
+
Robert Johansson <jrjohansson@gmail.com>
|
| 343 |
+
Kalevi Suominen <jksuom@gmail.com>
|
| 344 |
+
Kaushik Varanasi <kaushik.varanasi1@gmail.com>
|
| 345 |
+
Fawaz Alazemi <Mba7eth@gmail.com>
|
| 346 |
+
Ambar Mehrotra <mehrotraambar@gmail.com>
|
| 347 |
+
David P. Sanders <dpsanders@gmail.com>
|
| 348 |
+
Peter Brady <petertbrady@gmail.com>
|
| 349 |
+
John V. Siratt <jvsiratt@gmail.com>
|
| 350 |
+
Sarwar Chahal <chahal.sarwar98@gmail.com>
|
| 351 |
+
Nathan Woods <charlesnwoods@gmail.com>
|
| 352 |
+
Colin B. Macdonald <cbm@m.fsf.org>
|
| 353 |
+
Marcus Näslund <naslundx@gmail.com>
|
| 354 |
+
Clemens Novak <clemens@familie-novak.net>
|
| 355 |
+
Mridul Seth <seth.mridul@gmail.com>
|
| 356 |
+
Craig A. Stoudt <craig.stoudt@gmail.com>
|
| 357 |
+
Raj <raj454raj@gmail.com>
|
| 358 |
+
Mihai A. Ionescu <ionescu.a.mihai@gmail.com>
|
| 359 |
+
immerrr <immerrr@gmail.com>
|
| 360 |
+
Chai Wah Wu <cwwuieee@gmail.com>
|
| 361 |
+
Leonid Blouvshtein <leonidbl91@gmail.com>
|
| 362 |
+
Peleg Michaeli <freepeleg@gmail.com>
|
| 363 |
+
ck Lux <lux.r.ck@gmail.com>
|
| 364 |
+
zsc347 <zsc347@gmail.com>
|
| 365 |
+
Hamish Dickson <hamish.dickson@gmail.com>
|
| 366 |
+
Michael Gallaspy <gallaspy.michael@gmail.com>
|
| 367 |
+
Roman Inflianskas <infroma@gmail.com>
|
| 368 |
+
Duane Nykamp <nykamp@umn.edu>
|
| 369 |
+
Ted Dokos <tdokos@gmail.com>
|
| 370 |
+
Sunny Aggarwal <sunnyaggarwal1994@gmail.com>
|
| 371 |
+
Victor Brebenar <v.brebenar@gmail.com>
|
| 372 |
+
Akshat Jain <akshat.jain@students.iiit.ac.in>
|
| 373 |
+
Shivam Vats <shivamvats.iitkgp@gmail.com>
|
| 374 |
+
Longqi Wang <iqgnol@gmail.com>
|
| 375 |
+
Juan Felipe Osorio <jfosorio@gmail.com>
|
| 376 |
+
Ray Cathcart <github@cathcart.us>
|
| 377 |
+
Lukas Zorich <lukas.zorich@gmail.com>
|
| 378 |
+
Eric Miller <emiller42@gmail.com>
|
| 379 |
+
Cody Herbst <cyherbst@gmail.com>
|
| 380 |
+
Nishith Shah <nishithshah.2211@gmail.com>
|
| 381 |
+
Amit Kumar <dtu.amit@gmail.com>
|
| 382 |
+
Yury G. Kudryashov <urkud.urkud@gmail.com>
|
| 383 |
+
Guillaume Gay <contact@damcb.com>
|
| 384 |
+
Mihir Wadwekar <m.mihirw@gmail.com>
|
| 385 |
+
Tuan Manh Lai <laituan245@gmail.com>
|
| 386 |
+
Asish Panda <asishrocks95@gmail.com>
|
| 387 |
+
Darshan Chaudhary <deathbullet@gmail.com>
|
| 388 |
+
Alec Kalinin <alec.kalinin@gmail.com>
|
| 389 |
+
Ralf Stephan <ralf@ark.in-berlin.de>
|
| 390 |
+
Aaditya Nair <aadityanair6494@gmail.com>
|
| 391 |
+
Jayesh Lahori <jlahori92@gmail.com>
|
| 392 |
+
Harshil Goel <harshil158@gmail.com>
|
| 393 |
+
Luv Agarwal <agarwal.iiit@gmail.com>
|
| 394 |
+
Jason Ly <jason.ly@gmail.com>
|
| 395 |
+
Lokesh Sharma <lokeshhsharma@gmail.com>
|
| 396 |
+
Sartaj Singh <singhsartaj94@gmail.com>
|
| 397 |
+
Chris Swierczewski <cswiercz@gmail.com>
|
| 398 |
+
Konstantin Togoi <konstantin.togoi@gmail.com>
|
| 399 |
+
Param Singh <paramsingh258@gmail.com>
|
| 400 |
+
Sumith Kulal <sumith1896@gmail.com>
|
| 401 |
+
Juha Remes <jremes@outlook.com>
|
| 402 |
+
Philippe Bouafia <philippe.bouafia@ensea.fr>
|
| 403 |
+
Peter Schmidt <peter@peterjs.com>
|
| 404 |
+
Jiaxing Liang <liangjiaxing57@gmail.com>
|
| 405 |
+
Lucas Jones <lucas@lucasjones.co.uk>
|
| 406 |
+
Gregory Ashton <gash789@gmail.com>
|
| 407 |
+
Jennifer White <jcrw122@googlemail.com>
|
| 408 |
+
Renato Orsino <renato.orsino@gmail.com>
|
| 409 |
+
Alistair Lynn <arplynn@gmail.com>
|
| 410 |
+
Govind Sahai <gsiitbhu@gmail.com>
|
| 411 |
+
Adam Bloomston <adam@glitterfram.es>
|
| 412 |
+
Kyle McDaniel <mcdanie5@illinois.edu>
|
| 413 |
+
Nguyen Truong Duy <truongduy134@yahoo.com>
|
| 414 |
+
Alex Lindsay <adlinds3@ncsu.edu>
|
| 415 |
+
Mathew Chong <mathewchong.dev@gmail.com>
|
| 416 |
+
Jason Siefken <siefkenj@gmail.com>
|
| 417 |
+
Gaurav Dhingra <gauravdhingra.gxyd@gmail.com>
|
| 418 |
+
Gao, Xiang <qasdfgtyuiop@gmail.com>
|
| 419 |
+
Kevin Ventullo <kevin.ventullo@gmail.com>
|
| 420 |
+
mao8 <thisisma08@gmail.com>
|
| 421 |
+
Isuru Fernando <isuruf@gmail.com>
|
| 422 |
+
Shivam Tyagi <shivam.tyagi.apm13@itbhu.ac.in>
|
| 423 |
+
Richard Otis <richard.otis@outlook.com>
|
| 424 |
+
Rich LaSota <rjlasota@gmail.com>
|
| 425 |
+
dustyrockpyle <dustyrockpyle@gmail.com>
|
| 426 |
+
Anton Akhmerov <anton.akhmerov@gmail.com>
|
| 427 |
+
Michael Zingale <michael.zingale@stonybrook.edu>
|
| 428 |
+
Chak-Pong Chung <chakpongchung@gmail.com>
|
| 429 |
+
David T <derDavidT@users.noreply.github.com>
|
| 430 |
+
Phil Ruffwind <rf@rufflewind.com>
|
| 431 |
+
Sebastian Koslowski <koslowski@kit.edu>
|
| 432 |
+
Kumar Krishna Agrawal <kumar.1994.14@gmail.com>
|
| 433 |
+
Dustin Gadal <Dustin.Gadal@gmail.com>
|
| 434 |
+
João Moura <operte@gmail.com>
|
| 435 |
+
Yu Kobayashi <yukoba@accelart.jp>
|
| 436 |
+
Shashank Kumar <shashank.kumar.apc13@iitbhu.ac.in>
|
| 437 |
+
Timothy Cyrus <tcyrus@users.noreply.github.com>
|
| 438 |
+
Devyani Kota <devyanikota@gmail.com>
|
| 439 |
+
Keval Shah <kevalshah_96@yahoo.co.in>
|
| 440 |
+
Dzhelil Rufat <drufat@caltech.edu>
|
| 441 |
+
Pastafarianist <mr.pastafarianist@gmail.com>
|
| 442 |
+
Sourav Singh <souravsingh@users.noreply.github.com>
|
| 443 |
+
Jacob Garber <jgarber1@ualberta.ca>
|
| 444 |
+
Vinay Singh <csvinay.d@gmail.com>
|
| 445 |
+
GolimarOurHero <metalera94@hotmail.com>
|
| 446 |
+
Prashant Tyagi <prashanttyagi221295@gmail.com>
|
| 447 |
+
Matthew Davis <davisml.md@gmail.com>
|
| 448 |
+
Tschijnmo TSCHAU <tschijnmotschau@gmail.com>
|
| 449 |
+
Alexander Bentkamp <bentkamp@gmail.com>
|
| 450 |
+
Jack Kemp <metaknightdrake-git@yahoo.co.uk>
|
| 451 |
+
Kshitij Saraogi <KshitijSaraogi@gmail.com>
|
| 452 |
+
Thomas Baruchel <baruchel@gmx.com>
|
| 453 |
+
Nicolás Guarín-Zapata <nicoguarin@gmail.com>
|
| 454 |
+
Jens Jørgen Mortensen <jj@smoerhul.dk>
|
| 455 |
+
Sampad Kumar Saha <sampadsaha5@gmail.com>
|
| 456 |
+
Eva Charlotte Mayer <eva-charlotte.mayer@posteo.de>
|
| 457 |
+
Laura Domine <temigo@gmx.com>
|
| 458 |
+
Justin Blythe <jblythe29@gmail.com>
|
| 459 |
+
Meghana Madhyastha <meghana.madhyastha@gmail.com>
|
| 460 |
+
Tanu Hari Dixit <tokencolour@gmail.com>
|
| 461 |
+
Shekhar Prasad Rajak <shekharrajak@live.com>
|
| 462 |
+
Aqnouch Mohammed <aqnouch.mohammed@gmail.com>
|
| 463 |
+
Arafat Dad Khan <arafat.da.khan@gmail.com>
|
| 464 |
+
Boris Atamanovskiy <shaomoron@gmail.com>
|
| 465 |
+
Sam Tygier <sam.tygier@hep.manchester.ac.uk>
|
| 466 |
+
Jai Luthra <me@jailuthra.in>
|
| 467 |
+
Guo Xingjian <Seeker1995@gmail.com>
|
| 468 |
+
Sandeep Veethu <sandeep.veethu@gmail.com>
|
| 469 |
+
Archit Verma <architv07@gmail.com>
|
| 470 |
+
Shubham Tibra <shubh.tibra@gmail.com>
|
| 471 |
+
Ashutosh Saboo <ashutosh.saboo96@gmail.com>
|
| 472 |
+
Michael S. Hansen <michael.hansen@nih.gov>
|
| 473 |
+
Anish Shah <shah.anish07@gmail.com>
|
| 474 |
+
Guillaume Jacquenot <guillaume.jacquenot@gmail.com>
|
| 475 |
+
Bhautik Mavani <mavanibhautik@gmail.com>
|
| 476 |
+
Michał Radwański <enedil.isildur@gmail.com>
|
| 477 |
+
Jerry Li <jerry@jerryli.ca>
|
| 478 |
+
Pablo Zubieta <pabloferz@yahoo.com.mx>
|
| 479 |
+
Shivam Agarwal <knowthyself2503@gmail.com>
|
| 480 |
+
Chaitanya Sai Alaparthi <achaitanyasai@gmail.com>
|
| 481 |
+
Arihant Parsoya <parsoyaarihant@gmail.com>
|
| 482 |
+
Ruslan Pisarev <rpisarev@cloudlinux.com>
|
| 483 |
+
Akash Trehan <akash.trehan123@gmail.com>
|
| 484 |
+
Nishant Nikhil <nishantiam@gmail.com>
|
| 485 |
+
Vladimir Poluhsin <vovapolu@gmail.com>
|
| 486 |
+
Akshay Nagar <awesomeay13@yahoo.com>
|
| 487 |
+
James Brandon Milam <jmilam343@gmail.com>
|
| 488 |
+
Abhinav Agarwal <abhinavagarwal1996@gmail.com>
|
| 489 |
+
Rishabh Daal <rishabhdaal@gmail.com>
|
| 490 |
+
Sanya Khurana <sanya@monica.in>
|
| 491 |
+
Aman Deep <amandeep1024@gmail.com>
|
| 492 |
+
Aravind Reddy <aravindreddy255@gmail.com>
|
| 493 |
+
Abhishek Verma <iamvermaabhishek@gmail.com>
|
| 494 |
+
Matthew Parnell <matt@parnmatt.co.uk>
|
| 495 |
+
Thomas Hickman <Thomas.Hickman42@gmail.com>
|
| 496 |
+
Akshay Siramdas <akshaysiramdas@gmail.com>
|
| 497 |
+
YiDing Jiang <yidinggjiangg@gmail.com>
|
| 498 |
+
Jatin Yadav <jatinyadav25@gmail.com>
|
| 499 |
+
Matthew Thomas <mnmt@users.noreply.github.com>
|
| 500 |
+
Rehas Sachdeva <aquannie@gmail.com>
|
| 501 |
+
Michael Mueller <michaeldmueller7@gmail.com>
|
| 502 |
+
Srajan Garg <srajan.garg@gmail.com>
|
| 503 |
+
Prabhjot Singh <prabhjot.nith@gmail.com>
|
| 504 |
+
Haruki Moriguchi <harukimoriguchi@gmail.com>
|
| 505 |
+
Tom Gijselinck <tomgijselinck@gmail.com>
|
| 506 |
+
Nitin Chaudhary <nitinmax1000@gmail.com>
|
| 507 |
+
Alex Argunov <sajkoooo@gmail.com>
|
| 508 |
+
Nathan Musoke <nathan.musoke@gmail.com>
|
| 509 |
+
Abhishek Garg <abhishekgarg119@gmail.com>
|
| 510 |
+
Dana Jacobsen <dana@acm.org>
|
| 511 |
+
Vasiliy Dommes <vasdommes@gmail.com>
|
| 512 |
+
Phillip Berndt <phillip.berndt@googlemail.com>
|
| 513 |
+
Haimo Zhang <zh.hammer.dev@gmail.com>
|
| 514 |
+
Anthony Scopatz <scopatz@gmail.com>
|
| 515 |
+
bluebrook <perl4logic@gmail.com>
|
| 516 |
+
Leonid Kovalev <leonidvkovalev@gmail.com>
|
| 517 |
+
Josh Burkart <jburkart@gmail.com>
|
| 518 |
+
Dimitra Konomi <t8130064@dias.aueb.gr>
|
| 519 |
+
Christina Zografou <t8130048@dias.aueb.gr>
|
| 520 |
+
Fiach Antaw <fiach.antaw+github@gmail.com>
|
| 521 |
+
Langston Barrett <langston.barrett@gmail.com>
|
| 522 |
+
Krit Karan <kritkaran.b13@iiits.in>
|
| 523 |
+
G. D. McBain <gdmcbain@protonmail.com>
|
| 524 |
+
Prempal Singh <prempal.42@gmail.com>
|
| 525 |
+
Gabriel Orisaka <orisaka@gmail.com>
|
| 526 |
+
Matthias Bussonnier <bussonniermatthias@gmail.com>
|
| 527 |
+
rahuldan <rahul02013@gmail.com>
|
| 528 |
+
Colin Marquardt <github@marquardt-home.de>
|
| 529 |
+
Andrew Taber <andrew.e.taber@gmail.com>
|
| 530 |
+
Yash Reddy <write2yashreddy@gmail.com>
|
| 531 |
+
Peter Stangl <peter.stangl@ph.tum.de>
|
| 532 |
+
elvis-sik <e.sikora@grad.ufsc.br>
|
| 533 |
+
Nikos Karagiannakis <nikoskaragiannakis@gmail.com>
|
| 534 |
+
Jainul Vaghasia <jainulvaghasia@gmail.com>
|
| 535 |
+
Dennis Meckel <meckel@datenschuppen.de>
|
| 536 |
+
Harshil Meena <harshil.7535@gmail.com>
|
| 537 |
+
Micky <mickydroch@gmail.com>
|
| 538 |
+
Nick Curtis <nicholas.curtis@uconn.edu>
|
| 539 |
+
Michele Zaffalon <michele.zaffalon@gmail.com>
|
| 540 |
+
Martha Giannoudovardi <maapxa@gmail.com>
|
| 541 |
+
Devang Kulshreshtha <devang.kulshreshtha.cse14@itbhu.ac.in>
|
| 542 |
+
Steph Papanik <spapanik21@gmail.com>
|
| 543 |
+
Mohammad Sadeq Dousti <msdousti@gmail.com>
|
| 544 |
+
Arif Ahmed <arif.ahmed.5.10.1995@gmail.com>
|
| 545 |
+
Abdullah Javed Nesar <abduljaved1994@gmail.com>
|
| 546 |
+
Lakshya Agrawal <zeeshan.lakshya@gmail.com>
|
| 547 |
+
shruti <shrutishrm512@gmail.com>
|
| 548 |
+
Rohit Rango <rohit.rango@gmail.com>
|
| 549 |
+
Hong Xu <hong@topbug.net>
|
| 550 |
+
Ivan Petuhov <ivan@ostrovok.ru>
|
| 551 |
+
Alsheh <alsheh@rpi.edu>
|
| 552 |
+
Marcel Stimberg <marcel.stimberg@ens.fr>
|
| 553 |
+
Alexey Pakhocmhik <cool.Bakov@yandex.ru>
|
| 554 |
+
Tommy Olofsson <tommy.olofsson.90@gmail.com>
|
| 555 |
+
Zulfikar <zulfikar97@gmail.com>
|
| 556 |
+
Blair Azzopardi <blairuk@gmail.com>
|
| 557 |
+
Danny Hermes <daniel.j.hermes@gmail.com>
|
| 558 |
+
Sergey Pestov <pestov-sa@yandex.ru>
|
| 559 |
+
Mohit Chandra <mohit.chandra@research.iiit.ac.in>
|
| 560 |
+
Karthik Chintapalli <karthik.chintapalli@students.iiit.ac.in>
|
| 561 |
+
Marcin Briański <marcin.brianski@student.uj.edu.pl>
|
| 562 |
+
andreo <andrey.torba@gmail.com>
|
| 563 |
+
Flamy Owl <flamyowl@protonmail.ch>
|
| 564 |
+
Yicong Guo <guoyicong100@gmail.com>
|
| 565 |
+
Varun Garg <varun.garg03@gmail.com>
|
| 566 |
+
Rishabh Madan <rishabhmadan96@gmail.com>
|
| 567 |
+
Aditya Kapoor <aditya.kapoor.apm12@itbhu.ac.in>
|
| 568 |
+
Karan Sharma <karan1276@gmail.com>
|
| 569 |
+
Vedant Rathore <vedantr1998@gmail.com>
|
| 570 |
+
Johan Blåbäck <johan_bluecreek@riseup.net>
|
| 571 |
+
Pranjal Tale <pranjaltale16@gmail.com>
|
| 572 |
+
Jason Tokayer <jason.tokayer@gmail.com>
|
| 573 |
+
Raghav Jajodia <jajodia.raghav@gmail.com>
|
| 574 |
+
Rajat Thakur <rajatthakur1997@gmail.com>
|
| 575 |
+
Dhruv Bhanushali <dhruv_b@live.com>
|
| 576 |
+
Anjul Kumar Tyagi <anjul.ten@gmail.com>
|
| 577 |
+
Barun Parruck <barun.parruck@gmail.com>
|
| 578 |
+
Bao Chau <chauquocbao0907@gmail.com>
|
| 579 |
+
Tanay Agrawal <tanay_agrawal@hotmail.com>
|
| 580 |
+
Ranjith Kumar <ranjith.dakshana2015@gmail.com>
|
| 581 |
+
Shikhar Makhija <shikharmakhija2@gmail.com>
|
| 582 |
+
Yathartha Joshi <yathartha32@gmail.com>
|
| 583 |
+
Valeriia Gladkova <valeriia.gladkova@gmail.com>
|
| 584 |
+
Sagar Bharadwaj <sagarbharadwaj50@gmail.com>
|
| 585 |
+
Daniel Mahler <dmahler@gmail.com>
|
| 586 |
+
Ka Yi <chua.kayi@yahoo.com.sg>
|
| 587 |
+
Rishat Iskhakov <iskhakov@frtk.ru>
|
| 588 |
+
Szymon Mieszczak <szymon.mieszczak@gmail.com>
|
| 589 |
+
Sachin Agarwal <sachinagarwal0499@gmail.com>
|
| 590 |
+
Priyank Patel <pspbot7@gmail.com>
|
| 591 |
+
Satya Prakash Dwibedi <akash581050@gmail.com>
|
| 592 |
+
tools4origins <tools4origins@gmail.com>
|
| 593 |
+
Nico Schlömer <nico.schloemer@gmail.com>
|
| 594 |
+
Fermi Paradox <FermiParadox@users.noreply.github.com>
|
| 595 |
+
Ekansh Purohit <purohit.e15@gmail.com>
|
| 596 |
+
Vedarth Sharma <vedarth.sharma@gmail.com>
|
| 597 |
+
Peeyush Kushwaha <peeyush.p97@gmail.com>
|
| 598 |
+
Jayjayyy <vfhsln8s3l4b87t4c3@byom.de>
|
| 599 |
+
Christopher J. Wright <cjwright4242gh@gmail.com>
|
| 600 |
+
Jakub Wilk <jwilk@jwilk.net>
|
| 601 |
+
Mauro Garavello <mauro.garavello@unimib.it>
|
| 602 |
+
Chris Tefer <ctefer@gmail.com>
|
| 603 |
+
Shikhar Jaiswal <jaiswalshikhar87@gmail.com>
|
| 604 |
+
Chiu-Hsiang Hsu <wdv4758h@gmail.com>
|
| 605 |
+
Carlos Cordoba <ccordoba12@gmail.com>
|
| 606 |
+
Fabian Ball <fabian.ball@kit.edu>
|
| 607 |
+
Yerniyaz <yerniyaz.nurgabylov@nu.edu.kz>
|
| 608 |
+
Christiano Anderson <canderson@riseup.net>
|
| 609 |
+
Robin Neatherway <robin.neatherway@gmail.com>
|
| 610 |
+
Thomas Hunt <thomashunt13@gmail.com>
|
| 611 |
+
Theodore Han <theodorehan@hotmail.com>
|
| 612 |
+
Duc-Minh Phan <alephvn@gmail.com>
|
| 613 |
+
Lejla Metohajrova <l.metohajrova@gmail.com>
|
| 614 |
+
Samyak Jain <samyak.jain2016a@vitstudent.ac.in>
|
| 615 |
+
Aditya Rohan <riyuzakiiitk@gmail.com>
|
| 616 |
+
Vincent Delecroix <vincent.delecroix@labri.fr>
|
| 617 |
+
Michael Sparapany <msparapa@purdue.edu>
|
| 618 |
+
Harsh Jain <harshjniitr@gmail.com>
|
| 619 |
+
Nathan Goldbaum <ngoldbau@illinois.edu>
|
| 620 |
+
latot <felipematas@yahoo.com>
|
| 621 |
+
Kenneth Lyons <ixjlyons@gmail.com>
|
| 622 |
+
Stan Schymanski <stan.schymanski@env.ethz.ch>
|
| 623 |
+
David Daly <david.daly12@kzoo.edu>
|
| 624 |
+
Ayush Shridhar <ayush.shridhar1999@gmail.com>
|
| 625 |
+
Javed Nissar <javednissar@gmail.com>
|
| 626 |
+
Jiri Kuncar <jiri.kuncar@gmail.com>
|
| 627 |
+
vedantc98 <vedantc98@gmail.com>
|
| 628 |
+
Rupesh Harode <rupeshharode@gmail.com>
|
| 629 |
+
Rob Zinkov <rob@zinkov.com>
|
| 630 |
+
James Harrop <ebc121@gmail.com>
|
| 631 |
+
James Taylor <user234683@tutanota.com>
|
| 632 |
+
Ishan Joshi <ishanaj98@gmail.com>
|
| 633 |
+
Marco Mancini <marco.mancini@obspm.fr>
|
| 634 |
+
Boris Ettinger <ettinger.boris@gmail.com>
|
| 635 |
+
Micah Fitch <micahscopes@gmail.com>
|
| 636 |
+
Daniel Wennberg <daniel.wennberg@gmail.com>
|
| 637 |
+
ylemkimon <ylemkimon@naver.com>
|
| 638 |
+
Akash Vaish <akash.9712@gmail.com>
|
| 639 |
+
Peter Enenkel <peter.enenkel+git@gmail.com>
|
| 640 |
+
Waldir Pimenta <waldyrious@gmail.com>
|
| 641 |
+
Jithin D. George <jithindgeorge93@gmail.com>
|
| 642 |
+
Lev Chelyadinov <leva181777@gmail.com>
|
| 643 |
+
Lucas Wiman <lucas.wiman@gmail.com>
|
| 644 |
+
Rhea Parekh <rheaparekh12@gmail.com>
|
| 645 |
+
James Cotton <peabody124@gmail.com>
|
| 646 |
+
Robert Pollak <robert.pollak@posteo.net>
|
| 647 |
+
anca-mc <anca-mc@users.noreply.github.com>
|
| 648 |
+
Sourav Ghosh <souravghosh2197@gmail.com>
|
| 649 |
+
Jonathan Allan <jjallan@users.noreply.github.com>
|
| 650 |
+
Nikhil Pappu <nkhlpappu@gmail.com>
|
| 651 |
+
Ethan Ward <etkewa@gmail.com>
|
| 652 |
+
Cezary Marczak <zeddq1@gmail.com>
|
| 653 |
+
dps7ud <dps7ud@virginia.edu>
|
| 654 |
+
Nilabja Bhattacharya <nilabja10201992@gmail.com>
|
| 655 |
+
Itay4 <31018228+Itay4@users.noreply.github.com>
|
| 656 |
+
Poom Chiarawongse <eight1911@gmail.com>
|
| 657 |
+
Yang Yang <wdscxsj@gmail.com>
|
| 658 |
+
Cavendish McKay <cmckay@tachycline.com>
|
| 659 |
+
Bradley Gannon <bradley.m.gannon@gmail.com>
|
| 660 |
+
B McG <bmcg0890@gmail.com>
|
| 661 |
+
Rob Drynkin <rob.drynkin@gmail.com>
|
| 662 |
+
Seth Ebner <murgrehk@gmail.com>
|
| 663 |
+
Akash Kundu <sk.sayakkundu1997@gmail.com>
|
| 664 |
+
Mark Jeromin <mark.jeromin@sysfrog.net>
|
| 665 |
+
Roberto Díaz Pérez <r.r.1994a@gmail.com>
|
| 666 |
+
Gleb Siroki <g.shiroki@gmail.com>
|
| 667 |
+
Segev Finer <segev208@gmail.com>
|
| 668 |
+
Alex Lubbock <code@alexlubbock.com>
|
| 669 |
+
Ayodeji Ige <ayodeji18@outlook.com>
|
| 670 |
+
Matthew Wardrop <matthew.wardrop@airbnb.com>
|
| 671 |
+
Hugo van Kemenade <hugovk@users.noreply.github.com>
|
| 672 |
+
Austin Palmer <ap4000@nyu.edu>
|
| 673 |
+
der-blaue-elefant <github@kklein.de>
|
| 674 |
+
Filip Gokstorp <filip@gokstorp.se>
|
| 675 |
+
Yuki Matsuda <yuki.matsuda.w@gmail.com>
|
| 676 |
+
Aaron Miller <acmiller273@gmail.com>
|
| 677 |
+
Salil Vishnu Kapur <salilvishnukapur@gmail.com>
|
| 678 |
+
Atharva Khare <khareatharva@gmail.com>
|
| 679 |
+
Shubham Maheshwari <rmaheshwari05@gmail.com>
|
| 680 |
+
Pavel Tkachenko <paveltkachenko@email.com>
|
| 681 |
+
Ashish Kumar Gaurav <ashishkg0022@gmail.com>
|
| 682 |
+
Rajeev Singh <rajs2010@gmail.com>
|
| 683 |
+
Keno Goertz <keno@goertz-berlin.com>
|
| 684 |
+
Lucas Gallindo <lgallindo@gmail.com>
|
| 685 |
+
Himanshu <hs80941@gmail.com>
|
| 686 |
+
David Menéndez Hurtado <david.menendez.hurtado@scilifelab.se>
|
| 687 |
+
Amit Manchanda <amitdelhi1995@gmail.com>
|
| 688 |
+
Rohit Jain <rohitjain3241@gmail.com>
|
| 689 |
+
Jonathan A. Gross <jarthurgross@gmail.com>
|
| 690 |
+
Unknown <kunda@scribus.net>
|
| 691 |
+
Sayan Goswami <Sayan98@users.noreply.github.com>
|
| 692 |
+
Subhash Saurabh <subhashsaurabh419@gmail.com>
|
| 693 |
+
Rastislav Rabatin <rastislav.rabatin@gmail.com>
|
| 694 |
+
Vishal <vishalg2235@gmail.com>
|
| 695 |
+
Jeremey Gluck <jeremygluck@yahoo.com>
|
| 696 |
+
Akshat Maheshwari <akshat14714@gmail.com>
|
| 697 |
+
symbolique <symbolique@users.noreply.github.com>
|
| 698 |
+
Saloni Jain <tosalonijain@gmail.com>
|
| 699 |
+
Arighna Chakrabarty <arighna.chakrabarty100@gmail.com>
|
| 700 |
+
Abhigyan Khaund <mail@abhigyan.xyz>
|
| 701 |
+
Jashanpreet Singh <jashansingh.4398@gmail.com>
|
| 702 |
+
Saurabh Agarwal <shourabh.agarwal@gmail.com>
|
| 703 |
+
luzpaz <luzpaz@users.noreply.github.com>
|
| 704 |
+
P. Sai Prasanth <psai.prasanth.min16@itbhu.ac.in>
|
| 705 |
+
Nirmal Sarswat <nirmalsarswat400@gmail.com>
|
| 706 |
+
Cristian Di Pietrantonio <cristiandipietrantonio@gmail.com>
|
| 707 |
+
Ravi charan <ravicharan.vsp@gmail.com>
|
| 708 |
+
Nityananda Gohain <nityanandagohain@gmail.com>
|
| 709 |
+
Cédric Travelletti <cedrictravelletti@gmail.com>
|
| 710 |
+
Nicholas Bollweg <nick.bollweg@gmail.com>
|
| 711 |
+
Himanshu Ladia <hladia199811@gmail.com>
|
| 712 |
+
Adwait Baokar <adwaitbaokar18@gmail.com>
|
| 713 |
+
Mihail Tarigradschi <m.tarigradschi@gmail.com>
|
| 714 |
+
Saketh <alurusaisaketh@gmail.com>
|
| 715 |
+
rushyam <rushyamsonu@gmail.com>
|
| 716 |
+
sfoo <sfoohei@gmail.com>
|
| 717 |
+
Rahil Hastu <rahilhastu@gmail.com>
|
| 718 |
+
Zach Raines <raineszm@gmail.com>
|
| 719 |
+
Sidhant Nagpal <sidhantnagpal97@gmail.com>
|
| 720 |
+
Gagandeep Singh <singh.23@iitj.ac.in>
|
| 721 |
+
Rishav Chakraborty <annonymousxyz@outlook.com>
|
| 722 |
+
Malkhan Singh <malkhansinghrathaur@gmail.com>
|
| 723 |
+
Joaquim Monserrat <qmonserrat@mailoo.org>
|
| 724 |
+
Mayank Singh <mayank.singh081997@gmail.com>
|
| 725 |
+
Rémy Léone <rleone@online.net>
|
| 726 |
+
Maxence Mayrand <35958639+maxencemayrand@users.noreply.github.com>
|
| 727 |
+
Nikoleta Glynatsi <GlynatsiNE@cardiff.ac.uk>
|
| 728 |
+
helo9 <helo9@users.noreply.github.com>
|
| 729 |
+
Ken Wakita <wakita@is.titech.ac.jp>
|
| 730 |
+
Carl Sandrock <carl.sandrock@up.ac.za>
|
| 731 |
+
Fredrik Eriksson <freeriks@student.chalmers.se>
|
| 732 |
+
Ian Swire <oversizedpenguin@gmail.com>
|
| 733 |
+
Bulat <daianovich@mail.ru>
|
| 734 |
+
Ehren Metcalfe <ehren.m@gmail.com>
|
| 735 |
+
Dmitry Savransky <dsavransky@gmail.com>
|
| 736 |
+
Kiyohito Yamazaki <kyamaz@openql.org>
|
| 737 |
+
Caley Finn <caleyreuben@gmail.com>
|
| 738 |
+
Zhi-Qiang Zhou <zzq_890709@hotmail.com>
|
| 739 |
+
Alexander Pozdneev <pozdneev@users.noreply.github.com>
|
| 740 |
+
Wes Turner <50891+westurner@users.noreply.github.com>
|
| 741 |
+
JMSS-Unknown <31131631+JMSS-Unknown@users.noreply.github.com>
|
| 742 |
+
Arshdeep Singh <singh.arshdeep1999@gmail.com>
|
| 743 |
+
cym1 <16437732+cym1@users.noreply.github.com>
|
| 744 |
+
Stewart Wadsworth <stewart.wadsworth@gmail.com>
|
| 745 |
+
Jared Lumpe <mjlumpe@gmail.com>
|
| 746 |
+
Avi Shrivastava <shrivastavaavi123@gmail.com>
|
| 747 |
+
ramvenkat98 <ramvenkat98@gmail.com>
|
| 748 |
+
Bilal Ahmed <b.ahmed0918@gmail.com>
|
| 749 |
+
Dimas Abreu Archanjo Dutra <dimasad@ufmg.br>
|
| 750 |
+
Yatna Verma <yatnavermaa@gmail.com>
|
| 751 |
+
S.Y. Lee <sylee957@gmail.com>
|
| 752 |
+
Miro Hrončok <miro@hroncok.cz>
|
| 753 |
+
Sudarshan Kamath <sudarshan.kamath97@gmail.com>
|
| 754 |
+
Ayushman Koul <ayushmankoul4570@gmail.com>
|
| 755 |
+
Robert Dougherty-Bliss <robert.w.bliss@gmail.com>
|
| 756 |
+
Andrey Grozin <A.G.Grozin@inp.nsk.su>
|
| 757 |
+
Bavish Kulur <bavishkulur@gmail.com>
|
| 758 |
+
Arun Singh <arunsin997@gmail.com>
|
| 759 |
+
sirnicolaf <43586954+sirnicolaf@users.noreply.github.com>
|
| 760 |
+
Zachariah Etienne <zachetie@gmail.com>
|
| 761 |
+
Prayush Dawda <35144226+iamprayush@users.noreply.github.com>
|
| 762 |
+
2torus <boris.ettinger@gmail.com>
|
| 763 |
+
Faisal Riyaz <faisalriyaz011@gmail.com>
|
| 764 |
+
Martin Roelfs <u0114255@kuleuven.be>
|
| 765 |
+
SirJohnFranklin <sirjfu@googlemail.com>
|
| 766 |
+
Anthony Sottile <asottile@umich.edu>
|
| 767 |
+
ViacheslavP <public.viacheslav@gmail.com>
|
| 768 |
+
Safiya03 <safiyanesar@gmail.com>
|
| 769 |
+
Alexander Dunlap <alexander.dunlap@gmail.com>
|
| 770 |
+
Rohit Sharma <31184621+rohitx007@users.noreply.github.com>
|
| 771 |
+
Jonathan Warner <warnerjon12@gmail.com>
|
| 772 |
+
Mohit Balwani <mohitbalwani.ict17@gmail.com>
|
| 773 |
+
Marduk Bolaños <mardukbp@mac.com>
|
| 774 |
+
amsuhane <ayushsuhane99@iitkgp.ac.in>
|
| 775 |
+
Matthias Geier <Matthias.Geier@gmail.com>
|
| 776 |
+
klaasvanaarsen <44929042+klaasvanaarsen@users.noreply.github.com>
|
| 777 |
+
Shubham Kumar Jha <skjha832@gmail.com>
|
| 778 |
+
rationa-kunal <kunalgk1999@gmail.com>
|
| 779 |
+
Animesh Sinha <animeshsinha1309@gmail.com>
|
| 780 |
+
Gaurang Tandon <1gaurangtandon@gmail.com>
|
| 781 |
+
Matthew Craven <clyring@users.noreply.github.com>
|
| 782 |
+
Daniel Ingram <ingramds@appstate.edu>
|
| 783 |
+
Jogi Miglani <jmig5776@gmail.com>
|
| 784 |
+
Takumasa Nakamura <n.takumasa@gmail.com>
|
| 785 |
+
Ritu Raj Singh <RituRajSingh878@gmail.com>
|
| 786 |
+
Rajiv Ranjan Singh <rajivperfect007@gmail.com>
|
| 787 |
+
Vera Lozhkina <veralozhkina@gmail.com>
|
| 788 |
+
adhoc-king <46354827+adhoc-king@users.noreply.github.com>
|
| 789 |
+
Mikel Rouco <mikel.mrm@gmail.com>
|
| 790 |
+
Oscar Gustafsson <oscar.gustafsson@gmail.com>
|
| 791 |
+
damianos <damianos@semmle.com>
|
| 792 |
+
Supreet Agrawal <supreet11agrawal@gmail.com>
|
| 793 |
+
shiksha11 <shiksharawat01@gmail.com>
|
| 794 |
+
Martin Ueding <dev@martin-ueding.de>
|
| 795 |
+
sharma-kunal <kunalsharma6914@gmail.com>
|
| 796 |
+
Divyanshu Thakur <divyanshu@iiitmanipur.ac.in>
|
| 797 |
+
Susumu Ishizuka <susumu.ishizuka@kii.com>
|
| 798 |
+
Samnan Rahee <namanush.rsr.16@gmail.com>
|
| 799 |
+
Fredrik Andersson <fredrik.andersson@fcc.chalmers.se>
|
| 800 |
+
Bhavya Srivastava <bhavya17037@iiitd.ac.in>
|
| 801 |
+
Alpesh Jamgade <alpeshjamgade21@gmail.com>
|
| 802 |
+
Shubham Abhang <shubhamabhang77@gmail.com>
|
| 803 |
+
Vishesh Mangla <manglavishesh64@gmail.com>
|
| 804 |
+
Nicko van Someren <nicko@nicko.org>
|
| 805 |
+
dandiez <47832466+dandiez@users.noreply.github.com>
|
| 806 |
+
Frédéric Chapoton <fchapoton2@gmail.com>
|
| 807 |
+
jhanwar <f2015463@pilani.bits-pilani.ac.in>
|
| 808 |
+
Noumbissi valere Gille Geovan <noumbissivalere@gmail.com>
|
| 809 |
+
Salmista-94 <alejandrogroso@hotmail.com>
|
| 810 |
+
Shivani Kohli <shivanikohli.09@gmail.com>
|
| 811 |
+
Parker Berry <parkereberry@gmail.com>
|
| 812 |
+
Pragyan Mehrotra <pragyan18168@iiitd.ac.in>
|
| 813 |
+
Nabanita Dash <dashnabanita@gmail.com>
|
| 814 |
+
Gaetano Guerriero <x.guerriero@tin.it>
|
| 815 |
+
Ankit Raj Pandey <pandeyan@grinnell.edu>
|
| 816 |
+
Ritesh Kumar <ritesh99rakesh@gmail.com>
|
| 817 |
+
kangzhiq <709563092@qq.com>
|
| 818 |
+
Jun Lin <junlin0604@gmail.com>
|
| 819 |
+
Petr Kungurtsev <corwinat@gmail.com>
|
| 820 |
+
Anway De <anway1756@gmail.com>
|
| 821 |
+
znxftw <vishnu2101@gmail.com>
|
| 822 |
+
Denis Ivanenko <ivanenko@ucu.edu.ua>
|
| 823 |
+
Orestis Vaggelis <orestisvaggelis@mail.com>
|
| 824 |
+
Nikhil Maan <nikhilmaan22@gmail.com>
|
| 825 |
+
Abhinav Anand <abhinav.anand2807@gmail.com>
|
| 826 |
+
Qingsha Shi <googol.sqs@gmail.com>
|
| 827 |
+
Juan Barbosa <js.barbosa10@uniandes.edu.co>
|
| 828 |
+
Prionti Nasir <pdn3628@rit.edu>
|
| 829 |
+
Bharat Raghunathan <bharatraghunthan9767@gmail.com>
|
| 830 |
+
arooshiverma <av22@iitbbs.ac.in>
|
| 831 |
+
Christoph Gohle <ctg@mpq.mpg.de>
|
| 832 |
+
Charalampos Tsiagkalis <ctsiagkalis@uth.gr>
|
| 833 |
+
Daniel Sears <highpost@users.noreply.github.com>
|
| 834 |
+
Megan Ly <megan.ly@learnosity.com>
|
| 835 |
+
Sean P. Cornelius <spcornelius@gmail.com>
|
| 836 |
+
Erik R. Gomez <gomez@kth.se>
|
| 837 |
+
Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
|
| 838 |
+
Henry Metlov <genrih.metlov@gmail.com>
|
| 839 |
+
pekochun <hamburg_hamburger2000@yahoo.co.jp>
|
| 840 |
+
Bendik Samseth <b.samseth@gmail.com>
|
| 841 |
+
Vighnesh Shenoy <vighneshq@gmail.com>
|
| 842 |
+
Versus Void <versusvoid@gmail.com>
|
| 843 |
+
Denys Rybalka <rybalka.denis@gmail.com>
|
| 844 |
+
Mark Dickinson <dickinsm@gmail.com>
|
| 845 |
+
Rimi <rimibis@umich.edu>
|
| 846 |
+
rimibis <33387803+rimibis@users.noreply.github.com>
|
| 847 |
+
Steven Lee <stevenlee123@protonmail.com>
|
| 848 |
+
Gilles Schintgen <gschintgen@hambier.lu>
|
| 849 |
+
Abhi58 <abhijithbharadwaj58@gmail.com>
|
| 850 |
+
Tomasz Pytel <tompytel@gmail.com>
|
| 851 |
+
Aadit Kamat <aadit.k12@gmail.com>
|
| 852 |
+
Samesh <samesh.lakhotia@gmail.com>
|
| 853 |
+
Velibor Zeli <velibor@mech.kth.se>
|
| 854 |
+
Gabriel Bernardino <gabriel.bernardino@upf.edu>
|
| 855 |
+
Joseph Redfern <joseph@redfern.me>
|
| 856 |
+
Evelyn King <evelyn.cameron.king@gmail.com>
|
| 857 |
+
Miguel Marco <mmarco@unizar.es>
|
| 858 |
+
David Hagen <david@drhagen.com>
|
| 859 |
+
Hannah Kari <hannah.kari@marquette.edu>
|
| 860 |
+
Soniya Nayak <soniyanayak51@gmail.com>
|
| 861 |
+
Harsh Agarwal <hagarwal9200@gmail.com>
|
| 862 |
+
Enric Florit <efz1005@gmail.com>
|
| 863 |
+
Yogesh Mishra <ymishra013@gmail.com>
|
| 864 |
+
Denis Rykov <rykovd@gmail.com>
|
| 865 |
+
Ivan Tkachenko <me@ratijas.tk>
|
| 866 |
+
Kenneth Emeka Odoh <kenneth.odoh@gmail.com>
|
| 867 |
+
Stephan Seitz <stephan.seitz@fau.de>
|
| 868 |
+
Yeshwanth N <yeshsurya@gmail.com>
|
| 869 |
+
Oscar Gerardo Lazo Arjona <oscar.lazoarjona@physics.ox.ac.uk>
|
| 870 |
+
Srinivasa Arun Yeragudipati <ysarun1999@gmail.com>
|
| 871 |
+
Kirtan Mali <kirtanmali555@gmail.com>
|
| 872 |
+
TitanSnow <sweeto@live.cn>
|
| 873 |
+
Pengning Chao <8857165+PengningChao@users.noreply.github.com>
|
| 874 |
+
Louis Abraham <louis.abraham@yahoo.fr>
|
| 875 |
+
Morten Olsen Lysgaard <morten@lysgaard.no>
|
| 876 |
+
Akash Nagaraj (akasnaga) <akasnaga@cisco.com>
|
| 877 |
+
Akash Nagaraj <grassknoted@gmail.com>
|
| 878 |
+
Lauren Glattly <laurenglattly@gmail.com>
|
| 879 |
+
Hou-Rui <houruinus@gmail.com>
|
| 880 |
+
George Korepanov <gkorepanov.gk@gmail.com>
|
| 881 |
+
dranknight09 <cbhaavan@gmail.com>
|
| 882 |
+
aditisingh2362 <aditisingh2362@gmail.com>
|
| 883 |
+
Gina <Dr-G@users.noreply.github.com>
|
| 884 |
+
gregmedlock <gmedlo@gmail.com>
|
| 885 |
+
Georgios Giapitzakis Tzintanos <giorgosgiapis@mail.com>
|
| 886 |
+
Eric Wieser <wieser.eric@gmail.com>
|
| 887 |
+
Bradley Dowling <34559056+btdow@users.noreply.github.com>
|
| 888 |
+
Maria Marginean <33810762+mmargin@users.noreply.github.com>
|
| 889 |
+
Akash Agrawall <akash.wanted@gmail.com>
|
| 890 |
+
jgulian <josephdgulian@gmail.com>
|
| 891 |
+
Sourav Goyal <souravgl0@gmail.com>
|
| 892 |
+
Zlatan Vasović <zlatanvasovic@gmail.com>
|
| 893 |
+
Alex Meiburg <timeroot.alex@gmail.com>
|
| 894 |
+
Smit Lunagariya <smitlunagariya.mat18@itbhu.ac.in>
|
| 895 |
+
Naman Gera <namangera15@gmail.com>
|
| 896 |
+
Julien Palard <julien@palard.fr>
|
| 897 |
+
Dhruv Mendiratta <dhruvmendiratta6@gmail.com>
|
| 898 |
+
erdOne <36414270+erdOne@users.noreply.github.com>
|
| 899 |
+
risubaba <risubhjain1010@gmail.com>
|
| 900 |
+
abhinav28071999 <41710346+abhinav28071999@users.noreply.github.com>
|
| 901 |
+
Jisoo Song <jeesoo9595@snu.ac.kr>
|
| 902 |
+
Jaime R <38530589+Jaime02@users.noreply.github.com>
|
| 903 |
+
Vikrant Malik <vikrantmalik051@gmail.com>
|
| 904 |
+
Hardik Saini <43683678+Guardianofgotham@users.noreply.github.com>
|
| 905 |
+
Abhishek <uchiha@pop-os.localdomain>
|
| 906 |
+
Johannes Hartung <joha2@gmx.net>
|
| 907 |
+
Milan Jolly <milan.cs16@iitp.ac.in>
|
| 908 |
+
faizan2700 <syedfaizan824@gmail.com>
|
| 909 |
+
mohit <39158356+mohitacecode@users.noreply.github.com>
|
| 910 |
+
Mohit Gupta <mohitgupta@gmail.com>
|
| 911 |
+
Psycho-Pirate <prakharsaxena.civ18@iitbhu.ac.in>
|
| 912 |
+
Chanakya-Ekbote <ca10@iitbbs.ac.in>
|
| 913 |
+
Rashmi Shehana <rashmi.watagedara@syscolabs.com>
|
| 914 |
+
Jonty16117 <jonty@DESKTOP-J1O6ANP.localdomain>
|
| 915 |
+
Anubhav Gupta <anubhav.gupta.cse19@itbhu.ac.in>
|
| 916 |
+
Michal Grňo <m93a.cz@gmail.com>
|
| 917 |
+
vezeli <37907135+vezeli@users.noreply.github.com>
|
| 918 |
+
Tim Gates <tim.gates@iress.com>
|
| 919 |
+
Sandeep Murthy <smurthy@protonmail.ch>
|
| 920 |
+
Neil <mistersheik@gmail.com>
|
| 921 |
+
V1krant <46847915+V1krant@users.noreply.github.com>
|
| 922 |
+
alejandro <amartinhernan@gmail.com>
|
| 923 |
+
Riyan Dhiman <Riyandhiman14@gmail.com>
|
| 924 |
+
sbt4104 <sthorat661@gmail.com>
|
| 925 |
+
Seth Troisi <sethtroisi@google.com>
|
| 926 |
+
Bhaskar Gupta <guptabhanu1999@gmail.com>
|
| 927 |
+
Smit Gajjar <smitgajjar.gs@gmail.com>
|
| 928 |
+
rbl <rlee@grove.co>
|
| 929 |
+
Ilya Pchelintsev <ilya.pchelintsev@outlook.com>
|
| 930 |
+
Omar Wagih <o.wagih.ow@gmail.com>
|
| 931 |
+
prshnt19 <prashant.rawat216@gmail.com>
|
| 932 |
+
Johan Guzman <jguzm022@ucr.edu>
|
| 933 |
+
Vasileios Kalos <kalosbasileios@gmail.com>
|
| 934 |
+
BasileiosKal <61801875+BasileiosKal@users.noreply.github.com>
|
| 935 |
+
Shubham Thorat <37049710+sbt4104@users.noreply.github.com>
|
| 936 |
+
Arpan Chattopadhyay <f20180319@pilani.bits-pilani.ac.in>
|
| 937 |
+
Ashutosh Hathidara <ashutoshhathidara98@gmail.com>
|
| 938 |
+
Moses Paul R <iammosespaulr@gmail.com>
|
| 939 |
+
Saanidhya vats <saanidhyavats@gmail.com>
|
| 940 |
+
tnzl <you@example.com>
|
| 941 |
+
Vatsal Srivastava <alstav.trivas.sava@gmail.com>
|
| 942 |
+
Jean-Luc Herren <jlh@gmx.ch>
|
| 943 |
+
Dhruv Kothari <dhruvkothari22@gmail.com>
|
| 944 |
+
seadavis <45022599+seadavis@users.noreply.github.com>
|
| 945 |
+
kamimura <kamimura@live.jp>
|
| 946 |
+
slacker404 <pchantza@gmail.com>
|
| 947 |
+
Jaime Resano <gemailpersonal02@gmail.com>
|
| 948 |
+
Ebrahim Byagowi <ebrahim@gnu.org>
|
| 949 |
+
wuyudi <wuyudi119@163.com>
|
| 950 |
+
Akira Kyle <ak@akirakyle.com>
|
| 951 |
+
Calvin Jay Ross <calvinjayross@gmail.com>
|
| 952 |
+
Martin Thoma <info@martin-thoma.de>
|
| 953 |
+
Thomas A Caswell <tcaswell@gmail.com>
|
| 954 |
+
Lagaras Stelios <stel.lag@hotmail.com>
|
| 955 |
+
Jerry James <loganjerry@gmail.com>
|
| 956 |
+
Jan Kruse <janckruse@t-online.de>
|
| 957 |
+
Nathan Taylor <pecan.pine@gmail.com>
|
| 958 |
+
Vaishnav Damani <vaishnavdamani3496@gmail.com>
|
| 959 |
+
Mohit Shah <mohitshah3111999@gmail.com>
|
| 960 |
+
Mathias Louboutin <mathias.louboutin@gmail.com>
|
| 961 |
+
Marijan Smetko <marijansmetko123@gmail.com>
|
| 962 |
+
Dave Witte Morris <Dave.Morris@uleth.ca>
|
| 963 |
+
soumi7 <soumibardhan10@gmail.com>
|
| 964 |
+
Zhongshi <zj495@nyu.edu>
|
| 965 |
+
Wes Galbraith <galbwe92@gmail.com>
|
| 966 |
+
KaustubhDamania <kaustubh.damania@gmail.com>
|
| 967 |
+
w495 <w495@yandex-team.ru>
|
| 968 |
+
Akhil Rajput <akh1lrjput@gmail.com>
|
| 969 |
+
Markus Mohrhard <markus.mohrhard@googlemail.com>
|
| 970 |
+
Benjamin Wolba <mail@benjaminwolba.com>
|
| 971 |
+
彭于斌 <1931127624@qq.com>
|
| 972 |
+
Rudr Tiwari <rudrtiwari@gmail.com>
|
| 973 |
+
Aaryan Dewan <aaryandewan@yahoo.com>
|
| 974 |
+
Benedikt Placke <benedikt.placke@outlook.com>
|
| 975 |
+
Sneha Goddu <s.goddu@wustl.edu>
|
| 976 |
+
goddus <39923708+goddus@users.noreply.github.com>
|
| 977 |
+
Shivang Dubey <shivangdubey8@gmail.com>
|
| 978 |
+
Michael Greminger <michael.greminger@gmail.com>
|
| 979 |
+
Peter Cock <p.j.a.cock@googlemail.com>
|
| 980 |
+
Willem Melching <willem.melching@gmail.com>
|
| 981 |
+
Elias Basler <e.e.basler@protonmail.com>
|
| 982 |
+
Brandon David <brandon.david@zoho.com>
|
| 983 |
+
Abhay_Dhiman <abhaysdhimans@gmail.com>
|
| 984 |
+
Tasha Kim <jae_young_kim@brown.edu>
|
| 985 |
+
Ayush Malik <ayushmalik779@gmail.com>
|
| 986 |
+
Devesh Sawant <devesh47cool@gmail.com>
|
| 987 |
+
Wolfgang Stöcher <wolfgang@stoecher.com>
|
| 988 |
+
Sudeep Sidhu <sudeepmanilsidhu@gmail.com>
|
| 989 |
+
foice <foice.news@gmail.com>
|
| 990 |
+
Ben Payne <ben.is.located@gmail.com>
|
| 991 |
+
Muskan Kumar <31043527+muskanvk@users.noreply.github.com>
|
| 992 |
+
noam simcha finkelstein <noam.finkelstein@protonmail.com>
|
| 993 |
+
Garrett Folbe <gmfolbe@yahoo.com>
|
| 994 |
+
Islam Mansour <is3mansour@gmail.com>
|
| 995 |
+
Sayandip Halder <sayandiph4@gmail.com>
|
| 996 |
+
Shubham Agrawal <shubham.ag6845@gmail.com>
|
| 997 |
+
numbermaniac <5206120+numbermaniac@users.noreply.github.com>
|
| 998 |
+
Sakirul Alam <binarysakir@gmail.com>
|
| 999 |
+
Mohammed Bilal <r.mohammedbilal@gmail.com>
|
| 1000 |
+
Chris du Plessis <christopherjonduplessis@gmail.com>
|
| 1001 |
+
Coder-RG <rgoel1999@gmail.com>
|
| 1002 |
+
Ansh Mishra <anshmishra471@gmail.com>
|
| 1003 |
+
Alex Malins <github@alexmalins.com>
|
| 1004 |
+
Lorenzo Contento <lorenzo.contento@gmail.com>
|
| 1005 |
+
Naveen Sai <naveensaisreenivas@gmail.com>
|
| 1006 |
+
Shital Mule <shitalmule04@gmail.com>
|
| 1007 |
+
Amanda Dsouza <meezamanda@yahoo.com>
|
| 1008 |
+
Nijso Beishuizen <nijso@koolmees.numerically-related.com>
|
| 1009 |
+
Harry Zheng <harry@harryzheng.com>
|
| 1010 |
+
Felix Yan <felixonmars@archlinux.org>
|
| 1011 |
+
Constantin Mateescu <costica1234@me.com>
|
| 1012 |
+
Eva Tiwari <eva.tiwari@gmail.com>
|
| 1013 |
+
Aditya Kumar Sinha <adityakumar113141@gmail.com>
|
| 1014 |
+
Soumi Bardhan <51290447+Soumi7@users.noreply.github.com>
|
| 1015 |
+
Kaustubh Chaudhari <ckaustubhm06@gmail.com>
|
| 1016 |
+
Kristian Brünn <hello@kristianbrunn.com>
|
| 1017 |
+
Neel Gorasiya <mgorasiya1974@gmail.com>
|
| 1018 |
+
Akshat Sood <68052998+akshatsood2249@users.noreply.github.com>
|
| 1019 |
+
Jose M. Gomez <chemoki@gmail.com>
|
| 1020 |
+
Stefan Petrea <stefan@garage-coding.com>
|
| 1021 |
+
Praveen Sahu <povinsahu@gmail.com>
|
| 1022 |
+
Mark Bell <mark00bell@googlemail.com>
|
| 1023 |
+
AlexCQY <alex_chua@u.nus.edu>
|
| 1024 |
+
Fabian Froehlich <fabian@schaluck.com>
|
| 1025 |
+
Nikhil Gopalam <gopalamn@umich.edu>
|
| 1026 |
+
Kartik Sethi <kartiks31416@gmail.com>
|
| 1027 |
+
Muhammed Abdul Quadir Owais <quadirowais200@gmail.com>
|
| 1028 |
+
Harshit Yadav <harshityadav2k@gmail.com>
|
| 1029 |
+
Sidharth Mundhra <sidharthmundhra16@gmail.com>
|
| 1030 |
+
Suryam Arnav Kalra <suryamkalra35@gmail.com>
|
| 1031 |
+
Prince Gupta <codemastercpp@gmail.com>
|
| 1032 |
+
Kunal Singh <ksingh19136@gmail.com>
|
| 1033 |
+
Mayank Raj <mayank_1901cs35@iitp.ac.in>
|
| 1034 |
+
Achal Jain <2achaljain@gmail.com>
|
| 1035 |
+
Mario Maio <mario.maio@aruba.it>
|
| 1036 |
+
Aaron Stiff <69512633+AaronStiff@users.noreply.github.com>
|
| 1037 |
+
Wyatt Peak <wyattpeak@gmail.com>
|
| 1038 |
+
Bhaskar Joshi <bhaskar.joshi@research.iiit.ac.in>
|
| 1039 |
+
Aditya Jindal <jaditya8889@gmail.com>
|
| 1040 |
+
Vaibhav Bhat <vaibhav.bhat2097@gmail.com>
|
| 1041 |
+
Priyansh Rathi <techiepriyansh@gmail.com>
|
| 1042 |
+
Saket Kumar Singh <saketkumar1202@gmail.com>
|
| 1043 |
+
Yukai Chou <muzimuzhi@gmail.com>
|
| 1044 |
+
Qijia Liu <liumeo@pku.edu.cn>
|
| 1045 |
+
Paul Mandel <paulmandel@google.com>
|
| 1046 |
+
Nisarg Chaudhari <54911392+Nisarg-Chaudhari@users.noreply.github.com>
|
| 1047 |
+
Dominik Stańczak <stanczakdominik@gmail.com>
|
| 1048 |
+
Rodrigo Luger <rodluger@gmail.com>
|
| 1049 |
+
Marco Antônio Habitzreuter <mahabitzreuter@gmail.com>
|
| 1050 |
+
Ayush Bisht <bisht.ayush2001@gmail.com>
|
| 1051 |
+
Akshansh Bhatt <akshansh@tuta.io>
|
| 1052 |
+
Brandon T. Willard <brandonwillard@users.noreply.github.com>
|
| 1053 |
+
Thomas Aarholt <thomasaarholt@gmail.com>
|
| 1054 |
+
Hiren Chalodiya <hirenchalodiya99@gmail.com>
|
| 1055 |
+
Roland Dixon <rols121@gmail.com>
|
| 1056 |
+
dimasvq <dimas.vq.2020@bristol.ac.uk>
|
| 1057 |
+
Sagar231 <sagarfeb298@gmail.com>
|
| 1058 |
+
Michael Chu <michael02chu@gmail.com>
|
| 1059 |
+
Abby Ng <abigailjng@gmail.com>
|
| 1060 |
+
Angad Sandhu <55819847+angadsinghsandhu@users.noreply.github.com>
|
| 1061 |
+
Alexander Cockburn <alexander_cockburn12@hotmail.com>
|
| 1062 |
+
Yaser AlOsh <yaseralosh@outlook.com>
|
| 1063 |
+
Davide Sandonà <sandona.davide@gmail.com>
|
| 1064 |
+
Jonathan Gutow <gutow@uwosh.edu>
|
| 1065 |
+
Nihir Agarwal <f20180701@pilani.bits-pilani.ac.in>
|
| 1066 |
+
Lee Johnston <lee.johnston.100@gmail.com>
|
| 1067 |
+
Zach Carmichael <20629897+craymichael@users.noreply.github.com>
|
| 1068 |
+
Vijairam Ganesh Moorthy <vijairamg@gmail.com>
|
| 1069 |
+
Hanspeter Schmid <hanspeter.schmid@fhnw.ch>
|
| 1070 |
+
Ben Oostendorp <oostben@umich.edu>
|
| 1071 |
+
Nikita <nikita.student.cse19@itbhu.ac.in>
|
| 1072 |
+
Aman <amanmourya295@gmail.com>
|
| 1073 |
+
Shashank KS <shashankks0987@gmail.com>
|
| 1074 |
+
Aman Sharma <amansharma110603@gmail.com>
|
| 1075 |
+
Anup Parikh <parikhanupk@gmail.com>
|
| 1076 |
+
Lucy Mountain <lucymountain1@icloud.com>
|
| 1077 |
+
Miguel Torres Costa <miguelptcosta1995@gmail.com>
|
| 1078 |
+
Rikard Nordgren <rikard.nordgren@farmaci.uu.se>
|
| 1079 |
+
Arun sanganal <74652697+ArunSanganal@users.noreply.github.com>
|
| 1080 |
+
Kamlesh Joshi <72374645+kamleshjoshi8102@users.noreply.github.com>
|
| 1081 |
+
Joseph Rance <56409230+Joseph-Rance@users.noreply.github.com>
|
| 1082 |
+
Huangduirong <huangduirong@huawei.com>
|
| 1083 |
+
Nils Schulte <47043622+Schnilz@users.noreply.github.com>
|
| 1084 |
+
Matt Bogosian <matt@bogosian.net>
|
| 1085 |
+
Elisha Hollander <just4now666666@gmail.com>
|
| 1086 |
+
Aditya Ravuri <infprobscix@gmail.com>
|
| 1087 |
+
Mamidi Ratna Praneeth <praneethratna@gmail.com>
|
| 1088 |
+
Jeffrey Ryan <jeffaryan7@gmail.com>
|
| 1089 |
+
Jonathan Daniel <36337649+jond01@users.noreply.github.com>
|
| 1090 |
+
Robin Richard <raisin@ecomail.fr>
|
| 1091 |
+
Gautam Menghani <gum3ng@protonmail.com>
|
| 1092 |
+
Remco de Boer <29308176+redeboer@users.noreply.github.com>
|
| 1093 |
+
Sebastian East <sebastianeast@ymail.com>
|
| 1094 |
+
Evani Balasubramanyam <balasubramanyam.evani@gmail.com>
|
| 1095 |
+
Rahil Parikh <r.parikh@somaiya.edu>
|
| 1096 |
+
Jason Ross <jasonross1024@gmail.com>
|
| 1097 |
+
Joannah Nanjekye <joannah.nanjekye@ibm.com>
|
| 1098 |
+
Ayush Kumar <ayushk7102@gmail.com>
|
| 1099 |
+
Kshitij <kshitijparwani.mat18@itbhu.ac.in>
|
| 1100 |
+
Daniel Hyams <dhyams@gmail.com>
|
| 1101 |
+
alijosephine <alijosephine@gmail.com>
|
| 1102 |
+
Matthias Köppe <mkoeppe@math.ucdavis.edu>
|
| 1103 |
+
mohajain <mohajain99@gmail.com>
|
| 1104 |
+
Anibal M. Medina-Mardones <ammedmar@gmail.com>
|
| 1105 |
+
Travis Ens <ens.travis@gmail.com>
|
| 1106 |
+
Evgenia Karunus <lakesare@gmail.com>
|
| 1107 |
+
Risiraj Dey <risirajdey@gmail.com>
|
| 1108 |
+
lastcodestanding <rohang71604@gmail.com>
|
| 1109 |
+
Andrey Lekar <andrey_lekar@adoriasoft.com>
|
| 1110 |
+
Abbas Mohammed <42001049+iam-abbas@users.noreply.github.com>
|
| 1111 |
+
Anutosh Bhat <andersonbhat491@gmail.com>
|
| 1112 |
+
Steve Kieffer <sk@skieffer.info>
|
| 1113 |
+
Paul Spiering <paul@spiering.org>
|
| 1114 |
+
Pieter Gijsbers <p.gijsbers@tue.nl>
|
| 1115 |
+
Wang Ran (汪然) <wangr@smail.nju.edu.cn>
|
| 1116 |
+
naelsondouglas <naelson17@gmail.com>
|
| 1117 |
+
Aman Thakur <thakuraman22july@gmail.com>
|
| 1118 |
+
S. Hanko <suzy.hanko@gmail.com>
|
| 1119 |
+
Dennis Sweeney <sweeney.427@osu.edu>
|
| 1120 |
+
Gurpartap Singh <dhaliwal.gurpartap@gmail.com>
|
| 1121 |
+
Hampus Malmberg <hampus.malmberg88@gmail.com>
|
| 1122 |
+
scimax <max.kellermeier@hotmail.de>
|
| 1123 |
+
Nikhil Date <nikhil.s.date@gmail.com>
|
| 1124 |
+
Kuldeep Borkar Jr <kuldeepborkarjr765@gmail.com>
|
| 1125 |
+
AkuBrain <76952313+Franck2111@users.noreply.github.com>
|
| 1126 |
+
Leo Battle <leowbattle@gmail.com>
|
| 1127 |
+
Advait Pote <apote2050@gmail.com>
|
| 1128 |
+
Anurag Bhat <bhat.1@iitj.ac.in>
|
| 1129 |
+
Jeremy Monat <jemonat@calalum.org>
|
| 1130 |
+
Diane Tchuindjo <dtchuindjo@gmail.com>
|
| 1131 |
+
Tom Fryers <61272761+TomFryers@users.noreply.github.com>
|
| 1132 |
+
Zouhair <zouhair.mahboubi@gmail.com>
|
| 1133 |
+
zzj <29055749+zjzh@users.noreply.github.com>
|
| 1134 |
+
shubhayu09 <guptashubhayu601@gmail.com>
|
| 1135 |
+
Siddhant Jain <siddhantashoknagar@gmail.com>
|
| 1136 |
+
Tirthankar Mazumder <63574588+wermos@users.noreply.github.com>
|
| 1137 |
+
Sumit Kumar <mr.sumitkrr@gmail.com>
|
| 1138 |
+
Shivam Sagar <technoshivam12@gmail.com>
|
| 1139 |
+
Gaurav Jain <gjain369@gmail.com>
|
| 1140 |
+
Andrii Oriekhov <andriyorehov@gmail.com>
|
| 1141 |
+
Luis Talavera <luisfertalavera15@gmail.com>
|
| 1142 |
+
Arie Bovenberg <a.c.bovenberg@gmail.com>
|
| 1143 |
+
Carson McManus <carson.mcmanus1@gmail.com>
|
| 1144 |
+
Jack Schmidt <1107865+jackschmidt@users.noreply.github.com>
|
| 1145 |
+
Riley Britten <nrb1324@hotmail.com>
|
| 1146 |
+
Georges Khaznadar <georgesk@debian.org>
|
| 1147 |
+
Donald Wilson <donwilson1029@gmail.com>
|
| 1148 |
+
Timo Stienstra <timostienstra00@gmail.com>
|
| 1149 |
+
dispasha <dispasha@users.noreply.github.com>
|
| 1150 |
+
Saksham Alok <sakshamalok13@gmail.com>
|
| 1151 |
+
Varenyam Bhardwaj <varenyambhardwaj123@gmail.com>
|
| 1152 |
+
oittaa <8972248+oittaa@users.noreply.github.com>
|
| 1153 |
+
Omkaar <79257339+Pysics@users.noreply.github.com>
|
| 1154 |
+
Islem BOUZENIA <fi_bouzenia@esi.dz>
|
| 1155 |
+
extraymond <extraymond@gmail.com>
|
| 1156 |
+
Alexander Behrens <alex.git@gmx.net>
|
| 1157 |
+
user202729 <25191436+user202729@users.noreply.github.com>
|
| 1158 |
+
Pieter Eendebak <pieter.eendebak@gmail.com>
|
| 1159 |
+
Zaz Brown <zazbrown@zazbrown.com>
|
| 1160 |
+
ritikBhandari <ritikbhandari68@gmail.com>
|
| 1161 |
+
viocha <66580331+viocha@users.noreply.github.com>
|
| 1162 |
+
Arthur Ryman <arthur.ryman@gmail.com>
|
| 1163 |
+
Xiang Wu <hsiangwu@fb.com>
|
| 1164 |
+
tttc3 <T.Coxon2@lboro.ac.uk>
|
| 1165 |
+
Seth Poulsen <poulsenseth@yahoo.com>
|
| 1166 |
+
cocolato <haiizhu@outlook.com>
|
| 1167 |
+
Anton Golovanov <agolovanov256@gmail.com>
|
| 1168 |
+
Gareth Ma <grhkm21@gmail.com>
|
| 1169 |
+
Clément M.T. Robert <cr52@protonmail.com>
|
| 1170 |
+
Glenn Horton-Smith <glenn.hortonsmith@gmail.com>
|
| 1171 |
+
Karan <grgkaran03@gmail.com>
|
| 1172 |
+
Stefan Behnle <84378403+behnle@users.noreply.github.com>
|
| 1173 |
+
Shreyash Mishra <72146041+Shreyash-cyber@users.noreply.github.com>
|
| 1174 |
+
Arthur Milchior <arthur@milchior.fr>
|
| 1175 |
+
NotWearingPants <26556598+NotWearingPants@users.noreply.github.com>
|
| 1176 |
+
Ishan Pandhare <ishan9096137017@gmail.com>
|
| 1177 |
+
Carlos García Montoro <TrilceAC@gmail.com>
|
| 1178 |
+
Parcly Taxel <reddeloostw@gmail.com>
|
| 1179 |
+
Saicharan <saicharanhahaha@gmail.com>
|
| 1180 |
+
Kunal Sheth <kunal@kunalsheth.info>
|
| 1181 |
+
Biswadeep Purkayastha <98874428+metabiswadeep@users.noreply.github.com>
|
| 1182 |
+
Jyn Spring 琴春 <me@vx.st>
|
| 1183 |
+
Phil LeMaitre <phil_lemaitre@live.ca>
|
| 1184 |
+
Chris Kerr <chris.kerr@mykolab.ch>
|
| 1185 |
+
José Senart <jose.senart@gmail.com>
|
| 1186 |
+
Uwe L. Korn <uwelk@xhochy.com>
|
| 1187 |
+
ForeverHaibara <69423537+ForeverHaibara@users.noreply.github.com>
|
| 1188 |
+
Yves Tumushimire <yvestumushimire@gmail.com>
|
| 1189 |
+
wookie184 <wookie1840@gmail.com>
|
| 1190 |
+
Costor <pcs2009@web.de>
|
| 1191 |
+
Klaus Rettinghaus <klaus.rettinghaus@enote.com>
|
| 1192 |
+
Sam Brockie <sambrockie@icloud.com>
|
| 1193 |
+
Abhishek Patidar <1e9abhi1e10@gmail.com>
|
| 1194 |
+
Eric Demer <demer@mailbox.org>
|
| 1195 |
+
Pontus von Brömssen <pontus.vonbromssen+github@gmail.com>
|
| 1196 |
+
Victor Immanuel <chrollolucilfer1402@gmail.com>
|
| 1197 |
+
Evandro Bernardes <evbernardes@gmail.com>
|
| 1198 |
+
Michele Ceccacci <michelececcacci1@gmail.com>
|
| 1199 |
+
Ayush Aryan <ayush.aryan71@gmail.com>
|
| 1200 |
+
Kishore Gopalakrishnan <kishore96@gmail.com>
|
| 1201 |
+
Jan-Philipp Hoffmann <sonntagsgesicht@icloud.com>
|
| 1202 |
+
Daiki Takahashi <haru.td@gmail.com>
|
| 1203 |
+
Sayan Mitra <ee18b156@smail.iitm.ac.in>
|
| 1204 |
+
Aman Kumar Shukla <theprofessionalaman@gmail.com>
|
| 1205 |
+
Zoufiné Lauer-Baré <raszoufine@gmail.com>
|
| 1206 |
+
Charles Harris <erdos4d@gmail.com>
|
| 1207 |
+
Tejaswini Sanapathi <sastejaswini2002@gmail.com>
|
| 1208 |
+
Devansh <be19b002@smail.iitm.ac.in>
|
| 1209 |
+
Aaron Gokaslan <aaronGokaslan@gmail.com>
|
| 1210 |
+
Daan Koning (he/him) <daanolivierkoning@gmail.com>
|
| 1211 |
+
Steven Burns <royalstream@hotmail.com>
|
| 1212 |
+
Jay Patankar <patankarjays@gmail.com>
|
| 1213 |
+
Vivek Soni <sonisheela1977@gmail.com>
|
| 1214 |
+
Le Cong Minh Hieu <hieu.lecongminh@gmail.com>
|
| 1215 |
+
Sam Ritchie <sam@mentat.org>
|
| 1216 |
+
Maciej Skórski <maciej.skorski@gmail.com>
|
| 1217 |
+
Tilo Reneau-Cardoso <tiloreneau@gmail.com>
|
| 1218 |
+
Laurence Warne <laurencewarne@gmail.com>
|
| 1219 |
+
Lukas Molleman <Lukas.Molleman@gmail.com>
|
| 1220 |
+
Konstantinos Riganas <kostasriganas24@gmail.com>
|
| 1221 |
+
Grace Su <grace.duansu@gmail.com>
|
| 1222 |
+
Pedro Rosa <pedro_sxbr@usp.br>
|
| 1223 |
+
Abhinav Cillanki <abhinavcillanki@kgpian.iitkgp.ac.in>
|
| 1224 |
+
Baiyuan Qiu <1061688677@qq.com>
|
| 1225 |
+
Liwei Cai <cai.lw123@gmail.com>
|
| 1226 |
+
Daniel Weindl <daniel.weindl@helmholtz-muenchen.de>
|
| 1227 |
+
Isidora Araya <iarayaday@gmail.com>
|
| 1228 |
+
Seb Tiburzio <sebtiburzio@gmail.com>
|
| 1229 |
+
Victory Omole <vtomole2@gmail.com>
|
| 1230 |
+
Abhishek Chaudhary <ac5003@columbia.edu>
|
| 1231 |
+
Alexander Zhura <nice.zhura@list.ru>
|
| 1232 |
+
Shuai Zhou <shuaivzhou@berkeley.edu>
|
| 1233 |
+
Martin Manns <mmanns@gmx.net>
|
| 1234 |
+
John Möller <john.moller@outlook.com>
|
| 1235 |
+
zzc <1378113190@qq.com>
|
| 1236 |
+
Pablo Galindo Salgado <pablogsal@gmail.com>
|
| 1237 |
+
Johannes Kasimir <johannes.kasimir@math.lu.se>
|
| 1238 |
+
Theodore Dias <theodore.dias@hotmail.co.uk>
|
| 1239 |
+
Kaustubh <90597818+kaustubh-765@users.noreply.github.com>
|
| 1240 |
+
Idan Pazi <idan.kp@gmail.com>
|
| 1241 |
+
Bobby Palmer <bobbyp@umich.edu>
|
| 1242 |
+
Saikat Das <saikatdchhe@gmail.com>
|
| 1243 |
+
Suman mondal <smondal.qwerty@gmail.com>
|
| 1244 |
+
Taylan Sahin <info@taylansahin.net>
|
| 1245 |
+
Fabio Luporini <fabio@devitocodes.com>
|
| 1246 |
+
Oriel Malihi <orielmalihi1@gmail.com>
|
| 1247 |
+
Geetika Vadali <geetika.vadali4@gmail.com>
|
| 1248 |
+
Matthias Rettl <matthias.rettl@stud.unileoben.ac.at>
|
| 1249 |
+
Mikhail Remnev <maremnev@gmail.com>
|
| 1250 |
+
philwillnyc <56197213+philwillnyc@users.noreply.github.com>
|
| 1251 |
+
Raphael Lehner <raphael.lehner@gmail.com>
|
| 1252 |
+
Harry Mountain <harrymountain1@icloud.com>
|
| 1253 |
+
Bhavik Sachdev <b.sachdev1904@gmail.com>
|
| 1254 |
+
袁野 (Yuan Ye) <yuanyelele@tutanota.com>
|
| 1255 |
+
fazledyn-or <ataf@openrefactory.com>
|
| 1256 |
+
mohammedouahman <simofun85@gmail.com>
|
| 1257 |
+
K. Kraus <laqueray@googlemail.com>
|
| 1258 |
+
Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
|
| 1259 |
+
platypus <platypus.computerchip@gmail.com>
|
| 1260 |
+
codecruisader <nnisarg55@gmail.com>
|
| 1261 |
+
James Whitehead <whiteheadj@gmail.com>
|
| 1262 |
+
atharvParlikar <atharvparlikar@gmail.com>
|
| 1263 |
+
Ivan Petukhov <satels@gmail.com>
|
| 1264 |
+
Augusto Borges <borges.augustoar@gmail.com>
|
| 1265 |
+
Han Wei Ang <ang.h.w@u.nus.edu>
|
| 1266 |
+
Congxu Yang <u7189828@anu.edu.au>
|
| 1267 |
+
Saicharan <62512681+saicharan2804@users.noreply.github.com>
|
| 1268 |
+
Arnab Nandi <arnabnandi2002@gmail.com>
|
| 1269 |
+
Harrison Oates <48871176+HarrisonOates@users.noreply.github.com>
|
| 1270 |
+
Corey Cerovsek <corey@cerovsek.com>
|
| 1271 |
+
Harsh Kasat <hkasat@waymore.io>
|
| 1272 |
+
omahs <73983677+omahs@users.noreply.github.com>
|
| 1273 |
+
Pascal Gitz <pascal.gitz@hotmail.ch>
|
| 1274 |
+
Ravindu-Hirimuthugoda <ravindu.18@cse.mrt.ac.lk>
|
| 1275 |
+
Sophia Pustova <tripplezzed@gmail.com>
|
| 1276 |
+
George Pittock <gpittock4@gmail.com>
|
| 1277 |
+
Warren Jacinto <warrenjacinto@gmail.com>
|
| 1278 |
+
Sachin Singh <sachinishu02@gmail.com>
|
| 1279 |
+
Zedmat <104870914+harshkasat@users.noreply.github.com>
|
| 1280 |
+
Soumendra Ganguly <soumendraganguly@gmail.com>
|
| 1281 |
+
Samith Karunathilake <55777141+samithkavishke@users.noreply.github.com>
|
| 1282 |
+
Viraj Vekaria <virajv5593@gmail.com>
|
| 1283 |
+
Shishir Kushwaha <kushwahashishir1112@gmail.com>
|
| 1284 |
+
Ankit Kumar Singh <ankitdiswar10@gmail.com>
|
| 1285 |
+
Abhishek Kumar <abhishek.nitdelhi@gmail.com>
|
| 1286 |
+
Mohak Malviya <mohakmalviya2000@gmail.com>
|
| 1287 |
+
Matthias Liesenfeld <116307294+maliesen@users.noreply.github.com>
|
| 1288 |
+
dodo <palumbododo@gmail.com>
|
| 1289 |
+
Mohamed Rezk <mohrizq895@gmail.com>
|
| 1290 |
+
Tommaso Vaccari <05-gesto-follemente@icloud.com>
|
| 1291 |
+
Alexis Schotte <alexis.schotte@gmail.com>
|
| 1292 |
+
Lauren Yim <31467609+cherryblossom000@users.noreply.github.com>
|
| 1293 |
+
Prey Patel <patel.prey@iitgn.ac.in>
|
| 1294 |
+
Riccardo Di Girolamo <riccardodigirolamo01@gmail.com>
|
| 1295 |
+
Abhishek kumar <kumar325571@gmail.com>
|
| 1296 |
+
Sam Lubelsky <sammy56lt@gmail.com>
|
| 1297 |
+
Henrique Soares <henrique.c.soares@tecnico.ulisboa.pt>
|
| 1298 |
+
Vladimir Sereda <voffch@gmail.com>
|
| 1299 |
+
Hwayeon Kang <hwayeonniii@gmail.com>
|
| 1300 |
+
Raj Sapale <raj4sapale4@gmail.com>
|
| 1301 |
+
Gerald Teschl <gerald.teschl@univie.ac.at>
|
| 1302 |
+
Richard Samuel <98638849+samuelard7@users.noreply.github.com>
|
| 1303 |
+
HeeJae Chang <hechang@microsoft.com>
|
| 1304 |
+
Nick Harder <nharder@umich.edu>
|
| 1305 |
+
Ethan DeGuire <ethandeguire@gmail.com>
|
| 1306 |
+
Lorenz Winkler <lorenz.winkler@tuwien.ac.at>
|
| 1307 |
+
Richard Rodenbusch <rrodenbusch@gmail.com>
|
| 1308 |
+
Zhenxu Zhu <xzdlj@outlook.com>
|
| 1309 |
+
Mark van Gelder <m.j.vangelder@student.tudelft.nl>
|
| 1310 |
+
Mark van Gelder <mvgmvgmvg@live.com>
|
| 1311 |
+
Ishan Pandhare <91841626+Ishanned@users.noreply.github.com>
|
| 1312 |
+
James A. Preiss <jamesalanpreiss@gmail.com>
|
| 1313 |
+
Emile Fourcini <emile.fourcin1@gmail.com>
|
| 1314 |
+
Alberto Jiménez Ruiz <Alberto.Jimenez@uclm.es>
|
| 1315 |
+
João Bravo <joaocgbravo@tecnico.ulisboa.pt>
|
| 1316 |
+
Dean Price <dean1357price1357@gmail.com>
|
| 1317 |
+
Edward Z. Yang <ezyang@mit.edu>
|
| 1318 |
+
James Titus <titusjames299@gmail.com>
|
| 1319 |
+
Zhuoyuan Li <zy.li@stu.pku.edu.cn>
|
| 1320 |
+
Hugo Kerstens <hugo@kerstens.me>
|
| 1321 |
+
Jan Jancar <johny@neuromancer.sk>
|
| 1322 |
+
Andrew Mosson <amosson@yahoo.com>
|
| 1323 |
+
Marek Madejski <marekmadejski@yandex.com>
|
| 1324 |
+
Gonzalo Tornaría <tornaria@cmat.edu.uy>
|
| 1325 |
+
Peter Stahlecker <peter.stahlecker@gmail.com>
|
| 1326 |
+
Jean-François B <2589111+jfbu@users.noreply.github.com>
|
| 1327 |
+
Zexuan Zhou (Bruce) <zzx498636727@gmail.com>
|
| 1328 |
+
George Frolov <gosha@fro.lv>
|
| 1329 |
+
Corbet Elkins <corbet286@gmail.com>
|
| 1330 |
+
Håkon Kvernmoen <haakon.kvernmoen@gmail.com>
|
| 1331 |
+
Muhammad Maaz <mmaaz6004@gmail.com>
|
| 1332 |
+
Shishir Kushwaha <138311586+shishir-11@users.noreply.github.com>
|
| 1333 |
+
Matt Wang <mattwang44@gmail.com>
|
| 1334 |
+
bharatAmeria <21001019007@jcboseust.ac.in>
|
| 1335 |
+
Amir Ebrahimi <github@aebrahimi.com>
|
| 1336 |
+
Steven Esquea <steven.esquea@irreverente.net>
|
| 1337 |
+
Rishabh Kamboj <111004091+VectorNd@users.noreply.github.com>
|
| 1338 |
+
Aasim Ali <aasim250205@gmail.com>
|
| 1339 |
+
Ivan A. Melnikov <iv@altlinux.org>
|
| 1340 |
+
Borek Saheli <boreksaheli@gmail.com>
|
| 1341 |
+
Guido Roncarolo <guido.roncarolo@gmail.com>
|
| 1342 |
+
Quek Zi Yao <ziyaoqzy2001@gmail.com>
|
| 1343 |
+
Roelof Rietbroek <r.rietbroek@utwente.nl>
|
| 1344 |
+
MostafaGalal1 <mostafag649.mg@gmail.com>
|
| 1345 |
+
Au Huishan <huishan_au@outlook.com>
|
| 1346 |
+
Kris Katterjohn <katterjohn@gmail.com>
|
| 1347 |
+
Shiyao Guo <mivikq@gmail.com>
|
| 1348 |
+
Rushabh Mehta <mehtarushabh2005@gmail.com>
|
| 1349 |
+
Temiloluwa Yusuf ytemiloluwa@gmail.com ytemiloluwa <ytemiloluwa@gmail.com>
|
| 1350 |
+
Davi Laerte <davilae011@gmail.com>
|
| 1351 |
+
Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>
|
| 1352 |
+
Harshit Gupta <harshithigh2001@gmail.com>
|
| 1353 |
+
Praveen Perumal <ppraveen98841@gmail.com>
|
| 1354 |
+
Kevin McWhirter <klmcw@yahoo.com>
|
| 1355 |
+
Prayag V <v.prayag2005@gmail.com>
|
| 1356 |
+
Lucas Kletzander <lucas.kletzander@gmail.com>
|
| 1357 |
+
Pratyksh Gupta <pratykshgupta9999@gmail.com>
|
| 1358 |
+
Leonardo Mangani <leomangani4@gmail.com>
|
| 1359 |
+
Karan Anand <anandkarancompsci@gmail.com>
|
| 1360 |
+
Gagan Mishra <simonsimple305@gmail.com>
|
| 1361 |
+
Krishnav Bajoria <bajoriakrishnav@gmail.com>
|
| 1362 |
+
Matt Ord <matthew.ord1@gmail.com>
|
| 1363 |
+
Jatin Bhardwaj <bhardwajjatin093@gmail.com>
|
| 1364 |
+
Prashant Tandon <tandonprashant101@gmail.com>
|
| 1365 |
+
Paramjit Singh <paramjit1071@gmail.com>
|
| 1366 |
+
João Rodrigues <abcjoao@hotmail.com>
|
| 1367 |
+
Alejandro García Prada <114813960+AlexGarciaPrada@users.noreply.github.com>
|
| 1368 |
+
Matthew Treinish <mtreinish@kortar.org>
|
| 1369 |
+
Clayton Rabideau <claytonrabideau@gmail.com>
|
| 1370 |
+
Victoria Koval <bictoriakoval16@gmail.com>
|
| 1371 |
+
Voaides Negustor Robert <134785947+voaidesr@users.noreply.github.com>
|
| 1372 |
+
Ovsk Mendov <bbb23exposed@gmail.com>
|
| 1373 |
+
David Brooks <dave@bcs.co.nz>
|
| 1374 |
+
Nicholas Laustrup <124007393+nicklaustrup@users.noreply.github.com>
|
| 1375 |
+
Harikrishna Srinivasan <harikrishnasri3@gmail.com>
|
| 1376 |
+
Mathis Cros <mathis.cros@telecom-paris.fr>
|
| 1377 |
+
Arnav Mummineni <45217840+RCoder01@users.noreply.github.com>
|
| 1378 |
+
Thangaraju Sibiraj <85477603+t-sibiraj@users.noreply.github.com>
|
| 1379 |
+
KJaybhaye <krushnajaybhaye01@gmail.com>
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy-1.14.0.dist-info/licenses/LICENSE
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright (c) 2006-2023 SymPy Development Team
|
| 2 |
+
|
| 3 |
+
All rights reserved.
|
| 4 |
+
|
| 5 |
+
Redistribution and use in source and binary forms, with or without
|
| 6 |
+
modification, are permitted provided that the following conditions are met:
|
| 7 |
+
|
| 8 |
+
a. Redistributions of source code must retain the above copyright notice,
|
| 9 |
+
this list of conditions and the following disclaimer.
|
| 10 |
+
b. Redistributions in binary form must reproduce the above copyright
|
| 11 |
+
notice, this list of conditions and the following disclaimer in the
|
| 12 |
+
documentation and/or other materials provided with the distribution.
|
| 13 |
+
c. Neither the name of SymPy nor the names of its contributors
|
| 14 |
+
may be used to endorse or promote products derived from this software
|
| 15 |
+
without specific prior written permission.
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
| 19 |
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
| 20 |
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
| 21 |
+
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
|
| 22 |
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 23 |
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
| 24 |
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
| 25 |
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
| 26 |
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
| 27 |
+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 28 |
+
DAMAGE.
|
| 29 |
+
|
| 30 |
+
--------------------------------------------------------------------------------
|
| 31 |
+
|
| 32 |
+
Patches that were taken from the Diofant project (https://github.com/diofant/diofant)
|
| 33 |
+
are licensed as:
|
| 34 |
+
|
| 35 |
+
Copyright (c) 2006-2018 SymPy Development Team,
|
| 36 |
+
2013-2023 Sergey B Kirpichev
|
| 37 |
+
|
| 38 |
+
All rights reserved.
|
| 39 |
+
|
| 40 |
+
Redistribution and use in source and binary forms, with or without
|
| 41 |
+
modification, are permitted provided that the following conditions are met:
|
| 42 |
+
|
| 43 |
+
a. Redistributions of source code must retain the above copyright notice,
|
| 44 |
+
this list of conditions and the following disclaimer.
|
| 45 |
+
b. Redistributions in binary form must reproduce the above copyright
|
| 46 |
+
notice, this list of conditions and the following disclaimer in the
|
| 47 |
+
documentation and/or other materials provided with the distribution.
|
| 48 |
+
c. Neither the name of Diofant or SymPy nor the names of its contributors
|
| 49 |
+
may be used to endorse or promote products derived from this software
|
| 50 |
+
without specific prior written permission.
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
| 54 |
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
| 55 |
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
| 56 |
+
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
|
| 57 |
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 58 |
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
| 59 |
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
| 60 |
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
| 61 |
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
| 62 |
+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 63 |
+
DAMAGE.
|
| 64 |
+
|
| 65 |
+
--------------------------------------------------------------------------------
|
| 66 |
+
|
| 67 |
+
Submodules taken from the multipledispatch project (https://github.com/mrocklin/multipledispatch)
|
| 68 |
+
are licensed as:
|
| 69 |
+
|
| 70 |
+
Copyright (c) 2014 Matthew Rocklin
|
| 71 |
+
|
| 72 |
+
All rights reserved.
|
| 73 |
+
|
| 74 |
+
Redistribution and use in source and binary forms, with or without
|
| 75 |
+
modification, are permitted provided that the following conditions are met:
|
| 76 |
+
|
| 77 |
+
a. Redistributions of source code must retain the above copyright notice,
|
| 78 |
+
this list of conditions and the following disclaimer.
|
| 79 |
+
b. Redistributions in binary form must reproduce the above copyright
|
| 80 |
+
notice, this list of conditions and the following disclaimer in the
|
| 81 |
+
documentation and/or other materials provided with the distribution.
|
| 82 |
+
c. Neither the name of multipledispatch nor the names of its contributors
|
| 83 |
+
may be used to endorse or promote products derived from this software
|
| 84 |
+
without specific prior written permission.
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
| 88 |
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
| 89 |
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
| 90 |
+
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
|
| 91 |
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 92 |
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
| 93 |
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
| 94 |
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
| 95 |
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
| 96 |
+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 97 |
+
DAMAGE.
|
| 98 |
+
|
| 99 |
+
--------------------------------------------------------------------------------
|
| 100 |
+
|
| 101 |
+
The files under the directory sympy/parsing/autolev/tests/pydy-example-repo
|
| 102 |
+
are directly copied from PyDy project and are licensed as:
|
| 103 |
+
|
| 104 |
+
Copyright (c) 2009-2023, PyDy Authors
|
| 105 |
+
All rights reserved.
|
| 106 |
+
|
| 107 |
+
Redistribution and use in source and binary forms, with or without
|
| 108 |
+
modification, are permitted provided that the following conditions are met:
|
| 109 |
+
|
| 110 |
+
* Redistributions of source code must retain the above copyright
|
| 111 |
+
notice, this list of conditions and the following disclaimer.
|
| 112 |
+
* Redistributions in binary form must reproduce the above copyright
|
| 113 |
+
notice, this list of conditions and the following disclaimer in the
|
| 114 |
+
documentation and/or other materials provided with the distribution.
|
| 115 |
+
* Neither the name of this project nor the names of its contributors may be
|
| 116 |
+
used to endorse or promote products derived from this software without
|
| 117 |
+
specific prior written permission.
|
| 118 |
+
|
| 119 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
| 120 |
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
| 121 |
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
| 122 |
+
DISCLAIMED. IN NO EVENT SHALL PYDY AUTHORS BE LIABLE FOR ANY DIRECT,
|
| 123 |
+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 124 |
+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 125 |
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
| 126 |
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
| 127 |
+
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
| 128 |
+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 129 |
+
|
| 130 |
+
--------------------------------------------------------------------------------
|
| 131 |
+
|
| 132 |
+
The files under the directory sympy/parsing/latex
|
| 133 |
+
are directly copied from latex2sympy project and are licensed as:
|
| 134 |
+
|
| 135 |
+
Copyright 2016, latex2sympy
|
| 136 |
+
|
| 137 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 138 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 139 |
+
in the Software without restriction, including without limitation the rights
|
| 140 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 141 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 142 |
+
furnished to do so, subject to the following conditions:
|
| 143 |
+
|
| 144 |
+
The above copyright notice and this permission notice shall be included in all
|
| 145 |
+
copies or substantial portions of the Software.
|
| 146 |
+
|
| 147 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 148 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 149 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 150 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 151 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 152 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 153 |
+
SOFTWARE.
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy-1.14.0.dist-info/top_level.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
isympy
|
| 2 |
+
sympy
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/autolev/test-examples/pydy-example-repo/chaos_pendulum.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sympy.physics.mechanics as _me
|
| 2 |
+
import sympy as _sm
|
| 3 |
+
import math as m
|
| 4 |
+
import numpy as _np
|
| 5 |
+
|
| 6 |
+
g, lb, w, h = _sm.symbols('g lb w h', real=True)
|
| 7 |
+
theta, phi, omega, alpha = _me.dynamicsymbols('theta phi omega alpha')
|
| 8 |
+
theta_d, phi_d, omega_d, alpha_d = _me.dynamicsymbols('theta_ phi_ omega_ alpha_', 1)
|
| 9 |
+
theta_dd, phi_dd = _me.dynamicsymbols('theta_ phi_', 2)
|
| 10 |
+
frame_n = _me.ReferenceFrame('n')
|
| 11 |
+
body_a_cm = _me.Point('a_cm')
|
| 12 |
+
body_a_cm.set_vel(frame_n, 0)
|
| 13 |
+
body_a_f = _me.ReferenceFrame('a_f')
|
| 14 |
+
body_a = _me.RigidBody('a', body_a_cm, body_a_f, _sm.symbols('m'), (_me.outer(body_a_f.x,body_a_f.x),body_a_cm))
|
| 15 |
+
body_b_cm = _me.Point('b_cm')
|
| 16 |
+
body_b_cm.set_vel(frame_n, 0)
|
| 17 |
+
body_b_f = _me.ReferenceFrame('b_f')
|
| 18 |
+
body_b = _me.RigidBody('b', body_b_cm, body_b_f, _sm.symbols('m'), (_me.outer(body_b_f.x,body_b_f.x),body_b_cm))
|
| 19 |
+
body_a_f.orient(frame_n, 'Axis', [theta, frame_n.y])
|
| 20 |
+
body_b_f.orient(body_a_f, 'Axis', [phi, body_a_f.z])
|
| 21 |
+
point_o = _me.Point('o')
|
| 22 |
+
la = (lb-h/2)/2
|
| 23 |
+
body_a_cm.set_pos(point_o, la*body_a_f.z)
|
| 24 |
+
body_b_cm.set_pos(point_o, lb*body_a_f.z)
|
| 25 |
+
body_a_f.set_ang_vel(frame_n, omega*frame_n.y)
|
| 26 |
+
body_b_f.set_ang_vel(body_a_f, alpha*body_a_f.z)
|
| 27 |
+
point_o.set_vel(frame_n, 0)
|
| 28 |
+
body_a_cm.v2pt_theory(point_o,frame_n,body_a_f)
|
| 29 |
+
body_b_cm.v2pt_theory(point_o,frame_n,body_a_f)
|
| 30 |
+
ma = _sm.symbols('ma')
|
| 31 |
+
body_a.mass = ma
|
| 32 |
+
mb = _sm.symbols('mb')
|
| 33 |
+
body_b.mass = mb
|
| 34 |
+
iaxx = 1/12*ma*(2*la)**2
|
| 35 |
+
iayy = iaxx
|
| 36 |
+
iazz = 0
|
| 37 |
+
ibxx = 1/12*mb*h**2
|
| 38 |
+
ibyy = 1/12*mb*(w**2+h**2)
|
| 39 |
+
ibzz = 1/12*mb*w**2
|
| 40 |
+
body_a.inertia = (_me.inertia(body_a_f, iaxx, iayy, iazz, 0, 0, 0), body_a_cm)
|
| 41 |
+
body_b.inertia = (_me.inertia(body_b_f, ibxx, ibyy, ibzz, 0, 0, 0), body_b_cm)
|
| 42 |
+
force_a = body_a.mass*(g*frame_n.z)
|
| 43 |
+
force_b = body_b.mass*(g*frame_n.z)
|
| 44 |
+
kd_eqs = [theta_d - omega, phi_d - alpha]
|
| 45 |
+
forceList = [(body_a.masscenter,body_a.mass*(g*frame_n.z)), (body_b.masscenter,body_b.mass*(g*frame_n.z))]
|
| 46 |
+
kane = _me.KanesMethod(frame_n, q_ind=[theta,phi], u_ind=[omega, alpha], kd_eqs = kd_eqs)
|
| 47 |
+
fr, frstar = kane.kanes_equations([body_a, body_b], forceList)
|
| 48 |
+
zero = fr+frstar
|
| 49 |
+
from pydy.system import System
|
| 50 |
+
sys = System(kane, constants = {g:9.81, lb:0.2, w:0.2, h:0.1, ma:0.01, mb:0.1},
|
| 51 |
+
specifieds={},
|
| 52 |
+
initial_conditions={theta:_np.deg2rad(90), phi:_np.deg2rad(0.5), omega:0, alpha:0},
|
| 53 |
+
times = _np.linspace(0.0, 10, 10/0.02))
|
| 54 |
+
|
| 55 |
+
y=sys.integrate()
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/autolev/test-examples/pydy-example-repo/double_pendulum.al
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MOTIONVARIABLES' Q{2}', U{2}'
|
| 2 |
+
CONSTANTS L,M,G
|
| 3 |
+
NEWTONIAN N
|
| 4 |
+
FRAMES A,B
|
| 5 |
+
SIMPROT(N, A, 3, Q1)
|
| 6 |
+
SIMPROT(N, B, 3, Q2)
|
| 7 |
+
W_A_N>=U1*N3>
|
| 8 |
+
W_B_N>=U2*N3>
|
| 9 |
+
POINT O
|
| 10 |
+
PARTICLES P,R
|
| 11 |
+
P_O_P> = L*A1>
|
| 12 |
+
P_P_R> = L*B1>
|
| 13 |
+
V_O_N> = 0>
|
| 14 |
+
V2PTS(N, A, O, P)
|
| 15 |
+
V2PTS(N, B, P, R)
|
| 16 |
+
MASS P=M, R=M
|
| 17 |
+
Q1' = U1
|
| 18 |
+
Q2' = U2
|
| 19 |
+
GRAVITY(G*N1>)
|
| 20 |
+
ZERO = FR() + FRSTAR()
|
| 21 |
+
KANE()
|
| 22 |
+
INPUT M=1,G=9.81,L=1
|
| 23 |
+
INPUT Q1=.1,Q2=.2,U1=0,U2=0
|
| 24 |
+
INPUT TFINAL=10, INTEGSTP=.01
|
| 25 |
+
CODE DYNAMICS() some_filename.c
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/autolev/test-examples/pydy-example-repo/double_pendulum.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sympy.physics.mechanics as _me
|
| 2 |
+
import sympy as _sm
|
| 3 |
+
import math as m
|
| 4 |
+
import numpy as _np
|
| 5 |
+
|
| 6 |
+
q1, q2, u1, u2 = _me.dynamicsymbols('q1 q2 u1 u2')
|
| 7 |
+
q1_d, q2_d, u1_d, u2_d = _me.dynamicsymbols('q1_ q2_ u1_ u2_', 1)
|
| 8 |
+
l, m, g = _sm.symbols('l m g', real=True)
|
| 9 |
+
frame_n = _me.ReferenceFrame('n')
|
| 10 |
+
frame_a = _me.ReferenceFrame('a')
|
| 11 |
+
frame_b = _me.ReferenceFrame('b')
|
| 12 |
+
frame_a.orient(frame_n, 'Axis', [q1, frame_n.z])
|
| 13 |
+
frame_b.orient(frame_n, 'Axis', [q2, frame_n.z])
|
| 14 |
+
frame_a.set_ang_vel(frame_n, u1*frame_n.z)
|
| 15 |
+
frame_b.set_ang_vel(frame_n, u2*frame_n.z)
|
| 16 |
+
point_o = _me.Point('o')
|
| 17 |
+
particle_p = _me.Particle('p', _me.Point('p_pt'), _sm.Symbol('m'))
|
| 18 |
+
particle_r = _me.Particle('r', _me.Point('r_pt'), _sm.Symbol('m'))
|
| 19 |
+
particle_p.point.set_pos(point_o, l*frame_a.x)
|
| 20 |
+
particle_r.point.set_pos(particle_p.point, l*frame_b.x)
|
| 21 |
+
point_o.set_vel(frame_n, 0)
|
| 22 |
+
particle_p.point.v2pt_theory(point_o,frame_n,frame_a)
|
| 23 |
+
particle_r.point.v2pt_theory(particle_p.point,frame_n,frame_b)
|
| 24 |
+
particle_p.mass = m
|
| 25 |
+
particle_r.mass = m
|
| 26 |
+
force_p = particle_p.mass*(g*frame_n.x)
|
| 27 |
+
force_r = particle_r.mass*(g*frame_n.x)
|
| 28 |
+
kd_eqs = [q1_d - u1, q2_d - u2]
|
| 29 |
+
forceList = [(particle_p.point,particle_p.mass*(g*frame_n.x)), (particle_r.point,particle_r.mass*(g*frame_n.x))]
|
| 30 |
+
kane = _me.KanesMethod(frame_n, q_ind=[q1,q2], u_ind=[u1, u2], kd_eqs = kd_eqs)
|
| 31 |
+
fr, frstar = kane.kanes_equations([particle_p, particle_r], forceList)
|
| 32 |
+
zero = fr+frstar
|
| 33 |
+
from pydy.system import System
|
| 34 |
+
sys = System(kane, constants = {l:1, m:1, g:9.81},
|
| 35 |
+
specifieds={},
|
| 36 |
+
initial_conditions={q1:.1, q2:.2, u1:0, u2:0},
|
| 37 |
+
times = _np.linspace(0.0, 10, 10/.01))
|
| 38 |
+
|
| 39 |
+
y=sys.integrate()
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/autolev/test-examples/pydy-example-repo/mass_spring_damper.al
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
CONSTANTS M,K,B,G
|
| 2 |
+
MOTIONVARIABLES' POSITION',SPEED'
|
| 3 |
+
VARIABLES O
|
| 4 |
+
FORCE = O*SIN(T)
|
| 5 |
+
NEWTONIAN CEILING
|
| 6 |
+
POINTS ORIGIN
|
| 7 |
+
V_ORIGIN_CEILING> = 0>
|
| 8 |
+
PARTICLES BLOCK
|
| 9 |
+
P_ORIGIN_BLOCK> = POSITION*CEILING1>
|
| 10 |
+
MASS BLOCK=M
|
| 11 |
+
V_BLOCK_CEILING>=SPEED*CEILING1>
|
| 12 |
+
POSITION' = SPEED
|
| 13 |
+
FORCE_MAGNITUDE = M*G-K*POSITION-B*SPEED+FORCE
|
| 14 |
+
FORCE_BLOCK>=EXPLICIT(FORCE_MAGNITUDE*CEILING1>)
|
| 15 |
+
ZERO = FR() + FRSTAR()
|
| 16 |
+
KANE()
|
| 17 |
+
INPUT TFINAL=10.0, INTEGSTP=0.01
|
| 18 |
+
INPUT M=1.0, K=1.0, B=0.2, G=9.8, POSITION=0.1, SPEED=-1.0, O=2
|
| 19 |
+
CODE DYNAMICS() dummy_file.c
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/autolev/test-examples/pydy-example-repo/mass_spring_damper.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sympy.physics.mechanics as _me
|
| 2 |
+
import sympy as _sm
|
| 3 |
+
import math as m
|
| 4 |
+
import numpy as _np
|
| 5 |
+
|
| 6 |
+
m, k, b, g = _sm.symbols('m k b g', real=True)
|
| 7 |
+
position, speed = _me.dynamicsymbols('position speed')
|
| 8 |
+
position_d, speed_d = _me.dynamicsymbols('position_ speed_', 1)
|
| 9 |
+
o = _me.dynamicsymbols('o')
|
| 10 |
+
force = o*_sm.sin(_me.dynamicsymbols._t)
|
| 11 |
+
frame_ceiling = _me.ReferenceFrame('ceiling')
|
| 12 |
+
point_origin = _me.Point('origin')
|
| 13 |
+
point_origin.set_vel(frame_ceiling, 0)
|
| 14 |
+
particle_block = _me.Particle('block', _me.Point('block_pt'), _sm.Symbol('m'))
|
| 15 |
+
particle_block.point.set_pos(point_origin, position*frame_ceiling.x)
|
| 16 |
+
particle_block.mass = m
|
| 17 |
+
particle_block.point.set_vel(frame_ceiling, speed*frame_ceiling.x)
|
| 18 |
+
force_magnitude = m*g-k*position-b*speed+force
|
| 19 |
+
force_block = (force_magnitude*frame_ceiling.x).subs({position_d:speed})
|
| 20 |
+
kd_eqs = [position_d - speed]
|
| 21 |
+
forceList = [(particle_block.point,(force_magnitude*frame_ceiling.x).subs({position_d:speed}))]
|
| 22 |
+
kane = _me.KanesMethod(frame_ceiling, q_ind=[position], u_ind=[speed], kd_eqs = kd_eqs)
|
| 23 |
+
fr, frstar = kane.kanes_equations([particle_block], forceList)
|
| 24 |
+
zero = fr+frstar
|
| 25 |
+
from pydy.system import System
|
| 26 |
+
sys = System(kane, constants = {m:1.0, k:1.0, b:0.2, g:9.8},
|
| 27 |
+
specifieds={_me.dynamicsymbols('t'):lambda x, t: t, o:2},
|
| 28 |
+
initial_conditions={position:0.1, speed:-1*1.0},
|
| 29 |
+
times = _np.linspace(0.0, 10.0, 10.0/0.01))
|
| 30 |
+
|
| 31 |
+
y=sys.integrate()
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/autolev/test-examples/pydy-example-repo/non_min_pendulum.al
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MOTIONVARIABLES' Q{2}''
|
| 2 |
+
CONSTANTS L,M,G
|
| 3 |
+
NEWTONIAN N
|
| 4 |
+
POINT PN
|
| 5 |
+
V_PN_N> = 0>
|
| 6 |
+
THETA1 = ATAN(Q2/Q1)
|
| 7 |
+
FRAMES A
|
| 8 |
+
SIMPROT(N, A, 3, THETA1)
|
| 9 |
+
PARTICLES P
|
| 10 |
+
P_PN_P> = Q1*N1>+Q2*N2>
|
| 11 |
+
MASS P=M
|
| 12 |
+
V_P_N>=DT(P_P_PN>, N)
|
| 13 |
+
F_V = DOT(EXPRESS(V_P_N>,A), A1>)
|
| 14 |
+
GRAVITY(G*N1>)
|
| 15 |
+
DEPENDENT[1] = F_V
|
| 16 |
+
CONSTRAIN(DEPENDENT[Q1'])
|
| 17 |
+
ZERO=FR()+FRSTAR()
|
| 18 |
+
F_C = MAG(P_P_PN>)-L
|
| 19 |
+
CONFIG[1]=F_C
|
| 20 |
+
ZERO[2]=CONFIG[1]
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/autolev/test-examples/pydy-example-repo/non_min_pendulum.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sympy.physics.mechanics as _me
|
| 2 |
+
import sympy as _sm
|
| 3 |
+
import math as m
|
| 4 |
+
import numpy as _np
|
| 5 |
+
|
| 6 |
+
q1, q2 = _me.dynamicsymbols('q1 q2')
|
| 7 |
+
q1_d, q2_d = _me.dynamicsymbols('q1_ q2_', 1)
|
| 8 |
+
q1_dd, q2_dd = _me.dynamicsymbols('q1_ q2_', 2)
|
| 9 |
+
l, m, g = _sm.symbols('l m g', real=True)
|
| 10 |
+
frame_n = _me.ReferenceFrame('n')
|
| 11 |
+
point_pn = _me.Point('pn')
|
| 12 |
+
point_pn.set_vel(frame_n, 0)
|
| 13 |
+
theta1 = _sm.atan(q2/q1)
|
| 14 |
+
frame_a = _me.ReferenceFrame('a')
|
| 15 |
+
frame_a.orient(frame_n, 'Axis', [theta1, frame_n.z])
|
| 16 |
+
particle_p = _me.Particle('p', _me.Point('p_pt'), _sm.Symbol('m'))
|
| 17 |
+
particle_p.point.set_pos(point_pn, q1*frame_n.x+q2*frame_n.y)
|
| 18 |
+
particle_p.mass = m
|
| 19 |
+
particle_p.point.set_vel(frame_n, (point_pn.pos_from(particle_p.point)).dt(frame_n))
|
| 20 |
+
f_v = _me.dot((particle_p.point.vel(frame_n)).express(frame_a), frame_a.x)
|
| 21 |
+
force_p = particle_p.mass*(g*frame_n.x)
|
| 22 |
+
dependent = _sm.Matrix([[0]])
|
| 23 |
+
dependent[0] = f_v
|
| 24 |
+
velocity_constraints = [i for i in dependent]
|
| 25 |
+
u_q1_d = _me.dynamicsymbols('u_q1_d')
|
| 26 |
+
u_q2_d = _me.dynamicsymbols('u_q2_d')
|
| 27 |
+
kd_eqs = [q1_d-u_q1_d, q2_d-u_q2_d]
|
| 28 |
+
forceList = [(particle_p.point,particle_p.mass*(g*frame_n.x))]
|
| 29 |
+
kane = _me.KanesMethod(frame_n, q_ind=[q1,q2], u_ind=[u_q2_d], u_dependent=[u_q1_d], kd_eqs = kd_eqs, velocity_constraints = velocity_constraints)
|
| 30 |
+
fr, frstar = kane.kanes_equations([particle_p], forceList)
|
| 31 |
+
zero = fr+frstar
|
| 32 |
+
f_c = point_pn.pos_from(particle_p.point).magnitude()-l
|
| 33 |
+
config = _sm.Matrix([[0]])
|
| 34 |
+
config[0] = f_c
|
| 35 |
+
zero = zero.row_insert(zero.shape[0], _sm.Matrix([[0]]))
|
| 36 |
+
zero[zero.shape[0]-1] = config[0]
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/c/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Used for translating C source code into a SymPy expression"""
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/c/c_parser.py
ADDED
|
@@ -0,0 +1,1059 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
| 1 |
+
from sympy.external import import_module
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
cin = import_module('clang.cindex', import_kwargs = {'fromlist': ['cindex']})
|
| 5 |
+
|
| 6 |
+
"""
|
| 7 |
+
This module contains all the necessary Classes and Function used to Parse C and
|
| 8 |
+
C++ code into SymPy expression
|
| 9 |
+
The module serves as a backend for SymPyExpression to parse C code
|
| 10 |
+
It is also dependent on Clang's AST and SymPy's Codegen AST.
|
| 11 |
+
The module only supports the features currently supported by the Clang and
|
| 12 |
+
codegen AST which will be updated as the development of codegen AST and this
|
| 13 |
+
module progresses.
|
| 14 |
+
You might find unexpected bugs and exceptions while using the module, feel free
|
| 15 |
+
to report them to the SymPy Issue Tracker
|
| 16 |
+
|
| 17 |
+
Features Supported
|
| 18 |
+
==================
|
| 19 |
+
|
| 20 |
+
- Variable Declarations (integers and reals)
|
| 21 |
+
- Assignment (using integer & floating literal and function calls)
|
| 22 |
+
- Function Definitions and Declaration
|
| 23 |
+
- Function Calls
|
| 24 |
+
- Compound statements, Return statements
|
| 25 |
+
|
| 26 |
+
Notes
|
| 27 |
+
=====
|
| 28 |
+
|
| 29 |
+
The module is dependent on an external dependency which needs to be installed
|
| 30 |
+
to use the features of this module.
|
| 31 |
+
|
| 32 |
+
Clang: The C and C++ compiler which is used to extract an AST from the provided
|
| 33 |
+
C source code.
|
| 34 |
+
|
| 35 |
+
References
|
| 36 |
+
==========
|
| 37 |
+
|
| 38 |
+
.. [1] https://github.com/sympy/sympy/issues
|
| 39 |
+
.. [2] https://clang.llvm.org/docs/
|
| 40 |
+
.. [3] https://clang.llvm.org/docs/IntroductionToTheClangAST.html
|
| 41 |
+
|
| 42 |
+
"""
|
| 43 |
+
|
| 44 |
+
if cin:
|
| 45 |
+
from sympy.codegen.ast import (Variable, Integer, Float,
|
| 46 |
+
FunctionPrototype, FunctionDefinition, FunctionCall,
|
| 47 |
+
none, Return, Assignment, intc, int8, int16, int64,
|
| 48 |
+
uint8, uint16, uint32, uint64, float32, float64, float80,
|
| 49 |
+
aug_assign, bool_, While, CodeBlock)
|
| 50 |
+
from sympy.codegen.cnodes import (PreDecrement, PostDecrement,
|
| 51 |
+
PreIncrement, PostIncrement)
|
| 52 |
+
from sympy.core import Add, Mod, Mul, Pow, Rel
|
| 53 |
+
from sympy.logic.boolalg import And, as_Boolean, Not, Or
|
| 54 |
+
from sympy.core.symbol import Symbol
|
| 55 |
+
from sympy.core.sympify import sympify
|
| 56 |
+
from sympy.logic.boolalg import (false, true)
|
| 57 |
+
import sys
|
| 58 |
+
import tempfile
|
| 59 |
+
|
| 60 |
+
class BaseParser:
|
| 61 |
+
"""Base Class for the C parser"""
|
| 62 |
+
|
| 63 |
+
def __init__(self):
|
| 64 |
+
"""Initializes the Base parser creating a Clang AST index"""
|
| 65 |
+
self.index = cin.Index.create()
|
| 66 |
+
|
| 67 |
+
def diagnostics(self, out):
|
| 68 |
+
"""Diagostics function for the Clang AST"""
|
| 69 |
+
for diag in self.tu.diagnostics:
|
| 70 |
+
# tu = translation unit
|
| 71 |
+
print('%s %s (line %s, col %s) %s' % (
|
| 72 |
+
{
|
| 73 |
+
4: 'FATAL',
|
| 74 |
+
3: 'ERROR',
|
| 75 |
+
2: 'WARNING',
|
| 76 |
+
1: 'NOTE',
|
| 77 |
+
0: 'IGNORED',
|
| 78 |
+
}[diag.severity],
|
| 79 |
+
diag.location.file,
|
| 80 |
+
diag.location.line,
|
| 81 |
+
diag.location.column,
|
| 82 |
+
diag.spelling
|
| 83 |
+
), file=out)
|
| 84 |
+
|
| 85 |
+
class CCodeConverter(BaseParser):
|
| 86 |
+
"""The Code Convereter for Clang AST
|
| 87 |
+
|
| 88 |
+
The converter object takes the C source code or file as input and
|
| 89 |
+
converts them to SymPy Expressions.
|
| 90 |
+
"""
|
| 91 |
+
|
| 92 |
+
def __init__(self):
|
| 93 |
+
"""Initializes the code converter"""
|
| 94 |
+
super().__init__()
|
| 95 |
+
self._py_nodes = []
|
| 96 |
+
self._data_types = {
|
| 97 |
+
"void": {
|
| 98 |
+
cin.TypeKind.VOID: none
|
| 99 |
+
},
|
| 100 |
+
"bool": {
|
| 101 |
+
cin.TypeKind.BOOL: bool_
|
| 102 |
+
},
|
| 103 |
+
"int": {
|
| 104 |
+
cin.TypeKind.SCHAR: int8,
|
| 105 |
+
cin.TypeKind.SHORT: int16,
|
| 106 |
+
cin.TypeKind.INT: intc,
|
| 107 |
+
cin.TypeKind.LONG: int64,
|
| 108 |
+
cin.TypeKind.UCHAR: uint8,
|
| 109 |
+
cin.TypeKind.USHORT: uint16,
|
| 110 |
+
cin.TypeKind.UINT: uint32,
|
| 111 |
+
cin.TypeKind.ULONG: uint64
|
| 112 |
+
},
|
| 113 |
+
"float": {
|
| 114 |
+
cin.TypeKind.FLOAT: float32,
|
| 115 |
+
cin.TypeKind.DOUBLE: float64,
|
| 116 |
+
cin.TypeKind.LONGDOUBLE: float80
|
| 117 |
+
}
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
def parse(self, filename, flags):
|
| 121 |
+
"""Function to parse a file with C source code
|
| 122 |
+
|
| 123 |
+
It takes the filename as an attribute and creates a Clang AST
|
| 124 |
+
Translation Unit parsing the file.
|
| 125 |
+
Then the transformation function is called on the translation unit,
|
| 126 |
+
whose results are collected into a list which is returned by the
|
| 127 |
+
function.
|
| 128 |
+
|
| 129 |
+
Parameters
|
| 130 |
+
==========
|
| 131 |
+
|
| 132 |
+
filename : string
|
| 133 |
+
Path to the C file to be parsed
|
| 134 |
+
|
| 135 |
+
flags: list
|
| 136 |
+
Arguments to be passed to Clang while parsing the C code
|
| 137 |
+
|
| 138 |
+
Returns
|
| 139 |
+
=======
|
| 140 |
+
|
| 141 |
+
py_nodes: list
|
| 142 |
+
A list of SymPy AST nodes
|
| 143 |
+
|
| 144 |
+
"""
|
| 145 |
+
filepath = os.path.abspath(filename)
|
| 146 |
+
self.tu = self.index.parse(
|
| 147 |
+
filepath,
|
| 148 |
+
args=flags,
|
| 149 |
+
options=cin.TranslationUnit.PARSE_DETAILED_PROCESSING_RECORD
|
| 150 |
+
)
|
| 151 |
+
for child in self.tu.cursor.get_children():
|
| 152 |
+
if child.kind == cin.CursorKind.VAR_DECL or child.kind == cin.CursorKind.FUNCTION_DECL:
|
| 153 |
+
self._py_nodes.append(self.transform(child))
|
| 154 |
+
return self._py_nodes
|
| 155 |
+
|
| 156 |
+
def parse_str(self, source, flags):
|
| 157 |
+
"""Function to parse a string with C source code
|
| 158 |
+
|
| 159 |
+
It takes the source code as an attribute, stores it in a temporary
|
| 160 |
+
file and creates a Clang AST Translation Unit parsing the file.
|
| 161 |
+
Then the transformation function is called on the translation unit,
|
| 162 |
+
whose results are collected into a list which is returned by the
|
| 163 |
+
function.
|
| 164 |
+
|
| 165 |
+
Parameters
|
| 166 |
+
==========
|
| 167 |
+
|
| 168 |
+
source : string
|
| 169 |
+
A string containing the C source code to be parsed
|
| 170 |
+
|
| 171 |
+
flags: list
|
| 172 |
+
Arguments to be passed to Clang while parsing the C code
|
| 173 |
+
|
| 174 |
+
Returns
|
| 175 |
+
=======
|
| 176 |
+
|
| 177 |
+
py_nodes: list
|
| 178 |
+
A list of SymPy AST nodes
|
| 179 |
+
|
| 180 |
+
"""
|
| 181 |
+
file = tempfile.NamedTemporaryFile(mode = 'w+', suffix = '.cpp')
|
| 182 |
+
file.write(source)
|
| 183 |
+
file.flush()
|
| 184 |
+
file.seek(0)
|
| 185 |
+
self.tu = self.index.parse(
|
| 186 |
+
file.name,
|
| 187 |
+
args=flags,
|
| 188 |
+
options=cin.TranslationUnit.PARSE_DETAILED_PROCESSING_RECORD
|
| 189 |
+
)
|
| 190 |
+
file.close()
|
| 191 |
+
for child in self.tu.cursor.get_children():
|
| 192 |
+
if child.kind == cin.CursorKind.VAR_DECL or child.kind == cin.CursorKind.FUNCTION_DECL:
|
| 193 |
+
self._py_nodes.append(self.transform(child))
|
| 194 |
+
return self._py_nodes
|
| 195 |
+
|
| 196 |
+
def transform(self, node):
|
| 197 |
+
"""Transformation Function for Clang AST nodes
|
| 198 |
+
|
| 199 |
+
It determines the kind of node and calls the respective
|
| 200 |
+
transformation function for that node.
|
| 201 |
+
|
| 202 |
+
Raises
|
| 203 |
+
======
|
| 204 |
+
|
| 205 |
+
NotImplementedError : if the transformation for the provided node
|
| 206 |
+
is not implemented
|
| 207 |
+
|
| 208 |
+
"""
|
| 209 |
+
handler = getattr(self, 'transform_%s' % node.kind.name.lower(), None)
|
| 210 |
+
|
| 211 |
+
if handler is None:
|
| 212 |
+
print(
|
| 213 |
+
"Ignoring node of type %s (%s)" % (
|
| 214 |
+
node.kind,
|
| 215 |
+
' '.join(
|
| 216 |
+
t.spelling for t in node.get_tokens())
|
| 217 |
+
),
|
| 218 |
+
file=sys.stderr
|
| 219 |
+
)
|
| 220 |
+
|
| 221 |
+
return handler(node)
|
| 222 |
+
|
| 223 |
+
def transform_var_decl(self, node):
|
| 224 |
+
"""Transformation Function for Variable Declaration
|
| 225 |
+
|
| 226 |
+
Used to create nodes for variable declarations and assignments with
|
| 227 |
+
values or function call for the respective nodes in the clang AST
|
| 228 |
+
|
| 229 |
+
Returns
|
| 230 |
+
=======
|
| 231 |
+
|
| 232 |
+
A variable node as Declaration, with the initial value if given
|
| 233 |
+
|
| 234 |
+
Raises
|
| 235 |
+
======
|
| 236 |
+
|
| 237 |
+
NotImplementedError : if called for data types not currently
|
| 238 |
+
implemented
|
| 239 |
+
|
| 240 |
+
Notes
|
| 241 |
+
=====
|
| 242 |
+
|
| 243 |
+
The function currently supports following data types:
|
| 244 |
+
|
| 245 |
+
Boolean:
|
| 246 |
+
bool, _Bool
|
| 247 |
+
|
| 248 |
+
Integer:
|
| 249 |
+
8-bit: signed char and unsigned char
|
| 250 |
+
16-bit: short, short int, signed short,
|
| 251 |
+
signed short int, unsigned short, unsigned short int
|
| 252 |
+
32-bit: int, signed int, unsigned int
|
| 253 |
+
64-bit: long, long int, signed long,
|
| 254 |
+
signed long int, unsigned long, unsigned long int
|
| 255 |
+
|
| 256 |
+
Floating point:
|
| 257 |
+
Single Precision: float
|
| 258 |
+
Double Precision: double
|
| 259 |
+
Extended Precision: long double
|
| 260 |
+
|
| 261 |
+
"""
|
| 262 |
+
if node.type.kind in self._data_types["int"]:
|
| 263 |
+
type = self._data_types["int"][node.type.kind]
|
| 264 |
+
elif node.type.kind in self._data_types["float"]:
|
| 265 |
+
type = self._data_types["float"][node.type.kind]
|
| 266 |
+
elif node.type.kind in self._data_types["bool"]:
|
| 267 |
+
type = self._data_types["bool"][node.type.kind]
|
| 268 |
+
else:
|
| 269 |
+
raise NotImplementedError("Only bool, int "
|
| 270 |
+
"and float are supported")
|
| 271 |
+
try:
|
| 272 |
+
children = node.get_children()
|
| 273 |
+
child = next(children)
|
| 274 |
+
|
| 275 |
+
#ignoring namespace and type details for the variable
|
| 276 |
+
while child.kind == cin.CursorKind.NAMESPACE_REF or child.kind == cin.CursorKind.TYPE_REF:
|
| 277 |
+
child = next(children)
|
| 278 |
+
|
| 279 |
+
val = self.transform(child)
|
| 280 |
+
|
| 281 |
+
supported_rhs = [
|
| 282 |
+
cin.CursorKind.INTEGER_LITERAL,
|
| 283 |
+
cin.CursorKind.FLOATING_LITERAL,
|
| 284 |
+
cin.CursorKind.UNEXPOSED_EXPR,
|
| 285 |
+
cin.CursorKind.BINARY_OPERATOR,
|
| 286 |
+
cin.CursorKind.PAREN_EXPR,
|
| 287 |
+
cin.CursorKind.UNARY_OPERATOR,
|
| 288 |
+
cin.CursorKind.CXX_BOOL_LITERAL_EXPR
|
| 289 |
+
]
|
| 290 |
+
|
| 291 |
+
if child.kind in supported_rhs:
|
| 292 |
+
if isinstance(val, str):
|
| 293 |
+
value = Symbol(val)
|
| 294 |
+
elif isinstance(val, bool):
|
| 295 |
+
if node.type.kind in self._data_types["int"]:
|
| 296 |
+
value = Integer(0) if val == False else Integer(1)
|
| 297 |
+
elif node.type.kind in self._data_types["float"]:
|
| 298 |
+
value = Float(0.0) if val == False else Float(1.0)
|
| 299 |
+
elif node.type.kind in self._data_types["bool"]:
|
| 300 |
+
value = sympify(val)
|
| 301 |
+
elif isinstance(val, (Integer, int, Float, float)):
|
| 302 |
+
if node.type.kind in self._data_types["int"]:
|
| 303 |
+
value = Integer(val)
|
| 304 |
+
elif node.type.kind in self._data_types["float"]:
|
| 305 |
+
value = Float(val)
|
| 306 |
+
elif node.type.kind in self._data_types["bool"]:
|
| 307 |
+
value = sympify(bool(val))
|
| 308 |
+
else:
|
| 309 |
+
value = val
|
| 310 |
+
|
| 311 |
+
return Variable(
|
| 312 |
+
node.spelling
|
| 313 |
+
).as_Declaration(
|
| 314 |
+
type = type,
|
| 315 |
+
value = value
|
| 316 |
+
)
|
| 317 |
+
|
| 318 |
+
elif child.kind == cin.CursorKind.CALL_EXPR:
|
| 319 |
+
return Variable(
|
| 320 |
+
node.spelling
|
| 321 |
+
).as_Declaration(
|
| 322 |
+
value = val
|
| 323 |
+
)
|
| 324 |
+
|
| 325 |
+
else:
|
| 326 |
+
raise NotImplementedError("Given "
|
| 327 |
+
"variable declaration \"{}\" "
|
| 328 |
+
"is not possible to parse yet!"
|
| 329 |
+
.format(" ".join(
|
| 330 |
+
t.spelling for t in node.get_tokens()
|
| 331 |
+
)
|
| 332 |
+
))
|
| 333 |
+
|
| 334 |
+
except StopIteration:
|
| 335 |
+
return Variable(
|
| 336 |
+
node.spelling
|
| 337 |
+
).as_Declaration(
|
| 338 |
+
type = type
|
| 339 |
+
)
|
| 340 |
+
|
| 341 |
+
def transform_function_decl(self, node):
|
| 342 |
+
"""Transformation Function For Function Declaration
|
| 343 |
+
|
| 344 |
+
Used to create nodes for function declarations and definitions for
|
| 345 |
+
the respective nodes in the clang AST
|
| 346 |
+
|
| 347 |
+
Returns
|
| 348 |
+
=======
|
| 349 |
+
|
| 350 |
+
function : Codegen AST node
|
| 351 |
+
- FunctionPrototype node if function body is not present
|
| 352 |
+
- FunctionDefinition node if the function body is present
|
| 353 |
+
|
| 354 |
+
|
| 355 |
+
"""
|
| 356 |
+
|
| 357 |
+
if node.result_type.kind in self._data_types["int"]:
|
| 358 |
+
ret_type = self._data_types["int"][node.result_type.kind]
|
| 359 |
+
elif node.result_type.kind in self._data_types["float"]:
|
| 360 |
+
ret_type = self._data_types["float"][node.result_type.kind]
|
| 361 |
+
elif node.result_type.kind in self._data_types["bool"]:
|
| 362 |
+
ret_type = self._data_types["bool"][node.result_type.kind]
|
| 363 |
+
elif node.result_type.kind in self._data_types["void"]:
|
| 364 |
+
ret_type = self._data_types["void"][node.result_type.kind]
|
| 365 |
+
else:
|
| 366 |
+
raise NotImplementedError("Only void, bool, int "
|
| 367 |
+
"and float are supported")
|
| 368 |
+
body = []
|
| 369 |
+
param = []
|
| 370 |
+
|
| 371 |
+
# Subsequent nodes will be the parameters for the function.
|
| 372 |
+
for child in node.get_children():
|
| 373 |
+
decl = self.transform(child)
|
| 374 |
+
if child.kind == cin.CursorKind.PARM_DECL:
|
| 375 |
+
param.append(decl)
|
| 376 |
+
elif child.kind == cin.CursorKind.COMPOUND_STMT:
|
| 377 |
+
for val in decl:
|
| 378 |
+
body.append(val)
|
| 379 |
+
else:
|
| 380 |
+
body.append(decl)
|
| 381 |
+
|
| 382 |
+
if body == []:
|
| 383 |
+
function = FunctionPrototype(
|
| 384 |
+
return_type = ret_type,
|
| 385 |
+
name = node.spelling,
|
| 386 |
+
parameters = param
|
| 387 |
+
)
|
| 388 |
+
else:
|
| 389 |
+
function = FunctionDefinition(
|
| 390 |
+
return_type = ret_type,
|
| 391 |
+
name = node.spelling,
|
| 392 |
+
parameters = param,
|
| 393 |
+
body = body
|
| 394 |
+
)
|
| 395 |
+
return function
|
| 396 |
+
|
| 397 |
+
def transform_parm_decl(self, node):
|
| 398 |
+
"""Transformation function for Parameter Declaration
|
| 399 |
+
|
| 400 |
+
Used to create parameter nodes for the required functions for the
|
| 401 |
+
respective nodes in the clang AST
|
| 402 |
+
|
| 403 |
+
Returns
|
| 404 |
+
=======
|
| 405 |
+
|
| 406 |
+
param : Codegen AST Node
|
| 407 |
+
Variable node with the value and type of the variable
|
| 408 |
+
|
| 409 |
+
Raises
|
| 410 |
+
======
|
| 411 |
+
|
| 412 |
+
ValueError if multiple children encountered in the parameter node
|
| 413 |
+
|
| 414 |
+
"""
|
| 415 |
+
if node.type.kind in self._data_types["int"]:
|
| 416 |
+
type = self._data_types["int"][node.type.kind]
|
| 417 |
+
elif node.type.kind in self._data_types["float"]:
|
| 418 |
+
type = self._data_types["float"][node.type.kind]
|
| 419 |
+
elif node.type.kind in self._data_types["bool"]:
|
| 420 |
+
type = self._data_types["bool"][node.type.kind]
|
| 421 |
+
else:
|
| 422 |
+
raise NotImplementedError("Only bool, int "
|
| 423 |
+
"and float are supported")
|
| 424 |
+
try:
|
| 425 |
+
children = node.get_children()
|
| 426 |
+
child = next(children)
|
| 427 |
+
|
| 428 |
+
# Any namespace nodes can be ignored
|
| 429 |
+
while child.kind in [cin.CursorKind.NAMESPACE_REF,
|
| 430 |
+
cin.CursorKind.TYPE_REF,
|
| 431 |
+
cin.CursorKind.TEMPLATE_REF]:
|
| 432 |
+
child = next(children)
|
| 433 |
+
|
| 434 |
+
# If there is a child, it is the default value of the parameter.
|
| 435 |
+
lit = self.transform(child)
|
| 436 |
+
if node.type.kind in self._data_types["int"]:
|
| 437 |
+
val = Integer(lit)
|
| 438 |
+
elif node.type.kind in self._data_types["float"]:
|
| 439 |
+
val = Float(lit)
|
| 440 |
+
elif node.type.kind in self._data_types["bool"]:
|
| 441 |
+
val = sympify(bool(lit))
|
| 442 |
+
else:
|
| 443 |
+
raise NotImplementedError("Only bool, int "
|
| 444 |
+
"and float are supported")
|
| 445 |
+
|
| 446 |
+
param = Variable(
|
| 447 |
+
node.spelling
|
| 448 |
+
).as_Declaration(
|
| 449 |
+
type = type,
|
| 450 |
+
value = val
|
| 451 |
+
)
|
| 452 |
+
except StopIteration:
|
| 453 |
+
param = Variable(
|
| 454 |
+
node.spelling
|
| 455 |
+
).as_Declaration(
|
| 456 |
+
type = type
|
| 457 |
+
)
|
| 458 |
+
|
| 459 |
+
try:
|
| 460 |
+
self.transform(next(children))
|
| 461 |
+
raise ValueError("Can't handle multiple children on parameter")
|
| 462 |
+
except StopIteration:
|
| 463 |
+
pass
|
| 464 |
+
|
| 465 |
+
return param
|
| 466 |
+
|
| 467 |
+
def transform_integer_literal(self, node):
|
| 468 |
+
"""Transformation function for integer literal
|
| 469 |
+
|
| 470 |
+
Used to get the value and type of the given integer literal.
|
| 471 |
+
|
| 472 |
+
Returns
|
| 473 |
+
=======
|
| 474 |
+
|
| 475 |
+
val : list
|
| 476 |
+
List with two arguments type and Value
|
| 477 |
+
type contains the type of the integer
|
| 478 |
+
value contains the value stored in the variable
|
| 479 |
+
|
| 480 |
+
Notes
|
| 481 |
+
=====
|
| 482 |
+
|
| 483 |
+
Only Base Integer type supported for now
|
| 484 |
+
|
| 485 |
+
"""
|
| 486 |
+
try:
|
| 487 |
+
value = next(node.get_tokens()).spelling
|
| 488 |
+
except StopIteration:
|
| 489 |
+
# No tokens
|
| 490 |
+
value = node.literal
|
| 491 |
+
return int(value)
|
| 492 |
+
|
| 493 |
+
def transform_floating_literal(self, node):
|
| 494 |
+
"""Transformation function for floating literal
|
| 495 |
+
|
| 496 |
+
Used to get the value and type of the given floating literal.
|
| 497 |
+
|
| 498 |
+
Returns
|
| 499 |
+
=======
|
| 500 |
+
|
| 501 |
+
val : list
|
| 502 |
+
List with two arguments type and Value
|
| 503 |
+
type contains the type of float
|
| 504 |
+
value contains the value stored in the variable
|
| 505 |
+
|
| 506 |
+
Notes
|
| 507 |
+
=====
|
| 508 |
+
|
| 509 |
+
Only Base Float type supported for now
|
| 510 |
+
|
| 511 |
+
"""
|
| 512 |
+
try:
|
| 513 |
+
value = next(node.get_tokens()).spelling
|
| 514 |
+
except (StopIteration, ValueError):
|
| 515 |
+
# No tokens
|
| 516 |
+
value = node.literal
|
| 517 |
+
return float(value)
|
| 518 |
+
|
| 519 |
+
def transform_string_literal(self, node):
|
| 520 |
+
#TODO: No string type in AST
|
| 521 |
+
#type =
|
| 522 |
+
#try:
|
| 523 |
+
# value = next(node.get_tokens()).spelling
|
| 524 |
+
#except (StopIteration, ValueError):
|
| 525 |
+
# No tokens
|
| 526 |
+
# value = node.literal
|
| 527 |
+
#val = [type, value]
|
| 528 |
+
#return val
|
| 529 |
+
pass
|
| 530 |
+
|
| 531 |
+
def transform_character_literal(self, node):
|
| 532 |
+
"""Transformation function for character literal
|
| 533 |
+
|
| 534 |
+
Used to get the value of the given character literal.
|
| 535 |
+
|
| 536 |
+
Returns
|
| 537 |
+
=======
|
| 538 |
+
|
| 539 |
+
val : int
|
| 540 |
+
val contains the ascii value of the character literal
|
| 541 |
+
|
| 542 |
+
Notes
|
| 543 |
+
=====
|
| 544 |
+
|
| 545 |
+
Only for cases where character is assigned to a integer value,
|
| 546 |
+
since character literal is not in SymPy AST
|
| 547 |
+
|
| 548 |
+
"""
|
| 549 |
+
try:
|
| 550 |
+
value = next(node.get_tokens()).spelling
|
| 551 |
+
except (StopIteration, ValueError):
|
| 552 |
+
# No tokens
|
| 553 |
+
value = node.literal
|
| 554 |
+
return ord(str(value[1]))
|
| 555 |
+
|
| 556 |
+
def transform_cxx_bool_literal_expr(self, node):
|
| 557 |
+
"""Transformation function for boolean literal
|
| 558 |
+
|
| 559 |
+
Used to get the value of the given boolean literal.
|
| 560 |
+
|
| 561 |
+
Returns
|
| 562 |
+
=======
|
| 563 |
+
|
| 564 |
+
value : bool
|
| 565 |
+
value contains the boolean value of the variable
|
| 566 |
+
|
| 567 |
+
"""
|
| 568 |
+
try:
|
| 569 |
+
value = next(node.get_tokens()).spelling
|
| 570 |
+
except (StopIteration, ValueError):
|
| 571 |
+
value = node.literal
|
| 572 |
+
return True if value == 'true' else False
|
| 573 |
+
|
| 574 |
+
def transform_unexposed_decl(self,node):
|
| 575 |
+
"""Transformation function for unexposed declarations"""
|
| 576 |
+
pass
|
| 577 |
+
|
| 578 |
+
def transform_unexposed_expr(self, node):
|
| 579 |
+
"""Transformation function for unexposed expression
|
| 580 |
+
|
| 581 |
+
Unexposed expressions are used to wrap float, double literals and
|
| 582 |
+
expressions
|
| 583 |
+
|
| 584 |
+
Returns
|
| 585 |
+
=======
|
| 586 |
+
|
| 587 |
+
expr : Codegen AST Node
|
| 588 |
+
the result from the wrapped expression
|
| 589 |
+
|
| 590 |
+
None : NoneType
|
| 591 |
+
No children are found for the node
|
| 592 |
+
|
| 593 |
+
Raises
|
| 594 |
+
======
|
| 595 |
+
|
| 596 |
+
ValueError if the expression contains multiple children
|
| 597 |
+
|
| 598 |
+
"""
|
| 599 |
+
# Ignore unexposed nodes; pass whatever is the first
|
| 600 |
+
# (and should be only) child unaltered.
|
| 601 |
+
try:
|
| 602 |
+
children = node.get_children()
|
| 603 |
+
expr = self.transform(next(children))
|
| 604 |
+
except StopIteration:
|
| 605 |
+
return None
|
| 606 |
+
|
| 607 |
+
try:
|
| 608 |
+
next(children)
|
| 609 |
+
raise ValueError("Unexposed expression has > 1 children.")
|
| 610 |
+
except StopIteration:
|
| 611 |
+
pass
|
| 612 |
+
|
| 613 |
+
return expr
|
| 614 |
+
|
| 615 |
+
def transform_decl_ref_expr(self, node):
|
| 616 |
+
"""Returns the name of the declaration reference"""
|
| 617 |
+
return node.spelling
|
| 618 |
+
|
| 619 |
+
def transform_call_expr(self, node):
|
| 620 |
+
"""Transformation function for a call expression
|
| 621 |
+
|
| 622 |
+
Used to create function call nodes for the function calls present
|
| 623 |
+
in the C code
|
| 624 |
+
|
| 625 |
+
Returns
|
| 626 |
+
=======
|
| 627 |
+
|
| 628 |
+
FunctionCall : Codegen AST Node
|
| 629 |
+
FunctionCall node with parameters if any parameters are present
|
| 630 |
+
|
| 631 |
+
"""
|
| 632 |
+
param = []
|
| 633 |
+
children = node.get_children()
|
| 634 |
+
child = next(children)
|
| 635 |
+
|
| 636 |
+
while child.kind == cin.CursorKind.NAMESPACE_REF:
|
| 637 |
+
child = next(children)
|
| 638 |
+
while child.kind == cin.CursorKind.TYPE_REF:
|
| 639 |
+
child = next(children)
|
| 640 |
+
|
| 641 |
+
first_child = self.transform(child)
|
| 642 |
+
try:
|
| 643 |
+
for child in children:
|
| 644 |
+
arg = self.transform(child)
|
| 645 |
+
if child.kind == cin.CursorKind.INTEGER_LITERAL:
|
| 646 |
+
param.append(Integer(arg))
|
| 647 |
+
elif child.kind == cin.CursorKind.FLOATING_LITERAL:
|
| 648 |
+
param.append(Float(arg))
|
| 649 |
+
else:
|
| 650 |
+
param.append(arg)
|
| 651 |
+
return FunctionCall(first_child, param)
|
| 652 |
+
|
| 653 |
+
except StopIteration:
|
| 654 |
+
return FunctionCall(first_child)
|
| 655 |
+
|
| 656 |
+
def transform_return_stmt(self, node):
|
| 657 |
+
"""Returns the Return Node for a return statement"""
|
| 658 |
+
return Return(next(node.get_children()).spelling)
|
| 659 |
+
|
| 660 |
+
def transform_compound_stmt(self, node):
|
| 661 |
+
"""Transformation function for compound statements
|
| 662 |
+
|
| 663 |
+
Returns
|
| 664 |
+
=======
|
| 665 |
+
|
| 666 |
+
expr : list
|
| 667 |
+
list of Nodes for the expressions present in the statement
|
| 668 |
+
|
| 669 |
+
None : NoneType
|
| 670 |
+
if the compound statement is empty
|
| 671 |
+
|
| 672 |
+
"""
|
| 673 |
+
expr = []
|
| 674 |
+
children = node.get_children()
|
| 675 |
+
|
| 676 |
+
for child in children:
|
| 677 |
+
expr.append(self.transform(child))
|
| 678 |
+
return expr
|
| 679 |
+
|
| 680 |
+
def transform_decl_stmt(self, node):
|
| 681 |
+
"""Transformation function for declaration statements
|
| 682 |
+
|
| 683 |
+
These statements are used to wrap different kinds of declararions
|
| 684 |
+
like variable or function declaration
|
| 685 |
+
The function calls the transformer function for the child of the
|
| 686 |
+
given node
|
| 687 |
+
|
| 688 |
+
Returns
|
| 689 |
+
=======
|
| 690 |
+
|
| 691 |
+
statement : Codegen AST Node
|
| 692 |
+
contains the node returned by the children node for the type of
|
| 693 |
+
declaration
|
| 694 |
+
|
| 695 |
+
Raises
|
| 696 |
+
======
|
| 697 |
+
|
| 698 |
+
ValueError if multiple children present
|
| 699 |
+
|
| 700 |
+
"""
|
| 701 |
+
try:
|
| 702 |
+
children = node.get_children()
|
| 703 |
+
statement = self.transform(next(children))
|
| 704 |
+
except StopIteration:
|
| 705 |
+
pass
|
| 706 |
+
|
| 707 |
+
try:
|
| 708 |
+
self.transform(next(children))
|
| 709 |
+
raise ValueError("Don't know how to handle multiple statements")
|
| 710 |
+
except StopIteration:
|
| 711 |
+
pass
|
| 712 |
+
|
| 713 |
+
return statement
|
| 714 |
+
|
| 715 |
+
def transform_paren_expr(self, node):
|
| 716 |
+
"""Transformation function for Parenthesized expressions
|
| 717 |
+
|
| 718 |
+
Returns the result from its children nodes
|
| 719 |
+
|
| 720 |
+
"""
|
| 721 |
+
return self.transform(next(node.get_children()))
|
| 722 |
+
|
| 723 |
+
def transform_compound_assignment_operator(self, node):
|
| 724 |
+
"""Transformation function for handling shorthand operators
|
| 725 |
+
|
| 726 |
+
Returns
|
| 727 |
+
=======
|
| 728 |
+
|
| 729 |
+
augmented_assignment_expression: Codegen AST node
|
| 730 |
+
shorthand assignment expression represented as Codegen AST
|
| 731 |
+
|
| 732 |
+
Raises
|
| 733 |
+
======
|
| 734 |
+
|
| 735 |
+
NotImplementedError
|
| 736 |
+
If the shorthand operator for bitwise operators
|
| 737 |
+
(~=, ^=, &=, |=, <<=, >>=) is encountered
|
| 738 |
+
|
| 739 |
+
"""
|
| 740 |
+
return self.transform_binary_operator(node)
|
| 741 |
+
|
| 742 |
+
def transform_unary_operator(self, node):
|
| 743 |
+
"""Transformation function for handling unary operators
|
| 744 |
+
|
| 745 |
+
Returns
|
| 746 |
+
=======
|
| 747 |
+
|
| 748 |
+
unary_expression: Codegen AST node
|
| 749 |
+
simplified unary expression represented as Codegen AST
|
| 750 |
+
|
| 751 |
+
Raises
|
| 752 |
+
======
|
| 753 |
+
|
| 754 |
+
NotImplementedError
|
| 755 |
+
If dereferencing operator(*), address operator(&) or
|
| 756 |
+
bitwise NOT operator(~) is encountered
|
| 757 |
+
|
| 758 |
+
"""
|
| 759 |
+
# supported operators list
|
| 760 |
+
operators_list = ['+', '-', '++', '--', '!']
|
| 761 |
+
tokens = list(node.get_tokens())
|
| 762 |
+
|
| 763 |
+
# it can be either pre increment/decrement or any other operator from the list
|
| 764 |
+
if tokens[0].spelling in operators_list:
|
| 765 |
+
child = self.transform(next(node.get_children()))
|
| 766 |
+
# (decl_ref) e.g.; int a = ++b; or simply ++b;
|
| 767 |
+
if isinstance(child, str):
|
| 768 |
+
if tokens[0].spelling == '+':
|
| 769 |
+
return Symbol(child)
|
| 770 |
+
if tokens[0].spelling == '-':
|
| 771 |
+
return Mul(Symbol(child), -1)
|
| 772 |
+
if tokens[0].spelling == '++':
|
| 773 |
+
return PreIncrement(Symbol(child))
|
| 774 |
+
if tokens[0].spelling == '--':
|
| 775 |
+
return PreDecrement(Symbol(child))
|
| 776 |
+
if tokens[0].spelling == '!':
|
| 777 |
+
return Not(Symbol(child))
|
| 778 |
+
# e.g.; int a = -1; or int b = -(1 + 2);
|
| 779 |
+
else:
|
| 780 |
+
if tokens[0].spelling == '+':
|
| 781 |
+
return child
|
| 782 |
+
if tokens[0].spelling == '-':
|
| 783 |
+
return Mul(child, -1)
|
| 784 |
+
if tokens[0].spelling == '!':
|
| 785 |
+
return Not(sympify(bool(child)))
|
| 786 |
+
|
| 787 |
+
# it can be either post increment/decrement
|
| 788 |
+
# since variable name is obtained in token[0].spelling
|
| 789 |
+
elif tokens[1].spelling in ['++', '--']:
|
| 790 |
+
child = self.transform(next(node.get_children()))
|
| 791 |
+
if tokens[1].spelling == '++':
|
| 792 |
+
return PostIncrement(Symbol(child))
|
| 793 |
+
if tokens[1].spelling == '--':
|
| 794 |
+
return PostDecrement(Symbol(child))
|
| 795 |
+
else:
|
| 796 |
+
raise NotImplementedError("Dereferencing operator, "
|
| 797 |
+
"Address operator and bitwise NOT operator "
|
| 798 |
+
"have not been implemented yet!")
|
| 799 |
+
|
| 800 |
+
def transform_binary_operator(self, node):
|
| 801 |
+
"""Transformation function for handling binary operators
|
| 802 |
+
|
| 803 |
+
Returns
|
| 804 |
+
=======
|
| 805 |
+
|
| 806 |
+
binary_expression: Codegen AST node
|
| 807 |
+
simplified binary expression represented as Codegen AST
|
| 808 |
+
|
| 809 |
+
Raises
|
| 810 |
+
======
|
| 811 |
+
|
| 812 |
+
NotImplementedError
|
| 813 |
+
If a bitwise operator or
|
| 814 |
+
unary operator(which is a child of any binary
|
| 815 |
+
operator in Clang AST) is encountered
|
| 816 |
+
|
| 817 |
+
"""
|
| 818 |
+
# get all the tokens of assignment
|
| 819 |
+
# and store it in the tokens list
|
| 820 |
+
tokens = list(node.get_tokens())
|
| 821 |
+
|
| 822 |
+
# supported operators list
|
| 823 |
+
operators_list = ['+', '-', '*', '/', '%','=',
|
| 824 |
+
'>', '>=', '<', '<=', '==', '!=', '&&', '||', '+=', '-=',
|
| 825 |
+
'*=', '/=', '%=']
|
| 826 |
+
|
| 827 |
+
# this stack will contain variable content
|
| 828 |
+
# and type of variable in the rhs
|
| 829 |
+
combined_variables_stack = []
|
| 830 |
+
|
| 831 |
+
# this stack will contain operators
|
| 832 |
+
# to be processed in the rhs
|
| 833 |
+
operators_stack = []
|
| 834 |
+
|
| 835 |
+
# iterate through every token
|
| 836 |
+
for token in tokens:
|
| 837 |
+
# token is either '(', ')' or
|
| 838 |
+
# any of the supported operators from the operator list
|
| 839 |
+
if token.kind == cin.TokenKind.PUNCTUATION:
|
| 840 |
+
|
| 841 |
+
# push '(' to the operators stack
|
| 842 |
+
if token.spelling == '(':
|
| 843 |
+
operators_stack.append('(')
|
| 844 |
+
|
| 845 |
+
elif token.spelling == ')':
|
| 846 |
+
# keep adding the expression to the
|
| 847 |
+
# combined variables stack unless
|
| 848 |
+
# '(' is found
|
| 849 |
+
while (operators_stack
|
| 850 |
+
and operators_stack[-1] != '('):
|
| 851 |
+
if len(combined_variables_stack) < 2:
|
| 852 |
+
raise NotImplementedError(
|
| 853 |
+
"Unary operators as a part of "
|
| 854 |
+
"binary operators is not "
|
| 855 |
+
"supported yet!")
|
| 856 |
+
rhs = combined_variables_stack.pop()
|
| 857 |
+
lhs = combined_variables_stack.pop()
|
| 858 |
+
operator = operators_stack.pop()
|
| 859 |
+
combined_variables_stack.append(
|
| 860 |
+
self.perform_operation(
|
| 861 |
+
lhs, rhs, operator))
|
| 862 |
+
|
| 863 |
+
# pop '('
|
| 864 |
+
operators_stack.pop()
|
| 865 |
+
|
| 866 |
+
# token is an operator (supported)
|
| 867 |
+
elif token.spelling in operators_list:
|
| 868 |
+
while (operators_stack
|
| 869 |
+
and self.priority_of(token.spelling)
|
| 870 |
+
<= self.priority_of(
|
| 871 |
+
operators_stack[-1])):
|
| 872 |
+
if len(combined_variables_stack) < 2:
|
| 873 |
+
raise NotImplementedError(
|
| 874 |
+
"Unary operators as a part of "
|
| 875 |
+
"binary operators is not "
|
| 876 |
+
"supported yet!")
|
| 877 |
+
rhs = combined_variables_stack.pop()
|
| 878 |
+
lhs = combined_variables_stack.pop()
|
| 879 |
+
operator = operators_stack.pop()
|
| 880 |
+
combined_variables_stack.append(
|
| 881 |
+
self.perform_operation(
|
| 882 |
+
lhs, rhs, operator))
|
| 883 |
+
|
| 884 |
+
# push current operator
|
| 885 |
+
operators_stack.append(token.spelling)
|
| 886 |
+
|
| 887 |
+
# token is a bitwise operator
|
| 888 |
+
elif token.spelling in ['&', '|', '^', '<<', '>>']:
|
| 889 |
+
raise NotImplementedError(
|
| 890 |
+
"Bitwise operator has not been "
|
| 891 |
+
"implemented yet!")
|
| 892 |
+
|
| 893 |
+
# token is a shorthand bitwise operator
|
| 894 |
+
elif token.spelling in ['&=', '|=', '^=', '<<=',
|
| 895 |
+
'>>=']:
|
| 896 |
+
raise NotImplementedError(
|
| 897 |
+
"Shorthand bitwise operator has not been "
|
| 898 |
+
"implemented yet!")
|
| 899 |
+
else:
|
| 900 |
+
raise NotImplementedError(
|
| 901 |
+
"Given token {} is not implemented yet!"
|
| 902 |
+
.format(token.spelling))
|
| 903 |
+
|
| 904 |
+
# token is an identifier(variable)
|
| 905 |
+
elif token.kind == cin.TokenKind.IDENTIFIER:
|
| 906 |
+
combined_variables_stack.append(
|
| 907 |
+
[token.spelling, 'identifier'])
|
| 908 |
+
|
| 909 |
+
# token is a literal
|
| 910 |
+
elif token.kind == cin.TokenKind.LITERAL:
|
| 911 |
+
combined_variables_stack.append(
|
| 912 |
+
[token.spelling, 'literal'])
|
| 913 |
+
|
| 914 |
+
# token is a keyword, either true or false
|
| 915 |
+
elif (token.kind == cin.TokenKind.KEYWORD
|
| 916 |
+
and token.spelling in ['true', 'false']):
|
| 917 |
+
combined_variables_stack.append(
|
| 918 |
+
[token.spelling, 'boolean'])
|
| 919 |
+
else:
|
| 920 |
+
raise NotImplementedError(
|
| 921 |
+
"Given token {} is not implemented yet!"
|
| 922 |
+
.format(token.spelling))
|
| 923 |
+
|
| 924 |
+
# process remaining operators
|
| 925 |
+
while operators_stack:
|
| 926 |
+
if len(combined_variables_stack) < 2:
|
| 927 |
+
raise NotImplementedError(
|
| 928 |
+
"Unary operators as a part of "
|
| 929 |
+
"binary operators is not "
|
| 930 |
+
"supported yet!")
|
| 931 |
+
rhs = combined_variables_stack.pop()
|
| 932 |
+
lhs = combined_variables_stack.pop()
|
| 933 |
+
operator = operators_stack.pop()
|
| 934 |
+
combined_variables_stack.append(
|
| 935 |
+
self.perform_operation(lhs, rhs, operator))
|
| 936 |
+
|
| 937 |
+
return combined_variables_stack[-1][0]
|
| 938 |
+
|
| 939 |
+
def priority_of(self, op):
|
| 940 |
+
"""To get the priority of given operator"""
|
| 941 |
+
if op in ['=', '+=', '-=', '*=', '/=', '%=']:
|
| 942 |
+
return 1
|
| 943 |
+
if op in ['&&', '||']:
|
| 944 |
+
return 2
|
| 945 |
+
if op in ['<', '<=', '>', '>=', '==', '!=']:
|
| 946 |
+
return 3
|
| 947 |
+
if op in ['+', '-']:
|
| 948 |
+
return 4
|
| 949 |
+
if op in ['*', '/', '%']:
|
| 950 |
+
return 5
|
| 951 |
+
return 0
|
| 952 |
+
|
| 953 |
+
def perform_operation(self, lhs, rhs, op):
|
| 954 |
+
"""Performs operation supported by the SymPy core
|
| 955 |
+
|
| 956 |
+
Returns
|
| 957 |
+
=======
|
| 958 |
+
|
| 959 |
+
combined_variable: list
|
| 960 |
+
contains variable content and type of variable
|
| 961 |
+
|
| 962 |
+
"""
|
| 963 |
+
lhs_value = self.get_expr_for_operand(lhs)
|
| 964 |
+
rhs_value = self.get_expr_for_operand(rhs)
|
| 965 |
+
if op == '+':
|
| 966 |
+
return [Add(lhs_value, rhs_value), 'expr']
|
| 967 |
+
if op == '-':
|
| 968 |
+
return [Add(lhs_value, -rhs_value), 'expr']
|
| 969 |
+
if op == '*':
|
| 970 |
+
return [Mul(lhs_value, rhs_value), 'expr']
|
| 971 |
+
if op == '/':
|
| 972 |
+
return [Mul(lhs_value, Pow(rhs_value, Integer(-1))), 'expr']
|
| 973 |
+
if op == '%':
|
| 974 |
+
return [Mod(lhs_value, rhs_value), 'expr']
|
| 975 |
+
if op in ['<', '<=', '>', '>=', '==', '!=']:
|
| 976 |
+
return [Rel(lhs_value, rhs_value, op), 'expr']
|
| 977 |
+
if op == '&&':
|
| 978 |
+
return [And(as_Boolean(lhs_value), as_Boolean(rhs_value)), 'expr']
|
| 979 |
+
if op == '||':
|
| 980 |
+
return [Or(as_Boolean(lhs_value), as_Boolean(rhs_value)), 'expr']
|
| 981 |
+
if op == '=':
|
| 982 |
+
return [Assignment(Variable(lhs_value), rhs_value), 'expr']
|
| 983 |
+
if op in ['+=', '-=', '*=', '/=', '%=']:
|
| 984 |
+
return [aug_assign(Variable(lhs_value), op[0], rhs_value), 'expr']
|
| 985 |
+
|
| 986 |
+
def get_expr_for_operand(self, combined_variable):
|
| 987 |
+
"""Gives out SymPy Codegen AST node
|
| 988 |
+
|
| 989 |
+
AST node returned is corresponding to
|
| 990 |
+
combined variable passed.Combined variable contains
|
| 991 |
+
variable content and type of variable
|
| 992 |
+
|
| 993 |
+
"""
|
| 994 |
+
if combined_variable[1] == 'identifier':
|
| 995 |
+
return Symbol(combined_variable[0])
|
| 996 |
+
if combined_variable[1] == 'literal':
|
| 997 |
+
if '.' in combined_variable[0]:
|
| 998 |
+
return Float(float(combined_variable[0]))
|
| 999 |
+
else:
|
| 1000 |
+
return Integer(int(combined_variable[0]))
|
| 1001 |
+
if combined_variable[1] == 'expr':
|
| 1002 |
+
return combined_variable[0]
|
| 1003 |
+
if combined_variable[1] == 'boolean':
|
| 1004 |
+
return true if combined_variable[0] == 'true' else false
|
| 1005 |
+
|
| 1006 |
+
def transform_null_stmt(self, node):
|
| 1007 |
+
"""Handles Null Statement and returns None"""
|
| 1008 |
+
return none
|
| 1009 |
+
|
| 1010 |
+
def transform_while_stmt(self, node):
|
| 1011 |
+
"""Transformation function for handling while statement
|
| 1012 |
+
|
| 1013 |
+
Returns
|
| 1014 |
+
=======
|
| 1015 |
+
|
| 1016 |
+
while statement : Codegen AST Node
|
| 1017 |
+
contains the while statement node having condition and
|
| 1018 |
+
statement block
|
| 1019 |
+
|
| 1020 |
+
"""
|
| 1021 |
+
children = node.get_children()
|
| 1022 |
+
|
| 1023 |
+
condition = self.transform(next(children))
|
| 1024 |
+
statements = self.transform(next(children))
|
| 1025 |
+
|
| 1026 |
+
if isinstance(statements, list):
|
| 1027 |
+
statement_block = CodeBlock(*statements)
|
| 1028 |
+
else:
|
| 1029 |
+
statement_block = CodeBlock(statements)
|
| 1030 |
+
|
| 1031 |
+
return While(condition, statement_block)
|
| 1032 |
+
|
| 1033 |
+
|
| 1034 |
+
|
| 1035 |
+
else:
|
| 1036 |
+
class CCodeConverter(): # type: ignore
|
| 1037 |
+
def __init__(self, *args, **kwargs):
|
| 1038 |
+
raise ImportError("Module not Installed")
|
| 1039 |
+
|
| 1040 |
+
|
| 1041 |
+
def parse_c(source):
|
| 1042 |
+
"""Function for converting a C source code
|
| 1043 |
+
|
| 1044 |
+
The function reads the source code present in the given file and parses it
|
| 1045 |
+
to give out SymPy Expressions
|
| 1046 |
+
|
| 1047 |
+
Returns
|
| 1048 |
+
=======
|
| 1049 |
+
|
| 1050 |
+
src : list
|
| 1051 |
+
List of Python expression strings
|
| 1052 |
+
|
| 1053 |
+
"""
|
| 1054 |
+
converter = CCodeConverter()
|
| 1055 |
+
if os.path.exists(source):
|
| 1056 |
+
src = converter.parse(source, flags = [])
|
| 1057 |
+
else:
|
| 1058 |
+
src = converter.parse_str(source, flags = [])
|
| 1059 |
+
return src
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/fortran/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Used for translating Fortran source code into a SymPy expression. """
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/fortran/fortran_parser.py
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sympy.external import import_module
|
| 2 |
+
|
| 3 |
+
lfortran = import_module('lfortran')
|
| 4 |
+
|
| 5 |
+
if lfortran:
|
| 6 |
+
from sympy.codegen.ast import (Variable, IntBaseType, FloatBaseType, String,
|
| 7 |
+
Return, FunctionDefinition, Assignment)
|
| 8 |
+
from sympy.core import Add, Mul, Integer, Float
|
| 9 |
+
from sympy.core.symbol import Symbol
|
| 10 |
+
|
| 11 |
+
asr_mod = lfortran.asr
|
| 12 |
+
asr = lfortran.asr.asr
|
| 13 |
+
src_to_ast = lfortran.ast.src_to_ast
|
| 14 |
+
ast_to_asr = lfortran.semantic.ast_to_asr.ast_to_asr
|
| 15 |
+
|
| 16 |
+
"""
|
| 17 |
+
This module contains all the necessary Classes and Function used to Parse
|
| 18 |
+
Fortran code into SymPy expression
|
| 19 |
+
|
| 20 |
+
The module and its API are currently under development and experimental.
|
| 21 |
+
It is also dependent on LFortran for the ASR that is converted to SymPy syntax
|
| 22 |
+
which is also under development.
|
| 23 |
+
The module only supports the features currently supported by the LFortran ASR
|
| 24 |
+
which will be updated as the development of LFortran and this module progresses
|
| 25 |
+
|
| 26 |
+
You might find unexpected bugs and exceptions while using the module, feel free
|
| 27 |
+
to report them to the SymPy Issue Tracker
|
| 28 |
+
|
| 29 |
+
The API for the module might also change while in development if better and
|
| 30 |
+
more effective ways are discovered for the process
|
| 31 |
+
|
| 32 |
+
Features Supported
|
| 33 |
+
==================
|
| 34 |
+
|
| 35 |
+
- Variable Declarations (integers and reals)
|
| 36 |
+
- Function Definitions
|
| 37 |
+
- Assignments and Basic Binary Operations
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
Notes
|
| 41 |
+
=====
|
| 42 |
+
|
| 43 |
+
The module depends on an external dependency
|
| 44 |
+
|
| 45 |
+
LFortran : Required to parse Fortran source code into ASR
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
References
|
| 49 |
+
==========
|
| 50 |
+
|
| 51 |
+
.. [1] https://github.com/sympy/sympy/issues
|
| 52 |
+
.. [2] https://gitlab.com/lfortran/lfortran
|
| 53 |
+
.. [3] https://docs.lfortran.org/
|
| 54 |
+
|
| 55 |
+
"""
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
class ASR2PyVisitor(asr.ASTVisitor): # type: ignore
|
| 59 |
+
"""
|
| 60 |
+
Visitor Class for LFortran ASR
|
| 61 |
+
|
| 62 |
+
It is a Visitor class derived from asr.ASRVisitor which visits all the
|
| 63 |
+
nodes of the LFortran ASR and creates corresponding AST node for each
|
| 64 |
+
ASR node
|
| 65 |
+
|
| 66 |
+
"""
|
| 67 |
+
|
| 68 |
+
def __init__(self):
|
| 69 |
+
"""Initialize the Parser"""
|
| 70 |
+
self._py_ast = []
|
| 71 |
+
|
| 72 |
+
def visit_TranslationUnit(self, node):
|
| 73 |
+
"""
|
| 74 |
+
Function to visit all the elements of the Translation Unit
|
| 75 |
+
created by LFortran ASR
|
| 76 |
+
"""
|
| 77 |
+
for s in node.global_scope.symbols:
|
| 78 |
+
sym = node.global_scope.symbols[s]
|
| 79 |
+
self.visit(sym)
|
| 80 |
+
for item in node.items:
|
| 81 |
+
self.visit(item)
|
| 82 |
+
|
| 83 |
+
def visit_Assignment(self, node):
|
| 84 |
+
"""Visitor Function for Assignment
|
| 85 |
+
|
| 86 |
+
Visits each Assignment is the LFortran ASR and creates corresponding
|
| 87 |
+
assignment for SymPy.
|
| 88 |
+
|
| 89 |
+
Notes
|
| 90 |
+
=====
|
| 91 |
+
|
| 92 |
+
The function currently only supports variable assignment and binary
|
| 93 |
+
operation assignments of varying multitudes. Any type of numberS or
|
| 94 |
+
array is not supported.
|
| 95 |
+
|
| 96 |
+
Raises
|
| 97 |
+
======
|
| 98 |
+
|
| 99 |
+
NotImplementedError() when called for Numeric assignments or Arrays
|
| 100 |
+
|
| 101 |
+
"""
|
| 102 |
+
# TODO: Arithmetic Assignment
|
| 103 |
+
if isinstance(node.target, asr.Variable):
|
| 104 |
+
target = node.target
|
| 105 |
+
value = node.value
|
| 106 |
+
if isinstance(value, asr.Variable):
|
| 107 |
+
new_node = Assignment(
|
| 108 |
+
Variable(
|
| 109 |
+
target.name
|
| 110 |
+
),
|
| 111 |
+
Variable(
|
| 112 |
+
value.name
|
| 113 |
+
)
|
| 114 |
+
)
|
| 115 |
+
elif (type(value) == asr.BinOp):
|
| 116 |
+
exp_ast = call_visitor(value)
|
| 117 |
+
for expr in exp_ast:
|
| 118 |
+
new_node = Assignment(
|
| 119 |
+
Variable(target.name),
|
| 120 |
+
expr
|
| 121 |
+
)
|
| 122 |
+
else:
|
| 123 |
+
raise NotImplementedError("Numeric assignments not supported")
|
| 124 |
+
else:
|
| 125 |
+
raise NotImplementedError("Arrays not supported")
|
| 126 |
+
self._py_ast.append(new_node)
|
| 127 |
+
|
| 128 |
+
def visit_BinOp(self, node):
|
| 129 |
+
"""Visitor Function for Binary Operations
|
| 130 |
+
|
| 131 |
+
Visits each binary operation present in the LFortran ASR like addition,
|
| 132 |
+
subtraction, multiplication, division and creates the corresponding
|
| 133 |
+
operation node in SymPy's AST
|
| 134 |
+
|
| 135 |
+
In case of more than one binary operations, the function calls the
|
| 136 |
+
call_visitor() function on the child nodes of the binary operations
|
| 137 |
+
recursively until all the operations have been processed.
|
| 138 |
+
|
| 139 |
+
Notes
|
| 140 |
+
=====
|
| 141 |
+
|
| 142 |
+
The function currently only supports binary operations with Variables
|
| 143 |
+
or other binary operations. Numerics are not supported as of yet.
|
| 144 |
+
|
| 145 |
+
Raises
|
| 146 |
+
======
|
| 147 |
+
|
| 148 |
+
NotImplementedError() when called for Numeric assignments
|
| 149 |
+
|
| 150 |
+
"""
|
| 151 |
+
# TODO: Integer Binary Operations
|
| 152 |
+
op = node.op
|
| 153 |
+
lhs = node.left
|
| 154 |
+
rhs = node.right
|
| 155 |
+
|
| 156 |
+
if (type(lhs) == asr.Variable):
|
| 157 |
+
left_value = Symbol(lhs.name)
|
| 158 |
+
elif(type(lhs) == asr.BinOp):
|
| 159 |
+
l_exp_ast = call_visitor(lhs)
|
| 160 |
+
for exp in l_exp_ast:
|
| 161 |
+
left_value = exp
|
| 162 |
+
else:
|
| 163 |
+
raise NotImplementedError("Numbers Currently not supported")
|
| 164 |
+
|
| 165 |
+
if (type(rhs) == asr.Variable):
|
| 166 |
+
right_value = Symbol(rhs.name)
|
| 167 |
+
elif(type(rhs) == asr.BinOp):
|
| 168 |
+
r_exp_ast = call_visitor(rhs)
|
| 169 |
+
for exp in r_exp_ast:
|
| 170 |
+
right_value = exp
|
| 171 |
+
else:
|
| 172 |
+
raise NotImplementedError("Numbers Currently not supported")
|
| 173 |
+
|
| 174 |
+
if isinstance(op, asr.Add):
|
| 175 |
+
new_node = Add(left_value, right_value)
|
| 176 |
+
elif isinstance(op, asr.Sub):
|
| 177 |
+
new_node = Add(left_value, -right_value)
|
| 178 |
+
elif isinstance(op, asr.Div):
|
| 179 |
+
new_node = Mul(left_value, 1/right_value)
|
| 180 |
+
elif isinstance(op, asr.Mul):
|
| 181 |
+
new_node = Mul(left_value, right_value)
|
| 182 |
+
|
| 183 |
+
self._py_ast.append(new_node)
|
| 184 |
+
|
| 185 |
+
def visit_Variable(self, node):
|
| 186 |
+
"""Visitor Function for Variable Declaration
|
| 187 |
+
|
| 188 |
+
Visits each variable declaration present in the ASR and creates a
|
| 189 |
+
Symbol declaration for each variable
|
| 190 |
+
|
| 191 |
+
Notes
|
| 192 |
+
=====
|
| 193 |
+
|
| 194 |
+
The functions currently only support declaration of integer and
|
| 195 |
+
real variables. Other data types are still under development.
|
| 196 |
+
|
| 197 |
+
Raises
|
| 198 |
+
======
|
| 199 |
+
|
| 200 |
+
NotImplementedError() when called for unsupported data types
|
| 201 |
+
|
| 202 |
+
"""
|
| 203 |
+
if isinstance(node.type, asr.Integer):
|
| 204 |
+
var_type = IntBaseType(String('integer'))
|
| 205 |
+
value = Integer(0)
|
| 206 |
+
elif isinstance(node.type, asr.Real):
|
| 207 |
+
var_type = FloatBaseType(String('real'))
|
| 208 |
+
value = Float(0.0)
|
| 209 |
+
else:
|
| 210 |
+
raise NotImplementedError("Data type not supported")
|
| 211 |
+
|
| 212 |
+
if not (node.intent == 'in'):
|
| 213 |
+
new_node = Variable(
|
| 214 |
+
node.name
|
| 215 |
+
).as_Declaration(
|
| 216 |
+
type = var_type,
|
| 217 |
+
value = value
|
| 218 |
+
)
|
| 219 |
+
self._py_ast.append(new_node)
|
| 220 |
+
|
| 221 |
+
def visit_Sequence(self, seq):
|
| 222 |
+
"""Visitor Function for code sequence
|
| 223 |
+
|
| 224 |
+
Visits a code sequence/ block and calls the visitor function on all the
|
| 225 |
+
children of the code block to create corresponding code in python
|
| 226 |
+
|
| 227 |
+
"""
|
| 228 |
+
if seq is not None:
|
| 229 |
+
for node in seq:
|
| 230 |
+
self._py_ast.append(call_visitor(node))
|
| 231 |
+
|
| 232 |
+
def visit_Num(self, node):
|
| 233 |
+
"""Visitor Function for Numbers in ASR
|
| 234 |
+
|
| 235 |
+
This function is currently under development and will be updated
|
| 236 |
+
with improvements in the LFortran ASR
|
| 237 |
+
|
| 238 |
+
"""
|
| 239 |
+
# TODO:Numbers when the LFortran ASR is updated
|
| 240 |
+
# self._py_ast.append(Integer(node.n))
|
| 241 |
+
pass
|
| 242 |
+
|
| 243 |
+
def visit_Function(self, node):
|
| 244 |
+
"""Visitor Function for function Definitions
|
| 245 |
+
|
| 246 |
+
Visits each function definition present in the ASR and creates a
|
| 247 |
+
function definition node in the Python AST with all the elements of the
|
| 248 |
+
given function
|
| 249 |
+
|
| 250 |
+
The functions declare all the variables required as SymPy symbols in
|
| 251 |
+
the function before the function definition
|
| 252 |
+
|
| 253 |
+
This function also the call_visior_function to parse the contents of
|
| 254 |
+
the function body
|
| 255 |
+
|
| 256 |
+
"""
|
| 257 |
+
# TODO: Return statement, variable declaration
|
| 258 |
+
fn_args = [Variable(arg_iter.name) for arg_iter in node.args]
|
| 259 |
+
fn_body = []
|
| 260 |
+
fn_name = node.name
|
| 261 |
+
for i in node.body:
|
| 262 |
+
fn_ast = call_visitor(i)
|
| 263 |
+
try:
|
| 264 |
+
fn_body_expr = fn_ast
|
| 265 |
+
except UnboundLocalError:
|
| 266 |
+
fn_body_expr = []
|
| 267 |
+
for sym in node.symtab.symbols:
|
| 268 |
+
decl = call_visitor(node.symtab.symbols[sym])
|
| 269 |
+
for symbols in decl:
|
| 270 |
+
fn_body.append(symbols)
|
| 271 |
+
for elem in fn_body_expr:
|
| 272 |
+
fn_body.append(elem)
|
| 273 |
+
fn_body.append(
|
| 274 |
+
Return(
|
| 275 |
+
Variable(
|
| 276 |
+
node.return_var.name
|
| 277 |
+
)
|
| 278 |
+
)
|
| 279 |
+
)
|
| 280 |
+
if isinstance(node.return_var.type, asr.Integer):
|
| 281 |
+
ret_type = IntBaseType(String('integer'))
|
| 282 |
+
elif isinstance(node.return_var.type, asr.Real):
|
| 283 |
+
ret_type = FloatBaseType(String('real'))
|
| 284 |
+
else:
|
| 285 |
+
raise NotImplementedError("Data type not supported")
|
| 286 |
+
new_node = FunctionDefinition(
|
| 287 |
+
return_type = ret_type,
|
| 288 |
+
name = fn_name,
|
| 289 |
+
parameters = fn_args,
|
| 290 |
+
body = fn_body
|
| 291 |
+
)
|
| 292 |
+
self._py_ast.append(new_node)
|
| 293 |
+
|
| 294 |
+
def ret_ast(self):
|
| 295 |
+
"""Returns the AST nodes"""
|
| 296 |
+
return self._py_ast
|
| 297 |
+
else:
|
| 298 |
+
class ASR2PyVisitor(): # type: ignore
|
| 299 |
+
def __init__(self, *args, **kwargs):
|
| 300 |
+
raise ImportError('lfortran not available')
|
| 301 |
+
|
| 302 |
+
def call_visitor(fort_node):
|
| 303 |
+
"""Calls the AST Visitor on the Module
|
| 304 |
+
|
| 305 |
+
This function is used to call the AST visitor for a program or module
|
| 306 |
+
It imports all the required modules and calls the visit() function
|
| 307 |
+
on the given node
|
| 308 |
+
|
| 309 |
+
Parameters
|
| 310 |
+
==========
|
| 311 |
+
|
| 312 |
+
fort_node : LFortran ASR object
|
| 313 |
+
Node for the operation for which the NodeVisitor is called
|
| 314 |
+
|
| 315 |
+
Returns
|
| 316 |
+
=======
|
| 317 |
+
|
| 318 |
+
res_ast : list
|
| 319 |
+
list of SymPy AST Nodes
|
| 320 |
+
|
| 321 |
+
"""
|
| 322 |
+
v = ASR2PyVisitor()
|
| 323 |
+
v.visit(fort_node)
|
| 324 |
+
res_ast = v.ret_ast()
|
| 325 |
+
return res_ast
|
| 326 |
+
|
| 327 |
+
|
| 328 |
+
def src_to_sympy(src):
|
| 329 |
+
"""Wrapper function to convert the given Fortran source code to SymPy Expressions
|
| 330 |
+
|
| 331 |
+
Parameters
|
| 332 |
+
==========
|
| 333 |
+
|
| 334 |
+
src : string
|
| 335 |
+
A string with the Fortran source code
|
| 336 |
+
|
| 337 |
+
Returns
|
| 338 |
+
=======
|
| 339 |
+
|
| 340 |
+
py_src : string
|
| 341 |
+
A string with the Python source code compatible with SymPy
|
| 342 |
+
|
| 343 |
+
"""
|
| 344 |
+
a_ast = src_to_ast(src, translation_unit=False)
|
| 345 |
+
a = ast_to_asr(a_ast)
|
| 346 |
+
py_src = call_visitor(a)
|
| 347 |
+
return py_src
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License (MIT)
|
| 2 |
+
|
| 3 |
+
Copyright 2016, latex2sympy
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
ScaleDF_rebuttal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.txt
|
| 6 |
+
*/
|
| 7 |
+
|
| 8 |
+
/*
|
| 9 |
+
After changing this file, it is necessary to run `python setup.py antlr` in the root directory of
|
| 10 |
+
the repository. This will regenerate the code in `sympy/parsing/latex/_antlr/*.py`.
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
grammar LaTeX;
|
| 14 |
+
|
| 15 |
+
options {
|
| 16 |
+
language = Python3;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
WS: [ \t\r\n]+ -> skip;
|
| 20 |
+
THINSPACE: ('\\,' | '\\thinspace') -> skip;
|
| 21 |
+
MEDSPACE: ('\\:' | '\\medspace') -> skip;
|
| 22 |
+
THICKSPACE: ('\\;' | '\\thickspace') -> skip;
|
| 23 |
+
QUAD: '\\quad' -> skip;
|
| 24 |
+
QQUAD: '\\qquad' -> skip;
|
| 25 |
+
NEGTHINSPACE: ('\\!' | '\\negthinspace') -> skip;
|
| 26 |
+
NEGMEDSPACE: '\\negmedspace' -> skip;
|
| 27 |
+
NEGTHICKSPACE: '\\negthickspace' -> skip;
|
| 28 |
+
CMD_LEFT: '\\left' -> skip;
|
| 29 |
+
CMD_RIGHT: '\\right' -> skip;
|
| 30 |
+
|
| 31 |
+
IGNORE:
|
| 32 |
+
(
|
| 33 |
+
'\\vrule'
|
| 34 |
+
| '\\vcenter'
|
| 35 |
+
| '\\vbox'
|
| 36 |
+
| '\\vskip'
|
| 37 |
+
| '\\vspace'
|
| 38 |
+
| '\\hfil'
|
| 39 |
+
| '\\*'
|
| 40 |
+
| '\\-'
|
| 41 |
+
| '\\.'
|
| 42 |
+
| '\\/'
|
| 43 |
+
| '\\"'
|
| 44 |
+
| '\\('
|
| 45 |
+
| '\\='
|
| 46 |
+
) -> skip;
|
| 47 |
+
|
| 48 |
+
ADD: '+';
|
| 49 |
+
SUB: '-';
|
| 50 |
+
MUL: '*';
|
| 51 |
+
DIV: '/';
|
| 52 |
+
|
| 53 |
+
L_PAREN: '(';
|
| 54 |
+
R_PAREN: ')';
|
| 55 |
+
L_BRACE: '{';
|
| 56 |
+
R_BRACE: '}';
|
| 57 |
+
L_BRACE_LITERAL: '\\{';
|
| 58 |
+
R_BRACE_LITERAL: '\\}';
|
| 59 |
+
L_BRACKET: '[';
|
| 60 |
+
R_BRACKET: ']';
|
| 61 |
+
|
| 62 |
+
BAR: '|';
|
| 63 |
+
|
| 64 |
+
R_BAR: '\\right|';
|
| 65 |
+
L_BAR: '\\left|';
|
| 66 |
+
|
| 67 |
+
L_ANGLE: '\\langle';
|
| 68 |
+
R_ANGLE: '\\rangle';
|
| 69 |
+
FUNC_LIM: '\\lim';
|
| 70 |
+
LIM_APPROACH_SYM:
|
| 71 |
+
'\\to'
|
| 72 |
+
| '\\rightarrow'
|
| 73 |
+
| '\\Rightarrow'
|
| 74 |
+
| '\\longrightarrow'
|
| 75 |
+
| '\\Longrightarrow';
|
| 76 |
+
FUNC_INT:
|
| 77 |
+
'\\int'
|
| 78 |
+
| '\\int\\limits';
|
| 79 |
+
FUNC_SUM: '\\sum';
|
| 80 |
+
FUNC_PROD: '\\prod';
|
| 81 |
+
|
| 82 |
+
FUNC_EXP: '\\exp';
|
| 83 |
+
FUNC_LOG: '\\log';
|
| 84 |
+
FUNC_LG: '\\lg';
|
| 85 |
+
FUNC_LN: '\\ln';
|
| 86 |
+
FUNC_SIN: '\\sin';
|
| 87 |
+
FUNC_COS: '\\cos';
|
| 88 |
+
FUNC_TAN: '\\tan';
|
| 89 |
+
FUNC_CSC: '\\csc';
|
| 90 |
+
FUNC_SEC: '\\sec';
|
| 91 |
+
FUNC_COT: '\\cot';
|
| 92 |
+
|
| 93 |
+
FUNC_ARCSIN: '\\arcsin';
|
| 94 |
+
FUNC_ARCCOS: '\\arccos';
|
| 95 |
+
FUNC_ARCTAN: '\\arctan';
|
| 96 |
+
FUNC_ARCCSC: '\\arccsc';
|
| 97 |
+
FUNC_ARCSEC: '\\arcsec';
|
| 98 |
+
FUNC_ARCCOT: '\\arccot';
|
| 99 |
+
|
| 100 |
+
FUNC_SINH: '\\sinh';
|
| 101 |
+
FUNC_COSH: '\\cosh';
|
| 102 |
+
FUNC_TANH: '\\tanh';
|
| 103 |
+
FUNC_ARSINH: '\\arsinh';
|
| 104 |
+
FUNC_ARCOSH: '\\arcosh';
|
| 105 |
+
FUNC_ARTANH: '\\artanh';
|
| 106 |
+
|
| 107 |
+
L_FLOOR: '\\lfloor';
|
| 108 |
+
R_FLOOR: '\\rfloor';
|
| 109 |
+
L_CEIL: '\\lceil';
|
| 110 |
+
R_CEIL: '\\rceil';
|
| 111 |
+
|
| 112 |
+
FUNC_SQRT: '\\sqrt';
|
| 113 |
+
FUNC_OVERLINE: '\\overline';
|
| 114 |
+
|
| 115 |
+
CMD_TIMES: '\\times';
|
| 116 |
+
CMD_CDOT: '\\cdot';
|
| 117 |
+
CMD_DIV: '\\div';
|
| 118 |
+
CMD_FRAC:
|
| 119 |
+
'\\frac'
|
| 120 |
+
| '\\dfrac'
|
| 121 |
+
| '\\tfrac';
|
| 122 |
+
CMD_BINOM: '\\binom';
|
| 123 |
+
CMD_DBINOM: '\\dbinom';
|
| 124 |
+
CMD_TBINOM: '\\tbinom';
|
| 125 |
+
|
| 126 |
+
CMD_MATHIT: '\\mathit';
|
| 127 |
+
|
| 128 |
+
UNDERSCORE: '_';
|
| 129 |
+
CARET: '^';
|
| 130 |
+
COLON: ':';
|
| 131 |
+
|
| 132 |
+
fragment WS_CHAR: [ \t\r\n];
|
| 133 |
+
DIFFERENTIAL: 'd' WS_CHAR*? ([a-zA-Z] | '\\' [a-zA-Z]+);
|
| 134 |
+
|
| 135 |
+
LETTER: [a-zA-Z];
|
| 136 |
+
DIGIT: [0-9];
|
| 137 |
+
|
| 138 |
+
EQUAL: (('&' WS_CHAR*?)? '=') | ('=' (WS_CHAR*? '&')?);
|
| 139 |
+
NEQ: '\\neq';
|
| 140 |
+
|
| 141 |
+
LT: '<';
|
| 142 |
+
LTE: ('\\leq' | '\\le' | LTE_Q | LTE_S);
|
| 143 |
+
LTE_Q: '\\leqq';
|
| 144 |
+
LTE_S: '\\leqslant';
|
| 145 |
+
|
| 146 |
+
GT: '>';
|
| 147 |
+
GTE: ('\\geq' | '\\ge' | GTE_Q | GTE_S);
|
| 148 |
+
GTE_Q: '\\geqq';
|
| 149 |
+
GTE_S: '\\geqslant';
|
| 150 |
+
|
| 151 |
+
BANG: '!';
|
| 152 |
+
|
| 153 |
+
SINGLE_QUOTES: '\''+;
|
| 154 |
+
|
| 155 |
+
SYMBOL: '\\' [a-zA-Z]+;
|
| 156 |
+
|
| 157 |
+
math: relation;
|
| 158 |
+
|
| 159 |
+
relation:
|
| 160 |
+
relation (EQUAL | LT | LTE | GT | GTE | NEQ) relation
|
| 161 |
+
| expr;
|
| 162 |
+
|
| 163 |
+
equality: expr EQUAL expr;
|
| 164 |
+
|
| 165 |
+
expr: additive;
|
| 166 |
+
|
| 167 |
+
additive: additive (ADD | SUB) additive | mp;
|
| 168 |
+
|
| 169 |
+
// mult part
|
| 170 |
+
mp:
|
| 171 |
+
mp (MUL | CMD_TIMES | CMD_CDOT | DIV | CMD_DIV | COLON) mp
|
| 172 |
+
| unary;
|
| 173 |
+
|
| 174 |
+
mp_nofunc:
|
| 175 |
+
mp_nofunc (
|
| 176 |
+
MUL
|
| 177 |
+
| CMD_TIMES
|
| 178 |
+
| CMD_CDOT
|
| 179 |
+
| DIV
|
| 180 |
+
| CMD_DIV
|
| 181 |
+
| COLON
|
| 182 |
+
) mp_nofunc
|
| 183 |
+
| unary_nofunc;
|
| 184 |
+
|
| 185 |
+
unary: (ADD | SUB) unary | postfix+;
|
| 186 |
+
|
| 187 |
+
unary_nofunc:
|
| 188 |
+
(ADD | SUB) unary_nofunc
|
| 189 |
+
| postfix postfix_nofunc*;
|
| 190 |
+
|
| 191 |
+
postfix: exp postfix_op*;
|
| 192 |
+
postfix_nofunc: exp_nofunc postfix_op*;
|
| 193 |
+
postfix_op: BANG | eval_at;
|
| 194 |
+
|
| 195 |
+
eval_at:
|
| 196 |
+
BAR (eval_at_sup | eval_at_sub | eval_at_sup eval_at_sub);
|
| 197 |
+
|
| 198 |
+
eval_at_sub: UNDERSCORE L_BRACE (expr | equality) R_BRACE;
|
| 199 |
+
|
| 200 |
+
eval_at_sup: CARET L_BRACE (expr | equality) R_BRACE;
|
| 201 |
+
|
| 202 |
+
exp: exp CARET (atom | L_BRACE expr R_BRACE) subexpr? | comp;
|
| 203 |
+
|
| 204 |
+
exp_nofunc:
|
| 205 |
+
exp_nofunc CARET (atom | L_BRACE expr R_BRACE) subexpr?
|
| 206 |
+
| comp_nofunc;
|
| 207 |
+
|
| 208 |
+
comp:
|
| 209 |
+
group
|
| 210 |
+
| abs_group
|
| 211 |
+
| func
|
| 212 |
+
| atom
|
| 213 |
+
| floor
|
| 214 |
+
| ceil;
|
| 215 |
+
|
| 216 |
+
comp_nofunc:
|
| 217 |
+
group
|
| 218 |
+
| abs_group
|
| 219 |
+
| atom
|
| 220 |
+
| floor
|
| 221 |
+
| ceil;
|
| 222 |
+
|
| 223 |
+
group:
|
| 224 |
+
L_PAREN expr R_PAREN
|
| 225 |
+
| L_BRACKET expr R_BRACKET
|
| 226 |
+
| L_BRACE expr R_BRACE
|
| 227 |
+
| L_BRACE_LITERAL expr R_BRACE_LITERAL;
|
| 228 |
+
|
| 229 |
+
abs_group: BAR expr BAR;
|
| 230 |
+
|
| 231 |
+
number: DIGIT+ (',' DIGIT DIGIT DIGIT)* ('.' DIGIT+)?;
|
| 232 |
+
|
| 233 |
+
atom: (LETTER | SYMBOL) (subexpr? SINGLE_QUOTES? | SINGLE_QUOTES? subexpr?)
|
| 234 |
+
| number
|
| 235 |
+
| DIFFERENTIAL
|
| 236 |
+
| mathit
|
| 237 |
+
| frac
|
| 238 |
+
| binom
|
| 239 |
+
| bra
|
| 240 |
+
| ket;
|
| 241 |
+
|
| 242 |
+
bra: L_ANGLE expr (R_BAR | BAR);
|
| 243 |
+
ket: (L_BAR | BAR) expr R_ANGLE;
|
| 244 |
+
|
| 245 |
+
mathit: CMD_MATHIT L_BRACE mathit_text R_BRACE;
|
| 246 |
+
mathit_text: LETTER*;
|
| 247 |
+
|
| 248 |
+
frac: CMD_FRAC (upperd = DIGIT | L_BRACE upper = expr R_BRACE)
|
| 249 |
+
(lowerd = DIGIT | L_BRACE lower = expr R_BRACE);
|
| 250 |
+
|
| 251 |
+
binom:
|
| 252 |
+
(CMD_BINOM | CMD_DBINOM | CMD_TBINOM) L_BRACE n = expr R_BRACE L_BRACE k = expr R_BRACE;
|
| 253 |
+
|
| 254 |
+
floor: L_FLOOR val = expr R_FLOOR;
|
| 255 |
+
ceil: L_CEIL val = expr R_CEIL;
|
| 256 |
+
|
| 257 |
+
func_normal:
|
| 258 |
+
FUNC_EXP
|
| 259 |
+
| FUNC_LOG
|
| 260 |
+
| FUNC_LG
|
| 261 |
+
| FUNC_LN
|
| 262 |
+
| FUNC_SIN
|
| 263 |
+
| FUNC_COS
|
| 264 |
+
| FUNC_TAN
|
| 265 |
+
| FUNC_CSC
|
| 266 |
+
| FUNC_SEC
|
| 267 |
+
| FUNC_COT
|
| 268 |
+
| FUNC_ARCSIN
|
| 269 |
+
| FUNC_ARCCOS
|
| 270 |
+
| FUNC_ARCTAN
|
| 271 |
+
| FUNC_ARCCSC
|
| 272 |
+
| FUNC_ARCSEC
|
| 273 |
+
| FUNC_ARCCOT
|
| 274 |
+
| FUNC_SINH
|
| 275 |
+
| FUNC_COSH
|
| 276 |
+
| FUNC_TANH
|
| 277 |
+
| FUNC_ARSINH
|
| 278 |
+
| FUNC_ARCOSH
|
| 279 |
+
| FUNC_ARTANH;
|
| 280 |
+
|
| 281 |
+
func:
|
| 282 |
+
func_normal (subexpr? supexpr? | supexpr? subexpr?) (
|
| 283 |
+
L_PAREN func_arg R_PAREN
|
| 284 |
+
| func_arg_noparens
|
| 285 |
+
)
|
| 286 |
+
| (LETTER | SYMBOL) (subexpr? SINGLE_QUOTES? | SINGLE_QUOTES? subexpr?) // e.g. f(x), f_1'(x)
|
| 287 |
+
L_PAREN args R_PAREN
|
| 288 |
+
| FUNC_INT (subexpr supexpr | supexpr subexpr)? (
|
| 289 |
+
additive? DIFFERENTIAL
|
| 290 |
+
| frac
|
| 291 |
+
| additive
|
| 292 |
+
)
|
| 293 |
+
| FUNC_SQRT (L_BRACKET root = expr R_BRACKET)? L_BRACE base = expr R_BRACE
|
| 294 |
+
| FUNC_OVERLINE L_BRACE base = expr R_BRACE
|
| 295 |
+
| (FUNC_SUM | FUNC_PROD) (subeq supexpr | supexpr subeq) mp
|
| 296 |
+
| FUNC_LIM limit_sub mp;
|
| 297 |
+
|
| 298 |
+
args: (expr ',' args) | expr;
|
| 299 |
+
|
| 300 |
+
limit_sub:
|
| 301 |
+
UNDERSCORE L_BRACE (LETTER | SYMBOL) LIM_APPROACH_SYM expr (
|
| 302 |
+
CARET ((L_BRACE (ADD | SUB) R_BRACE) | ADD | SUB)
|
| 303 |
+
)? R_BRACE;
|
| 304 |
+
|
| 305 |
+
func_arg: expr | (expr ',' func_arg);
|
| 306 |
+
func_arg_noparens: mp_nofunc;
|
| 307 |
+
|
| 308 |
+
subexpr: UNDERSCORE (atom | L_BRACE expr R_BRACE);
|
| 309 |
+
supexpr: CARET (atom | L_BRACE expr R_BRACE);
|
| 310 |
+
|
| 311 |
+
subeq: UNDERSCORE L_BRACE equality R_BRACE;
|
| 312 |
+
supeq: UNDERSCORE L_BRACE equality R_BRACE;
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/__init__.py
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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external import import_module
|
| 2 |
+
from sympy.utilities.decorator import doctest_depends_on
|
| 3 |
+
from re import compile as rcompile
|
| 4 |
+
|
| 5 |
+
from sympy.parsing.latex.lark import LarkLaTeXParser, TransformToSymPyExpr, parse_latex_lark # noqa
|
| 6 |
+
|
| 7 |
+
from .errors import LaTeXParsingError # noqa
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
IGNORE_L = r"\s*[{]*\s*"
|
| 11 |
+
IGNORE_R = r"\s*[}]*\s*"
|
| 12 |
+
NO_LEFT = r"(?<!\\left)"
|
| 13 |
+
BEGIN_AMS_MAT = r"\\begin{matrix}"
|
| 14 |
+
END_AMS_MAT = r"\\end{matrix}"
|
| 15 |
+
BEGIN_ARR = r"\\begin{array}{.*?}"
|
| 16 |
+
END_ARR = r"\\end{array}"
|
| 17 |
+
|
| 18 |
+
# begin_delim_regex: end_delim_regex
|
| 19 |
+
MATRIX_DELIMS = {fr"\\left\({IGNORE_L}{BEGIN_AMS_MAT}": fr"{END_AMS_MAT}{IGNORE_R}\\right\)",
|
| 20 |
+
fr"{NO_LEFT}\({IGNORE_L}{BEGIN_AMS_MAT}": fr"{END_AMS_MAT}{IGNORE_R}\)",
|
| 21 |
+
fr"\\left\[{IGNORE_L}{BEGIN_AMS_MAT}": fr"{END_AMS_MAT}{IGNORE_R}\\right\]",
|
| 22 |
+
fr"{NO_LEFT}\[{IGNORE_L}{BEGIN_AMS_MAT}": fr"{END_AMS_MAT}{IGNORE_R}\]",
|
| 23 |
+
fr"\\left\|{IGNORE_L}{BEGIN_AMS_MAT}": fr"{END_AMS_MAT}{IGNORE_R}\\right\|",
|
| 24 |
+
fr"{NO_LEFT}\|{IGNORE_L}{BEGIN_AMS_MAT}": fr"{END_AMS_MAT}{IGNORE_R}\|",
|
| 25 |
+
r"\\begin{pmatrix}": r"\\end{pmatrix}",
|
| 26 |
+
r"\\begin{bmatrix}": r"\\end{bmatrix}",
|
| 27 |
+
r"\\begin{vmatrix}": r"\\end{vmatrix}",
|
| 28 |
+
fr"\\left\({IGNORE_L}{BEGIN_ARR}": fr"{END_ARR}{IGNORE_R}\\right\)",
|
| 29 |
+
fr"{NO_LEFT}\({IGNORE_L}{BEGIN_ARR}": fr"{END_ARR}{IGNORE_R}\)",
|
| 30 |
+
fr"\\left\[{IGNORE_L}{BEGIN_ARR}": fr"{END_ARR}{IGNORE_R}\\right\]",
|
| 31 |
+
fr"{NO_LEFT}\[{IGNORE_L}{BEGIN_ARR}": fr"{END_ARR}{IGNORE_R}\]",
|
| 32 |
+
fr"\\left\|{IGNORE_L}{BEGIN_ARR}": fr"{END_ARR}{IGNORE_R}\\right\|",
|
| 33 |
+
fr"{NO_LEFT}\|{IGNORE_L}{BEGIN_ARR}": fr"{END_ARR}{IGNORE_R}\|"
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
MATRIX_DELIMS_INV = {v: k for k, v in MATRIX_DELIMS.items()}
|
| 37 |
+
|
| 38 |
+
# begin_delim_regex: ideal_begin_delim_representative
|
| 39 |
+
BEGIN_DELIM_REPR = {fr"\\left\({IGNORE_L}{BEGIN_AMS_MAT}": "\\left(\\begin{matrix}",
|
| 40 |
+
fr"{NO_LEFT}\({IGNORE_L}{BEGIN_AMS_MAT}": "(\\begin{matrix}",
|
| 41 |
+
fr"\\left\[{IGNORE_L}{BEGIN_AMS_MAT}": "\\left[\\begin{matrix}",
|
| 42 |
+
fr"{NO_LEFT}\[{IGNORE_L}{BEGIN_AMS_MAT}": "[\\begin{matrix}",
|
| 43 |
+
fr"\\left\|{IGNORE_L}{BEGIN_AMS_MAT}": "\\left|\\begin{matrix}",
|
| 44 |
+
fr"{NO_LEFT}\|{IGNORE_L}{BEGIN_AMS_MAT}": "|\\begin{matrix}",
|
| 45 |
+
r"\\begin{pmatrix}": "\\begin{pmatrix}",
|
| 46 |
+
r"\\begin{bmatrix}": "\\begin{bmatrix}",
|
| 47 |
+
r"\\begin{vmatrix}": "\\begin{vmatrix}",
|
| 48 |
+
fr"\\left\({IGNORE_L}{BEGIN_ARR}": "\\left(\\begin{array}{COLUMN_SPECIFIERS}",
|
| 49 |
+
fr"{NO_LEFT}\({IGNORE_L}{BEGIN_ARR}": "(\\begin{array}{COLUMN_SPECIFIERS}",
|
| 50 |
+
fr"\\left\[{IGNORE_L}{BEGIN_ARR}": "\\left[\\begin{array}{COLUMN_SPECIFIERS}",
|
| 51 |
+
fr"{NO_LEFT}\[{IGNORE_L}{BEGIN_ARR}": "[\\begin{array}{COLUMN_SPECIFIERS}",
|
| 52 |
+
fr"\\left\|{IGNORE_L}{BEGIN_ARR}": "\\left|\\begin{array}{COLUMN_SPECIFIERS}",
|
| 53 |
+
fr"{NO_LEFT}\|{IGNORE_L}{BEGIN_ARR}": "|\\begin{array}{COLUMN_SPECIFIERS}"
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
# end_delim_regex: ideal_end_delim_representative
|
| 57 |
+
END_DELIM_REPR = {fr"{END_AMS_MAT}{IGNORE_R}\\right\)": "\\end{matrix}\\right)",
|
| 58 |
+
fr"{END_AMS_MAT}{IGNORE_R}\)": "\\end{matrix})",
|
| 59 |
+
fr"{END_AMS_MAT}{IGNORE_R}\\right\]": "\\end{matrix}\\right]",
|
| 60 |
+
fr"{END_AMS_MAT}{IGNORE_R}\]": "\\end{matrix}]",
|
| 61 |
+
fr"{END_AMS_MAT}{IGNORE_R}\\right\|": "\\end{matrix}\\right|",
|
| 62 |
+
fr"{END_AMS_MAT}{IGNORE_R}\|": "\\end{matrix}|",
|
| 63 |
+
r"\\end{pmatrix}": "\\end{pmatrix}",
|
| 64 |
+
r"\\end{bmatrix}": "\\end{bmatrix}",
|
| 65 |
+
r"\\end{vmatrix}": "\\end{vmatrix}",
|
| 66 |
+
fr"{END_ARR}{IGNORE_R}\\right\)": "\\end{array}\\right)",
|
| 67 |
+
fr"{END_ARR}{IGNORE_R}\)": "\\end{array})",
|
| 68 |
+
fr"{END_ARR}{IGNORE_R}\\right\]": "\\end{array}\\right]",
|
| 69 |
+
fr"{END_ARR}{IGNORE_R}\]": "\\end{array}]",
|
| 70 |
+
fr"{END_ARR}{IGNORE_R}\\right\|": "\\end{array}\\right|",
|
| 71 |
+
fr"{END_ARR}{IGNORE_R}\|": "\\end{array}|"
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def check_matrix_delimiters(latex_str):
|
| 76 |
+
"""Report mismatched, excess, or missing matrix delimiters."""
|
| 77 |
+
spans = []
|
| 78 |
+
for begin_delim in MATRIX_DELIMS:
|
| 79 |
+
end_delim = MATRIX_DELIMS[begin_delim]
|
| 80 |
+
|
| 81 |
+
p = rcompile(begin_delim)
|
| 82 |
+
q = rcompile(end_delim)
|
| 83 |
+
|
| 84 |
+
spans.extend([(*m.span(), m.group(),
|
| 85 |
+
begin_delim) for m in p.finditer(latex_str)])
|
| 86 |
+
spans.extend([(*m.span(), m.group(),
|
| 87 |
+
end_delim) for m in q.finditer(latex_str)])
|
| 88 |
+
|
| 89 |
+
spans.sort(key=(lambda x: x[0]))
|
| 90 |
+
if len(spans) % 2 == 1:
|
| 91 |
+
# Odd number of delimiters; therefore something
|
| 92 |
+
# is wrong. We do not complain yet; let's see if
|
| 93 |
+
# we can pinpoint the actual error.
|
| 94 |
+
spans.append((None, None, None, None))
|
| 95 |
+
|
| 96 |
+
spans = [(*x, *y) for (x, y) in zip(spans[::2], spans[1::2])]
|
| 97 |
+
for x in spans:
|
| 98 |
+
# x is supposed to be an 8-tuple of the following form:
|
| 99 |
+
#
|
| 100 |
+
# (begin_delim_span_start, begin_delim_span_end,
|
| 101 |
+
# begin_delim_match, begin_delim_regex,
|
| 102 |
+
# end_delim_span_start, end_delim_span_end,
|
| 103 |
+
# end_delim_match, end_delim_regex)
|
| 104 |
+
|
| 105 |
+
sellipsis = "..."
|
| 106 |
+
s = x[0] - 10
|
| 107 |
+
if s < 0:
|
| 108 |
+
s = 0
|
| 109 |
+
sellipsis = ""
|
| 110 |
+
|
| 111 |
+
eellipsis = "..."
|
| 112 |
+
e = x[1] + 10
|
| 113 |
+
if e > len(latex_str):
|
| 114 |
+
e = len(latex_str)
|
| 115 |
+
eellipsis = ""
|
| 116 |
+
|
| 117 |
+
if x[3] in END_DELIM_REPR:
|
| 118 |
+
err = (f"Extra '{x[2]}' at index {x[0]} or "
|
| 119 |
+
"missing corresponding "
|
| 120 |
+
f"'{BEGIN_DELIM_REPR[MATRIX_DELIMS_INV[x[3]]]}' "
|
| 121 |
+
f"in LaTeX string: {sellipsis}{latex_str[s:e]}"
|
| 122 |
+
f"{eellipsis}")
|
| 123 |
+
raise LaTeXParsingError(err)
|
| 124 |
+
|
| 125 |
+
if x[7] is None:
|
| 126 |
+
err = (f"Extra '{x[2]}' at index {x[0]} or "
|
| 127 |
+
"missing corresponding "
|
| 128 |
+
f"'{END_DELIM_REPR[MATRIX_DELIMS[x[3]]]}' "
|
| 129 |
+
f"in LaTeX string: {sellipsis}{latex_str[s:e]}"
|
| 130 |
+
f"{eellipsis}")
|
| 131 |
+
raise LaTeXParsingError(err)
|
| 132 |
+
|
| 133 |
+
correct_end_regex = MATRIX_DELIMS[x[3]]
|
| 134 |
+
sellipsis = "..." if x[0] > 0 else ""
|
| 135 |
+
eellipsis = "..." if x[5] < len(latex_str) else ""
|
| 136 |
+
if x[7] != correct_end_regex:
|
| 137 |
+
err = ("Expected "
|
| 138 |
+
f"'{END_DELIM_REPR[correct_end_regex]}' "
|
| 139 |
+
f"to close the '{x[2]}' at index {x[0]} but "
|
| 140 |
+
f"found '{x[6]}' at index {x[4]} of LaTeX "
|
| 141 |
+
f"string instead: {sellipsis}{latex_str[x[0]:x[5]]}"
|
| 142 |
+
f"{eellipsis}")
|
| 143 |
+
raise LaTeXParsingError(err)
|
| 144 |
+
|
| 145 |
+
__doctest_requires__ = {('parse_latex',): ['antlr4', 'lark']}
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
@doctest_depends_on(modules=('antlr4', 'lark'))
|
| 149 |
+
def parse_latex(s, strict=False, backend="antlr"):
|
| 150 |
+
r"""Converts the input LaTeX string ``s`` to a SymPy ``Expr``.
|
| 151 |
+
|
| 152 |
+
Parameters
|
| 153 |
+
==========
|
| 154 |
+
|
| 155 |
+
s : str
|
| 156 |
+
The LaTeX string to parse. In Python source containing LaTeX,
|
| 157 |
+
*raw strings* (denoted with ``r"``, like this one) are preferred,
|
| 158 |
+
as LaTeX makes liberal use of the ``\`` character, which would
|
| 159 |
+
trigger escaping in normal Python strings.
|
| 160 |
+
backend : str, optional
|
| 161 |
+
Currently, there are two backends supported: ANTLR, and Lark.
|
| 162 |
+
The default setting is to use the ANTLR backend, which can be
|
| 163 |
+
changed to Lark if preferred.
|
| 164 |
+
|
| 165 |
+
Use ``backend="antlr"`` for the ANTLR-based parser, and
|
| 166 |
+
``backend="lark"`` for the Lark-based parser.
|
| 167 |
+
|
| 168 |
+
The ``backend`` option is case-sensitive, and must be in
|
| 169 |
+
all lowercase.
|
| 170 |
+
strict : bool, optional
|
| 171 |
+
This option is only available with the ANTLR backend.
|
| 172 |
+
|
| 173 |
+
If True, raise an exception if the string cannot be parsed as
|
| 174 |
+
valid LaTeX. If False, try to recover gracefully from common
|
| 175 |
+
mistakes.
|
| 176 |
+
|
| 177 |
+
Examples
|
| 178 |
+
========
|
| 179 |
+
|
| 180 |
+
>>> from sympy.parsing.latex import parse_latex
|
| 181 |
+
>>> expr = parse_latex(r"\frac {1 + \sqrt {\a}} {\b}")
|
| 182 |
+
>>> expr
|
| 183 |
+
(sqrt(a) + 1)/b
|
| 184 |
+
>>> expr.evalf(4, subs=dict(a=5, b=2))
|
| 185 |
+
1.618
|
| 186 |
+
>>> func = parse_latex(r"\int_1^\alpha \dfrac{\mathrm{d}t}{t}", backend="lark")
|
| 187 |
+
>>> func.evalf(subs={"alpha": 2})
|
| 188 |
+
0.693147180559945
|
| 189 |
+
"""
|
| 190 |
+
|
| 191 |
+
check_matrix_delimiters(s)
|
| 192 |
+
|
| 193 |
+
if backend == "antlr":
|
| 194 |
+
_latex = import_module(
|
| 195 |
+
'sympy.parsing.latex._parse_latex_antlr',
|
| 196 |
+
import_kwargs={'fromlist': ['X']})
|
| 197 |
+
|
| 198 |
+
if _latex is not None:
|
| 199 |
+
return _latex.parse_latex(s, strict)
|
| 200 |
+
elif backend == "lark":
|
| 201 |
+
return parse_latex_lark(s)
|
| 202 |
+
else:
|
| 203 |
+
raise NotImplementedError(f"Using the '{backend}' backend in the LaTeX" \
|
| 204 |
+
" parser is not supported.")
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/_antlr/__init__.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# *** GENERATED BY `setup.py antlr`, DO NOT EDIT BY HAND ***
|
| 2 |
+
#
|
| 3 |
+
# Generated from ../LaTeX.g4, derived from latex2sympy
|
| 4 |
+
# latex2sympy is licensed under the MIT license
|
| 5 |
+
# https://github.com/augustt198/latex2sympy/blob/master/LICENSE.txt
|
| 6 |
+
#
|
| 7 |
+
# Generated with antlr4
|
| 8 |
+
# antlr4 is licensed under the BSD-3-Clause License
|
| 9 |
+
# https://github.com/antlr/antlr4/blob/master/LICENSE.txt
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/_antlr/latexlexer.py
ADDED
|
@@ -0,0 +1,512 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# *** GENERATED BY `setup.py antlr`, DO NOT EDIT BY HAND ***
|
| 2 |
+
#
|
| 3 |
+
# Generated from ../LaTeX.g4, derived from latex2sympy
|
| 4 |
+
# latex2sympy is licensed under the MIT license
|
| 5 |
+
# https://github.com/augustt198/latex2sympy/blob/master/LICENSE.txt
|
| 6 |
+
#
|
| 7 |
+
# Generated with antlr4
|
| 8 |
+
# antlr4 is licensed under the BSD-3-Clause License
|
| 9 |
+
# https://github.com/antlr/antlr4/blob/master/LICENSE.txt
|
| 10 |
+
from antlr4 import *
|
| 11 |
+
from io import StringIO
|
| 12 |
+
import sys
|
| 13 |
+
if sys.version_info[1] > 5:
|
| 14 |
+
from typing import TextIO
|
| 15 |
+
else:
|
| 16 |
+
from typing.io import TextIO
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def serializedATN():
|
| 20 |
+
return [
|
| 21 |
+
4,0,91,911,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,
|
| 22 |
+
2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,
|
| 23 |
+
13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,
|
| 24 |
+
19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,
|
| 25 |
+
26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,
|
| 26 |
+
32,2,33,7,33,2,34,7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,
|
| 27 |
+
39,7,39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7,
|
| 28 |
+
45,2,46,7,46,2,47,7,47,2,48,7,48,2,49,7,49,2,50,7,50,2,51,7,51,2,
|
| 29 |
+
52,7,52,2,53,7,53,2,54,7,54,2,55,7,55,2,56,7,56,2,57,7,57,2,58,7,
|
| 30 |
+
58,2,59,7,59,2,60,7,60,2,61,7,61,2,62,7,62,2,63,7,63,2,64,7,64,2,
|
| 31 |
+
65,7,65,2,66,7,66,2,67,7,67,2,68,7,68,2,69,7,69,2,70,7,70,2,71,7,
|
| 32 |
+
71,2,72,7,72,2,73,7,73,2,74,7,74,2,75,7,75,2,76,7,76,2,77,7,77,2,
|
| 33 |
+
78,7,78,2,79,7,79,2,80,7,80,2,81,7,81,2,82,7,82,2,83,7,83,2,84,7,
|
| 34 |
+
84,2,85,7,85,2,86,7,86,2,87,7,87,2,88,7,88,2,89,7,89,2,90,7,90,2,
|
| 35 |
+
91,7,91,1,0,1,0,1,1,1,1,1,2,4,2,191,8,2,11,2,12,2,192,1,2,1,2,1,
|
| 36 |
+
3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,3,3,209,8,3,1,3,1,
|
| 37 |
+
3,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,3,4,224,8,4,1,4,1,
|
| 38 |
+
4,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,3,5,241,8,
|
| 39 |
+
5,1,5,1,5,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,7,1,7,1,7,1,7,1,7,1,
|
| 40 |
+
7,1,7,1,7,1,7,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,
|
| 41 |
+
8,1,8,1,8,3,8,277,8,8,1,8,1,8,1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,
|
| 42 |
+
9,1,9,1,9,1,9,1,9,1,9,1,9,1,10,1,10,1,10,1,10,1,10,1,10,1,10,1,10,
|
| 43 |
+
1,10,1,10,1,10,1,10,1,10,1,10,1,10,1,10,1,10,1,11,1,11,1,11,1,11,
|
| 44 |
+
1,11,1,11,1,11,1,11,1,12,1,12,1,12,1,12,1,12,1,12,1,12,1,12,1,12,
|
| 45 |
+
1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,
|
| 46 |
+
1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,
|
| 47 |
+
1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,
|
| 48 |
+
1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,3,13,
|
| 49 |
+
381,8,13,1,13,1,13,1,14,1,14,1,15,1,15,1,16,1,16,1,17,1,17,1,18,
|
| 50 |
+
1,18,1,19,1,19,1,20,1,20,1,21,1,21,1,22,1,22,1,22,1,23,1,23,1,23,
|
| 51 |
+
1,24,1,24,1,25,1,25,1,26,1,26,1,27,1,27,1,27,1,27,1,27,1,27,1,27,
|
| 52 |
+
1,27,1,28,1,28,1,28,1,28,1,28,1,28,1,28,1,29,1,29,1,29,1,29,1,29,
|
| 53 |
+
1,29,1,29,1,29,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,31,1,31,
|
| 54 |
+
1,31,1,31,1,31,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,
|
| 55 |
+
1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,
|
| 56 |
+
1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,
|
| 57 |
+
1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,
|
| 58 |
+
1,32,1,32,1,32,1,32,1,32,1,32,3,32,504,8,32,1,33,1,33,1,33,1,33,
|
| 59 |
+
1,33,1,33,1,33,1,33,1,33,1,33,1,33,1,33,1,33,1,33,1,33,3,33,521,
|
| 60 |
+
8,33,1,34,1,34,1,34,1,34,1,34,1,35,1,35,1,35,1,35,1,35,1,35,1,36,
|
| 61 |
+
1,36,1,36,1,36,1,36,1,37,1,37,1,37,1,37,1,37,1,38,1,38,1,38,1,38,
|
| 62 |
+
1,39,1,39,1,39,1,39,1,40,1,40,1,40,1,40,1,40,1,41,1,41,1,41,1,41,
|
| 63 |
+
1,41,1,42,1,42,1,42,1,42,1,42,1,43,1,43,1,43,1,43,1,43,1,44,1,44,
|
| 64 |
+
1,44,1,44,1,44,1,45,1,45,1,45,1,45,1,45,1,46,1,46,1,46,1,46,1,46,
|
| 65 |
+
1,46,1,46,1,46,1,47,1,47,1,47,1,47,1,47,1,47,1,47,1,47,1,48,1,48,
|
| 66 |
+
1,48,1,48,1,48,1,48,1,48,1,48,1,49,1,49,1,49,1,49,1,49,1,49,1,49,
|
| 67 |
+
1,49,1,50,1,50,1,50,1,50,1,50,1,50,1,50,1,50,1,51,1,51,1,51,1,51,
|
| 68 |
+
1,51,1,51,1,51,1,51,1,52,1,52,1,52,1,52,1,52,1,52,1,53,1,53,1,53,
|
| 69 |
+
1,53,1,53,1,53,1,54,1,54,1,54,1,54,1,54,1,54,1,55,1,55,1,55,1,55,
|
| 70 |
+
1,55,1,55,1,55,1,55,1,56,1,56,1,56,1,56,1,56,1,56,1,56,1,56,1,57,
|
| 71 |
+
1,57,1,57,1,57,1,57,1,57,1,57,1,57,1,58,1,58,1,58,1,58,1,58,1,58,
|
| 72 |
+
1,58,1,58,1,59,1,59,1,59,1,59,1,59,1,59,1,59,1,59,1,60,1,60,1,60,
|
| 73 |
+
1,60,1,60,1,60,1,60,1,61,1,61,1,61,1,61,1,61,1,61,1,61,1,62,1,62,
|
| 74 |
+
1,62,1,62,1,62,1,62,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,
|
| 75 |
+
1,63,1,64,1,64,1,64,1,64,1,64,1,64,1,64,1,65,1,65,1,65,1,65,1,65,
|
| 76 |
+
1,65,1,66,1,66,1,66,1,66,1,66,1,67,1,67,1,67,1,67,1,67,1,67,1,67,
|
| 77 |
+
1,67,1,67,1,67,1,67,1,67,1,67,1,67,1,67,1,67,1,67,3,67,753,8,67,
|
| 78 |
+
1,68,1,68,1,68,1,68,1,68,1,68,1,68,1,69,1,69,1,69,1,69,1,69,1,69,
|
| 79 |
+
1,69,1,69,1,70,1,70,1,70,1,70,1,70,1,70,1,70,1,70,1,71,1,71,1,71,
|
| 80 |
+
1,71,1,71,1,71,1,71,1,71,1,72,1,72,1,73,1,73,1,74,1,74,1,75,1,75,
|
| 81 |
+
1,76,1,76,5,76,796,8,76,10,76,12,76,799,9,76,1,76,1,76,1,76,4,76,
|
| 82 |
+
804,8,76,11,76,12,76,805,3,76,808,8,76,1,77,1,77,1,78,1,78,1,79,
|
| 83 |
+
1,79,5,79,816,8,79,10,79,12,79,819,9,79,3,79,821,8,79,1,79,1,79,
|
| 84 |
+
1,79,5,79,826,8,79,10,79,12,79,829,9,79,1,79,3,79,832,8,79,3,79,
|
| 85 |
+
834,8,79,1,80,1,80,1,80,1,80,1,80,1,81,1,81,1,82,1,82,1,82,1,82,
|
| 86 |
+
1,82,1,82,1,82,1,82,1,82,3,82,852,8,82,1,83,1,83,1,83,1,83,1,83,
|
| 87 |
+
1,83,1,84,1,84,1,84,1,84,1,84,1,84,1,84,1,84,1,84,1,84,1,85,1,85,
|
| 88 |
+
1,86,1,86,1,86,1,86,1,86,1,86,1,86,1,86,1,86,3,86,881,8,86,1,87,
|
| 89 |
+
1,87,1,87,1,87,1,87,1,87,1,88,1,88,1,88,1,88,1,88,1,88,1,88,1,88,
|
| 90 |
+
1,88,1,88,1,89,1,89,1,90,4,90,902,8,90,11,90,12,90,903,1,91,1,91,
|
| 91 |
+
4,91,908,8,91,11,91,12,91,909,3,797,817,827,0,92,1,1,3,2,5,3,7,4,
|
| 92 |
+
9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,13,27,14,29,15,31,16,
|
| 93 |
+
33,17,35,18,37,19,39,20,41,21,43,22,45,23,47,24,49,25,51,26,53,27,
|
| 94 |
+
55,28,57,29,59,30,61,31,63,32,65,33,67,34,69,35,71,36,73,37,75,38,
|
| 95 |
+
77,39,79,40,81,41,83,42,85,43,87,44,89,45,91,46,93,47,95,48,97,49,
|
| 96 |
+
99,50,101,51,103,52,105,53,107,54,109,55,111,56,113,57,115,58,117,
|
| 97 |
+
59,119,60,121,61,123,62,125,63,127,64,129,65,131,66,133,67,135,68,
|
| 98 |
+
137,69,139,70,141,71,143,72,145,73,147,74,149,75,151,0,153,76,155,
|
| 99 |
+
77,157,78,159,79,161,80,163,81,165,82,167,83,169,84,171,85,173,86,
|
| 100 |
+
175,87,177,88,179,89,181,90,183,91,1,0,3,3,0,9,10,13,13,32,32,2,
|
| 101 |
+
0,65,90,97,122,1,0,48,57,949,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,
|
| 102 |
+
0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,
|
| 103 |
+
17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,
|
| 104 |
+
27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,
|
| 105 |
+
37,1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0,0,0,0,45,1,0,0,0,0,
|
| 106 |
+
47,1,0,0,0,0,49,1,0,0,0,0,51,1,0,0,0,0,53,1,0,0,0,0,55,1,0,0,0,0,
|
| 107 |
+
57,1,0,0,0,0,59,1,0,0,0,0,61,1,0,0,0,0,63,1,0,0,0,0,65,1,0,0,0,0,
|
| 108 |
+
67,1,0,0,0,0,69,1,0,0,0,0,71,1,0,0,0,0,73,1,0,0,0,0,75,1,0,0,0,0,
|
| 109 |
+
77,1,0,0,0,0,79,1,0,0,0,0,81,1,0,0,0,0,83,1,0,0,0,0,85,1,0,0,0,0,
|
| 110 |
+
87,1,0,0,0,0,89,1,0,0,0,0,91,1,0,0,0,0,93,1,0,0,0,0,95,1,0,0,0,0,
|
| 111 |
+
97,1,0,0,0,0,99,1,0,0,0,0,101,1,0,0,0,0,103,1,0,0,0,0,105,1,0,0,
|
| 112 |
+
0,0,107,1,0,0,0,0,109,1,0,0,0,0,111,1,0,0,0,0,113,1,0,0,0,0,115,
|
| 113 |
+
1,0,0,0,0,117,1,0,0,0,0,119,1,0,0,0,0,121,1,0,0,0,0,123,1,0,0,0,
|
| 114 |
+
0,125,1,0,0,0,0,127,1,0,0,0,0,129,1,0,0,0,0,131,1,0,0,0,0,133,1,
|
| 115 |
+
0,0,0,0,135,1,0,0,0,0,137,1,0,0,0,0,139,1,0,0,0,0,141,1,0,0,0,0,
|
| 116 |
+
143,1,0,0,0,0,145,1,0,0,0,0,147,1,0,0,0,0,149,1,0,0,0,0,153,1,0,
|
| 117 |
+
0,0,0,155,1,0,0,0,0,157,1,0,0,0,0,159,1,0,0,0,0,161,1,0,0,0,0,163,
|
| 118 |
+
1,0,0,0,0,165,1,0,0,0,0,167,1,0,0,0,0,169,1,0,0,0,0,171,1,0,0,0,
|
| 119 |
+
0,173,1,0,0,0,0,175,1,0,0,0,0,177,1,0,0,0,0,179,1,0,0,0,0,181,1,
|
| 120 |
+
0,0,0,0,183,1,0,0,0,1,185,1,0,0,0,3,187,1,0,0,0,5,190,1,0,0,0,7,
|
| 121 |
+
208,1,0,0,0,9,223,1,0,0,0,11,240,1,0,0,0,13,244,1,0,0,0,15,252,1,
|
| 122 |
+
0,0,0,17,276,1,0,0,0,19,280,1,0,0,0,21,295,1,0,0,0,23,312,1,0,0,
|
| 123 |
+
0,25,320,1,0,0,0,27,380,1,0,0,0,29,384,1,0,0,0,31,386,1,0,0,0,33,
|
| 124 |
+
388,1,0,0,0,35,390,1,0,0,0,37,392,1,0,0,0,39,394,1,0,0,0,41,396,
|
| 125 |
+
1,0,0,0,43,398,1,0,0,0,45,400,1,0,0,0,47,403,1,0,0,0,49,406,1,0,
|
| 126 |
+
0,0,51,408,1,0,0,0,53,410,1,0,0,0,55,412,1,0,0,0,57,420,1,0,0,0,
|
| 127 |
+
59,427,1,0,0,0,61,435,1,0,0,0,63,443,1,0,0,0,65,503,1,0,0,0,67,520,
|
| 128 |
+
1,0,0,0,69,522,1,0,0,0,71,527,1,0,0,0,73,533,1,0,0,0,75,538,1,0,
|
| 129 |
+
0,0,77,543,1,0,0,0,79,547,1,0,0,0,81,551,1,0,0,0,83,556,1,0,0,0,
|
| 130 |
+
85,561,1,0,0,0,87,566,1,0,0,0,89,571,1,0,0,0,91,576,1,0,0,0,93,581,
|
| 131 |
+
1,0,0,0,95,589,1,0,0,0,97,597,1,0,0,0,99,605,1,0,0,0,101,613,1,0,
|
| 132 |
+
0,0,103,621,1,0,0,0,105,629,1,0,0,0,107,635,1,0,0,0,109,641,1,0,
|
| 133 |
+
0,0,111,647,1,0,0,0,113,655,1,0,0,0,115,663,1,0,0,0,117,671,1,0,
|
| 134 |
+
0,0,119,679,1,0,0,0,121,687,1,0,0,0,123,694,1,0,0,0,125,701,1,0,
|
| 135 |
+
0,0,127,707,1,0,0,0,129,717,1,0,0,0,131,724,1,0,0,0,133,730,1,0,
|
| 136 |
+
0,0,135,752,1,0,0,0,137,754,1,0,0,0,139,761,1,0,0,0,141,769,1,0,
|
| 137 |
+
0,0,143,777,1,0,0,0,145,785,1,0,0,0,147,787,1,0,0,0,149,789,1,0,
|
| 138 |
+
0,0,151,791,1,0,0,0,153,793,1,0,0,0,155,809,1,0,0,0,157,811,1,0,
|
| 139 |
+
0,0,159,833,1,0,0,0,161,835,1,0,0,0,163,840,1,0,0,0,165,851,1,0,
|
| 140 |
+
0,0,167,853,1,0,0,0,169,859,1,0,0,0,171,869,1,0,0,0,173,880,1,0,
|
| 141 |
+
0,0,175,882,1,0,0,0,177,888,1,0,0,0,179,898,1,0,0,0,181,901,1,0,
|
| 142 |
+
0,0,183,905,1,0,0,0,185,186,5,44,0,0,186,2,1,0,0,0,187,188,5,46,
|
| 143 |
+
0,0,188,4,1,0,0,0,189,191,7,0,0,0,190,189,1,0,0,0,191,192,1,0,0,
|
| 144 |
+
0,192,190,1,0,0,0,192,193,1,0,0,0,193,194,1,0,0,0,194,195,6,2,0,
|
| 145 |
+
0,195,6,1,0,0,0,196,197,5,92,0,0,197,209,5,44,0,0,198,199,5,92,0,
|
| 146 |
+
0,199,200,5,116,0,0,200,201,5,104,0,0,201,202,5,105,0,0,202,203,
|
| 147 |
+
5,110,0,0,203,204,5,115,0,0,204,205,5,112,0,0,205,206,5,97,0,0,206,
|
| 148 |
+
207,5,99,0,0,207,209,5,101,0,0,208,196,1,0,0,0,208,198,1,0,0,0,209,
|
| 149 |
+
210,1,0,0,0,210,211,6,3,0,0,211,8,1,0,0,0,212,213,5,92,0,0,213,224,
|
| 150 |
+
5,58,0,0,214,215,5,92,0,0,215,216,5,109,0,0,216,217,5,101,0,0,217,
|
| 151 |
+
218,5,100,0,0,218,219,5,115,0,0,219,220,5,112,0,0,220,221,5,97,0,
|
| 152 |
+
0,221,222,5,99,0,0,222,224,5,101,0,0,223,212,1,0,0,0,223,214,1,0,
|
| 153 |
+
0,0,224,225,1,0,0,0,225,226,6,4,0,0,226,10,1,0,0,0,227,228,5,92,
|
| 154 |
+
0,0,228,241,5,59,0,0,229,230,5,92,0,0,230,231,5,116,0,0,231,232,
|
| 155 |
+
5,104,0,0,232,233,5,105,0,0,233,234,5,99,0,0,234,235,5,107,0,0,235,
|
| 156 |
+
236,5,115,0,0,236,237,5,112,0,0,237,238,5,97,0,0,238,239,5,99,0,
|
| 157 |
+
0,239,241,5,101,0,0,240,227,1,0,0,0,240,229,1,0,0,0,241,242,1,0,
|
| 158 |
+
0,0,242,243,6,5,0,0,243,12,1,0,0,0,244,245,5,92,0,0,245,246,5,113,
|
| 159 |
+
0,0,246,247,5,117,0,0,247,248,5,97,0,0,248,249,5,100,0,0,249,250,
|
| 160 |
+
1,0,0,0,250,251,6,6,0,0,251,14,1,0,0,0,252,253,5,92,0,0,253,254,
|
| 161 |
+
5,113,0,0,254,255,5,113,0,0,255,256,5,117,0,0,256,257,5,97,0,0,257,
|
| 162 |
+
258,5,100,0,0,258,259,1,0,0,0,259,260,6,7,0,0,260,16,1,0,0,0,261,
|
| 163 |
+
262,5,92,0,0,262,277,5,33,0,0,263,264,5,92,0,0,264,265,5,110,0,0,
|
| 164 |
+
265,266,5,101,0,0,266,267,5,103,0,0,267,268,5,116,0,0,268,269,5,
|
| 165 |
+
104,0,0,269,270,5,105,0,0,270,271,5,110,0,0,271,272,5,115,0,0,272,
|
| 166 |
+
273,5,112,0,0,273,274,5,97,0,0,274,275,5,99,0,0,275,277,5,101,0,
|
| 167 |
+
0,276,261,1,0,0,0,276,263,1,0,0,0,277,278,1,0,0,0,278,279,6,8,0,
|
| 168 |
+
0,279,18,1,0,0,0,280,281,5,92,0,0,281,282,5,110,0,0,282,283,5,101,
|
| 169 |
+
0,0,283,284,5,103,0,0,284,285,5,109,0,0,285,286,5,101,0,0,286,287,
|
| 170 |
+
5,100,0,0,287,288,5,115,0,0,288,289,5,112,0,0,289,290,5,97,0,0,290,
|
| 171 |
+
291,5,99,0,0,291,292,5,101,0,0,292,293,1,0,0,0,293,294,6,9,0,0,294,
|
| 172 |
+
20,1,0,0,0,295,296,5,92,0,0,296,297,5,110,0,0,297,298,5,101,0,0,
|
| 173 |
+
298,299,5,103,0,0,299,300,5,116,0,0,300,301,5,104,0,0,301,302,5,
|
| 174 |
+
105,0,0,302,303,5,99,0,0,303,304,5,107,0,0,304,305,5,115,0,0,305,
|
| 175 |
+
306,5,112,0,0,306,307,5,97,0,0,307,308,5,99,0,0,308,309,5,101,0,
|
| 176 |
+
0,309,310,1,0,0,0,310,311,6,10,0,0,311,22,1,0,0,0,312,313,5,92,0,
|
| 177 |
+
0,313,314,5,108,0,0,314,315,5,101,0,0,315,316,5,102,0,0,316,317,
|
| 178 |
+
5,116,0,0,317,318,1,0,0,0,318,319,6,11,0,0,319,24,1,0,0,0,320,321,
|
| 179 |
+
5,92,0,0,321,322,5,114,0,0,322,323,5,105,0,0,323,324,5,103,0,0,324,
|
| 180 |
+
325,5,104,0,0,325,326,5,116,0,0,326,327,1,0,0,0,327,328,6,12,0,0,
|
| 181 |
+
328,26,1,0,0,0,329,330,5,92,0,0,330,331,5,118,0,0,331,332,5,114,
|
| 182 |
+
0,0,332,333,5,117,0,0,333,334,5,108,0,0,334,381,5,101,0,0,335,336,
|
| 183 |
+
5,92,0,0,336,337,5,118,0,0,337,338,5,99,0,0,338,339,5,101,0,0,339,
|
| 184 |
+
340,5,110,0,0,340,341,5,116,0,0,341,342,5,101,0,0,342,381,5,114,
|
| 185 |
+
0,0,343,344,5,92,0,0,344,345,5,118,0,0,345,346,5,98,0,0,346,347,
|
| 186 |
+
5,111,0,0,347,381,5,120,0,0,348,349,5,92,0,0,349,350,5,118,0,0,350,
|
| 187 |
+
351,5,115,0,0,351,352,5,107,0,0,352,353,5,105,0,0,353,381,5,112,
|
| 188 |
+
0,0,354,355,5,92,0,0,355,356,5,118,0,0,356,357,5,115,0,0,357,358,
|
| 189 |
+
5,112,0,0,358,359,5,97,0,0,359,360,5,99,0,0,360,381,5,101,0,0,361,
|
| 190 |
+
362,5,92,0,0,362,363,5,104,0,0,363,364,5,102,0,0,364,365,5,105,0,
|
| 191 |
+
0,365,381,5,108,0,0,366,367,5,92,0,0,367,381,5,42,0,0,368,369,5,
|
| 192 |
+
92,0,0,369,381,5,45,0,0,370,371,5,92,0,0,371,381,5,46,0,0,372,373,
|
| 193 |
+
5,92,0,0,373,381,5,47,0,0,374,375,5,92,0,0,375,381,5,34,0,0,376,
|
| 194 |
+
377,5,92,0,0,377,381,5,40,0,0,378,379,5,92,0,0,379,381,5,61,0,0,
|
| 195 |
+
380,329,1,0,0,0,380,335,1,0,0,0,380,343,1,0,0,0,380,348,1,0,0,0,
|
| 196 |
+
380,354,1,0,0,0,380,361,1,0,0,0,380,366,1,0,0,0,380,368,1,0,0,0,
|
| 197 |
+
380,370,1,0,0,0,380,372,1,0,0,0,380,374,1,0,0,0,380,376,1,0,0,0,
|
| 198 |
+
380,378,1,0,0,0,381,382,1,0,0,0,382,383,6,13,0,0,383,28,1,0,0,0,
|
| 199 |
+
384,385,5,43,0,0,385,30,1,0,0,0,386,387,5,45,0,0,387,32,1,0,0,0,
|
| 200 |
+
388,389,5,42,0,0,389,34,1,0,0,0,390,391,5,47,0,0,391,36,1,0,0,0,
|
| 201 |
+
392,393,5,40,0,0,393,38,1,0,0,0,394,395,5,41,0,0,395,40,1,0,0,0,
|
| 202 |
+
396,397,5,123,0,0,397,42,1,0,0,0,398,399,5,125,0,0,399,44,1,0,0,
|
| 203 |
+
0,400,401,5,92,0,0,401,402,5,123,0,0,402,46,1,0,0,0,403,404,5,92,
|
| 204 |
+
0,0,404,405,5,125,0,0,405,48,1,0,0,0,406,407,5,91,0,0,407,50,1,0,
|
| 205 |
+
0,0,408,409,5,93,0,0,409,52,1,0,0,0,410,411,5,124,0,0,411,54,1,0,
|
| 206 |
+
0,0,412,413,5,92,0,0,413,414,5,114,0,0,414,415,5,105,0,0,415,416,
|
| 207 |
+
5,103,0,0,416,417,5,104,0,0,417,418,5,116,0,0,418,419,5,124,0,0,
|
| 208 |
+
419,56,1,0,0,0,420,421,5,92,0,0,421,422,5,108,0,0,422,423,5,101,
|
| 209 |
+
0,0,423,424,5,102,0,0,424,425,5,116,0,0,425,426,5,124,0,0,426,58,
|
| 210 |
+
1,0,0,0,427,428,5,92,0,0,428,429,5,108,0,0,429,430,5,97,0,0,430,
|
| 211 |
+
431,5,110,0,0,431,432,5,103,0,0,432,433,5,108,0,0,433,434,5,101,
|
| 212 |
+
0,0,434,60,1,0,0,0,435,436,5,92,0,0,436,437,5,114,0,0,437,438,5,
|
| 213 |
+
97,0,0,438,439,5,110,0,0,439,440,5,103,0,0,440,441,5,108,0,0,441,
|
| 214 |
+
442,5,101,0,0,442,62,1,0,0,0,443,444,5,92,0,0,444,445,5,108,0,0,
|
| 215 |
+
445,446,5,105,0,0,446,447,5,109,0,0,447,64,1,0,0,0,448,449,5,92,
|
| 216 |
+
0,0,449,450,5,116,0,0,450,504,5,111,0,0,451,452,5,92,0,0,452,453,
|
| 217 |
+
5,114,0,0,453,454,5,105,0,0,454,455,5,103,0,0,455,456,5,104,0,0,
|
| 218 |
+
456,457,5,116,0,0,457,458,5,97,0,0,458,459,5,114,0,0,459,460,5,114,
|
| 219 |
+
0,0,460,461,5,111,0,0,461,504,5,119,0,0,462,463,5,92,0,0,463,464,
|
| 220 |
+
5,82,0,0,464,465,5,105,0,0,465,466,5,103,0,0,466,467,5,104,0,0,467,
|
| 221 |
+
468,5,116,0,0,468,469,5,97,0,0,469,470,5,114,0,0,470,471,5,114,0,
|
| 222 |
+
0,471,472,5,111,0,0,472,504,5,119,0,0,473,474,5,92,0,0,474,475,5,
|
| 223 |
+
108,0,0,475,476,5,111,0,0,476,477,5,110,0,0,477,478,5,103,0,0,478,
|
| 224 |
+
479,5,114,0,0,479,480,5,105,0,0,480,481,5,103,0,0,481,482,5,104,
|
| 225 |
+
0,0,482,483,5,116,0,0,483,484,5,97,0,0,484,485,5,114,0,0,485,486,
|
| 226 |
+
5,114,0,0,486,487,5,111,0,0,487,504,5,119,0,0,488,489,5,92,0,0,489,
|
| 227 |
+
490,5,76,0,0,490,491,5,111,0,0,491,492,5,110,0,0,492,493,5,103,0,
|
| 228 |
+
0,493,494,5,114,0,0,494,495,5,105,0,0,495,496,5,103,0,0,496,497,
|
| 229 |
+
5,104,0,0,497,498,5,116,0,0,498,499,5,97,0,0,499,500,5,114,0,0,500,
|
| 230 |
+
501,5,114,0,0,501,502,5,111,0,0,502,504,5,119,0,0,503,448,1,0,0,
|
| 231 |
+
0,503,451,1,0,0,0,503,462,1,0,0,0,503,473,1,0,0,0,503,488,1,0,0,
|
| 232 |
+
0,504,66,1,0,0,0,505,506,5,92,0,0,506,507,5,105,0,0,507,508,5,110,
|
| 233 |
+
0,0,508,521,5,116,0,0,509,510,5,92,0,0,510,511,5,105,0,0,511,512,
|
| 234 |
+
5,110,0,0,512,513,5,116,0,0,513,514,5,92,0,0,514,515,5,108,0,0,515,
|
| 235 |
+
516,5,105,0,0,516,517,5,109,0,0,517,518,5,105,0,0,518,519,5,116,
|
| 236 |
+
0,0,519,521,5,115,0,0,520,505,1,0,0,0,520,509,1,0,0,0,521,68,1,0,
|
| 237 |
+
0,0,522,523,5,92,0,0,523,524,5,115,0,0,524,525,5,117,0,0,525,526,
|
| 238 |
+
5,109,0,0,526,70,1,0,0,0,527,528,5,92,0,0,528,529,5,112,0,0,529,
|
| 239 |
+
530,5,114,0,0,530,531,5,111,0,0,531,532,5,100,0,0,532,72,1,0,0,0,
|
| 240 |
+
533,534,5,92,0,0,534,535,5,101,0,0,535,536,5,120,0,0,536,537,5,112,
|
| 241 |
+
0,0,537,74,1,0,0,0,538,539,5,92,0,0,539,540,5,108,0,0,540,541,5,
|
| 242 |
+
111,0,0,541,542,5,103,0,0,542,76,1,0,0,0,543,544,5,92,0,0,544,545,
|
| 243 |
+
5,108,0,0,545,546,5,103,0,0,546,78,1,0,0,0,547,548,5,92,0,0,548,
|
| 244 |
+
549,5,108,0,0,549,550,5,110,0,0,550,80,1,0,0,0,551,552,5,92,0,0,
|
| 245 |
+
552,553,5,115,0,0,553,554,5,105,0,0,554,555,5,110,0,0,555,82,1,0,
|
| 246 |
+
0,0,556,557,5,92,0,0,557,558,5,99,0,0,558,559,5,111,0,0,559,560,
|
| 247 |
+
5,115,0,0,560,84,1,0,0,0,561,562,5,92,0,0,562,563,5,116,0,0,563,
|
| 248 |
+
564,5,97,0,0,564,565,5,110,0,0,565,86,1,0,0,0,566,567,5,92,0,0,567,
|
| 249 |
+
568,5,99,0,0,568,569,5,115,0,0,569,570,5,99,0,0,570,88,1,0,0,0,571,
|
| 250 |
+
572,5,92,0,0,572,573,5,115,0,0,573,574,5,101,0,0,574,575,5,99,0,
|
| 251 |
+
0,575,90,1,0,0,0,576,577,5,92,0,0,577,578,5,99,0,0,578,579,5,111,
|
| 252 |
+
0,0,579,580,5,116,0,0,580,92,1,0,0,0,581,582,5,92,0,0,582,583,5,
|
| 253 |
+
97,0,0,583,584,5,114,0,0,584,585,5,99,0,0,585,586,5,115,0,0,586,
|
| 254 |
+
587,5,105,0,0,587,588,5,110,0,0,588,94,1,0,0,0,589,590,5,92,0,0,
|
| 255 |
+
590,591,5,97,0,0,591,592,5,114,0,0,592,593,5,99,0,0,593,594,5,99,
|
| 256 |
+
0,0,594,595,5,111,0,0,595,596,5,115,0,0,596,96,1,0,0,0,597,598,5,
|
| 257 |
+
92,0,0,598,599,5,97,0,0,599,600,5,114,0,0,600,601,5,99,0,0,601,602,
|
| 258 |
+
5,116,0,0,602,603,5,97,0,0,603,604,5,110,0,0,604,98,1,0,0,0,605,
|
| 259 |
+
606,5,92,0,0,606,607,5,97,0,0,607,608,5,114,0,0,608,609,5,99,0,0,
|
| 260 |
+
609,610,5,99,0,0,610,611,5,115,0,0,611,612,5,99,0,0,612,100,1,0,
|
| 261 |
+
0,0,613,614,5,92,0,0,614,615,5,97,0,0,615,616,5,114,0,0,616,617,
|
| 262 |
+
5,99,0,0,617,618,5,115,0,0,618,619,5,101,0,0,619,620,5,99,0,0,620,
|
| 263 |
+
102,1,0,0,0,621,622,5,92,0,0,622,623,5,97,0,0,623,624,5,114,0,0,
|
| 264 |
+
624,625,5,99,0,0,625,626,5,99,0,0,626,627,5,111,0,0,627,628,5,116,
|
| 265 |
+
0,0,628,104,1,0,0,0,629,630,5,92,0,0,630,631,5,115,0,0,631,632,5,
|
| 266 |
+
105,0,0,632,633,5,110,0,0,633,634,5,104,0,0,634,106,1,0,0,0,635,
|
| 267 |
+
636,5,92,0,0,636,637,5,99,0,0,637,638,5,111,0,0,638,639,5,115,0,
|
| 268 |
+
0,639,640,5,104,0,0,640,108,1,0,0,0,641,642,5,92,0,0,642,643,5,116,
|
| 269 |
+
0,0,643,644,5,97,0,0,644,645,5,110,0,0,645,646,5,104,0,0,646,110,
|
| 270 |
+
1,0,0,0,647,648,5,92,0,0,648,649,5,97,0,0,649,650,5,114,0,0,650,
|
| 271 |
+
651,5,115,0,0,651,652,5,105,0,0,652,653,5,110,0,0,653,654,5,104,
|
| 272 |
+
0,0,654,112,1,0,0,0,655,656,5,92,0,0,656,657,5,97,0,0,657,658,5,
|
| 273 |
+
114,0,0,658,659,5,99,0,0,659,660,5,111,0,0,660,661,5,115,0,0,661,
|
| 274 |
+
662,5,104,0,0,662,114,1,0,0,0,663,664,5,92,0,0,664,665,5,97,0,0,
|
| 275 |
+
665,666,5,114,0,0,666,667,5,116,0,0,667,668,5,97,0,0,668,669,5,110,
|
| 276 |
+
0,0,669,670,5,104,0,0,670,116,1,0,0,0,671,672,5,92,0,0,672,673,5,
|
| 277 |
+
108,0,0,673,674,5,102,0,0,674,675,5,108,0,0,675,676,5,111,0,0,676,
|
| 278 |
+
677,5,111,0,0,677,678,5,114,0,0,678,118,1,0,0,0,679,680,5,92,0,0,
|
| 279 |
+
680,681,5,114,0,0,681,682,5,102,0,0,682,683,5,108,0,0,683,684,5,
|
| 280 |
+
111,0,0,684,685,5,111,0,0,685,686,5,114,0,0,686,120,1,0,0,0,687,
|
| 281 |
+
688,5,92,0,0,688,689,5,108,0,0,689,690,5,99,0,0,690,691,5,101,0,
|
| 282 |
+
0,691,692,5,105,0,0,692,693,5,108,0,0,693,122,1,0,0,0,694,695,5,
|
| 283 |
+
92,0,0,695,696,5,114,0,0,696,697,5,99,0,0,697,698,5,101,0,0,698,
|
| 284 |
+
699,5,105,0,0,699,700,5,108,0,0,700,124,1,0,0,0,701,702,5,92,0,0,
|
| 285 |
+
702,703,5,115,0,0,703,704,5,113,0,0,704,705,5,114,0,0,705,706,5,
|
| 286 |
+
116,0,0,706,126,1,0,0,0,707,708,5,92,0,0,708,709,5,111,0,0,709,710,
|
| 287 |
+
5,118,0,0,710,711,5,101,0,0,711,712,5,114,0,0,712,713,5,108,0,0,
|
| 288 |
+
713,714,5,105,0,0,714,715,5,110,0,0,715,716,5,101,0,0,716,128,1,
|
| 289 |
+
0,0,0,717,718,5,92,0,0,718,719,5,116,0,0,719,720,5,105,0,0,720,721,
|
| 290 |
+
5,109,0,0,721,722,5,101,0,0,722,723,5,115,0,0,723,130,1,0,0,0,724,
|
| 291 |
+
725,5,92,0,0,725,726,5,99,0,0,726,727,5,100,0,0,727,728,5,111,0,
|
| 292 |
+
0,728,729,5,116,0,0,729,132,1,0,0,0,730,731,5,92,0,0,731,732,5,100,
|
| 293 |
+
0,0,732,733,5,105,0,0,733,734,5,118,0,0,734,134,1,0,0,0,735,736,
|
| 294 |
+
5,92,0,0,736,737,5,102,0,0,737,738,5,114,0,0,738,739,5,97,0,0,739,
|
| 295 |
+
753,5,99,0,0,740,741,5,92,0,0,741,742,5,100,0,0,742,743,5,102,0,
|
| 296 |
+
0,743,744,5,114,0,0,744,745,5,97,0,0,745,753,5,99,0,0,746,747,5,
|
| 297 |
+
92,0,0,747,748,5,116,0,0,748,749,5,102,0,0,749,750,5,114,0,0,750,
|
| 298 |
+
751,5,97,0,0,751,753,5,99,0,0,752,735,1,0,0,0,752,740,1,0,0,0,752,
|
| 299 |
+
746,1,0,0,0,753,136,1,0,0,0,754,755,5,92,0,0,755,756,5,98,0,0,756,
|
| 300 |
+
757,5,105,0,0,757,758,5,110,0,0,758,759,5,111,0,0,759,760,5,109,
|
| 301 |
+
0,0,760,138,1,0,0,0,761,762,5,92,0,0,762,763,5,100,0,0,763,764,5,
|
| 302 |
+
98,0,0,764,765,5,105,0,0,765,766,5,110,0,0,766,767,5,111,0,0,767,
|
| 303 |
+
768,5,109,0,0,768,140,1,0,0,0,769,770,5,92,0,0,770,771,5,116,0,0,
|
| 304 |
+
771,772,5,98,0,0,772,773,5,105,0,0,773,774,5,110,0,0,774,775,5,111,
|
| 305 |
+
0,0,775,776,5,109,0,0,776,142,1,0,0,0,777,778,5,92,0,0,778,779,5,
|
| 306 |
+
109,0,0,779,780,5,97,0,0,780,781,5,116,0,0,781,782,5,104,0,0,782,
|
| 307 |
+
783,5,105,0,0,783,784,5,116,0,0,784,144,1,0,0,0,785,786,5,95,0,0,
|
| 308 |
+
786,146,1,0,0,0,787,788,5,94,0,0,788,148,1,0,0,0,789,790,5,58,0,
|
| 309 |
+
0,790,150,1,0,0,0,791,792,7,0,0,0,792,152,1,0,0,0,793,797,5,100,
|
| 310 |
+
0,0,794,796,3,151,75,0,795,794,1,0,0,0,796,799,1,0,0,0,797,798,1,
|
| 311 |
+
0,0,0,797,795,1,0,0,0,798,807,1,0,0,0,799,797,1,0,0,0,800,808,7,
|
| 312 |
+
1,0,0,801,803,5,92,0,0,802,804,7,1,0,0,803,802,1,0,0,0,804,805,1,
|
| 313 |
+
0,0,0,805,803,1,0,0,0,805,806,1,0,0,0,806,808,1,0,0,0,807,800,1,
|
| 314 |
+
0,0,0,807,801,1,0,0,0,808,154,1,0,0,0,809,810,7,1,0,0,810,156,1,
|
| 315 |
+
0,0,0,811,812,7,2,0,0,812,158,1,0,0,0,813,817,5,38,0,0,814,816,3,
|
| 316 |
+
151,75,0,815,814,1,0,0,0,816,819,1,0,0,0,817,818,1,0,0,0,817,815,
|
| 317 |
+
1,0,0,0,818,821,1,0,0,0,819,817,1,0,0,0,820,813,1,0,0,0,820,821,
|
| 318 |
+
1,0,0,0,821,822,1,0,0,0,822,834,5,61,0,0,823,831,5,61,0,0,824,826,
|
| 319 |
+
3,151,75,0,825,824,1,0,0,0,826,829,1,0,0,0,827,828,1,0,0,0,827,825,
|
| 320 |
+
1,0,0,0,828,830,1,0,0,0,829,827,1,0,0,0,830,832,5,38,0,0,831,827,
|
| 321 |
+
1,0,0,0,831,832,1,0,0,0,832,834,1,0,0,0,833,820,1,0,0,0,833,823,
|
| 322 |
+
1,0,0,0,834,160,1,0,0,0,835,836,5,92,0,0,836,837,5,110,0,0,837,838,
|
| 323 |
+
5,101,0,0,838,839,5,113,0,0,839,162,1,0,0,0,840,841,5,60,0,0,841,
|
| 324 |
+
164,1,0,0,0,842,843,5,92,0,0,843,844,5,108,0,0,844,845,5,101,0,0,
|
| 325 |
+
845,852,5,113,0,0,846,847,5,92,0,0,847,848,5,108,0,0,848,852,5,101,
|
| 326 |
+
0,0,849,852,3,167,83,0,850,852,3,169,84,0,851,842,1,0,0,0,851,846,
|
| 327 |
+
1,0,0,0,851,849,1,0,0,0,851,850,1,0,0,0,852,166,1,0,0,0,853,854,
|
| 328 |
+
5,92,0,0,854,855,5,108,0,0,855,856,5,101,0,0,856,857,5,113,0,0,857,
|
| 329 |
+
858,5,113,0,0,858,168,1,0,0,0,859,860,5,92,0,0,860,861,5,108,0,0,
|
| 330 |
+
861,862,5,101,0,0,862,863,5,113,0,0,863,864,5,115,0,0,864,865,5,
|
| 331 |
+
108,0,0,865,866,5,97,0,0,866,867,5,110,0,0,867,868,5,116,0,0,868,
|
| 332 |
+
170,1,0,0,0,869,870,5,62,0,0,870,172,1,0,0,0,871,872,5,92,0,0,872,
|
| 333 |
+
873,5,103,0,0,873,874,5,101,0,0,874,881,5,113,0,0,875,876,5,92,0,
|
| 334 |
+
0,876,877,5,103,0,0,877,881,5,101,0,0,878,881,3,175,87,0,879,881,
|
| 335 |
+
3,177,88,0,880,871,1,0,0,0,880,875,1,0,0,0,880,878,1,0,0,0,880,879,
|
| 336 |
+
1,0,0,0,881,174,1,0,0,0,882,883,5,92,0,0,883,884,5,103,0,0,884,885,
|
| 337 |
+
5,101,0,0,885,886,5,113,0,0,886,887,5,113,0,0,887,176,1,0,0,0,888,
|
| 338 |
+
889,5,92,0,0,889,890,5,103,0,0,890,891,5,101,0,0,891,892,5,113,0,
|
| 339 |
+
0,892,893,5,115,0,0,893,894,5,108,0,0,894,895,5,97,0,0,895,896,5,
|
| 340 |
+
110,0,0,896,897,5,116,0,0,897,178,1,0,0,0,898,899,5,33,0,0,899,180,
|
| 341 |
+
1,0,0,0,900,902,5,39,0,0,901,900,1,0,0,0,902,903,1,0,0,0,903,901,
|
| 342 |
+
1,0,0,0,903,904,1,0,0,0,904,182,1,0,0,0,905,907,5,92,0,0,906,908,
|
| 343 |
+
7,1,0,0,907,906,1,0,0,0,908,909,1,0,0,0,909,907,1,0,0,0,909,910,
|
| 344 |
+
1,0,0,0,910,184,1,0,0,0,22,0,192,208,223,240,276,380,503,520,752,
|
| 345 |
+
797,805,807,817,820,827,831,833,851,880,903,909,1,6,0,0
|
| 346 |
+
]
|
| 347 |
+
|
| 348 |
+
class LaTeXLexer(Lexer):
|
| 349 |
+
|
| 350 |
+
atn = ATNDeserializer().deserialize(serializedATN())
|
| 351 |
+
|
| 352 |
+
decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
|
| 353 |
+
|
| 354 |
+
T__0 = 1
|
| 355 |
+
T__1 = 2
|
| 356 |
+
WS = 3
|
| 357 |
+
THINSPACE = 4
|
| 358 |
+
MEDSPACE = 5
|
| 359 |
+
THICKSPACE = 6
|
| 360 |
+
QUAD = 7
|
| 361 |
+
QQUAD = 8
|
| 362 |
+
NEGTHINSPACE = 9
|
| 363 |
+
NEGMEDSPACE = 10
|
| 364 |
+
NEGTHICKSPACE = 11
|
| 365 |
+
CMD_LEFT = 12
|
| 366 |
+
CMD_RIGHT = 13
|
| 367 |
+
IGNORE = 14
|
| 368 |
+
ADD = 15
|
| 369 |
+
SUB = 16
|
| 370 |
+
MUL = 17
|
| 371 |
+
DIV = 18
|
| 372 |
+
L_PAREN = 19
|
| 373 |
+
R_PAREN = 20
|
| 374 |
+
L_BRACE = 21
|
| 375 |
+
R_BRACE = 22
|
| 376 |
+
L_BRACE_LITERAL = 23
|
| 377 |
+
R_BRACE_LITERAL = 24
|
| 378 |
+
L_BRACKET = 25
|
| 379 |
+
R_BRACKET = 26
|
| 380 |
+
BAR = 27
|
| 381 |
+
R_BAR = 28
|
| 382 |
+
L_BAR = 29
|
| 383 |
+
L_ANGLE = 30
|
| 384 |
+
R_ANGLE = 31
|
| 385 |
+
FUNC_LIM = 32
|
| 386 |
+
LIM_APPROACH_SYM = 33
|
| 387 |
+
FUNC_INT = 34
|
| 388 |
+
FUNC_SUM = 35
|
| 389 |
+
FUNC_PROD = 36
|
| 390 |
+
FUNC_EXP = 37
|
| 391 |
+
FUNC_LOG = 38
|
| 392 |
+
FUNC_LG = 39
|
| 393 |
+
FUNC_LN = 40
|
| 394 |
+
FUNC_SIN = 41
|
| 395 |
+
FUNC_COS = 42
|
| 396 |
+
FUNC_TAN = 43
|
| 397 |
+
FUNC_CSC = 44
|
| 398 |
+
FUNC_SEC = 45
|
| 399 |
+
FUNC_COT = 46
|
| 400 |
+
FUNC_ARCSIN = 47
|
| 401 |
+
FUNC_ARCCOS = 48
|
| 402 |
+
FUNC_ARCTAN = 49
|
| 403 |
+
FUNC_ARCCSC = 50
|
| 404 |
+
FUNC_ARCSEC = 51
|
| 405 |
+
FUNC_ARCCOT = 52
|
| 406 |
+
FUNC_SINH = 53
|
| 407 |
+
FUNC_COSH = 54
|
| 408 |
+
FUNC_TANH = 55
|
| 409 |
+
FUNC_ARSINH = 56
|
| 410 |
+
FUNC_ARCOSH = 57
|
| 411 |
+
FUNC_ARTANH = 58
|
| 412 |
+
L_FLOOR = 59
|
| 413 |
+
R_FLOOR = 60
|
| 414 |
+
L_CEIL = 61
|
| 415 |
+
R_CEIL = 62
|
| 416 |
+
FUNC_SQRT = 63
|
| 417 |
+
FUNC_OVERLINE = 64
|
| 418 |
+
CMD_TIMES = 65
|
| 419 |
+
CMD_CDOT = 66
|
| 420 |
+
CMD_DIV = 67
|
| 421 |
+
CMD_FRAC = 68
|
| 422 |
+
CMD_BINOM = 69
|
| 423 |
+
CMD_DBINOM = 70
|
| 424 |
+
CMD_TBINOM = 71
|
| 425 |
+
CMD_MATHIT = 72
|
| 426 |
+
UNDERSCORE = 73
|
| 427 |
+
CARET = 74
|
| 428 |
+
COLON = 75
|
| 429 |
+
DIFFERENTIAL = 76
|
| 430 |
+
LETTER = 77
|
| 431 |
+
DIGIT = 78
|
| 432 |
+
EQUAL = 79
|
| 433 |
+
NEQ = 80
|
| 434 |
+
LT = 81
|
| 435 |
+
LTE = 82
|
| 436 |
+
LTE_Q = 83
|
| 437 |
+
LTE_S = 84
|
| 438 |
+
GT = 85
|
| 439 |
+
GTE = 86
|
| 440 |
+
GTE_Q = 87
|
| 441 |
+
GTE_S = 88
|
| 442 |
+
BANG = 89
|
| 443 |
+
SINGLE_QUOTES = 90
|
| 444 |
+
SYMBOL = 91
|
| 445 |
+
|
| 446 |
+
channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ]
|
| 447 |
+
|
| 448 |
+
modeNames = [ "DEFAULT_MODE" ]
|
| 449 |
+
|
| 450 |
+
literalNames = [ "<INVALID>",
|
| 451 |
+
"','", "'.'", "'\\quad'", "'\\qquad'", "'\\negmedspace'", "'\\negthickspace'",
|
| 452 |
+
"'\\left'", "'\\right'", "'+'", "'-'", "'*'", "'/'", "'('",
|
| 453 |
+
"')'", "'{'", "'}'", "'\\{'", "'\\}'", "'['", "']'", "'|'",
|
| 454 |
+
"'\\right|'", "'\\left|'", "'\\langle'", "'\\rangle'", "'\\lim'",
|
| 455 |
+
"'\\sum'", "'\\prod'", "'\\exp'", "'\\log'", "'\\lg'", "'\\ln'",
|
| 456 |
+
"'\\sin'", "'\\cos'", "'\\tan'", "'\\csc'", "'\\sec'", "'\\cot'",
|
| 457 |
+
"'\\arcsin'", "'\\arccos'", "'\\arctan'", "'\\arccsc'", "'\\arcsec'",
|
| 458 |
+
"'\\arccot'", "'\\sinh'", "'\\cosh'", "'\\tanh'", "'\\arsinh'",
|
| 459 |
+
"'\\arcosh'", "'\\artanh'", "'\\lfloor'", "'\\rfloor'", "'\\lceil'",
|
| 460 |
+
"'\\rceil'", "'\\sqrt'", "'\\overline'", "'\\times'", "'\\cdot'",
|
| 461 |
+
"'\\div'", "'\\binom'", "'\\dbinom'", "'\\tbinom'", "'\\mathit'",
|
| 462 |
+
"'_'", "'^'", "':'", "'\\neq'", "'<'", "'\\leqq'", "'\\leqslant'",
|
| 463 |
+
"'>'", "'\\geqq'", "'\\geqslant'", "'!'" ]
|
| 464 |
+
|
| 465 |
+
symbolicNames = [ "<INVALID>",
|
| 466 |
+
"WS", "THINSPACE", "MEDSPACE", "THICKSPACE", "QUAD", "QQUAD",
|
| 467 |
+
"NEGTHINSPACE", "NEGMEDSPACE", "NEGTHICKSPACE", "CMD_LEFT",
|
| 468 |
+
"CMD_RIGHT", "IGNORE", "ADD", "SUB", "MUL", "DIV", "L_PAREN",
|
| 469 |
+
"R_PAREN", "L_BRACE", "R_BRACE", "L_BRACE_LITERAL", "R_BRACE_LITERAL",
|
| 470 |
+
"L_BRACKET", "R_BRACKET", "BAR", "R_BAR", "L_BAR", "L_ANGLE",
|
| 471 |
+
"R_ANGLE", "FUNC_LIM", "LIM_APPROACH_SYM", "FUNC_INT", "FUNC_SUM",
|
| 472 |
+
"FUNC_PROD", "FUNC_EXP", "FUNC_LOG", "FUNC_LG", "FUNC_LN", "FUNC_SIN",
|
| 473 |
+
"FUNC_COS", "FUNC_TAN", "FUNC_CSC", "FUNC_SEC", "FUNC_COT",
|
| 474 |
+
"FUNC_ARCSIN", "FUNC_ARCCOS", "FUNC_ARCTAN", "FUNC_ARCCSC",
|
| 475 |
+
"FUNC_ARCSEC", "FUNC_ARCCOT", "FUNC_SINH", "FUNC_COSH", "FUNC_TANH",
|
| 476 |
+
"FUNC_ARSINH", "FUNC_ARCOSH", "FUNC_ARTANH", "L_FLOOR", "R_FLOOR",
|
| 477 |
+
"L_CEIL", "R_CEIL", "FUNC_SQRT", "FUNC_OVERLINE", "CMD_TIMES",
|
| 478 |
+
"CMD_CDOT", "CMD_DIV", "CMD_FRAC", "CMD_BINOM", "CMD_DBINOM",
|
| 479 |
+
"CMD_TBINOM", "CMD_MATHIT", "UNDERSCORE", "CARET", "COLON",
|
| 480 |
+
"DIFFERENTIAL", "LETTER", "DIGIT", "EQUAL", "NEQ", "LT", "LTE",
|
| 481 |
+
"LTE_Q", "LTE_S", "GT", "GTE", "GTE_Q", "GTE_S", "BANG", "SINGLE_QUOTES",
|
| 482 |
+
"SYMBOL" ]
|
| 483 |
+
|
| 484 |
+
ruleNames = [ "T__0", "T__1", "WS", "THINSPACE", "MEDSPACE", "THICKSPACE",
|
| 485 |
+
"QUAD", "QQUAD", "NEGTHINSPACE", "NEGMEDSPACE", "NEGTHICKSPACE",
|
| 486 |
+
"CMD_LEFT", "CMD_RIGHT", "IGNORE", "ADD", "SUB", "MUL",
|
| 487 |
+
"DIV", "L_PAREN", "R_PAREN", "L_BRACE", "R_BRACE", "L_BRACE_LITERAL",
|
| 488 |
+
"R_BRACE_LITERAL", "L_BRACKET", "R_BRACKET", "BAR", "R_BAR",
|
| 489 |
+
"L_BAR", "L_ANGLE", "R_ANGLE", "FUNC_LIM", "LIM_APPROACH_SYM",
|
| 490 |
+
"FUNC_INT", "FUNC_SUM", "FUNC_PROD", "FUNC_EXP", "FUNC_LOG",
|
| 491 |
+
"FUNC_LG", "FUNC_LN", "FUNC_SIN", "FUNC_COS", "FUNC_TAN",
|
| 492 |
+
"FUNC_CSC", "FUNC_SEC", "FUNC_COT", "FUNC_ARCSIN", "FUNC_ARCCOS",
|
| 493 |
+
"FUNC_ARCTAN", "FUNC_ARCCSC", "FUNC_ARCSEC", "FUNC_ARCCOT",
|
| 494 |
+
"FUNC_SINH", "FUNC_COSH", "FUNC_TANH", "FUNC_ARSINH",
|
| 495 |
+
"FUNC_ARCOSH", "FUNC_ARTANH", "L_FLOOR", "R_FLOOR", "L_CEIL",
|
| 496 |
+
"R_CEIL", "FUNC_SQRT", "FUNC_OVERLINE", "CMD_TIMES", "CMD_CDOT",
|
| 497 |
+
"CMD_DIV", "CMD_FRAC", "CMD_BINOM", "CMD_DBINOM", "CMD_TBINOM",
|
| 498 |
+
"CMD_MATHIT", "UNDERSCORE", "CARET", "COLON", "WS_CHAR",
|
| 499 |
+
"DIFFERENTIAL", "LETTER", "DIGIT", "EQUAL", "NEQ", "LT",
|
| 500 |
+
"LTE", "LTE_Q", "LTE_S", "GT", "GTE", "GTE_Q", "GTE_S",
|
| 501 |
+
"BANG", "SINGLE_QUOTES", "SYMBOL" ]
|
| 502 |
+
|
| 503 |
+
grammarFileName = "LaTeX.g4"
|
| 504 |
+
|
| 505 |
+
def __init__(self, input=None, output:TextIO = sys.stdout):
|
| 506 |
+
super().__init__(input, output)
|
| 507 |
+
self.checkVersion("4.11.1")
|
| 508 |
+
self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
|
| 509 |
+
self._actions = None
|
| 510 |
+
self._predicates = None
|
| 511 |
+
|
| 512 |
+
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/_antlr/latexparser.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/_build_latex_antlr.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import subprocess
|
| 3 |
+
import glob
|
| 4 |
+
|
| 5 |
+
from sympy.utilities.misc import debug
|
| 6 |
+
|
| 7 |
+
here = os.path.dirname(__file__)
|
| 8 |
+
grammar_file = os.path.abspath(os.path.join(here, "LaTeX.g4"))
|
| 9 |
+
dir_latex_antlr = os.path.join(here, "_antlr")
|
| 10 |
+
|
| 11 |
+
header = '''\
|
| 12 |
+
# *** GENERATED BY `setup.py antlr`, DO NOT EDIT BY HAND ***
|
| 13 |
+
#
|
| 14 |
+
# Generated from ../LaTeX.g4, derived from latex2sympy
|
| 15 |
+
# latex2sympy is licensed under the MIT license
|
| 16 |
+
# https://github.com/augustt198/latex2sympy/blob/master/LICENSE.txt
|
| 17 |
+
#
|
| 18 |
+
# Generated with antlr4
|
| 19 |
+
# antlr4 is licensed under the BSD-3-Clause License
|
| 20 |
+
# https://github.com/antlr/antlr4/blob/master/LICENSE.txt
|
| 21 |
+
'''
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def check_antlr_version():
|
| 25 |
+
debug("Checking antlr4 version...")
|
| 26 |
+
|
| 27 |
+
try:
|
| 28 |
+
debug(subprocess.check_output(["antlr4"])
|
| 29 |
+
.decode('utf-8').split("\n")[0])
|
| 30 |
+
return True
|
| 31 |
+
except (subprocess.CalledProcessError, FileNotFoundError):
|
| 32 |
+
debug("The 'antlr4' command line tool is not installed, "
|
| 33 |
+
"or not on your PATH.\n"
|
| 34 |
+
"> Please refer to the README.md file for more information.")
|
| 35 |
+
return False
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def build_parser(output_dir=dir_latex_antlr):
|
| 39 |
+
check_antlr_version()
|
| 40 |
+
|
| 41 |
+
debug("Updating ANTLR-generated code in {}".format(output_dir))
|
| 42 |
+
|
| 43 |
+
if not os.path.exists(output_dir):
|
| 44 |
+
os.makedirs(output_dir)
|
| 45 |
+
|
| 46 |
+
with open(os.path.join(output_dir, "__init__.py"), "w+") as fp:
|
| 47 |
+
fp.write(header)
|
| 48 |
+
|
| 49 |
+
args = [
|
| 50 |
+
"antlr4",
|
| 51 |
+
grammar_file,
|
| 52 |
+
"-o", output_dir,
|
| 53 |
+
# for now, not generating these as latex2sympy did not use them
|
| 54 |
+
"-no-visitor",
|
| 55 |
+
"-no-listener",
|
| 56 |
+
]
|
| 57 |
+
|
| 58 |
+
debug("Running code generation...\n\t$ {}".format(" ".join(args)))
|
| 59 |
+
subprocess.check_output(args, cwd=output_dir)
|
| 60 |
+
|
| 61 |
+
debug("Applying headers, removing unnecessary files and renaming...")
|
| 62 |
+
# Handle case insensitive file systems. If the files are already
|
| 63 |
+
# generated, they will be written to latex* but LaTeX*.* won't match them.
|
| 64 |
+
for path in (glob.glob(os.path.join(output_dir, "LaTeX*.*")) or
|
| 65 |
+
glob.glob(os.path.join(output_dir, "latex*.*"))):
|
| 66 |
+
|
| 67 |
+
# Remove files ending in .interp or .tokens as they are not needed.
|
| 68 |
+
if not path.endswith(".py"):
|
| 69 |
+
os.unlink(path)
|
| 70 |
+
continue
|
| 71 |
+
|
| 72 |
+
new_path = os.path.join(output_dir, os.path.basename(path).lower())
|
| 73 |
+
with open(path, 'r') as f:
|
| 74 |
+
lines = [line.rstrip() + '\n' for line in f]
|
| 75 |
+
|
| 76 |
+
os.unlink(path)
|
| 77 |
+
|
| 78 |
+
with open(new_path, "w") as out_file:
|
| 79 |
+
offset = 0
|
| 80 |
+
while lines[offset].startswith('#'):
|
| 81 |
+
offset += 1
|
| 82 |
+
out_file.write(header)
|
| 83 |
+
out_file.writelines(lines[offset:])
|
| 84 |
+
|
| 85 |
+
debug("\t{}".format(new_path))
|
| 86 |
+
|
| 87 |
+
return True
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
if __name__ == "__main__":
|
| 91 |
+
build_parser()
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/_parse_latex_antlr.py
ADDED
|
@@ -0,0 +1,607 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ported from latex2sympy by @augustt198
|
| 2 |
+
# https://github.com/augustt198/latex2sympy
|
| 3 |
+
# See license in LICENSE.txt
|
| 4 |
+
from importlib.metadata import version
|
| 5 |
+
import sympy
|
| 6 |
+
from sympy.external import import_module
|
| 7 |
+
from sympy.printing.str import StrPrinter
|
| 8 |
+
from sympy.physics.quantum.state import Bra, Ket
|
| 9 |
+
|
| 10 |
+
from .errors import LaTeXParsingError
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
LaTeXParser = LaTeXLexer = MathErrorListener = None
|
| 14 |
+
|
| 15 |
+
try:
|
| 16 |
+
LaTeXParser = import_module('sympy.parsing.latex._antlr.latexparser',
|
| 17 |
+
import_kwargs={'fromlist': ['LaTeXParser']}).LaTeXParser
|
| 18 |
+
LaTeXLexer = import_module('sympy.parsing.latex._antlr.latexlexer',
|
| 19 |
+
import_kwargs={'fromlist': ['LaTeXLexer']}).LaTeXLexer
|
| 20 |
+
except Exception:
|
| 21 |
+
pass
|
| 22 |
+
|
| 23 |
+
ErrorListener = import_module('antlr4.error.ErrorListener',
|
| 24 |
+
warn_not_installed=True,
|
| 25 |
+
import_kwargs={'fromlist': ['ErrorListener']}
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
if ErrorListener:
|
| 31 |
+
class MathErrorListener(ErrorListener.ErrorListener): # type:ignore # noqa:F811
|
| 32 |
+
def __init__(self, src):
|
| 33 |
+
super(ErrorListener.ErrorListener, self).__init__()
|
| 34 |
+
self.src = src
|
| 35 |
+
|
| 36 |
+
def syntaxError(self, recog, symbol, line, col, msg, e):
|
| 37 |
+
fmt = "%s\n%s\n%s"
|
| 38 |
+
marker = "~" * col + "^"
|
| 39 |
+
|
| 40 |
+
if msg.startswith("missing"):
|
| 41 |
+
err = fmt % (msg, self.src, marker)
|
| 42 |
+
elif msg.startswith("no viable"):
|
| 43 |
+
err = fmt % ("I expected something else here", self.src, marker)
|
| 44 |
+
elif msg.startswith("mismatched"):
|
| 45 |
+
names = LaTeXParser.literalNames
|
| 46 |
+
expected = [
|
| 47 |
+
names[i] for i in e.getExpectedTokens() if i < len(names)
|
| 48 |
+
]
|
| 49 |
+
if len(expected) < 10:
|
| 50 |
+
expected = " ".join(expected)
|
| 51 |
+
err = (fmt % ("I expected one of these: " + expected, self.src,
|
| 52 |
+
marker))
|
| 53 |
+
else:
|
| 54 |
+
err = (fmt % ("I expected something else here", self.src,
|
| 55 |
+
marker))
|
| 56 |
+
else:
|
| 57 |
+
err = fmt % ("I don't understand this", self.src, marker)
|
| 58 |
+
raise LaTeXParsingError(err)
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def parse_latex(sympy, strict=False):
|
| 62 |
+
antlr4 = import_module('antlr4')
|
| 63 |
+
|
| 64 |
+
if None in [antlr4, MathErrorListener] or \
|
| 65 |
+
not version('antlr4-python3-runtime').startswith('4.11'):
|
| 66 |
+
raise ImportError("LaTeX parsing requires the antlr4 Python package,"
|
| 67 |
+
" provided by pip (antlr4-python3-runtime) or"
|
| 68 |
+
" conda (antlr-python-runtime), version 4.11")
|
| 69 |
+
|
| 70 |
+
sympy = sympy.strip()
|
| 71 |
+
matherror = MathErrorListener(sympy)
|
| 72 |
+
|
| 73 |
+
stream = antlr4.InputStream(sympy)
|
| 74 |
+
lex = LaTeXLexer(stream)
|
| 75 |
+
lex.removeErrorListeners()
|
| 76 |
+
lex.addErrorListener(matherror)
|
| 77 |
+
|
| 78 |
+
tokens = antlr4.CommonTokenStream(lex)
|
| 79 |
+
parser = LaTeXParser(tokens)
|
| 80 |
+
|
| 81 |
+
# remove default console error listener
|
| 82 |
+
parser.removeErrorListeners()
|
| 83 |
+
parser.addErrorListener(matherror)
|
| 84 |
+
|
| 85 |
+
relation = parser.math().relation()
|
| 86 |
+
if strict and (relation.start.start != 0 or relation.stop.stop != len(sympy) - 1):
|
| 87 |
+
raise LaTeXParsingError("Invalid LaTeX")
|
| 88 |
+
expr = convert_relation(relation)
|
| 89 |
+
|
| 90 |
+
return expr
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
def convert_relation(rel):
|
| 94 |
+
if rel.expr():
|
| 95 |
+
return convert_expr(rel.expr())
|
| 96 |
+
|
| 97 |
+
lh = convert_relation(rel.relation(0))
|
| 98 |
+
rh = convert_relation(rel.relation(1))
|
| 99 |
+
if rel.LT():
|
| 100 |
+
return sympy.StrictLessThan(lh, rh)
|
| 101 |
+
elif rel.LTE():
|
| 102 |
+
return sympy.LessThan(lh, rh)
|
| 103 |
+
elif rel.GT():
|
| 104 |
+
return sympy.StrictGreaterThan(lh, rh)
|
| 105 |
+
elif rel.GTE():
|
| 106 |
+
return sympy.GreaterThan(lh, rh)
|
| 107 |
+
elif rel.EQUAL():
|
| 108 |
+
return sympy.Eq(lh, rh)
|
| 109 |
+
elif rel.NEQ():
|
| 110 |
+
return sympy.Ne(lh, rh)
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
def convert_expr(expr):
|
| 114 |
+
return convert_add(expr.additive())
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
def convert_add(add):
|
| 118 |
+
if add.ADD():
|
| 119 |
+
lh = convert_add(add.additive(0))
|
| 120 |
+
rh = convert_add(add.additive(1))
|
| 121 |
+
return sympy.Add(lh, rh, evaluate=False)
|
| 122 |
+
elif add.SUB():
|
| 123 |
+
lh = convert_add(add.additive(0))
|
| 124 |
+
rh = convert_add(add.additive(1))
|
| 125 |
+
if hasattr(rh, "is_Atom") and rh.is_Atom:
|
| 126 |
+
return sympy.Add(lh, -1 * rh, evaluate=False)
|
| 127 |
+
return sympy.Add(lh, sympy.Mul(-1, rh, evaluate=False), evaluate=False)
|
| 128 |
+
else:
|
| 129 |
+
return convert_mp(add.mp())
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
def convert_mp(mp):
|
| 133 |
+
if hasattr(mp, 'mp'):
|
| 134 |
+
mp_left = mp.mp(0)
|
| 135 |
+
mp_right = mp.mp(1)
|
| 136 |
+
else:
|
| 137 |
+
mp_left = mp.mp_nofunc(0)
|
| 138 |
+
mp_right = mp.mp_nofunc(1)
|
| 139 |
+
|
| 140 |
+
if mp.MUL() or mp.CMD_TIMES() or mp.CMD_CDOT():
|
| 141 |
+
lh = convert_mp(mp_left)
|
| 142 |
+
rh = convert_mp(mp_right)
|
| 143 |
+
return sympy.Mul(lh, rh, evaluate=False)
|
| 144 |
+
elif mp.DIV() or mp.CMD_DIV() or mp.COLON():
|
| 145 |
+
lh = convert_mp(mp_left)
|
| 146 |
+
rh = convert_mp(mp_right)
|
| 147 |
+
return sympy.Mul(lh, sympy.Pow(rh, -1, evaluate=False), evaluate=False)
|
| 148 |
+
else:
|
| 149 |
+
if hasattr(mp, 'unary'):
|
| 150 |
+
return convert_unary(mp.unary())
|
| 151 |
+
else:
|
| 152 |
+
return convert_unary(mp.unary_nofunc())
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
def convert_unary(unary):
|
| 156 |
+
if hasattr(unary, 'unary'):
|
| 157 |
+
nested_unary = unary.unary()
|
| 158 |
+
else:
|
| 159 |
+
nested_unary = unary.unary_nofunc()
|
| 160 |
+
if hasattr(unary, 'postfix_nofunc'):
|
| 161 |
+
first = unary.postfix()
|
| 162 |
+
tail = unary.postfix_nofunc()
|
| 163 |
+
postfix = [first] + tail
|
| 164 |
+
else:
|
| 165 |
+
postfix = unary.postfix()
|
| 166 |
+
|
| 167 |
+
if unary.ADD():
|
| 168 |
+
return convert_unary(nested_unary)
|
| 169 |
+
elif unary.SUB():
|
| 170 |
+
numabs = convert_unary(nested_unary)
|
| 171 |
+
# Use Integer(-n) instead of Mul(-1, n)
|
| 172 |
+
return -numabs
|
| 173 |
+
elif postfix:
|
| 174 |
+
return convert_postfix_list(postfix)
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
def convert_postfix_list(arr, i=0):
|
| 178 |
+
if i >= len(arr):
|
| 179 |
+
raise LaTeXParsingError("Index out of bounds")
|
| 180 |
+
|
| 181 |
+
res = convert_postfix(arr[i])
|
| 182 |
+
if isinstance(res, sympy.Expr):
|
| 183 |
+
if i == len(arr) - 1:
|
| 184 |
+
return res # nothing to multiply by
|
| 185 |
+
else:
|
| 186 |
+
if i > 0:
|
| 187 |
+
left = convert_postfix(arr[i - 1])
|
| 188 |
+
right = convert_postfix(arr[i + 1])
|
| 189 |
+
if isinstance(left, sympy.Expr) and isinstance(
|
| 190 |
+
right, sympy.Expr):
|
| 191 |
+
left_syms = convert_postfix(arr[i - 1]).atoms(sympy.Symbol)
|
| 192 |
+
right_syms = convert_postfix(arr[i + 1]).atoms(
|
| 193 |
+
sympy.Symbol)
|
| 194 |
+
# if the left and right sides contain no variables and the
|
| 195 |
+
# symbol in between is 'x', treat as multiplication.
|
| 196 |
+
if not (left_syms or right_syms) and str(res) == 'x':
|
| 197 |
+
return convert_postfix_list(arr, i + 1)
|
| 198 |
+
# multiply by next
|
| 199 |
+
return sympy.Mul(
|
| 200 |
+
res, convert_postfix_list(arr, i + 1), evaluate=False)
|
| 201 |
+
else: # must be derivative
|
| 202 |
+
wrt = res[0]
|
| 203 |
+
if i == len(arr) - 1:
|
| 204 |
+
raise LaTeXParsingError("Expected expression for derivative")
|
| 205 |
+
else:
|
| 206 |
+
expr = convert_postfix_list(arr, i + 1)
|
| 207 |
+
return sympy.Derivative(expr, wrt)
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
def do_subs(expr, at):
|
| 211 |
+
if at.expr():
|
| 212 |
+
at_expr = convert_expr(at.expr())
|
| 213 |
+
syms = at_expr.atoms(sympy.Symbol)
|
| 214 |
+
if len(syms) == 0:
|
| 215 |
+
return expr
|
| 216 |
+
elif len(syms) > 0:
|
| 217 |
+
sym = next(iter(syms))
|
| 218 |
+
return expr.subs(sym, at_expr)
|
| 219 |
+
elif at.equality():
|
| 220 |
+
lh = convert_expr(at.equality().expr(0))
|
| 221 |
+
rh = convert_expr(at.equality().expr(1))
|
| 222 |
+
return expr.subs(lh, rh)
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
def convert_postfix(postfix):
|
| 226 |
+
if hasattr(postfix, 'exp'):
|
| 227 |
+
exp_nested = postfix.exp()
|
| 228 |
+
else:
|
| 229 |
+
exp_nested = postfix.exp_nofunc()
|
| 230 |
+
|
| 231 |
+
exp = convert_exp(exp_nested)
|
| 232 |
+
for op in postfix.postfix_op():
|
| 233 |
+
if op.BANG():
|
| 234 |
+
if isinstance(exp, list):
|
| 235 |
+
raise LaTeXParsingError("Cannot apply postfix to derivative")
|
| 236 |
+
exp = sympy.factorial(exp, evaluate=False)
|
| 237 |
+
elif op.eval_at():
|
| 238 |
+
ev = op.eval_at()
|
| 239 |
+
at_b = None
|
| 240 |
+
at_a = None
|
| 241 |
+
if ev.eval_at_sup():
|
| 242 |
+
at_b = do_subs(exp, ev.eval_at_sup())
|
| 243 |
+
if ev.eval_at_sub():
|
| 244 |
+
at_a = do_subs(exp, ev.eval_at_sub())
|
| 245 |
+
if at_b is not None and at_a is not None:
|
| 246 |
+
exp = sympy.Add(at_b, -1 * at_a, evaluate=False)
|
| 247 |
+
elif at_b is not None:
|
| 248 |
+
exp = at_b
|
| 249 |
+
elif at_a is not None:
|
| 250 |
+
exp = at_a
|
| 251 |
+
|
| 252 |
+
return exp
|
| 253 |
+
|
| 254 |
+
|
| 255 |
+
def convert_exp(exp):
|
| 256 |
+
if hasattr(exp, 'exp'):
|
| 257 |
+
exp_nested = exp.exp()
|
| 258 |
+
else:
|
| 259 |
+
exp_nested = exp.exp_nofunc()
|
| 260 |
+
|
| 261 |
+
if exp_nested:
|
| 262 |
+
base = convert_exp(exp_nested)
|
| 263 |
+
if isinstance(base, list):
|
| 264 |
+
raise LaTeXParsingError("Cannot raise derivative to power")
|
| 265 |
+
if exp.atom():
|
| 266 |
+
exponent = convert_atom(exp.atom())
|
| 267 |
+
elif exp.expr():
|
| 268 |
+
exponent = convert_expr(exp.expr())
|
| 269 |
+
return sympy.Pow(base, exponent, evaluate=False)
|
| 270 |
+
else:
|
| 271 |
+
if hasattr(exp, 'comp'):
|
| 272 |
+
return convert_comp(exp.comp())
|
| 273 |
+
else:
|
| 274 |
+
return convert_comp(exp.comp_nofunc())
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
def convert_comp(comp):
|
| 278 |
+
if comp.group():
|
| 279 |
+
return convert_expr(comp.group().expr())
|
| 280 |
+
elif comp.abs_group():
|
| 281 |
+
return sympy.Abs(convert_expr(comp.abs_group().expr()), evaluate=False)
|
| 282 |
+
elif comp.atom():
|
| 283 |
+
return convert_atom(comp.atom())
|
| 284 |
+
elif comp.floor():
|
| 285 |
+
return convert_floor(comp.floor())
|
| 286 |
+
elif comp.ceil():
|
| 287 |
+
return convert_ceil(comp.ceil())
|
| 288 |
+
elif comp.func():
|
| 289 |
+
return convert_func(comp.func())
|
| 290 |
+
|
| 291 |
+
|
| 292 |
+
def convert_atom(atom):
|
| 293 |
+
if atom.LETTER():
|
| 294 |
+
sname = atom.LETTER().getText()
|
| 295 |
+
if atom.subexpr():
|
| 296 |
+
if atom.subexpr().expr(): # subscript is expr
|
| 297 |
+
subscript = convert_expr(atom.subexpr().expr())
|
| 298 |
+
else: # subscript is atom
|
| 299 |
+
subscript = convert_atom(atom.subexpr().atom())
|
| 300 |
+
sname += '_{' + StrPrinter().doprint(subscript) + '}'
|
| 301 |
+
if atom.SINGLE_QUOTES():
|
| 302 |
+
sname += atom.SINGLE_QUOTES().getText() # put after subscript for easy identify
|
| 303 |
+
return sympy.Symbol(sname)
|
| 304 |
+
elif atom.SYMBOL():
|
| 305 |
+
s = atom.SYMBOL().getText()[1:]
|
| 306 |
+
if s == "infty":
|
| 307 |
+
return sympy.oo
|
| 308 |
+
else:
|
| 309 |
+
if atom.subexpr():
|
| 310 |
+
subscript = None
|
| 311 |
+
if atom.subexpr().expr(): # subscript is expr
|
| 312 |
+
subscript = convert_expr(atom.subexpr().expr())
|
| 313 |
+
else: # subscript is atom
|
| 314 |
+
subscript = convert_atom(atom.subexpr().atom())
|
| 315 |
+
subscriptName = StrPrinter().doprint(subscript)
|
| 316 |
+
s += '_{' + subscriptName + '}'
|
| 317 |
+
return sympy.Symbol(s)
|
| 318 |
+
elif atom.number():
|
| 319 |
+
s = atom.number().getText().replace(",", "")
|
| 320 |
+
return sympy.Number(s)
|
| 321 |
+
elif atom.DIFFERENTIAL():
|
| 322 |
+
var = get_differential_var(atom.DIFFERENTIAL())
|
| 323 |
+
return sympy.Symbol('d' + var.name)
|
| 324 |
+
elif atom.mathit():
|
| 325 |
+
text = rule2text(atom.mathit().mathit_text())
|
| 326 |
+
return sympy.Symbol(text)
|
| 327 |
+
elif atom.frac():
|
| 328 |
+
return convert_frac(atom.frac())
|
| 329 |
+
elif atom.binom():
|
| 330 |
+
return convert_binom(atom.binom())
|
| 331 |
+
elif atom.bra():
|
| 332 |
+
val = convert_expr(atom.bra().expr())
|
| 333 |
+
return Bra(val)
|
| 334 |
+
elif atom.ket():
|
| 335 |
+
val = convert_expr(atom.ket().expr())
|
| 336 |
+
return Ket(val)
|
| 337 |
+
|
| 338 |
+
|
| 339 |
+
def rule2text(ctx):
|
| 340 |
+
stream = ctx.start.getInputStream()
|
| 341 |
+
# starting index of starting token
|
| 342 |
+
startIdx = ctx.start.start
|
| 343 |
+
# stopping index of stopping token
|
| 344 |
+
stopIdx = ctx.stop.stop
|
| 345 |
+
|
| 346 |
+
return stream.getText(startIdx, stopIdx)
|
| 347 |
+
|
| 348 |
+
|
| 349 |
+
def convert_frac(frac):
|
| 350 |
+
diff_op = False
|
| 351 |
+
partial_op = False
|
| 352 |
+
if frac.lower and frac.upper:
|
| 353 |
+
lower_itv = frac.lower.getSourceInterval()
|
| 354 |
+
lower_itv_len = lower_itv[1] - lower_itv[0] + 1
|
| 355 |
+
if (frac.lower.start == frac.lower.stop
|
| 356 |
+
and frac.lower.start.type == LaTeXLexer.DIFFERENTIAL):
|
| 357 |
+
wrt = get_differential_var_str(frac.lower.start.text)
|
| 358 |
+
diff_op = True
|
| 359 |
+
elif (lower_itv_len == 2 and frac.lower.start.type == LaTeXLexer.SYMBOL
|
| 360 |
+
and frac.lower.start.text == '\\partial'
|
| 361 |
+
and (frac.lower.stop.type == LaTeXLexer.LETTER
|
| 362 |
+
or frac.lower.stop.type == LaTeXLexer.SYMBOL)):
|
| 363 |
+
partial_op = True
|
| 364 |
+
wrt = frac.lower.stop.text
|
| 365 |
+
if frac.lower.stop.type == LaTeXLexer.SYMBOL:
|
| 366 |
+
wrt = wrt[1:]
|
| 367 |
+
|
| 368 |
+
if diff_op or partial_op:
|
| 369 |
+
wrt = sympy.Symbol(wrt)
|
| 370 |
+
if (diff_op and frac.upper.start == frac.upper.stop
|
| 371 |
+
and frac.upper.start.type == LaTeXLexer.LETTER
|
| 372 |
+
and frac.upper.start.text == 'd'):
|
| 373 |
+
return [wrt]
|
| 374 |
+
elif (partial_op and frac.upper.start == frac.upper.stop
|
| 375 |
+
and frac.upper.start.type == LaTeXLexer.SYMBOL
|
| 376 |
+
and frac.upper.start.text == '\\partial'):
|
| 377 |
+
return [wrt]
|
| 378 |
+
upper_text = rule2text(frac.upper)
|
| 379 |
+
|
| 380 |
+
expr_top = None
|
| 381 |
+
if diff_op and upper_text.startswith('d'):
|
| 382 |
+
expr_top = parse_latex(upper_text[1:])
|
| 383 |
+
elif partial_op and frac.upper.start.text == '\\partial':
|
| 384 |
+
expr_top = parse_latex(upper_text[len('\\partial'):])
|
| 385 |
+
if expr_top:
|
| 386 |
+
return sympy.Derivative(expr_top, wrt)
|
| 387 |
+
if frac.upper:
|
| 388 |
+
expr_top = convert_expr(frac.upper)
|
| 389 |
+
else:
|
| 390 |
+
expr_top = sympy.Number(frac.upperd.text)
|
| 391 |
+
if frac.lower:
|
| 392 |
+
expr_bot = convert_expr(frac.lower)
|
| 393 |
+
else:
|
| 394 |
+
expr_bot = sympy.Number(frac.lowerd.text)
|
| 395 |
+
inverse_denom = sympy.Pow(expr_bot, -1, evaluate=False)
|
| 396 |
+
if expr_top == 1:
|
| 397 |
+
return inverse_denom
|
| 398 |
+
else:
|
| 399 |
+
return sympy.Mul(expr_top, inverse_denom, evaluate=False)
|
| 400 |
+
|
| 401 |
+
def convert_binom(binom):
|
| 402 |
+
expr_n = convert_expr(binom.n)
|
| 403 |
+
expr_k = convert_expr(binom.k)
|
| 404 |
+
return sympy.binomial(expr_n, expr_k, evaluate=False)
|
| 405 |
+
|
| 406 |
+
def convert_floor(floor):
|
| 407 |
+
val = convert_expr(floor.val)
|
| 408 |
+
return sympy.floor(val, evaluate=False)
|
| 409 |
+
|
| 410 |
+
def convert_ceil(ceil):
|
| 411 |
+
val = convert_expr(ceil.val)
|
| 412 |
+
return sympy.ceiling(val, evaluate=False)
|
| 413 |
+
|
| 414 |
+
def convert_func(func):
|
| 415 |
+
if func.func_normal():
|
| 416 |
+
if func.L_PAREN(): # function called with parenthesis
|
| 417 |
+
arg = convert_func_arg(func.func_arg())
|
| 418 |
+
else:
|
| 419 |
+
arg = convert_func_arg(func.func_arg_noparens())
|
| 420 |
+
|
| 421 |
+
name = func.func_normal().start.text[1:]
|
| 422 |
+
|
| 423 |
+
# change arc<trig> -> a<trig>
|
| 424 |
+
if name in [
|
| 425 |
+
"arcsin", "arccos", "arctan", "arccsc", "arcsec", "arccot"
|
| 426 |
+
]:
|
| 427 |
+
name = "a" + name[3:]
|
| 428 |
+
expr = getattr(sympy.functions, name)(arg, evaluate=False)
|
| 429 |
+
if name in ["arsinh", "arcosh", "artanh"]:
|
| 430 |
+
name = "a" + name[2:]
|
| 431 |
+
expr = getattr(sympy.functions, name)(arg, evaluate=False)
|
| 432 |
+
|
| 433 |
+
if name == "exp":
|
| 434 |
+
expr = sympy.exp(arg, evaluate=False)
|
| 435 |
+
|
| 436 |
+
if name in ("log", "lg", "ln"):
|
| 437 |
+
if func.subexpr():
|
| 438 |
+
if func.subexpr().expr():
|
| 439 |
+
base = convert_expr(func.subexpr().expr())
|
| 440 |
+
else:
|
| 441 |
+
base = convert_atom(func.subexpr().atom())
|
| 442 |
+
elif name == "lg": # ISO 80000-2:2019
|
| 443 |
+
base = 10
|
| 444 |
+
elif name in ("ln", "log"): # SymPy's latex printer prints ln as log by default
|
| 445 |
+
base = sympy.E
|
| 446 |
+
expr = sympy.log(arg, base, evaluate=False)
|
| 447 |
+
|
| 448 |
+
func_pow = None
|
| 449 |
+
should_pow = True
|
| 450 |
+
if func.supexpr():
|
| 451 |
+
if func.supexpr().expr():
|
| 452 |
+
func_pow = convert_expr(func.supexpr().expr())
|
| 453 |
+
else:
|
| 454 |
+
func_pow = convert_atom(func.supexpr().atom())
|
| 455 |
+
|
| 456 |
+
if name in [
|
| 457 |
+
"sin", "cos", "tan", "csc", "sec", "cot", "sinh", "cosh",
|
| 458 |
+
"tanh"
|
| 459 |
+
]:
|
| 460 |
+
if func_pow == -1:
|
| 461 |
+
name = "a" + name
|
| 462 |
+
should_pow = False
|
| 463 |
+
expr = getattr(sympy.functions, name)(arg, evaluate=False)
|
| 464 |
+
|
| 465 |
+
if func_pow and should_pow:
|
| 466 |
+
expr = sympy.Pow(expr, func_pow, evaluate=False)
|
| 467 |
+
|
| 468 |
+
return expr
|
| 469 |
+
elif func.LETTER() or func.SYMBOL():
|
| 470 |
+
if func.LETTER():
|
| 471 |
+
fname = func.LETTER().getText()
|
| 472 |
+
elif func.SYMBOL():
|
| 473 |
+
fname = func.SYMBOL().getText()[1:]
|
| 474 |
+
fname = str(fname) # can't be unicode
|
| 475 |
+
if func.subexpr():
|
| 476 |
+
if func.subexpr().expr(): # subscript is expr
|
| 477 |
+
subscript = convert_expr(func.subexpr().expr())
|
| 478 |
+
else: # subscript is atom
|
| 479 |
+
subscript = convert_atom(func.subexpr().atom())
|
| 480 |
+
subscriptName = StrPrinter().doprint(subscript)
|
| 481 |
+
fname += '_{' + subscriptName + '}'
|
| 482 |
+
if func.SINGLE_QUOTES():
|
| 483 |
+
fname += func.SINGLE_QUOTES().getText()
|
| 484 |
+
input_args = func.args()
|
| 485 |
+
output_args = []
|
| 486 |
+
while input_args.args(): # handle multiple arguments to function
|
| 487 |
+
output_args.append(convert_expr(input_args.expr()))
|
| 488 |
+
input_args = input_args.args()
|
| 489 |
+
output_args.append(convert_expr(input_args.expr()))
|
| 490 |
+
return sympy.Function(fname)(*output_args)
|
| 491 |
+
elif func.FUNC_INT():
|
| 492 |
+
return handle_integral(func)
|
| 493 |
+
elif func.FUNC_SQRT():
|
| 494 |
+
expr = convert_expr(func.base)
|
| 495 |
+
if func.root:
|
| 496 |
+
r = convert_expr(func.root)
|
| 497 |
+
return sympy.root(expr, r, evaluate=False)
|
| 498 |
+
else:
|
| 499 |
+
return sympy.sqrt(expr, evaluate=False)
|
| 500 |
+
elif func.FUNC_OVERLINE():
|
| 501 |
+
expr = convert_expr(func.base)
|
| 502 |
+
return sympy.conjugate(expr, evaluate=False)
|
| 503 |
+
elif func.FUNC_SUM():
|
| 504 |
+
return handle_sum_or_prod(func, "summation")
|
| 505 |
+
elif func.FUNC_PROD():
|
| 506 |
+
return handle_sum_or_prod(func, "product")
|
| 507 |
+
elif func.FUNC_LIM():
|
| 508 |
+
return handle_limit(func)
|
| 509 |
+
|
| 510 |
+
|
| 511 |
+
def convert_func_arg(arg):
|
| 512 |
+
if hasattr(arg, 'expr'):
|
| 513 |
+
return convert_expr(arg.expr())
|
| 514 |
+
else:
|
| 515 |
+
return convert_mp(arg.mp_nofunc())
|
| 516 |
+
|
| 517 |
+
|
| 518 |
+
def handle_integral(func):
|
| 519 |
+
if func.additive():
|
| 520 |
+
integrand = convert_add(func.additive())
|
| 521 |
+
elif func.frac():
|
| 522 |
+
integrand = convert_frac(func.frac())
|
| 523 |
+
else:
|
| 524 |
+
integrand = 1
|
| 525 |
+
|
| 526 |
+
int_var = None
|
| 527 |
+
if func.DIFFERENTIAL():
|
| 528 |
+
int_var = get_differential_var(func.DIFFERENTIAL())
|
| 529 |
+
else:
|
| 530 |
+
for sym in integrand.atoms(sympy.Symbol):
|
| 531 |
+
s = str(sym)
|
| 532 |
+
if len(s) > 1 and s[0] == 'd':
|
| 533 |
+
if s[1] == '\\':
|
| 534 |
+
int_var = sympy.Symbol(s[2:])
|
| 535 |
+
else:
|
| 536 |
+
int_var = sympy.Symbol(s[1:])
|
| 537 |
+
int_sym = sym
|
| 538 |
+
if int_var:
|
| 539 |
+
integrand = integrand.subs(int_sym, 1)
|
| 540 |
+
else:
|
| 541 |
+
# Assume dx by default
|
| 542 |
+
int_var = sympy.Symbol('x')
|
| 543 |
+
|
| 544 |
+
if func.subexpr():
|
| 545 |
+
if func.subexpr().atom():
|
| 546 |
+
lower = convert_atom(func.subexpr().atom())
|
| 547 |
+
else:
|
| 548 |
+
lower = convert_expr(func.subexpr().expr())
|
| 549 |
+
if func.supexpr().atom():
|
| 550 |
+
upper = convert_atom(func.supexpr().atom())
|
| 551 |
+
else:
|
| 552 |
+
upper = convert_expr(func.supexpr().expr())
|
| 553 |
+
return sympy.Integral(integrand, (int_var, lower, upper))
|
| 554 |
+
else:
|
| 555 |
+
return sympy.Integral(integrand, int_var)
|
| 556 |
+
|
| 557 |
+
|
| 558 |
+
def handle_sum_or_prod(func, name):
|
| 559 |
+
val = convert_mp(func.mp())
|
| 560 |
+
iter_var = convert_expr(func.subeq().equality().expr(0))
|
| 561 |
+
start = convert_expr(func.subeq().equality().expr(1))
|
| 562 |
+
if func.supexpr().expr(): # ^{expr}
|
| 563 |
+
end = convert_expr(func.supexpr().expr())
|
| 564 |
+
else: # ^atom
|
| 565 |
+
end = convert_atom(func.supexpr().atom())
|
| 566 |
+
|
| 567 |
+
if name == "summation":
|
| 568 |
+
return sympy.Sum(val, (iter_var, start, end))
|
| 569 |
+
elif name == "product":
|
| 570 |
+
return sympy.Product(val, (iter_var, start, end))
|
| 571 |
+
|
| 572 |
+
|
| 573 |
+
def handle_limit(func):
|
| 574 |
+
sub = func.limit_sub()
|
| 575 |
+
if sub.LETTER():
|
| 576 |
+
var = sympy.Symbol(sub.LETTER().getText())
|
| 577 |
+
elif sub.SYMBOL():
|
| 578 |
+
var = sympy.Symbol(sub.SYMBOL().getText()[1:])
|
| 579 |
+
else:
|
| 580 |
+
var = sympy.Symbol('x')
|
| 581 |
+
if sub.SUB():
|
| 582 |
+
direction = "-"
|
| 583 |
+
elif sub.ADD():
|
| 584 |
+
direction = "+"
|
| 585 |
+
else:
|
| 586 |
+
direction = "+-"
|
| 587 |
+
approaching = convert_expr(sub.expr())
|
| 588 |
+
content = convert_mp(func.mp())
|
| 589 |
+
|
| 590 |
+
return sympy.Limit(content, var, approaching, direction)
|
| 591 |
+
|
| 592 |
+
|
| 593 |
+
def get_differential_var(d):
|
| 594 |
+
text = get_differential_var_str(d.getText())
|
| 595 |
+
return sympy.Symbol(text)
|
| 596 |
+
|
| 597 |
+
|
| 598 |
+
def get_differential_var_str(text):
|
| 599 |
+
for i in range(1, len(text)):
|
| 600 |
+
c = text[i]
|
| 601 |
+
if not (c == " " or c == "\r" or c == "\n" or c == "\t"):
|
| 602 |
+
idx = i
|
| 603 |
+
break
|
| 604 |
+
text = text[idx:]
|
| 605 |
+
if text[0] == "\\":
|
| 606 |
+
text = text[1:]
|
| 607 |
+
return text
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/errors.py
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class LaTeXParsingError(Exception):
|
| 2 |
+
pass
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/lark/__init__.py
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .latex_parser import parse_latex_lark, LarkLaTeXParser # noqa
|
| 2 |
+
from .transformer import TransformToSymPyExpr # noqa
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/lark/grammar/greek_symbols.lark
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Greek symbols
|
| 2 |
+
// TODO: Shouold we include the uppercase variants for the symbols where the uppercase variant doesn't have a separate meaning?
|
| 3 |
+
ALPHA: "\\alpha"
|
| 4 |
+
BETA: "\\beta"
|
| 5 |
+
GAMMA: "\\gamma"
|
| 6 |
+
DELTA: "\\delta" // TODO: Should this be included? Delta usually denotes other things.
|
| 7 |
+
EPSILON: "\\epsilon" | "\\varepsilon"
|
| 8 |
+
ZETA: "\\zeta"
|
| 9 |
+
ETA: "\\eta"
|
| 10 |
+
THETA: "\\theta" | "\\vartheta"
|
| 11 |
+
// TODO: Should I add iota to the list?
|
| 12 |
+
KAPPA: "\\kappa"
|
| 13 |
+
LAMBDA: "\\lambda" // TODO: What about the uppercase variant?
|
| 14 |
+
MU: "\\mu"
|
| 15 |
+
NU: "\\nu"
|
| 16 |
+
XI: "\\xi"
|
| 17 |
+
// TODO: Should there be a separate note for transforming \pi into sympy.pi?
|
| 18 |
+
RHO: "\\rho" | "\\varrho"
|
| 19 |
+
// TODO: What should we do about sigma?
|
| 20 |
+
TAU: "\\tau"
|
| 21 |
+
UPSILON: "\\upsilon"
|
| 22 |
+
PHI: "\\phi" | "\\varphi"
|
| 23 |
+
CHI: "\\chi"
|
| 24 |
+
PSI: "\\psi"
|
| 25 |
+
OMEGA: "\\omega"
|
| 26 |
+
|
| 27 |
+
GREEK_SYMBOL: ALPHA | BETA | GAMMA | DELTA | EPSILON | ZETA | ETA | THETA | KAPPA
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%ignore /[ \t\n\r]+/
|
| 2 |
+
|
| 3 |
+
%ignore "\\," | "\\thinspace" | "\\:" | "\\medspace" | "\\;" | "\\thickspace"
|
| 4 |
+
%ignore "\\quad" | "\\qquad"
|
| 5 |
+
%ignore "\\!" | "\\negthinspace" | "\\negmedspace" | "\\negthickspace"
|
| 6 |
+
%ignore "\\vrule" | "\\vcenter" | "\\vbox" | "\\vskip" | "\\vspace" | "\\hfill"
|
| 7 |
+
%ignore "\\*" | "\\-" | "\\." | "\\/" | "\\(" | "\\="
|
| 8 |
+
|
| 9 |
+
%ignore "\\left" | "\\right"
|
| 10 |
+
%ignore "\\limits" | "\\nolimits"
|
| 11 |
+
%ignore "\\displaystyle"
|
| 12 |
+
|
| 13 |
+
///////////////////// tokens ///////////////////////
|
| 14 |
+
|
| 15 |
+
// basic binary operators
|
| 16 |
+
ADD: "+"
|
| 17 |
+
SUB: "-"
|
| 18 |
+
MUL: "*"
|
| 19 |
+
DIV: "/"
|
| 20 |
+
|
| 21 |
+
// tokens with distinct left and right symbols
|
| 22 |
+
L_BRACE: "{"
|
| 23 |
+
R_BRACE: "}"
|
| 24 |
+
L_BRACE_LITERAL: "\\{"
|
| 25 |
+
R_BRACE_LITERAL: "\\}"
|
| 26 |
+
L_BRACKET: "["
|
| 27 |
+
R_BRACKET: "]"
|
| 28 |
+
L_CEIL: "\\lceil"
|
| 29 |
+
R_CEIL: "\\rceil"
|
| 30 |
+
L_FLOOR: "\\lfloor"
|
| 31 |
+
R_FLOOR: "\\rfloor"
|
| 32 |
+
L_PAREN: "("
|
| 33 |
+
R_PAREN: ")"
|
| 34 |
+
|
| 35 |
+
// limit, integral, sum, and product symbols
|
| 36 |
+
FUNC_LIM: "\\lim"
|
| 37 |
+
LIM_APPROACH_SYM: "\\to" | "\\rightarrow" | "\\Rightarrow" | "\\longrightarrow" | "\\Longrightarrow"
|
| 38 |
+
FUNC_INT: "\\int" | "\\intop"
|
| 39 |
+
FUNC_SUM: "\\sum"
|
| 40 |
+
FUNC_PROD: "\\prod"
|
| 41 |
+
|
| 42 |
+
// common functions
|
| 43 |
+
FUNC_EXP: "\\exp"
|
| 44 |
+
FUNC_LOG: "\\log"
|
| 45 |
+
FUNC_LN: "\\ln"
|
| 46 |
+
FUNC_LG: "\\lg"
|
| 47 |
+
FUNC_MIN: "\\min"
|
| 48 |
+
FUNC_MAX: "\\max"
|
| 49 |
+
|
| 50 |
+
// trigonometric functions
|
| 51 |
+
FUNC_SIN: "\\sin"
|
| 52 |
+
FUNC_COS: "\\cos"
|
| 53 |
+
FUNC_TAN: "\\tan"
|
| 54 |
+
FUNC_CSC: "\\csc"
|
| 55 |
+
FUNC_SEC: "\\sec"
|
| 56 |
+
FUNC_COT: "\\cot"
|
| 57 |
+
|
| 58 |
+
// inverse trigonometric functions
|
| 59 |
+
FUNC_ARCSIN: "\\arcsin"
|
| 60 |
+
FUNC_ARCCOS: "\\arccos"
|
| 61 |
+
FUNC_ARCTAN: "\\arctan"
|
| 62 |
+
FUNC_ARCCSC: "\\arccsc"
|
| 63 |
+
FUNC_ARCSEC: "\\arcsec"
|
| 64 |
+
FUNC_ARCCOT: "\\arccot"
|
| 65 |
+
|
| 66 |
+
// hyperbolic trigonometric functions
|
| 67 |
+
FUNC_SINH: "\\sinh"
|
| 68 |
+
FUNC_COSH: "\\cosh"
|
| 69 |
+
FUNC_TANH: "\\tanh"
|
| 70 |
+
FUNC_ARSINH: "\\arsinh"
|
| 71 |
+
FUNC_ARCOSH: "\\arcosh"
|
| 72 |
+
FUNC_ARTANH: "\\artanh"
|
| 73 |
+
|
| 74 |
+
FUNC_SQRT: "\\sqrt"
|
| 75 |
+
|
| 76 |
+
// miscellaneous symbols
|
| 77 |
+
CMD_TIMES: "\\times"
|
| 78 |
+
CMD_CDOT: "\\cdot"
|
| 79 |
+
CMD_DIV: "\\div"
|
| 80 |
+
CMD_FRAC: "\\frac" | "\\dfrac" | "\\tfrac" | "\\nicefrac"
|
| 81 |
+
CMD_BINOM: "\\binom" | "\\dbinom" | "\\tbinom"
|
| 82 |
+
CMD_OVERLINE: "\\overline"
|
| 83 |
+
CMD_LANGLE: "\\langle"
|
| 84 |
+
CMD_RANGLE: "\\rangle"
|
| 85 |
+
|
| 86 |
+
CMD_MATHIT: "\\mathit"
|
| 87 |
+
|
| 88 |
+
CMD_INFTY: "\\infty"
|
| 89 |
+
|
| 90 |
+
BANG: "!"
|
| 91 |
+
BAR: "|"
|
| 92 |
+
CARET: "^"
|
| 93 |
+
COLON: ":"
|
| 94 |
+
UNDERSCORE: "_"
|
| 95 |
+
|
| 96 |
+
// relational symbols
|
| 97 |
+
EQUAL: "="
|
| 98 |
+
NOT_EQUAL: "\\neq" | "\\ne"
|
| 99 |
+
LT: "<"
|
| 100 |
+
LTE: "\\leq" | "\\le" | "\\leqslant"
|
| 101 |
+
GT: ">"
|
| 102 |
+
GTE: "\\geq" | "\\ge" | "\\geqslant"
|
| 103 |
+
|
| 104 |
+
DIV_SYMBOL: CMD_DIV | DIV
|
| 105 |
+
MUL_SYMBOL: MUL | CMD_TIMES | CMD_CDOT
|
| 106 |
+
|
| 107 |
+
%import .greek_symbols.GREEK_SYMBOL
|
| 108 |
+
|
| 109 |
+
UPRIGHT_DIFFERENTIAL_SYMBOL: "\\text{d}" | "\\mathrm{d}"
|
| 110 |
+
DIFFERENTIAL_SYMBOL: "d" | UPRIGHT_DIFFERENTIAL_SYMBOL
|
| 111 |
+
|
| 112 |
+
// disallow "d" as a variable name because we want to parse "d" as a differential symbol.
|
| 113 |
+
SYMBOL: /[a-zA-Z]'*/
|
| 114 |
+
GREEK_SYMBOL_WITH_PRIMES: GREEK_SYMBOL "'"*
|
| 115 |
+
LATIN_SYMBOL_WITH_LATIN_SUBSCRIPT: /([a-zA-Z]'*)_(([A-Za-z0-9]|[a-zA-Z]+)|\{([A-Za-z0-9]|[a-zA-Z]+'*)\})/
|
| 116 |
+
LATIN_SYMBOL_WITH_GREEK_SUBSCRIPT: /([a-zA-Z]'*)_/ GREEK_SYMBOL | /([a-zA-Z]'*)_/ L_BRACE GREEK_SYMBOL_WITH_PRIMES R_BRACE
|
| 117 |
+
// best to define the variant with braces like that instead of shoving it all into one case like in
|
| 118 |
+
// /([a-zA-Z])_/ L_BRACE? GREEK_SYMBOL R_BRACE? because then we can easily error out on input like
|
| 119 |
+
// r"h_{\theta"
|
| 120 |
+
GREEK_SYMBOL_WITH_LATIN_SUBSCRIPT: GREEK_SYMBOL_WITH_PRIMES /_(([A-Za-z0-9]|[a-zA-Z]+)|\{([A-Za-z0-9]|[a-zA-Z]+'*)\})/
|
| 121 |
+
GREEK_SYMBOL_WITH_GREEK_SUBSCRIPT: GREEK_SYMBOL_WITH_PRIMES /_/ (GREEK_SYMBOL | L_BRACE GREEK_SYMBOL_WITH_PRIMES R_BRACE)
|
| 122 |
+
MULTI_LETTER_SYMBOL: /[a-zA-Z]+(\s+[a-zA-Z]+)*'*/
|
| 123 |
+
|
| 124 |
+
%import common.DIGIT -> DIGIT
|
| 125 |
+
|
| 126 |
+
CMD_PRIME: "\\prime"
|
| 127 |
+
CMD_ASTERISK: "\\ast"
|
| 128 |
+
|
| 129 |
+
PRIMES: "'"+
|
| 130 |
+
STARS: "*"+
|
| 131 |
+
PRIMES_VIA_CMD: CMD_PRIME+
|
| 132 |
+
STARS_VIA_CMD: CMD_ASTERISK+
|
| 133 |
+
|
| 134 |
+
CMD_IMAGINARY_UNIT: "\\imaginaryunit"
|
| 135 |
+
|
| 136 |
+
CMD_BEGIN: "\\begin"
|
| 137 |
+
CMD_END: "\\end"
|
| 138 |
+
|
| 139 |
+
// matrices
|
| 140 |
+
IGNORE_L: /[ \t\n\r]*/ L_BRACE* /[ \t\n\r]*/
|
| 141 |
+
IGNORE_R: /[ \t\n\r]*/ R_BRACE* /[ \t\n\r]*/
|
| 142 |
+
ARRAY_MATRIX_BEGIN: L_BRACE "array" R_BRACE L_BRACE /[^}]*/ R_BRACE
|
| 143 |
+
ARRAY_MATRIX_END: L_BRACE "array" R_BRACE
|
| 144 |
+
AMSMATH_MATRIX: L_BRACE "matrix" R_BRACE
|
| 145 |
+
AMSMATH_PMATRIX: L_BRACE "pmatrix" R_BRACE
|
| 146 |
+
AMSMATH_BMATRIX: L_BRACE "bmatrix" R_BRACE
|
| 147 |
+
// Without the (L|R)_PARENs and (L|R)_BRACKETs, a matrix defined using
|
| 148 |
+
// \begin{array}...\end{array} or \begin{matrix}...\end{matrix} must
|
| 149 |
+
// not qualify as a complete matrix expression; this is done so that
|
| 150 |
+
// if we have \begin{array}...\end{array} or \begin{matrix}...\end{matrix}
|
| 151 |
+
// between BAR pairs, then they should be interpreted as determinants as
|
| 152 |
+
// opposed to sympy.Abs (absolute value) applied to a matrix.
|
| 153 |
+
CMD_BEGIN_AMSPMATRIX_AMSBMATRIX: CMD_BEGIN (AMSMATH_PMATRIX | AMSMATH_BMATRIX)
|
| 154 |
+
CMD_BEGIN_ARRAY_AMSMATRIX: (L_PAREN | L_BRACKET) IGNORE_L CMD_BEGIN (ARRAY_MATRIX_BEGIN | AMSMATH_MATRIX)
|
| 155 |
+
CMD_MATRIX_BEGIN: CMD_BEGIN_AMSPMATRIX_AMSBMATRIX | CMD_BEGIN_ARRAY_AMSMATRIX
|
| 156 |
+
CMD_END_AMSPMATRIX_AMSBMATRIX: CMD_END (AMSMATH_PMATRIX | AMSMATH_BMATRIX)
|
| 157 |
+
CMD_END_ARRAY_AMSMATRIX: CMD_END (ARRAY_MATRIX_END | AMSMATH_MATRIX) IGNORE_R "\\right"? (R_PAREN | R_BRACKET)
|
| 158 |
+
CMD_MATRIX_END: CMD_END_AMSPMATRIX_AMSBMATRIX | CMD_END_ARRAY_AMSMATRIX
|
| 159 |
+
MATRIX_COL_DELIM: "&"
|
| 160 |
+
MATRIX_ROW_DELIM: "\\\\"
|
| 161 |
+
FUNC_MATRIX_TRACE: "\\trace"
|
| 162 |
+
FUNC_MATRIX_ADJUGATE: "\\adjugate"
|
| 163 |
+
|
| 164 |
+
// determinants
|
| 165 |
+
AMSMATH_VMATRIX: L_BRACE "vmatrix" R_BRACE
|
| 166 |
+
CMD_DETERMINANT_BEGIN_SIMPLE: CMD_BEGIN AMSMATH_VMATRIX
|
| 167 |
+
CMD_DETERMINANT_BEGIN_VARIANT: BAR IGNORE_L CMD_BEGIN (ARRAY_MATRIX_BEGIN | AMSMATH_MATRIX)
|
| 168 |
+
CMD_DETERMINANT_BEGIN: CMD_DETERMINANT_BEGIN_SIMPLE | CMD_DETERMINANT_BEGIN_VARIANT
|
| 169 |
+
CMD_DETERMINANT_END_SIMPLE: CMD_END AMSMATH_VMATRIX
|
| 170 |
+
CMD_DETERMINANT_END_VARIANT: CMD_END (ARRAY_MATRIX_END | AMSMATH_MATRIX) IGNORE_R "\\right"? BAR
|
| 171 |
+
CMD_DETERMINANT_END: CMD_DETERMINANT_END_SIMPLE | CMD_DETERMINANT_END_VARIANT
|
| 172 |
+
FUNC_DETERMINANT: "\\det"
|
| 173 |
+
|
| 174 |
+
//////////////////// grammar //////////////////////
|
| 175 |
+
|
| 176 |
+
latex_string: _relation | _expression
|
| 177 |
+
|
| 178 |
+
_one_letter_symbol: SYMBOL
|
| 179 |
+
| LATIN_SYMBOL_WITH_LATIN_SUBSCRIPT
|
| 180 |
+
| LATIN_SYMBOL_WITH_GREEK_SUBSCRIPT
|
| 181 |
+
| GREEK_SYMBOL_WITH_LATIN_SUBSCRIPT
|
| 182 |
+
| GREEK_SYMBOL_WITH_GREEK_SUBSCRIPT
|
| 183 |
+
| GREEK_SYMBOL_WITH_PRIMES
|
| 184 |
+
// LuaTeX-generated outputs of \mathit{foo'} and \mathit{foo}'
|
| 185 |
+
// seem to be the same on the surface. We allow both styles.
|
| 186 |
+
multi_letter_symbol: CMD_MATHIT L_BRACE MULTI_LETTER_SYMBOL R_BRACE
|
| 187 |
+
| CMD_MATHIT L_BRACE MULTI_LETTER_SYMBOL R_BRACE /'+/
|
| 188 |
+
number: /\d+(\.\d*)?/ | CMD_IMAGINARY_UNIT
|
| 189 |
+
|
| 190 |
+
_atomic_expr: _one_letter_symbol
|
| 191 |
+
| multi_letter_symbol
|
| 192 |
+
| number
|
| 193 |
+
| CMD_INFTY
|
| 194 |
+
|
| 195 |
+
group_round_parentheses: L_PAREN _expression R_PAREN
|
| 196 |
+
group_square_brackets: L_BRACKET _expression R_BRACKET
|
| 197 |
+
group_curly_parentheses: L_BRACE _expression R_BRACE
|
| 198 |
+
|
| 199 |
+
_relation: eq | ne | lt | lte | gt | gte
|
| 200 |
+
|
| 201 |
+
eq: _expression EQUAL _expression
|
| 202 |
+
ne: _expression NOT_EQUAL _expression
|
| 203 |
+
lt: _expression LT _expression
|
| 204 |
+
lte: _expression LTE _expression
|
| 205 |
+
gt: _expression GT _expression
|
| 206 |
+
gte: _expression GTE _expression
|
| 207 |
+
|
| 208 |
+
_expression_core: _atomic_expr | group_curly_parentheses
|
| 209 |
+
|
| 210 |
+
add: _expression ADD _expression_mul
|
| 211 |
+
| ADD _expression_mul
|
| 212 |
+
sub: _expression SUB _expression_mul
|
| 213 |
+
| SUB _expression_mul
|
| 214 |
+
mul: _expression_mul MUL_SYMBOL _expression_power
|
| 215 |
+
div: _expression_mul DIV_SYMBOL _expression_power
|
| 216 |
+
|
| 217 |
+
adjacent_expressions: (_one_letter_symbol | number) _expression_mul
|
| 218 |
+
| group_round_parentheses (group_round_parentheses | _one_letter_symbol)
|
| 219 |
+
| _function _function
|
| 220 |
+
| fraction _expression_mul
|
| 221 |
+
|
| 222 |
+
_expression_func: _expression_core
|
| 223 |
+
| group_round_parentheses
|
| 224 |
+
| fraction
|
| 225 |
+
| binomial
|
| 226 |
+
| _function
|
| 227 |
+
| _integral// | derivative
|
| 228 |
+
| limit
|
| 229 |
+
| matrix
|
| 230 |
+
|
| 231 |
+
_expression_power: _expression_func | superscript | matrix_prime | symbol_prime
|
| 232 |
+
|
| 233 |
+
_expression_mul: _expression_power
|
| 234 |
+
| mul | div | adjacent_expressions
|
| 235 |
+
| summation | product
|
| 236 |
+
|
| 237 |
+
_expression: _expression_mul | add | sub
|
| 238 |
+
|
| 239 |
+
_limit_dir: "+" | "-" | L_BRACE ("+" | "-") R_BRACE
|
| 240 |
+
|
| 241 |
+
limit_dir_expr: _expression CARET _limit_dir
|
| 242 |
+
|
| 243 |
+
group_curly_parentheses_lim: L_BRACE _expression LIM_APPROACH_SYM (limit_dir_expr | _expression) R_BRACE
|
| 244 |
+
|
| 245 |
+
limit: FUNC_LIM UNDERSCORE group_curly_parentheses_lim _expression
|
| 246 |
+
|
| 247 |
+
differential: DIFFERENTIAL_SYMBOL _one_letter_symbol
|
| 248 |
+
|
| 249 |
+
//_derivative_operator: CMD_FRAC L_BRACE DIFFERENTIAL_SYMBOL R_BRACE L_BRACE differential R_BRACE
|
| 250 |
+
|
| 251 |
+
//derivative: _derivative_operator _expression
|
| 252 |
+
|
| 253 |
+
_integral: normal_integral | integral_with_special_fraction
|
| 254 |
+
|
| 255 |
+
normal_integral: FUNC_INT _expression DIFFERENTIAL_SYMBOL _one_letter_symbol
|
| 256 |
+
| FUNC_INT (CARET _expression_core UNDERSCORE _expression_core)? _expression? DIFFERENTIAL_SYMBOL _one_letter_symbol
|
| 257 |
+
| FUNC_INT (UNDERSCORE _expression_core CARET _expression_core)? _expression? DIFFERENTIAL_SYMBOL _one_letter_symbol
|
| 258 |
+
|
| 259 |
+
group_curly_parentheses_int: L_BRACE _expression? differential R_BRACE
|
| 260 |
+
|
| 261 |
+
special_fraction: CMD_FRAC group_curly_parentheses_int group_curly_parentheses
|
| 262 |
+
|
| 263 |
+
integral_with_special_fraction: FUNC_INT special_fraction
|
| 264 |
+
| FUNC_INT (CARET _expression_core UNDERSCORE _expression_core)? special_fraction
|
| 265 |
+
| FUNC_INT (UNDERSCORE _expression_core CARET _expression_core)? special_fraction
|
| 266 |
+
|
| 267 |
+
group_curly_parentheses_special: UNDERSCORE L_BRACE _atomic_expr EQUAL _atomic_expr R_BRACE CARET _expression_core
|
| 268 |
+
| CARET _expression_core UNDERSCORE L_BRACE _atomic_expr EQUAL _atomic_expr R_BRACE
|
| 269 |
+
|
| 270 |
+
summation: FUNC_SUM group_curly_parentheses_special _expression
|
| 271 |
+
| FUNC_SUM group_curly_parentheses_special _expression
|
| 272 |
+
|
| 273 |
+
product: FUNC_PROD group_curly_parentheses_special _expression
|
| 274 |
+
| FUNC_PROD group_curly_parentheses_special _expression
|
| 275 |
+
|
| 276 |
+
superscript: _expression_func CARET (_expression_power | CMD_PRIME | CMD_ASTERISK)
|
| 277 |
+
| _expression_func CARET L_BRACE (PRIMES | STARS | PRIMES_VIA_CMD | STARS_VIA_CMD) R_BRACE
|
| 278 |
+
|
| 279 |
+
matrix_prime: (matrix | group_round_parentheses) PRIMES
|
| 280 |
+
|
| 281 |
+
symbol_prime: (LATIN_SYMBOL_WITH_LATIN_SUBSCRIPT
|
| 282 |
+
| LATIN_SYMBOL_WITH_GREEK_SUBSCRIPT
|
| 283 |
+
| GREEK_SYMBOL_WITH_LATIN_SUBSCRIPT
|
| 284 |
+
| GREEK_SYMBOL_WITH_GREEK_SUBSCRIPT) PRIMES
|
| 285 |
+
|
| 286 |
+
fraction: _basic_fraction
|
| 287 |
+
| _simple_fraction
|
| 288 |
+
| _general_fraction
|
| 289 |
+
|
| 290 |
+
_basic_fraction: CMD_FRAC DIGIT (DIGIT | SYMBOL | GREEK_SYMBOL_WITH_PRIMES)
|
| 291 |
+
|
| 292 |
+
_simple_fraction: CMD_FRAC DIGIT group_curly_parentheses
|
| 293 |
+
| CMD_FRAC group_curly_parentheses (DIGIT | SYMBOL | GREEK_SYMBOL_WITH_PRIMES)
|
| 294 |
+
|
| 295 |
+
_general_fraction: CMD_FRAC group_curly_parentheses group_curly_parentheses
|
| 296 |
+
|
| 297 |
+
binomial: _basic_binomial
|
| 298 |
+
| _simple_binomial
|
| 299 |
+
| _general_binomial
|
| 300 |
+
|
| 301 |
+
_basic_binomial: CMD_BINOM DIGIT (DIGIT | SYMBOL | GREEK_SYMBOL_WITH_PRIMES)
|
| 302 |
+
|
| 303 |
+
_simple_binomial: CMD_BINOM DIGIT group_curly_parentheses
|
| 304 |
+
| CMD_BINOM group_curly_parentheses (DIGIT | SYMBOL | GREEK_SYMBOL_WITH_PRIMES)
|
| 305 |
+
|
| 306 |
+
_general_binomial: CMD_BINOM group_curly_parentheses group_curly_parentheses
|
| 307 |
+
|
| 308 |
+
list_of_expressions: _expression ("," _expression)*
|
| 309 |
+
|
| 310 |
+
function_applied: _one_letter_symbol L_PAREN list_of_expressions R_PAREN
|
| 311 |
+
|
| 312 |
+
min: FUNC_MIN L_PAREN list_of_expressions R_PAREN
|
| 313 |
+
|
| 314 |
+
max: FUNC_MAX L_PAREN list_of_expressions R_PAREN
|
| 315 |
+
|
| 316 |
+
bra: CMD_LANGLE _expression BAR
|
| 317 |
+
|
| 318 |
+
ket: BAR _expression CMD_RANGLE
|
| 319 |
+
|
| 320 |
+
inner_product: CMD_LANGLE _expression BAR _expression CMD_RANGLE
|
| 321 |
+
|
| 322 |
+
_function: function_applied
|
| 323 |
+
| abs | floor | ceil
|
| 324 |
+
| _trigonometric_function | _inverse_trigonometric_function
|
| 325 |
+
| _trigonometric_function_power
|
| 326 |
+
| _hyperbolic_trigonometric_function | _inverse_hyperbolic_trigonometric_function
|
| 327 |
+
| exponential
|
| 328 |
+
| log
|
| 329 |
+
| square_root
|
| 330 |
+
| factorial
|
| 331 |
+
| conjugate
|
| 332 |
+
| max | min
|
| 333 |
+
| bra | ket | inner_product
|
| 334 |
+
| determinant
|
| 335 |
+
| trace
|
| 336 |
+
| adjugate
|
| 337 |
+
|
| 338 |
+
exponential: FUNC_EXP _expression
|
| 339 |
+
|
| 340 |
+
log: FUNC_LOG _expression
|
| 341 |
+
| FUNC_LN _expression
|
| 342 |
+
| FUNC_LG _expression
|
| 343 |
+
| FUNC_LOG UNDERSCORE (DIGIT | _one_letter_symbol) _expression
|
| 344 |
+
| FUNC_LOG UNDERSCORE group_curly_parentheses _expression
|
| 345 |
+
|
| 346 |
+
square_root: FUNC_SQRT group_curly_parentheses
|
| 347 |
+
| FUNC_SQRT group_square_brackets group_curly_parentheses
|
| 348 |
+
|
| 349 |
+
factorial: _expression_func BANG
|
| 350 |
+
|
| 351 |
+
conjugate: CMD_OVERLINE group_curly_parentheses
|
| 352 |
+
| CMD_OVERLINE DIGIT
|
| 353 |
+
|
| 354 |
+
_trigonometric_function: sin | cos | tan | csc | sec | cot
|
| 355 |
+
|
| 356 |
+
sin: FUNC_SIN _expression
|
| 357 |
+
cos: FUNC_COS _expression
|
| 358 |
+
tan: FUNC_TAN _expression
|
| 359 |
+
csc: FUNC_CSC _expression
|
| 360 |
+
sec: FUNC_SEC _expression
|
| 361 |
+
cot: FUNC_COT _expression
|
| 362 |
+
|
| 363 |
+
_trigonometric_function_power: sin_power | cos_power | tan_power | csc_power | sec_power | cot_power
|
| 364 |
+
|
| 365 |
+
sin_power: FUNC_SIN CARET _expression_core _expression
|
| 366 |
+
cos_power: FUNC_COS CARET _expression_core _expression
|
| 367 |
+
tan_power: FUNC_TAN CARET _expression_core _expression
|
| 368 |
+
csc_power: FUNC_CSC CARET _expression_core _expression
|
| 369 |
+
sec_power: FUNC_SEC CARET _expression_core _expression
|
| 370 |
+
cot_power: FUNC_COT CARET _expression_core _expression
|
| 371 |
+
|
| 372 |
+
_hyperbolic_trigonometric_function: sinh | cosh | tanh
|
| 373 |
+
|
| 374 |
+
sinh: FUNC_SINH _expression
|
| 375 |
+
cosh: FUNC_COSH _expression
|
| 376 |
+
tanh: FUNC_TANH _expression
|
| 377 |
+
|
| 378 |
+
_inverse_trigonometric_function: arcsin | arccos | arctan | arccsc | arcsec | arccot
|
| 379 |
+
|
| 380 |
+
arcsin: FUNC_ARCSIN _expression
|
| 381 |
+
arccos: FUNC_ARCCOS _expression
|
| 382 |
+
arctan: FUNC_ARCTAN _expression
|
| 383 |
+
arccsc: FUNC_ARCCSC _expression
|
| 384 |
+
arcsec: FUNC_ARCSEC _expression
|
| 385 |
+
arccot: FUNC_ARCCOT _expression
|
| 386 |
+
|
| 387 |
+
_inverse_hyperbolic_trigonometric_function: asinh | acosh | atanh
|
| 388 |
+
|
| 389 |
+
asinh: FUNC_ARSINH _expression
|
| 390 |
+
acosh: FUNC_ARCOSH _expression
|
| 391 |
+
atanh: FUNC_ARTANH _expression
|
| 392 |
+
|
| 393 |
+
abs: BAR _expression BAR
|
| 394 |
+
floor: L_FLOOR _expression R_FLOOR
|
| 395 |
+
ceil: L_CEIL _expression R_CEIL
|
| 396 |
+
|
| 397 |
+
matrix: CMD_MATRIX_BEGIN matrix_body CMD_MATRIX_END
|
| 398 |
+
matrix_body: matrix_row (MATRIX_ROW_DELIM matrix_row)* (MATRIX_ROW_DELIM)?
|
| 399 |
+
matrix_row: _expression (MATRIX_COL_DELIM _expression)*
|
| 400 |
+
determinant: (CMD_DETERMINANT_BEGIN matrix_body CMD_DETERMINANT_END)
|
| 401 |
+
| FUNC_DETERMINANT _expression
|
| 402 |
+
trace: FUNC_MATRIX_TRACE _expression
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|
| 4 |
+
from pathlib import Path
|
| 5 |
+
|
| 6 |
+
from sympy.external import import_module
|
| 7 |
+
from sympy.parsing.latex.lark.transformer import TransformToSymPyExpr
|
| 8 |
+
|
| 9 |
+
_lark = import_module("lark")
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
class LarkLaTeXParser:
|
| 13 |
+
r"""Class for converting input `\mathrm{\LaTeX}` strings into SymPy Expressions.
|
| 14 |
+
It holds all the necessary internal data for doing so, and exposes hooks for
|
| 15 |
+
customizing its behavior.
|
| 16 |
+
|
| 17 |
+
Parameters
|
| 18 |
+
==========
|
| 19 |
+
|
| 20 |
+
print_debug_output : bool, optional
|
| 21 |
+
|
| 22 |
+
If set to ``True``, prints debug output to the logger. Defaults to ``False``.
|
| 23 |
+
|
| 24 |
+
transform : bool, optional
|
| 25 |
+
|
| 26 |
+
If set to ``True``, the class runs the Transformer class on the parse tree
|
| 27 |
+
generated by running ``Lark.parse`` on the input string. Defaults to ``True``.
|
| 28 |
+
|
| 29 |
+
Setting it to ``False`` can help with debugging the `\mathrm{\LaTeX}` grammar.
|
| 30 |
+
|
| 31 |
+
grammar_file : str, optional
|
| 32 |
+
|
| 33 |
+
The path to the grammar file that the parser should use. If set to ``None``,
|
| 34 |
+
it uses the default grammar, which is in ``grammar/latex.lark``, relative to
|
| 35 |
+
the ``sympy/parsing/latex/lark/`` directory.
|
| 36 |
+
|
| 37 |
+
transformer : str, optional
|
| 38 |
+
|
| 39 |
+
The name of the Transformer class to use. If set to ``None``, it uses the
|
| 40 |
+
default transformer class, which is :py:func:`TransformToSymPyExpr`.
|
| 41 |
+
|
| 42 |
+
"""
|
| 43 |
+
def __init__(self, print_debug_output=False, transform=True, grammar_file=None, transformer=None):
|
| 44 |
+
grammar_dir_path = os.path.join(os.path.dirname(__file__), "grammar/")
|
| 45 |
+
|
| 46 |
+
if grammar_file is None:
|
| 47 |
+
latex_grammar = Path(os.path.join(grammar_dir_path, "latex.lark")).read_text(encoding="utf-8")
|
| 48 |
+
else:
|
| 49 |
+
latex_grammar = Path(grammar_file).read_text(encoding="utf-8")
|
| 50 |
+
|
| 51 |
+
self.parser = _lark.Lark(
|
| 52 |
+
latex_grammar,
|
| 53 |
+
source_path=grammar_dir_path,
|
| 54 |
+
parser="earley",
|
| 55 |
+
start="latex_string",
|
| 56 |
+
lexer="auto",
|
| 57 |
+
ambiguity="explicit",
|
| 58 |
+
propagate_positions=False,
|
| 59 |
+
maybe_placeholders=False,
|
| 60 |
+
keep_all_tokens=True)
|
| 61 |
+
|
| 62 |
+
self.print_debug_output = print_debug_output
|
| 63 |
+
self.transform_expr = transform
|
| 64 |
+
|
| 65 |
+
if transformer is None:
|
| 66 |
+
self.transformer = TransformToSymPyExpr()
|
| 67 |
+
else:
|
| 68 |
+
self.transformer = transformer()
|
| 69 |
+
|
| 70 |
+
def doparse(self, s: str):
|
| 71 |
+
if self.print_debug_output:
|
| 72 |
+
_lark.logger.setLevel(logging.DEBUG)
|
| 73 |
+
|
| 74 |
+
parse_tree = self.parser.parse(s)
|
| 75 |
+
|
| 76 |
+
if not self.transform_expr:
|
| 77 |
+
# exit early and return the parse tree
|
| 78 |
+
_lark.logger.debug("expression = %s", s)
|
| 79 |
+
_lark.logger.debug(parse_tree)
|
| 80 |
+
_lark.logger.debug(parse_tree.pretty())
|
| 81 |
+
return parse_tree
|
| 82 |
+
|
| 83 |
+
if self.print_debug_output:
|
| 84 |
+
# print this stuff before attempting to run the transformer
|
| 85 |
+
_lark.logger.debug("expression = %s", s)
|
| 86 |
+
# print the `parse_tree` variable
|
| 87 |
+
_lark.logger.debug(parse_tree.pretty())
|
| 88 |
+
|
| 89 |
+
sympy_expression = self.transformer.transform(parse_tree)
|
| 90 |
+
|
| 91 |
+
if self.print_debug_output:
|
| 92 |
+
_lark.logger.debug("SymPy expression = %s", sympy_expression)
|
| 93 |
+
|
| 94 |
+
return sympy_expression
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
if _lark is not None:
|
| 98 |
+
_lark_latex_parser = LarkLaTeXParser()
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
def parse_latex_lark(s: str):
|
| 102 |
+
"""
|
| 103 |
+
Experimental LaTeX parser using Lark.
|
| 104 |
+
|
| 105 |
+
This function is still under development and its API may change with the
|
| 106 |
+
next releases of SymPy.
|
| 107 |
+
"""
|
| 108 |
+
if _lark is None:
|
| 109 |
+
raise ImportError("Lark is probably not installed")
|
| 110 |
+
return _lark_latex_parser.doparse(s)
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
def _pretty_print_lark_trees(tree, indent=0, show_expr=True):
|
| 114 |
+
if isinstance(tree, _lark.Token):
|
| 115 |
+
return tree.value
|
| 116 |
+
|
| 117 |
+
data = str(tree.data)
|
| 118 |
+
|
| 119 |
+
is_expr = data.startswith("expression")
|
| 120 |
+
|
| 121 |
+
if is_expr:
|
| 122 |
+
data = re.sub(r"^expression", "E", data)
|
| 123 |
+
|
| 124 |
+
is_ambig = (data == "_ambig")
|
| 125 |
+
|
| 126 |
+
if is_ambig:
|
| 127 |
+
new_indent = indent + 2
|
| 128 |
+
else:
|
| 129 |
+
new_indent = indent
|
| 130 |
+
|
| 131 |
+
output = ""
|
| 132 |
+
show_node = not is_expr or show_expr
|
| 133 |
+
|
| 134 |
+
if show_node:
|
| 135 |
+
output += str(data) + "("
|
| 136 |
+
|
| 137 |
+
if is_ambig:
|
| 138 |
+
output += "\n" + "\n".join([" " * new_indent + _pretty_print_lark_trees(i, new_indent, show_expr) for i in tree.children])
|
| 139 |
+
else:
|
| 140 |
+
output += ",".join([_pretty_print_lark_trees(i, new_indent, show_expr) for i in tree.children])
|
| 141 |
+
|
| 142 |
+
if show_node:
|
| 143 |
+
output += ")"
|
| 144 |
+
|
| 145 |
+
return output
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/latex/lark/transformer.py
ADDED
|
@@ -0,0 +1,730 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
|
| 3 |
+
import sympy
|
| 4 |
+
from sympy.external import import_module
|
| 5 |
+
from sympy.parsing.latex.errors import LaTeXParsingError
|
| 6 |
+
|
| 7 |
+
lark = import_module("lark")
|
| 8 |
+
|
| 9 |
+
if lark:
|
| 10 |
+
from lark import Transformer, Token, Tree # type: ignore
|
| 11 |
+
else:
|
| 12 |
+
class Transformer: # type: ignore
|
| 13 |
+
def transform(self, *args):
|
| 14 |
+
pass
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class Token: # type: ignore
|
| 18 |
+
pass
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class Tree: # type: ignore
|
| 22 |
+
pass
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
# noinspection PyPep8Naming,PyMethodMayBeStatic
|
| 26 |
+
class TransformToSymPyExpr(Transformer):
|
| 27 |
+
"""Returns a SymPy expression that is generated by traversing the ``lark.Tree``
|
| 28 |
+
passed to the ``.transform()`` function.
|
| 29 |
+
|
| 30 |
+
Notes
|
| 31 |
+
=====
|
| 32 |
+
|
| 33 |
+
**This class is never supposed to be used directly.**
|
| 34 |
+
|
| 35 |
+
In order to tweak the behavior of this class, it has to be subclassed and then after
|
| 36 |
+
the required modifications are made, the name of the new class should be passed to
|
| 37 |
+
the :py:class:`LarkLaTeXParser` class by using the ``transformer`` argument in the
|
| 38 |
+
constructor.
|
| 39 |
+
|
| 40 |
+
Parameters
|
| 41 |
+
==========
|
| 42 |
+
|
| 43 |
+
visit_tokens : bool, optional
|
| 44 |
+
For information about what this option does, see `here
|
| 45 |
+
<https://lark-parser.readthedocs.io/en/latest/visitors.html#lark.visitors.Transformer>`_.
|
| 46 |
+
|
| 47 |
+
Note that the option must be set to ``True`` for the default parser to work.
|
| 48 |
+
"""
|
| 49 |
+
|
| 50 |
+
SYMBOL = sympy.Symbol
|
| 51 |
+
DIGIT = sympy.core.numbers.Integer
|
| 52 |
+
|
| 53 |
+
def CMD_INFTY(self, tokens):
|
| 54 |
+
return sympy.oo
|
| 55 |
+
|
| 56 |
+
def GREEK_SYMBOL_WITH_PRIMES(self, tokens):
|
| 57 |
+
# we omit the first character because it is a backslash. Also, if the variable name has "var" in it,
|
| 58 |
+
# like "varphi" or "varepsilon", we remove that too
|
| 59 |
+
variable_name = re.sub("var", "", tokens[1:])
|
| 60 |
+
|
| 61 |
+
return sympy.Symbol(variable_name)
|
| 62 |
+
|
| 63 |
+
def LATIN_SYMBOL_WITH_LATIN_SUBSCRIPT(self, tokens):
|
| 64 |
+
base, sub = tokens.value.split("_")
|
| 65 |
+
if sub.startswith("{"):
|
| 66 |
+
return sympy.Symbol("%s_{%s}" % (base, sub[1:-1]))
|
| 67 |
+
else:
|
| 68 |
+
return sympy.Symbol("%s_{%s}" % (base, sub))
|
| 69 |
+
|
| 70 |
+
def GREEK_SYMBOL_WITH_LATIN_SUBSCRIPT(self, tokens):
|
| 71 |
+
base, sub = tokens.value.split("_")
|
| 72 |
+
greek_letter = re.sub("var", "", base[1:])
|
| 73 |
+
|
| 74 |
+
if sub.startswith("{"):
|
| 75 |
+
return sympy.Symbol("%s_{%s}" % (greek_letter, sub[1:-1]))
|
| 76 |
+
else:
|
| 77 |
+
return sympy.Symbol("%s_{%s}" % (greek_letter, sub))
|
| 78 |
+
|
| 79 |
+
def LATIN_SYMBOL_WITH_GREEK_SUBSCRIPT(self, tokens):
|
| 80 |
+
base, sub = tokens.value.split("_")
|
| 81 |
+
if sub.startswith("{"):
|
| 82 |
+
greek_letter = sub[2:-1]
|
| 83 |
+
else:
|
| 84 |
+
greek_letter = sub[1:]
|
| 85 |
+
|
| 86 |
+
greek_letter = re.sub("var", "", greek_letter)
|
| 87 |
+
return sympy.Symbol("%s_{%s}" % (base, greek_letter))
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
def GREEK_SYMBOL_WITH_GREEK_SUBSCRIPT(self, tokens):
|
| 91 |
+
base, sub = tokens.value.split("_")
|
| 92 |
+
greek_base = re.sub("var", "", base[1:])
|
| 93 |
+
|
| 94 |
+
if sub.startswith("{"):
|
| 95 |
+
greek_sub = sub[2:-1]
|
| 96 |
+
else:
|
| 97 |
+
greek_sub = sub[1:]
|
| 98 |
+
|
| 99 |
+
greek_sub = re.sub("var", "", greek_sub)
|
| 100 |
+
return sympy.Symbol("%s_{%s}" % (greek_base, greek_sub))
|
| 101 |
+
|
| 102 |
+
def multi_letter_symbol(self, tokens):
|
| 103 |
+
if len(tokens) == 4: # no primes (single quotes) on symbol
|
| 104 |
+
return sympy.Symbol(tokens[2])
|
| 105 |
+
if len(tokens) == 5: # there are primes on the symbol
|
| 106 |
+
return sympy.Symbol(tokens[2] + tokens[4])
|
| 107 |
+
|
| 108 |
+
def number(self, tokens):
|
| 109 |
+
if tokens[0].type == "CMD_IMAGINARY_UNIT":
|
| 110 |
+
return sympy.I
|
| 111 |
+
|
| 112 |
+
if "." in tokens[0]:
|
| 113 |
+
return sympy.core.numbers.Float(tokens[0])
|
| 114 |
+
else:
|
| 115 |
+
return sympy.core.numbers.Integer(tokens[0])
|
| 116 |
+
|
| 117 |
+
def latex_string(self, tokens):
|
| 118 |
+
return tokens[0]
|
| 119 |
+
|
| 120 |
+
def group_round_parentheses(self, tokens):
|
| 121 |
+
return tokens[1]
|
| 122 |
+
|
| 123 |
+
def group_square_brackets(self, tokens):
|
| 124 |
+
return tokens[1]
|
| 125 |
+
|
| 126 |
+
def group_curly_parentheses(self, tokens):
|
| 127 |
+
return tokens[1]
|
| 128 |
+
|
| 129 |
+
def eq(self, tokens):
|
| 130 |
+
return sympy.Eq(tokens[0], tokens[2])
|
| 131 |
+
|
| 132 |
+
def ne(self, tokens):
|
| 133 |
+
return sympy.Ne(tokens[0], tokens[2])
|
| 134 |
+
|
| 135 |
+
def lt(self, tokens):
|
| 136 |
+
return sympy.Lt(tokens[0], tokens[2])
|
| 137 |
+
|
| 138 |
+
def lte(self, tokens):
|
| 139 |
+
return sympy.Le(tokens[0], tokens[2])
|
| 140 |
+
|
| 141 |
+
def gt(self, tokens):
|
| 142 |
+
return sympy.Gt(tokens[0], tokens[2])
|
| 143 |
+
|
| 144 |
+
def gte(self, tokens):
|
| 145 |
+
return sympy.Ge(tokens[0], tokens[2])
|
| 146 |
+
|
| 147 |
+
def add(self, tokens):
|
| 148 |
+
if len(tokens) == 2: # +a
|
| 149 |
+
return tokens[1]
|
| 150 |
+
if len(tokens) == 3: # a + b
|
| 151 |
+
lh = tokens[0]
|
| 152 |
+
rh = tokens[2]
|
| 153 |
+
|
| 154 |
+
if self._obj_is_sympy_Matrix(lh) or self._obj_is_sympy_Matrix(rh):
|
| 155 |
+
return sympy.MatAdd(lh, rh)
|
| 156 |
+
|
| 157 |
+
return sympy.Add(lh, rh)
|
| 158 |
+
|
| 159 |
+
def sub(self, tokens):
|
| 160 |
+
if len(tokens) == 2: # -a
|
| 161 |
+
x = tokens[1]
|
| 162 |
+
|
| 163 |
+
if self._obj_is_sympy_Matrix(x):
|
| 164 |
+
return sympy.MatMul(-1, x)
|
| 165 |
+
|
| 166 |
+
return -x
|
| 167 |
+
if len(tokens) == 3: # a - b
|
| 168 |
+
lh = tokens[0]
|
| 169 |
+
rh = tokens[2]
|
| 170 |
+
|
| 171 |
+
if self._obj_is_sympy_Matrix(lh) or self._obj_is_sympy_Matrix(rh):
|
| 172 |
+
return sympy.MatAdd(lh, sympy.MatMul(-1, rh))
|
| 173 |
+
|
| 174 |
+
return sympy.Add(lh, -rh)
|
| 175 |
+
|
| 176 |
+
def mul(self, tokens):
|
| 177 |
+
lh = tokens[0]
|
| 178 |
+
rh = tokens[2]
|
| 179 |
+
|
| 180 |
+
if self._obj_is_sympy_Matrix(lh) or self._obj_is_sympy_Matrix(rh):
|
| 181 |
+
return sympy.MatMul(lh, rh)
|
| 182 |
+
|
| 183 |
+
return sympy.Mul(lh, rh)
|
| 184 |
+
|
| 185 |
+
def div(self, tokens):
|
| 186 |
+
return self._handle_division(tokens[0], tokens[2])
|
| 187 |
+
|
| 188 |
+
def adjacent_expressions(self, tokens):
|
| 189 |
+
# Most of the time, if two expressions are next to each other, it means implicit multiplication,
|
| 190 |
+
# but not always
|
| 191 |
+
from sympy.physics.quantum import Bra, Ket
|
| 192 |
+
if isinstance(tokens[0], Ket) and isinstance(tokens[1], Bra):
|
| 193 |
+
from sympy.physics.quantum import OuterProduct
|
| 194 |
+
return OuterProduct(tokens[0], tokens[1])
|
| 195 |
+
elif tokens[0] == sympy.Symbol("d"):
|
| 196 |
+
# If the leftmost token is a "d", then it is highly likely that this is a differential
|
| 197 |
+
return tokens[0], tokens[1]
|
| 198 |
+
elif isinstance(tokens[0], tuple):
|
| 199 |
+
# then we have a derivative
|
| 200 |
+
return sympy.Derivative(tokens[1], tokens[0][1])
|
| 201 |
+
else:
|
| 202 |
+
return sympy.Mul(tokens[0], tokens[1])
|
| 203 |
+
|
| 204 |
+
def superscript(self, tokens):
|
| 205 |
+
def isprime(x):
|
| 206 |
+
return isinstance(x, Token) and x.type == "PRIMES"
|
| 207 |
+
|
| 208 |
+
def iscmdprime(x):
|
| 209 |
+
return isinstance(x, Token) and (x.type == "PRIMES_VIA_CMD"
|
| 210 |
+
or x.type == "CMD_PRIME")
|
| 211 |
+
|
| 212 |
+
def isstar(x):
|
| 213 |
+
return isinstance(x, Token) and x.type == "STARS"
|
| 214 |
+
|
| 215 |
+
def iscmdstar(x):
|
| 216 |
+
return isinstance(x, Token) and (x.type == "STARS_VIA_CMD"
|
| 217 |
+
or x.type == "CMD_ASTERISK")
|
| 218 |
+
|
| 219 |
+
base = tokens[0]
|
| 220 |
+
if len(tokens) == 3: # a^b OR a^\prime OR a^\ast
|
| 221 |
+
sup = tokens[2]
|
| 222 |
+
if len(tokens) == 5:
|
| 223 |
+
# a^{'}, a^{''}, ... OR
|
| 224 |
+
# a^{*}, a^{**}, ... OR
|
| 225 |
+
# a^{\prime}, a^{\prime\prime}, ... OR
|
| 226 |
+
# a^{\ast}, a^{\ast\ast}, ...
|
| 227 |
+
sup = tokens[3]
|
| 228 |
+
|
| 229 |
+
if self._obj_is_sympy_Matrix(base):
|
| 230 |
+
if sup == sympy.Symbol("T"):
|
| 231 |
+
return sympy.Transpose(base)
|
| 232 |
+
if sup == sympy.Symbol("H"):
|
| 233 |
+
return sympy.adjoint(base)
|
| 234 |
+
if isprime(sup):
|
| 235 |
+
sup = sup.value
|
| 236 |
+
if len(sup) % 2 == 0:
|
| 237 |
+
return base
|
| 238 |
+
return sympy.Transpose(base)
|
| 239 |
+
if iscmdprime(sup):
|
| 240 |
+
sup = sup.value
|
| 241 |
+
if (len(sup)/len(r"\prime")) % 2 == 0:
|
| 242 |
+
return base
|
| 243 |
+
return sympy.Transpose(base)
|
| 244 |
+
if isstar(sup):
|
| 245 |
+
sup = sup.value
|
| 246 |
+
# need .doit() in order to be consistent with
|
| 247 |
+
# sympy.adjoint() which returns the evaluated adjoint
|
| 248 |
+
# of a matrix
|
| 249 |
+
if len(sup) % 2 == 0:
|
| 250 |
+
return base.doit()
|
| 251 |
+
return sympy.adjoint(base)
|
| 252 |
+
if iscmdstar(sup):
|
| 253 |
+
sup = sup.value
|
| 254 |
+
# need .doit() for same reason as above
|
| 255 |
+
if (len(sup)/len(r"\ast")) % 2 == 0:
|
| 256 |
+
return base.doit()
|
| 257 |
+
return sympy.adjoint(base)
|
| 258 |
+
|
| 259 |
+
if isprime(sup) or iscmdprime(sup) or isstar(sup) or iscmdstar(sup):
|
| 260 |
+
raise LaTeXParsingError(f"{base} with superscript {sup} is not understood.")
|
| 261 |
+
|
| 262 |
+
return sympy.Pow(base, sup)
|
| 263 |
+
|
| 264 |
+
def matrix_prime(self, tokens):
|
| 265 |
+
base = tokens[0]
|
| 266 |
+
primes = tokens[1].value
|
| 267 |
+
|
| 268 |
+
if not self._obj_is_sympy_Matrix(base):
|
| 269 |
+
raise LaTeXParsingError(f"({base}){primes} is not understood.")
|
| 270 |
+
|
| 271 |
+
if len(primes) % 2 == 0:
|
| 272 |
+
return base
|
| 273 |
+
|
| 274 |
+
return sympy.Transpose(base)
|
| 275 |
+
|
| 276 |
+
def symbol_prime(self, tokens):
|
| 277 |
+
base = tokens[0]
|
| 278 |
+
primes = tokens[1].value
|
| 279 |
+
|
| 280 |
+
return sympy.Symbol(f"{base.name}{primes}")
|
| 281 |
+
|
| 282 |
+
def fraction(self, tokens):
|
| 283 |
+
numerator = tokens[1]
|
| 284 |
+
if isinstance(tokens[2], tuple):
|
| 285 |
+
# we only need the variable w.r.t. which we are differentiating
|
| 286 |
+
_, variable = tokens[2]
|
| 287 |
+
|
| 288 |
+
# we will pass this information upwards
|
| 289 |
+
return "derivative", variable
|
| 290 |
+
else:
|
| 291 |
+
denominator = tokens[2]
|
| 292 |
+
return self._handle_division(numerator, denominator)
|
| 293 |
+
|
| 294 |
+
def binomial(self, tokens):
|
| 295 |
+
return sympy.binomial(tokens[1], tokens[2])
|
| 296 |
+
|
| 297 |
+
def normal_integral(self, tokens):
|
| 298 |
+
underscore_index = None
|
| 299 |
+
caret_index = None
|
| 300 |
+
|
| 301 |
+
if "_" in tokens:
|
| 302 |
+
# we need to know the index because the next item in the list is the
|
| 303 |
+
# arguments for the lower bound of the integral
|
| 304 |
+
underscore_index = tokens.index("_")
|
| 305 |
+
|
| 306 |
+
if "^" in tokens:
|
| 307 |
+
# we need to know the index because the next item in the list is the
|
| 308 |
+
# arguments for the upper bound of the integral
|
| 309 |
+
caret_index = tokens.index("^")
|
| 310 |
+
|
| 311 |
+
lower_bound = tokens[underscore_index + 1] if underscore_index else None
|
| 312 |
+
upper_bound = tokens[caret_index + 1] if caret_index else None
|
| 313 |
+
|
| 314 |
+
differential_symbol = self._extract_differential_symbol(tokens)
|
| 315 |
+
|
| 316 |
+
if differential_symbol is None:
|
| 317 |
+
raise LaTeXParsingError("Differential symbol was not found in the expression."
|
| 318 |
+
"Valid differential symbols are \"d\", \"\\text{d}, and \"\\mathrm{d}\".")
|
| 319 |
+
|
| 320 |
+
# else we can assume that a differential symbol was found
|
| 321 |
+
differential_variable_index = tokens.index(differential_symbol) + 1
|
| 322 |
+
differential_variable = tokens[differential_variable_index]
|
| 323 |
+
|
| 324 |
+
# we can't simply do something like `if (lower_bound and not upper_bound) ...` because this would
|
| 325 |
+
# evaluate to `True` if the `lower_bound` is 0 and upper bound is non-zero
|
| 326 |
+
if lower_bound is not None and upper_bound is None:
|
| 327 |
+
# then one was given and the other wasn't
|
| 328 |
+
raise LaTeXParsingError("Lower bound for the integral was found, but upper bound was not found.")
|
| 329 |
+
|
| 330 |
+
if upper_bound is not None and lower_bound is None:
|
| 331 |
+
# then one was given and the other wasn't
|
| 332 |
+
raise LaTeXParsingError("Upper bound for the integral was found, but lower bound was not found.")
|
| 333 |
+
|
| 334 |
+
# check if any expression was given or not. If it wasn't, then set the integrand to 1.
|
| 335 |
+
if underscore_index is not None and underscore_index == differential_variable_index - 3:
|
| 336 |
+
# The Token at differential_variable_index - 2 should be the integrand. However, if going one more step
|
| 337 |
+
# backwards after that gives us the underscore, then that means that there _was_ no integrand.
|
| 338 |
+
# Example: \int^7_0 dx
|
| 339 |
+
integrand = 1
|
| 340 |
+
elif caret_index is not None and caret_index == differential_variable_index - 3:
|
| 341 |
+
# The Token at differential_variable_index - 2 should be the integrand. However, if going one more step
|
| 342 |
+
# backwards after that gives us the caret, then that means that there _was_ no integrand.
|
| 343 |
+
# Example: \int_0^7 dx
|
| 344 |
+
integrand = 1
|
| 345 |
+
elif differential_variable_index == 2:
|
| 346 |
+
# this means we have something like "\int dx", because the "\int" symbol will always be
|
| 347 |
+
# at index 0 in `tokens`
|
| 348 |
+
integrand = 1
|
| 349 |
+
else:
|
| 350 |
+
# The Token at differential_variable_index - 1 is the differential symbol itself, so we need to go one
|
| 351 |
+
# more step before that.
|
| 352 |
+
integrand = tokens[differential_variable_index - 2]
|
| 353 |
+
|
| 354 |
+
if lower_bound is not None:
|
| 355 |
+
# then we have a definite integral
|
| 356 |
+
|
| 357 |
+
# we can assume that either both the lower and upper bounds are given, or
|
| 358 |
+
# neither of them are
|
| 359 |
+
return sympy.Integral(integrand, (differential_variable, lower_bound, upper_bound))
|
| 360 |
+
else:
|
| 361 |
+
# we have an indefinite integral
|
| 362 |
+
return sympy.Integral(integrand, differential_variable)
|
| 363 |
+
|
| 364 |
+
def group_curly_parentheses_int(self, tokens):
|
| 365 |
+
# return signature is a tuple consisting of the expression in the numerator, along with the variable of
|
| 366 |
+
# integration
|
| 367 |
+
if len(tokens) == 3:
|
| 368 |
+
return 1, tokens[1]
|
| 369 |
+
elif len(tokens) == 4:
|
| 370 |
+
return tokens[1], tokens[2]
|
| 371 |
+
# there are no other possibilities
|
| 372 |
+
|
| 373 |
+
def special_fraction(self, tokens):
|
| 374 |
+
numerator, variable = tokens[1]
|
| 375 |
+
denominator = tokens[2]
|
| 376 |
+
|
| 377 |
+
# We pass the integrand, along with information about the variable of integration, upw
|
| 378 |
+
return sympy.Mul(numerator, sympy.Pow(denominator, -1)), variable
|
| 379 |
+
|
| 380 |
+
def integral_with_special_fraction(self, tokens):
|
| 381 |
+
underscore_index = None
|
| 382 |
+
caret_index = None
|
| 383 |
+
|
| 384 |
+
if "_" in tokens:
|
| 385 |
+
# we need to know the index because the next item in the list is the
|
| 386 |
+
# arguments for the lower bound of the integral
|
| 387 |
+
underscore_index = tokens.index("_")
|
| 388 |
+
|
| 389 |
+
if "^" in tokens:
|
| 390 |
+
# we need to know the index because the next item in the list is the
|
| 391 |
+
# arguments for the upper bound of the integral
|
| 392 |
+
caret_index = tokens.index("^")
|
| 393 |
+
|
| 394 |
+
lower_bound = tokens[underscore_index + 1] if underscore_index else None
|
| 395 |
+
upper_bound = tokens[caret_index + 1] if caret_index else None
|
| 396 |
+
|
| 397 |
+
# we can't simply do something like `if (lower_bound and not upper_bound) ...` because this would
|
| 398 |
+
# evaluate to `True` if the `lower_bound` is 0 and upper bound is non-zero
|
| 399 |
+
if lower_bound is not None and upper_bound is None:
|
| 400 |
+
# then one was given and the other wasn't
|
| 401 |
+
raise LaTeXParsingError("Lower bound for the integral was found, but upper bound was not found.")
|
| 402 |
+
|
| 403 |
+
if upper_bound is not None and lower_bound is None:
|
| 404 |
+
# then one was given and the other wasn't
|
| 405 |
+
raise LaTeXParsingError("Upper bound for the integral was found, but lower bound was not found.")
|
| 406 |
+
|
| 407 |
+
integrand, differential_variable = tokens[-1]
|
| 408 |
+
|
| 409 |
+
if lower_bound is not None:
|
| 410 |
+
# then we have a definite integral
|
| 411 |
+
|
| 412 |
+
# we can assume that either both the lower and upper bounds are given, or
|
| 413 |
+
# neither of them are
|
| 414 |
+
return sympy.Integral(integrand, (differential_variable, lower_bound, upper_bound))
|
| 415 |
+
else:
|
| 416 |
+
# we have an indefinite integral
|
| 417 |
+
return sympy.Integral(integrand, differential_variable)
|
| 418 |
+
|
| 419 |
+
def group_curly_parentheses_special(self, tokens):
|
| 420 |
+
underscore_index = tokens.index("_")
|
| 421 |
+
caret_index = tokens.index("^")
|
| 422 |
+
|
| 423 |
+
# given the type of expressions we are parsing, we can assume that the lower limit
|
| 424 |
+
# will always use braces around its arguments. This is because we don't support
|
| 425 |
+
# converting unconstrained sums into SymPy expressions.
|
| 426 |
+
|
| 427 |
+
# first we isolate the bottom limit
|
| 428 |
+
left_brace_index = tokens.index("{", underscore_index)
|
| 429 |
+
right_brace_index = tokens.index("}", underscore_index)
|
| 430 |
+
|
| 431 |
+
bottom_limit = tokens[left_brace_index + 1: right_brace_index]
|
| 432 |
+
|
| 433 |
+
# next, we isolate the upper limit
|
| 434 |
+
top_limit = tokens[caret_index + 1:]
|
| 435 |
+
|
| 436 |
+
# the code below will be useful for supporting things like `\sum_{n = 0}^{n = 5} n^2`
|
| 437 |
+
# if "{" in top_limit:
|
| 438 |
+
# left_brace_index = tokens.index("{", caret_index)
|
| 439 |
+
# if left_brace_index != -1:
|
| 440 |
+
# # then there's a left brace in the string, and we need to find the closing right brace
|
| 441 |
+
# right_brace_index = tokens.index("}", caret_index)
|
| 442 |
+
# top_limit = tokens[left_brace_index + 1: right_brace_index]
|
| 443 |
+
|
| 444 |
+
# print(f"top limit = {top_limit}")
|
| 445 |
+
|
| 446 |
+
index_variable = bottom_limit[0]
|
| 447 |
+
lower_limit = bottom_limit[-1]
|
| 448 |
+
upper_limit = top_limit[0] # for now, the index will always be 0
|
| 449 |
+
|
| 450 |
+
# print(f"return value = ({index_variable}, {lower_limit}, {upper_limit})")
|
| 451 |
+
|
| 452 |
+
return index_variable, lower_limit, upper_limit
|
| 453 |
+
|
| 454 |
+
def summation(self, tokens):
|
| 455 |
+
return sympy.Sum(tokens[2], tokens[1])
|
| 456 |
+
|
| 457 |
+
def product(self, tokens):
|
| 458 |
+
return sympy.Product(tokens[2], tokens[1])
|
| 459 |
+
|
| 460 |
+
def limit_dir_expr(self, tokens):
|
| 461 |
+
caret_index = tokens.index("^")
|
| 462 |
+
|
| 463 |
+
if "{" in tokens:
|
| 464 |
+
left_curly_brace_index = tokens.index("{", caret_index)
|
| 465 |
+
direction = tokens[left_curly_brace_index + 1]
|
| 466 |
+
else:
|
| 467 |
+
direction = tokens[caret_index + 1]
|
| 468 |
+
|
| 469 |
+
if direction == "+":
|
| 470 |
+
return tokens[0], "+"
|
| 471 |
+
elif direction == "-":
|
| 472 |
+
return tokens[0], "-"
|
| 473 |
+
else:
|
| 474 |
+
return tokens[0], "+-"
|
| 475 |
+
|
| 476 |
+
def group_curly_parentheses_lim(self, tokens):
|
| 477 |
+
limit_variable = tokens[1]
|
| 478 |
+
if isinstance(tokens[3], tuple):
|
| 479 |
+
destination, direction = tokens[3]
|
| 480 |
+
else:
|
| 481 |
+
destination = tokens[3]
|
| 482 |
+
direction = "+-"
|
| 483 |
+
|
| 484 |
+
return limit_variable, destination, direction
|
| 485 |
+
|
| 486 |
+
def limit(self, tokens):
|
| 487 |
+
limit_variable, destination, direction = tokens[2]
|
| 488 |
+
|
| 489 |
+
return sympy.Limit(tokens[-1], limit_variable, destination, direction)
|
| 490 |
+
|
| 491 |
+
def differential(self, tokens):
|
| 492 |
+
return tokens[1]
|
| 493 |
+
|
| 494 |
+
def derivative(self, tokens):
|
| 495 |
+
return sympy.Derivative(tokens[-1], tokens[5])
|
| 496 |
+
|
| 497 |
+
def list_of_expressions(self, tokens):
|
| 498 |
+
if len(tokens) == 1:
|
| 499 |
+
# we return it verbatim because the function_applied node expects
|
| 500 |
+
# a list
|
| 501 |
+
return tokens
|
| 502 |
+
else:
|
| 503 |
+
def remove_tokens(args):
|
| 504 |
+
if isinstance(args, Token):
|
| 505 |
+
if args.type != "COMMA":
|
| 506 |
+
# An unexpected token was encountered
|
| 507 |
+
raise LaTeXParsingError("A comma token was expected, but some other token was encountered.")
|
| 508 |
+
return False
|
| 509 |
+
return True
|
| 510 |
+
|
| 511 |
+
return filter(remove_tokens, tokens)
|
| 512 |
+
|
| 513 |
+
def function_applied(self, tokens):
|
| 514 |
+
return sympy.Function(tokens[0])(*tokens[2])
|
| 515 |
+
|
| 516 |
+
def min(self, tokens):
|
| 517 |
+
return sympy.Min(*tokens[2])
|
| 518 |
+
|
| 519 |
+
def max(self, tokens):
|
| 520 |
+
return sympy.Max(*tokens[2])
|
| 521 |
+
|
| 522 |
+
def bra(self, tokens):
|
| 523 |
+
from sympy.physics.quantum import Bra
|
| 524 |
+
return Bra(tokens[1])
|
| 525 |
+
|
| 526 |
+
def ket(self, tokens):
|
| 527 |
+
from sympy.physics.quantum import Ket
|
| 528 |
+
return Ket(tokens[1])
|
| 529 |
+
|
| 530 |
+
def inner_product(self, tokens):
|
| 531 |
+
from sympy.physics.quantum import Bra, Ket, InnerProduct
|
| 532 |
+
return InnerProduct(Bra(tokens[1]), Ket(tokens[3]))
|
| 533 |
+
|
| 534 |
+
def sin(self, tokens):
|
| 535 |
+
return sympy.sin(tokens[1])
|
| 536 |
+
|
| 537 |
+
def cos(self, tokens):
|
| 538 |
+
return sympy.cos(tokens[1])
|
| 539 |
+
|
| 540 |
+
def tan(self, tokens):
|
| 541 |
+
return sympy.tan(tokens[1])
|
| 542 |
+
|
| 543 |
+
def csc(self, tokens):
|
| 544 |
+
return sympy.csc(tokens[1])
|
| 545 |
+
|
| 546 |
+
def sec(self, tokens):
|
| 547 |
+
return sympy.sec(tokens[1])
|
| 548 |
+
|
| 549 |
+
def cot(self, tokens):
|
| 550 |
+
return sympy.cot(tokens[1])
|
| 551 |
+
|
| 552 |
+
def sin_power(self, tokens):
|
| 553 |
+
exponent = tokens[2]
|
| 554 |
+
if exponent == -1:
|
| 555 |
+
return sympy.asin(tokens[-1])
|
| 556 |
+
else:
|
| 557 |
+
return sympy.Pow(sympy.sin(tokens[-1]), exponent)
|
| 558 |
+
|
| 559 |
+
def cos_power(self, tokens):
|
| 560 |
+
exponent = tokens[2]
|
| 561 |
+
if exponent == -1:
|
| 562 |
+
return sympy.acos(tokens[-1])
|
| 563 |
+
else:
|
| 564 |
+
return sympy.Pow(sympy.cos(tokens[-1]), exponent)
|
| 565 |
+
|
| 566 |
+
def tan_power(self, tokens):
|
| 567 |
+
exponent = tokens[2]
|
| 568 |
+
if exponent == -1:
|
| 569 |
+
return sympy.atan(tokens[-1])
|
| 570 |
+
else:
|
| 571 |
+
return sympy.Pow(sympy.tan(tokens[-1]), exponent)
|
| 572 |
+
|
| 573 |
+
def csc_power(self, tokens):
|
| 574 |
+
exponent = tokens[2]
|
| 575 |
+
if exponent == -1:
|
| 576 |
+
return sympy.acsc(tokens[-1])
|
| 577 |
+
else:
|
| 578 |
+
return sympy.Pow(sympy.csc(tokens[-1]), exponent)
|
| 579 |
+
|
| 580 |
+
def sec_power(self, tokens):
|
| 581 |
+
exponent = tokens[2]
|
| 582 |
+
if exponent == -1:
|
| 583 |
+
return sympy.asec(tokens[-1])
|
| 584 |
+
else:
|
| 585 |
+
return sympy.Pow(sympy.sec(tokens[-1]), exponent)
|
| 586 |
+
|
| 587 |
+
def cot_power(self, tokens):
|
| 588 |
+
exponent = tokens[2]
|
| 589 |
+
if exponent == -1:
|
| 590 |
+
return sympy.acot(tokens[-1])
|
| 591 |
+
else:
|
| 592 |
+
return sympy.Pow(sympy.cot(tokens[-1]), exponent)
|
| 593 |
+
|
| 594 |
+
def arcsin(self, tokens):
|
| 595 |
+
return sympy.asin(tokens[1])
|
| 596 |
+
|
| 597 |
+
def arccos(self, tokens):
|
| 598 |
+
return sympy.acos(tokens[1])
|
| 599 |
+
|
| 600 |
+
def arctan(self, tokens):
|
| 601 |
+
return sympy.atan(tokens[1])
|
| 602 |
+
|
| 603 |
+
def arccsc(self, tokens):
|
| 604 |
+
return sympy.acsc(tokens[1])
|
| 605 |
+
|
| 606 |
+
def arcsec(self, tokens):
|
| 607 |
+
return sympy.asec(tokens[1])
|
| 608 |
+
|
| 609 |
+
def arccot(self, tokens):
|
| 610 |
+
return sympy.acot(tokens[1])
|
| 611 |
+
|
| 612 |
+
def sinh(self, tokens):
|
| 613 |
+
return sympy.sinh(tokens[1])
|
| 614 |
+
|
| 615 |
+
def cosh(self, tokens):
|
| 616 |
+
return sympy.cosh(tokens[1])
|
| 617 |
+
|
| 618 |
+
def tanh(self, tokens):
|
| 619 |
+
return sympy.tanh(tokens[1])
|
| 620 |
+
|
| 621 |
+
def asinh(self, tokens):
|
| 622 |
+
return sympy.asinh(tokens[1])
|
| 623 |
+
|
| 624 |
+
def acosh(self, tokens):
|
| 625 |
+
return sympy.acosh(tokens[1])
|
| 626 |
+
|
| 627 |
+
def atanh(self, tokens):
|
| 628 |
+
return sympy.atanh(tokens[1])
|
| 629 |
+
|
| 630 |
+
def abs(self, tokens):
|
| 631 |
+
return sympy.Abs(tokens[1])
|
| 632 |
+
|
| 633 |
+
def floor(self, tokens):
|
| 634 |
+
return sympy.floor(tokens[1])
|
| 635 |
+
|
| 636 |
+
def ceil(self, tokens):
|
| 637 |
+
return sympy.ceiling(tokens[1])
|
| 638 |
+
|
| 639 |
+
def factorial(self, tokens):
|
| 640 |
+
return sympy.factorial(tokens[0])
|
| 641 |
+
|
| 642 |
+
def conjugate(self, tokens):
|
| 643 |
+
return sympy.conjugate(tokens[1])
|
| 644 |
+
|
| 645 |
+
def square_root(self, tokens):
|
| 646 |
+
if len(tokens) == 2:
|
| 647 |
+
# then there was no square bracket argument
|
| 648 |
+
return sympy.sqrt(tokens[1])
|
| 649 |
+
elif len(tokens) == 3:
|
| 650 |
+
# then there _was_ a square bracket argument
|
| 651 |
+
return sympy.root(tokens[2], tokens[1])
|
| 652 |
+
|
| 653 |
+
def exponential(self, tokens):
|
| 654 |
+
return sympy.exp(tokens[1])
|
| 655 |
+
|
| 656 |
+
def log(self, tokens):
|
| 657 |
+
if tokens[0].type == "FUNC_LG":
|
| 658 |
+
# we don't need to check if there's an underscore or not because having one
|
| 659 |
+
# in this case would be meaningless
|
| 660 |
+
# TODO: ANTLR refers to ISO 80000-2:2019. should we keep base 10 or base 2?
|
| 661 |
+
return sympy.log(tokens[1], 10)
|
| 662 |
+
elif tokens[0].type == "FUNC_LN":
|
| 663 |
+
return sympy.log(tokens[1])
|
| 664 |
+
elif tokens[0].type == "FUNC_LOG":
|
| 665 |
+
# we check if a base was specified or not
|
| 666 |
+
if "_" in tokens:
|
| 667 |
+
# then a base was specified
|
| 668 |
+
return sympy.log(tokens[3], tokens[2])
|
| 669 |
+
else:
|
| 670 |
+
# a base was not specified
|
| 671 |
+
return sympy.log(tokens[1])
|
| 672 |
+
|
| 673 |
+
def _extract_differential_symbol(self, s: str):
|
| 674 |
+
differential_symbols = {"d", r"\text{d}", r"\mathrm{d}"}
|
| 675 |
+
|
| 676 |
+
differential_symbol = next((symbol for symbol in differential_symbols if symbol in s), None)
|
| 677 |
+
|
| 678 |
+
return differential_symbol
|
| 679 |
+
|
| 680 |
+
def matrix(self, tokens):
|
| 681 |
+
def is_matrix_row(x):
|
| 682 |
+
return (isinstance(x, Tree) and x.data == "matrix_row")
|
| 683 |
+
|
| 684 |
+
def is_not_col_delim(y):
|
| 685 |
+
return (not isinstance(y, Token) or y.type != "MATRIX_COL_DELIM")
|
| 686 |
+
|
| 687 |
+
matrix_body = tokens[1].children
|
| 688 |
+
return sympy.Matrix([[y for y in x.children if is_not_col_delim(y)]
|
| 689 |
+
for x in matrix_body if is_matrix_row(x)])
|
| 690 |
+
|
| 691 |
+
def determinant(self, tokens):
|
| 692 |
+
if len(tokens) == 2: # \det A
|
| 693 |
+
if not self._obj_is_sympy_Matrix(tokens[1]):
|
| 694 |
+
raise LaTeXParsingError("Cannot take determinant of non-matrix.")
|
| 695 |
+
|
| 696 |
+
return tokens[1].det()
|
| 697 |
+
|
| 698 |
+
if len(tokens) == 3: # | A |
|
| 699 |
+
return self.matrix(tokens).det()
|
| 700 |
+
|
| 701 |
+
def trace(self, tokens):
|
| 702 |
+
if not self._obj_is_sympy_Matrix(tokens[1]):
|
| 703 |
+
raise LaTeXParsingError("Cannot take trace of non-matrix.")
|
| 704 |
+
|
| 705 |
+
return sympy.Trace(tokens[1])
|
| 706 |
+
|
| 707 |
+
def adjugate(self, tokens):
|
| 708 |
+
if not self._obj_is_sympy_Matrix(tokens[1]):
|
| 709 |
+
raise LaTeXParsingError("Cannot take adjugate of non-matrix.")
|
| 710 |
+
|
| 711 |
+
# need .doit() since MatAdd does not support .adjugate() method
|
| 712 |
+
return tokens[1].doit().adjugate()
|
| 713 |
+
|
| 714 |
+
def _obj_is_sympy_Matrix(self, obj):
|
| 715 |
+
if hasattr(obj, "is_Matrix"):
|
| 716 |
+
return obj.is_Matrix
|
| 717 |
+
|
| 718 |
+
return isinstance(obj, sympy.Matrix)
|
| 719 |
+
|
| 720 |
+
def _handle_division(self, numerator, denominator):
|
| 721 |
+
if self._obj_is_sympy_Matrix(denominator):
|
| 722 |
+
raise LaTeXParsingError("Cannot divide by matrices like this since "
|
| 723 |
+
"it is not clear if left or right multiplication "
|
| 724 |
+
"by the inverse is intended. Try explicitly "
|
| 725 |
+
"multiplying by the inverse instead.")
|
| 726 |
+
|
| 727 |
+
if self._obj_is_sympy_Matrix(numerator):
|
| 728 |
+
return sympy.MatMul(numerator, sympy.Pow(denominator, -1))
|
| 729 |
+
|
| 730 |
+
return sympy.Mul(numerator, sympy.Pow(denominator, -1))
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/__init__.py
ADDED
|
File without changes
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_ast_parser.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sympy.core.singleton import S
|
| 2 |
+
from sympy.core.symbol import symbols
|
| 3 |
+
from sympy.parsing.ast_parser import parse_expr
|
| 4 |
+
from sympy.testing.pytest import raises
|
| 5 |
+
from sympy.core.sympify import SympifyError
|
| 6 |
+
import warnings
|
| 7 |
+
|
| 8 |
+
def test_parse_expr():
|
| 9 |
+
a, b = symbols('a, b')
|
| 10 |
+
# tests issue_16393
|
| 11 |
+
assert parse_expr('a + b', {}) == a + b
|
| 12 |
+
raises(SympifyError, lambda: parse_expr('a + ', {}))
|
| 13 |
+
|
| 14 |
+
# tests Transform.visit_Constant
|
| 15 |
+
assert parse_expr('1 + 2', {}) == S(3)
|
| 16 |
+
assert parse_expr('1 + 2.0', {}) == S(3.0)
|
| 17 |
+
|
| 18 |
+
# tests Transform.visit_Name
|
| 19 |
+
assert parse_expr('Rational(1, 2)', {}) == S(1)/2
|
| 20 |
+
assert parse_expr('a', {'a': a}) == a
|
| 21 |
+
|
| 22 |
+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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
+
from sympy.functions.elementary.trigonometric import (cos, sin)
|
| 4 |
+
from sympy.external import import_module
|
| 5 |
+
from sympy.testing.pytest import skip
|
| 6 |
+
from sympy.parsing.autolev import parse_autolev
|
| 7 |
+
|
| 8 |
+
antlr4 = import_module("antlr4")
|
| 9 |
+
|
| 10 |
+
if not antlr4:
|
| 11 |
+
disabled = True
|
| 12 |
+
|
| 13 |
+
FILE_DIR = os.path.dirname(
|
| 14 |
+
os.path.dirname(os.path.abspath(os.path.realpath(__file__))))
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def _test_examples(in_filename, out_filename, test_name=""):
|
| 18 |
+
|
| 19 |
+
in_file_path = os.path.join(FILE_DIR, 'autolev', 'test-examples',
|
| 20 |
+
in_filename)
|
| 21 |
+
correct_file_path = os.path.join(FILE_DIR, 'autolev', 'test-examples',
|
| 22 |
+
out_filename)
|
| 23 |
+
with open(in_file_path) as f:
|
| 24 |
+
generated_code = parse_autolev(f, include_numeric=True)
|
| 25 |
+
|
| 26 |
+
with open(correct_file_path) as f:
|
| 27 |
+
for idx, line1 in enumerate(f):
|
| 28 |
+
if line1.startswith("#"):
|
| 29 |
+
break
|
| 30 |
+
try:
|
| 31 |
+
line2 = generated_code.split('\n')[idx]
|
| 32 |
+
assert line1.rstrip() == line2.rstrip()
|
| 33 |
+
except Exception:
|
| 34 |
+
msg = 'mismatch in ' + test_name + ' in line no: {0}'
|
| 35 |
+
raise AssertionError(msg.format(idx+1))
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def test_rule_tests():
|
| 39 |
+
|
| 40 |
+
l = ["ruletest1", "ruletest2", "ruletest3", "ruletest4", "ruletest5",
|
| 41 |
+
"ruletest6", "ruletest7", "ruletest8", "ruletest9", "ruletest10",
|
| 42 |
+
"ruletest11", "ruletest12"]
|
| 43 |
+
|
| 44 |
+
for i in l:
|
| 45 |
+
in_filepath = i + ".al"
|
| 46 |
+
out_filepath = i + ".py"
|
| 47 |
+
_test_examples(in_filepath, out_filepath, i)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def test_pydy_examples():
|
| 51 |
+
|
| 52 |
+
l = ["mass_spring_damper", "chaos_pendulum", "double_pendulum",
|
| 53 |
+
"non_min_pendulum"]
|
| 54 |
+
|
| 55 |
+
for i in l:
|
| 56 |
+
in_filepath = os.path.join("pydy-example-repo", i + ".al")
|
| 57 |
+
out_filepath = os.path.join("pydy-example-repo", i + ".py")
|
| 58 |
+
_test_examples(in_filepath, out_filepath, i)
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def test_autolev_tutorial():
|
| 62 |
+
|
| 63 |
+
dir_path = os.path.join(FILE_DIR, 'autolev', 'test-examples',
|
| 64 |
+
'autolev-tutorial')
|
| 65 |
+
|
| 66 |
+
if os.path.isdir(dir_path):
|
| 67 |
+
l = ["tutor1", "tutor2", "tutor3", "tutor4", "tutor5", "tutor6",
|
| 68 |
+
"tutor7"]
|
| 69 |
+
for i in l:
|
| 70 |
+
in_filepath = os.path.join("autolev-tutorial", i + ".al")
|
| 71 |
+
out_filepath = os.path.join("autolev-tutorial", i + ".py")
|
| 72 |
+
_test_examples(in_filepath, out_filepath, i)
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def test_dynamics_online():
|
| 76 |
+
|
| 77 |
+
dir_path = os.path.join(FILE_DIR, 'autolev', 'test-examples',
|
| 78 |
+
'dynamics-online')
|
| 79 |
+
|
| 80 |
+
if os.path.isdir(dir_path):
|
| 81 |
+
ch1 = ["1-4", "1-5", "1-6", "1-7", "1-8", "1-9_1", "1-9_2", "1-9_3"]
|
| 82 |
+
ch2 = ["2-1", "2-2", "2-3", "2-4", "2-5", "2-6", "2-7", "2-8", "2-9",
|
| 83 |
+
"circular"]
|
| 84 |
+
ch3 = ["3-1_1", "3-1_2", "3-2_1", "3-2_2", "3-2_3", "3-2_4", "3-2_5",
|
| 85 |
+
"3-3"]
|
| 86 |
+
ch4 = ["4-1_1", "4-2_1", "4-4_1", "4-4_2", "4-5_1", "4-5_2"]
|
| 87 |
+
chapters = [(ch1, "ch1"), (ch2, "ch2"), (ch3, "ch3"), (ch4, "ch4")]
|
| 88 |
+
for ch, name in chapters:
|
| 89 |
+
for i in ch:
|
| 90 |
+
in_filepath = os.path.join("dynamics-online", name, i + ".al")
|
| 91 |
+
out_filepath = os.path.join("dynamics-online", name, i + ".py")
|
| 92 |
+
_test_examples(in_filepath, out_filepath, i)
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
def test_output_01():
|
| 96 |
+
"""Autolev example calculates the position, velocity, and acceleration of a
|
| 97 |
+
point and expresses in a single reference frame::
|
| 98 |
+
|
| 99 |
+
(1) FRAMES C,D,F
|
| 100 |
+
(2) VARIABLES FD'',DC''
|
| 101 |
+
(3) CONSTANTS R,L
|
| 102 |
+
(4) POINTS O,E
|
| 103 |
+
(5) SIMPROT(F,D,1,FD)
|
| 104 |
+
-> (6) F_D = [1, 0, 0; 0, COS(FD), -SIN(FD); 0, SIN(FD), COS(FD)]
|
| 105 |
+
(7) SIMPROT(D,C,2,DC)
|
| 106 |
+
-> (8) D_C = [COS(DC), 0, SIN(DC); 0, 1, 0; -SIN(DC), 0, COS(DC)]
|
| 107 |
+
(9) W_C_F> = EXPRESS(W_C_F>, F)
|
| 108 |
+
-> (10) W_C_F> = FD'*F1> + COS(FD)*DC'*F2> + SIN(FD)*DC'*F3>
|
| 109 |
+
(11) P_O_E>=R*D2>-L*C1>
|
| 110 |
+
(12) P_O_E>=EXPRESS(P_O_E>, D)
|
| 111 |
+
-> (13) P_O_E> = -L*COS(DC)*D1> + R*D2> + L*SIN(DC)*D3>
|
| 112 |
+
(14) V_E_F>=EXPRESS(DT(P_O_E>,F),D)
|
| 113 |
+
-> (15) V_E_F> = L*SIN(DC)*DC'*D1> - L*SIN(DC)*FD'*D2> + (R*FD'+L*COS(DC)*DC')*D3>
|
| 114 |
+
(16) A_E_F>=EXPRESS(DT(V_E_F>,F),D)
|
| 115 |
+
-> (17) A_E_F> = L*(COS(DC)*DC'^2+SIN(DC)*DC'')*D1> + (-R*FD'^2-2*L*COS(DC)*DC'*FD'-L*SIN(DC)*FD'')*D2> + (R*FD''+L*COS(DC)*DC''-L*SIN(DC)*DC'^2-L*SIN(DC)*FD'^2)*D3>
|
| 116 |
+
|
| 117 |
+
"""
|
| 118 |
+
|
| 119 |
+
if not antlr4:
|
| 120 |
+
skip('Test skipped: antlr4 is not installed.')
|
| 121 |
+
|
| 122 |
+
autolev_input = """\
|
| 123 |
+
FRAMES C,D,F
|
| 124 |
+
VARIABLES FD'',DC''
|
| 125 |
+
CONSTANTS R,L
|
| 126 |
+
POINTS O,E
|
| 127 |
+
SIMPROT(F,D,1,FD)
|
| 128 |
+
SIMPROT(D,C,2,DC)
|
| 129 |
+
W_C_F>=EXPRESS(W_C_F>,F)
|
| 130 |
+
P_O_E>=R*D2>-L*C1>
|
| 131 |
+
P_O_E>=EXPRESS(P_O_E>,D)
|
| 132 |
+
V_E_F>=EXPRESS(DT(P_O_E>,F),D)
|
| 133 |
+
A_E_F>=EXPRESS(DT(V_E_F>,F),D)\
|
| 134 |
+
"""
|
| 135 |
+
|
| 136 |
+
sympy_input = parse_autolev(autolev_input)
|
| 137 |
+
|
| 138 |
+
g = {}
|
| 139 |
+
l = {}
|
| 140 |
+
exec(sympy_input, g, l)
|
| 141 |
+
|
| 142 |
+
w_c_f = l['frame_c'].ang_vel_in(l['frame_f'])
|
| 143 |
+
# P_O_E> means "the position of point E wrt to point O"
|
| 144 |
+
p_o_e = l['point_e'].pos_from(l['point_o'])
|
| 145 |
+
v_e_f = l['point_e'].vel(l['frame_f'])
|
| 146 |
+
a_e_f = l['point_e'].acc(l['frame_f'])
|
| 147 |
+
|
| 148 |
+
# NOTE : The Autolev outputs above were manually transformed into
|
| 149 |
+
# equivalent SymPy physics vector expressions. Would be nice to automate
|
| 150 |
+
# this transformation.
|
| 151 |
+
expected_w_c_f = (l['fd'].diff()*l['frame_f'].x +
|
| 152 |
+
cos(l['fd'])*l['dc'].diff()*l['frame_f'].y +
|
| 153 |
+
sin(l['fd'])*l['dc'].diff()*l['frame_f'].z)
|
| 154 |
+
|
| 155 |
+
assert (w_c_f - expected_w_c_f).simplify() == 0
|
| 156 |
+
|
| 157 |
+
expected_p_o_e = (-l['l']*cos(l['dc'])*l['frame_d'].x +
|
| 158 |
+
l['r']*l['frame_d'].y +
|
| 159 |
+
l['l']*sin(l['dc'])*l['frame_d'].z)
|
| 160 |
+
|
| 161 |
+
assert (p_o_e - expected_p_o_e).simplify() == 0
|
| 162 |
+
|
| 163 |
+
expected_v_e_f = (l['l']*sin(l['dc'])*l['dc'].diff()*l['frame_d'].x -
|
| 164 |
+
l['l']*sin(l['dc'])*l['fd'].diff()*l['frame_d'].y +
|
| 165 |
+
(l['r']*l['fd'].diff() +
|
| 166 |
+
l['l']*cos(l['dc'])*l['dc'].diff())*l['frame_d'].z)
|
| 167 |
+
assert (v_e_f - expected_v_e_f).simplify() == 0
|
| 168 |
+
|
| 169 |
+
expected_a_e_f = (l['l']*(cos(l['dc'])*l['dc'].diff()**2 +
|
| 170 |
+
sin(l['dc'])*l['dc'].diff().diff())*l['frame_d'].x +
|
| 171 |
+
(-l['r']*l['fd'].diff()**2 -
|
| 172 |
+
2*l['l']*cos(l['dc'])*l['dc'].diff()*l['fd'].diff() -
|
| 173 |
+
l['l']*sin(l['dc'])*l['fd'].diff().diff())*l['frame_d'].y +
|
| 174 |
+
(l['r']*l['fd'].diff().diff() +
|
| 175 |
+
l['l']*cos(l['dc'])*l['dc'].diff().diff() -
|
| 176 |
+
l['l']*sin(l['dc'])*l['dc'].diff()**2 -
|
| 177 |
+
l['l']*sin(l['dc'])*l['fd'].diff()**2)*l['frame_d'].z)
|
| 178 |
+
assert (a_e_f - expected_a_e_f).simplify() == 0
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_c_parser.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_custom_latex.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import tempfile
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
|
| 5 |
+
import sympy
|
| 6 |
+
from sympy.testing.pytest import raises
|
| 7 |
+
from sympy.parsing.latex.lark import LarkLaTeXParser, TransformToSymPyExpr, parse_latex_lark
|
| 8 |
+
from sympy.external import import_module
|
| 9 |
+
|
| 10 |
+
lark = import_module("lark")
|
| 11 |
+
|
| 12 |
+
# disable tests if lark is not present
|
| 13 |
+
disabled = lark is None
|
| 14 |
+
|
| 15 |
+
grammar_file = os.path.join(os.path.dirname(__file__), "../latex/lark/grammar/latex.lark")
|
| 16 |
+
|
| 17 |
+
modification1 = """
|
| 18 |
+
%override DIV_SYMBOL: DIV
|
| 19 |
+
%override MUL_SYMBOL: MUL | CMD_TIMES
|
| 20 |
+
"""
|
| 21 |
+
|
| 22 |
+
modification2 = r"""
|
| 23 |
+
%override number: /\d+(,\d*)?/
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
def init_custom_parser(modification, transformer=None):
|
| 27 |
+
latex_grammar = Path(grammar_file).read_text(encoding="utf-8")
|
| 28 |
+
latex_grammar += modification
|
| 29 |
+
|
| 30 |
+
with tempfile.NamedTemporaryFile() as f:
|
| 31 |
+
f.write(bytes(latex_grammar, encoding="utf8"))
|
| 32 |
+
f.flush()
|
| 33 |
+
|
| 34 |
+
parser = LarkLaTeXParser(grammar_file=f.name, transformer=transformer)
|
| 35 |
+
|
| 36 |
+
return parser
|
| 37 |
+
|
| 38 |
+
def test_custom1():
|
| 39 |
+
# Removes the parser's ability to understand \cdot and \div.
|
| 40 |
+
|
| 41 |
+
parser = init_custom_parser(modification1)
|
| 42 |
+
|
| 43 |
+
with raises(lark.exceptions.UnexpectedCharacters):
|
| 44 |
+
parser.doparse(r"a \cdot b")
|
| 45 |
+
parser.doparse(r"x \div y")
|
| 46 |
+
|
| 47 |
+
class CustomTransformer(TransformToSymPyExpr):
|
| 48 |
+
def number(self, tokens):
|
| 49 |
+
if "," in tokens[0]:
|
| 50 |
+
# The Float constructor expects a dot as the decimal separator
|
| 51 |
+
return sympy.core.numbers.Float(tokens[0].replace(",", "."))
|
| 52 |
+
else:
|
| 53 |
+
return sympy.core.numbers.Integer(tokens[0])
|
| 54 |
+
|
| 55 |
+
def test_custom2():
|
| 56 |
+
# Makes the parser parse commas as the decimal separator instead of dots
|
| 57 |
+
|
| 58 |
+
parser = init_custom_parser(modification2, CustomTransformer)
|
| 59 |
+
|
| 60 |
+
with raises(lark.exceptions.UnexpectedCharacters):
|
| 61 |
+
# Asserting that the default parser cannot parse numbers which have commas as
|
| 62 |
+
# the decimal separator
|
| 63 |
+
parse_latex_lark("100,1")
|
| 64 |
+
parse_latex_lark("0,009")
|
| 65 |
+
|
| 66 |
+
parser.doparse("100,1")
|
| 67 |
+
parser.doparse("0,009")
|
| 68 |
+
parser.doparse("2,71828")
|
| 69 |
+
parser.doparse("3,14159")
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_fortran_parser.py
ADDED
|
@@ -0,0 +1,406 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sympy.testing.pytest import raises
|
| 2 |
+
from sympy.parsing.sym_expr import SymPyExpression
|
| 3 |
+
from sympy.external import import_module
|
| 4 |
+
|
| 5 |
+
lfortran = import_module('lfortran')
|
| 6 |
+
|
| 7 |
+
if lfortran:
|
| 8 |
+
from sympy.codegen.ast import (Variable, IntBaseType, FloatBaseType, String,
|
| 9 |
+
Return, FunctionDefinition, Assignment,
|
| 10 |
+
Declaration, CodeBlock)
|
| 11 |
+
from sympy.core import Integer, Float, Add
|
| 12 |
+
from sympy.core.symbol import Symbol
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
expr1 = SymPyExpression()
|
| 16 |
+
expr2 = SymPyExpression()
|
| 17 |
+
src = """\
|
| 18 |
+
integer :: a, b, c, d
|
| 19 |
+
real :: p, q, r, s
|
| 20 |
+
"""
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def test_sym_expr():
|
| 24 |
+
src1 = (
|
| 25 |
+
src +
|
| 26 |
+
"""\
|
| 27 |
+
d = a + b -c
|
| 28 |
+
"""
|
| 29 |
+
)
|
| 30 |
+
expr3 = SymPyExpression(src,'f')
|
| 31 |
+
expr4 = SymPyExpression(src1,'f')
|
| 32 |
+
ls1 = expr3.return_expr()
|
| 33 |
+
ls2 = expr4.return_expr()
|
| 34 |
+
for i in range(0, 7):
|
| 35 |
+
assert isinstance(ls1[i], Declaration)
|
| 36 |
+
assert isinstance(ls2[i], Declaration)
|
| 37 |
+
assert isinstance(ls2[8], Assignment)
|
| 38 |
+
assert ls1[0] == Declaration(
|
| 39 |
+
Variable(
|
| 40 |
+
Symbol('a'),
|
| 41 |
+
type = IntBaseType(String('integer')),
|
| 42 |
+
value = Integer(0)
|
| 43 |
+
)
|
| 44 |
+
)
|
| 45 |
+
assert ls1[1] == Declaration(
|
| 46 |
+
Variable(
|
| 47 |
+
Symbol('b'),
|
| 48 |
+
type = IntBaseType(String('integer')),
|
| 49 |
+
value = Integer(0)
|
| 50 |
+
)
|
| 51 |
+
)
|
| 52 |
+
assert ls1[2] == Declaration(
|
| 53 |
+
Variable(
|
| 54 |
+
Symbol('c'),
|
| 55 |
+
type = IntBaseType(String('integer')),
|
| 56 |
+
value = Integer(0)
|
| 57 |
+
)
|
| 58 |
+
)
|
| 59 |
+
assert ls1[3] == Declaration(
|
| 60 |
+
Variable(
|
| 61 |
+
Symbol('d'),
|
| 62 |
+
type = IntBaseType(String('integer')),
|
| 63 |
+
value = Integer(0)
|
| 64 |
+
)
|
| 65 |
+
)
|
| 66 |
+
assert ls1[4] == Declaration(
|
| 67 |
+
Variable(
|
| 68 |
+
Symbol('p'),
|
| 69 |
+
type = FloatBaseType(String('real')),
|
| 70 |
+
value = Float(0.0)
|
| 71 |
+
)
|
| 72 |
+
)
|
| 73 |
+
assert ls1[5] == Declaration(
|
| 74 |
+
Variable(
|
| 75 |
+
Symbol('q'),
|
| 76 |
+
type = FloatBaseType(String('real')),
|
| 77 |
+
value = Float(0.0)
|
| 78 |
+
)
|
| 79 |
+
)
|
| 80 |
+
assert ls1[6] == Declaration(
|
| 81 |
+
Variable(
|
| 82 |
+
Symbol('r'),
|
| 83 |
+
type = FloatBaseType(String('real')),
|
| 84 |
+
value = Float(0.0)
|
| 85 |
+
)
|
| 86 |
+
)
|
| 87 |
+
assert ls1[7] == Declaration(
|
| 88 |
+
Variable(
|
| 89 |
+
Symbol('s'),
|
| 90 |
+
type = FloatBaseType(String('real')),
|
| 91 |
+
value = Float(0.0)
|
| 92 |
+
)
|
| 93 |
+
)
|
| 94 |
+
assert ls2[8] == Assignment(
|
| 95 |
+
Variable(Symbol('d')),
|
| 96 |
+
Symbol('a') + Symbol('b') - Symbol('c')
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
def test_assignment():
|
| 100 |
+
src1 = (
|
| 101 |
+
src +
|
| 102 |
+
"""\
|
| 103 |
+
a = b
|
| 104 |
+
c = d
|
| 105 |
+
p = q
|
| 106 |
+
r = s
|
| 107 |
+
"""
|
| 108 |
+
)
|
| 109 |
+
expr1.convert_to_expr(src1, 'f')
|
| 110 |
+
ls1 = expr1.return_expr()
|
| 111 |
+
for iter in range(0, 12):
|
| 112 |
+
if iter < 8:
|
| 113 |
+
assert isinstance(ls1[iter], Declaration)
|
| 114 |
+
else:
|
| 115 |
+
assert isinstance(ls1[iter], Assignment)
|
| 116 |
+
assert ls1[8] == Assignment(
|
| 117 |
+
Variable(Symbol('a')),
|
| 118 |
+
Variable(Symbol('b'))
|
| 119 |
+
)
|
| 120 |
+
assert ls1[9] == Assignment(
|
| 121 |
+
Variable(Symbol('c')),
|
| 122 |
+
Variable(Symbol('d'))
|
| 123 |
+
)
|
| 124 |
+
assert ls1[10] == Assignment(
|
| 125 |
+
Variable(Symbol('p')),
|
| 126 |
+
Variable(Symbol('q'))
|
| 127 |
+
)
|
| 128 |
+
assert ls1[11] == Assignment(
|
| 129 |
+
Variable(Symbol('r')),
|
| 130 |
+
Variable(Symbol('s'))
|
| 131 |
+
)
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
def test_binop_add():
|
| 135 |
+
src1 = (
|
| 136 |
+
src +
|
| 137 |
+
"""\
|
| 138 |
+
c = a + b
|
| 139 |
+
d = a + c
|
| 140 |
+
s = p + q + r
|
| 141 |
+
"""
|
| 142 |
+
)
|
| 143 |
+
expr1.convert_to_expr(src1, 'f')
|
| 144 |
+
ls1 = expr1.return_expr()
|
| 145 |
+
for iter in range(8, 11):
|
| 146 |
+
assert isinstance(ls1[iter], Assignment)
|
| 147 |
+
assert ls1[8] == Assignment(
|
| 148 |
+
Variable(Symbol('c')),
|
| 149 |
+
Symbol('a') + Symbol('b')
|
| 150 |
+
)
|
| 151 |
+
assert ls1[9] == Assignment(
|
| 152 |
+
Variable(Symbol('d')),
|
| 153 |
+
Symbol('a') + Symbol('c')
|
| 154 |
+
)
|
| 155 |
+
assert ls1[10] == Assignment(
|
| 156 |
+
Variable(Symbol('s')),
|
| 157 |
+
Symbol('p') + Symbol('q') + Symbol('r')
|
| 158 |
+
)
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
def test_binop_sub():
|
| 162 |
+
src1 = (
|
| 163 |
+
src +
|
| 164 |
+
"""\
|
| 165 |
+
c = a - b
|
| 166 |
+
d = a - c
|
| 167 |
+
s = p - q - r
|
| 168 |
+
"""
|
| 169 |
+
)
|
| 170 |
+
expr1.convert_to_expr(src1, 'f')
|
| 171 |
+
ls1 = expr1.return_expr()
|
| 172 |
+
for iter in range(8, 11):
|
| 173 |
+
assert isinstance(ls1[iter], Assignment)
|
| 174 |
+
assert ls1[8] == Assignment(
|
| 175 |
+
Variable(Symbol('c')),
|
| 176 |
+
Symbol('a') - Symbol('b')
|
| 177 |
+
)
|
| 178 |
+
assert ls1[9] == Assignment(
|
| 179 |
+
Variable(Symbol('d')),
|
| 180 |
+
Symbol('a') - Symbol('c')
|
| 181 |
+
)
|
| 182 |
+
assert ls1[10] == Assignment(
|
| 183 |
+
Variable(Symbol('s')),
|
| 184 |
+
Symbol('p') - Symbol('q') - Symbol('r')
|
| 185 |
+
)
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
def test_binop_mul():
|
| 189 |
+
src1 = (
|
| 190 |
+
src +
|
| 191 |
+
"""\
|
| 192 |
+
c = a * b
|
| 193 |
+
d = a * c
|
| 194 |
+
s = p * q * r
|
| 195 |
+
"""
|
| 196 |
+
)
|
| 197 |
+
expr1.convert_to_expr(src1, 'f')
|
| 198 |
+
ls1 = expr1.return_expr()
|
| 199 |
+
for iter in range(8, 11):
|
| 200 |
+
assert isinstance(ls1[iter], Assignment)
|
| 201 |
+
assert ls1[8] == Assignment(
|
| 202 |
+
Variable(Symbol('c')),
|
| 203 |
+
Symbol('a') * Symbol('b')
|
| 204 |
+
)
|
| 205 |
+
assert ls1[9] == Assignment(
|
| 206 |
+
Variable(Symbol('d')),
|
| 207 |
+
Symbol('a') * Symbol('c')
|
| 208 |
+
)
|
| 209 |
+
assert ls1[10] == Assignment(
|
| 210 |
+
Variable(Symbol('s')),
|
| 211 |
+
Symbol('p') * Symbol('q') * Symbol('r')
|
| 212 |
+
)
|
| 213 |
+
|
| 214 |
+
|
| 215 |
+
def test_binop_div():
|
| 216 |
+
src1 = (
|
| 217 |
+
src +
|
| 218 |
+
"""\
|
| 219 |
+
c = a / b
|
| 220 |
+
d = a / c
|
| 221 |
+
s = p / q
|
| 222 |
+
r = q / p
|
| 223 |
+
"""
|
| 224 |
+
)
|
| 225 |
+
expr1.convert_to_expr(src1, 'f')
|
| 226 |
+
ls1 = expr1.return_expr()
|
| 227 |
+
for iter in range(8, 12):
|
| 228 |
+
assert isinstance(ls1[iter], Assignment)
|
| 229 |
+
assert ls1[8] == Assignment(
|
| 230 |
+
Variable(Symbol('c')),
|
| 231 |
+
Symbol('a') / Symbol('b')
|
| 232 |
+
)
|
| 233 |
+
assert ls1[9] == Assignment(
|
| 234 |
+
Variable(Symbol('d')),
|
| 235 |
+
Symbol('a') / Symbol('c')
|
| 236 |
+
)
|
| 237 |
+
assert ls1[10] == Assignment(
|
| 238 |
+
Variable(Symbol('s')),
|
| 239 |
+
Symbol('p') / Symbol('q')
|
| 240 |
+
)
|
| 241 |
+
assert ls1[11] == Assignment(
|
| 242 |
+
Variable(Symbol('r')),
|
| 243 |
+
Symbol('q') / Symbol('p')
|
| 244 |
+
)
|
| 245 |
+
|
| 246 |
+
def test_mul_binop():
|
| 247 |
+
src1 = (
|
| 248 |
+
src +
|
| 249 |
+
"""\
|
| 250 |
+
d = a + b - c
|
| 251 |
+
c = a * b + d
|
| 252 |
+
s = p * q / r
|
| 253 |
+
r = p * s + q / p
|
| 254 |
+
"""
|
| 255 |
+
)
|
| 256 |
+
expr1.convert_to_expr(src1, 'f')
|
| 257 |
+
ls1 = expr1.return_expr()
|
| 258 |
+
for iter in range(8, 12):
|
| 259 |
+
assert isinstance(ls1[iter], Assignment)
|
| 260 |
+
assert ls1[8] == Assignment(
|
| 261 |
+
Variable(Symbol('d')),
|
| 262 |
+
Symbol('a') + Symbol('b') - Symbol('c')
|
| 263 |
+
)
|
| 264 |
+
assert ls1[9] == Assignment(
|
| 265 |
+
Variable(Symbol('c')),
|
| 266 |
+
Symbol('a') * Symbol('b') + Symbol('d')
|
| 267 |
+
)
|
| 268 |
+
assert ls1[10] == Assignment(
|
| 269 |
+
Variable(Symbol('s')),
|
| 270 |
+
Symbol('p') * Symbol('q') / Symbol('r')
|
| 271 |
+
)
|
| 272 |
+
assert ls1[11] == Assignment(
|
| 273 |
+
Variable(Symbol('r')),
|
| 274 |
+
Symbol('p') * Symbol('s') + Symbol('q') / Symbol('p')
|
| 275 |
+
)
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
def test_function():
|
| 279 |
+
src1 = """\
|
| 280 |
+
integer function f(a,b)
|
| 281 |
+
integer :: x, y
|
| 282 |
+
f = x + y
|
| 283 |
+
end function
|
| 284 |
+
"""
|
| 285 |
+
expr1.convert_to_expr(src1, 'f')
|
| 286 |
+
for iter in expr1.return_expr():
|
| 287 |
+
assert isinstance(iter, FunctionDefinition)
|
| 288 |
+
assert iter == FunctionDefinition(
|
| 289 |
+
IntBaseType(String('integer')),
|
| 290 |
+
name=String('f'),
|
| 291 |
+
parameters=(
|
| 292 |
+
Variable(Symbol('a')),
|
| 293 |
+
Variable(Symbol('b'))
|
| 294 |
+
),
|
| 295 |
+
body=CodeBlock(
|
| 296 |
+
Declaration(
|
| 297 |
+
Variable(
|
| 298 |
+
Symbol('a'),
|
| 299 |
+
type=IntBaseType(String('integer')),
|
| 300 |
+
value=Integer(0)
|
| 301 |
+
)
|
| 302 |
+
),
|
| 303 |
+
Declaration(
|
| 304 |
+
Variable(
|
| 305 |
+
Symbol('b'),
|
| 306 |
+
type=IntBaseType(String('integer')),
|
| 307 |
+
value=Integer(0)
|
| 308 |
+
)
|
| 309 |
+
),
|
| 310 |
+
Declaration(
|
| 311 |
+
Variable(
|
| 312 |
+
Symbol('f'),
|
| 313 |
+
type=IntBaseType(String('integer')),
|
| 314 |
+
value=Integer(0)
|
| 315 |
+
)
|
| 316 |
+
),
|
| 317 |
+
Declaration(
|
| 318 |
+
Variable(
|
| 319 |
+
Symbol('x'),
|
| 320 |
+
type=IntBaseType(String('integer')),
|
| 321 |
+
value=Integer(0)
|
| 322 |
+
)
|
| 323 |
+
),
|
| 324 |
+
Declaration(
|
| 325 |
+
Variable(
|
| 326 |
+
Symbol('y'),
|
| 327 |
+
type=IntBaseType(String('integer')),
|
| 328 |
+
value=Integer(0)
|
| 329 |
+
)
|
| 330 |
+
),
|
| 331 |
+
Assignment(
|
| 332 |
+
Variable(Symbol('f')),
|
| 333 |
+
Add(Symbol('x'), Symbol('y'))
|
| 334 |
+
),
|
| 335 |
+
Return(Variable(Symbol('f')))
|
| 336 |
+
)
|
| 337 |
+
)
|
| 338 |
+
|
| 339 |
+
|
| 340 |
+
def test_var():
|
| 341 |
+
expr1.convert_to_expr(src, 'f')
|
| 342 |
+
ls = expr1.return_expr()
|
| 343 |
+
for iter in expr1.return_expr():
|
| 344 |
+
assert isinstance(iter, Declaration)
|
| 345 |
+
assert ls[0] == Declaration(
|
| 346 |
+
Variable(
|
| 347 |
+
Symbol('a'),
|
| 348 |
+
type = IntBaseType(String('integer')),
|
| 349 |
+
value = Integer(0)
|
| 350 |
+
)
|
| 351 |
+
)
|
| 352 |
+
assert ls[1] == Declaration(
|
| 353 |
+
Variable(
|
| 354 |
+
Symbol('b'),
|
| 355 |
+
type = IntBaseType(String('integer')),
|
| 356 |
+
value = Integer(0)
|
| 357 |
+
)
|
| 358 |
+
)
|
| 359 |
+
assert ls[2] == Declaration(
|
| 360 |
+
Variable(
|
| 361 |
+
Symbol('c'),
|
| 362 |
+
type = IntBaseType(String('integer')),
|
| 363 |
+
value = Integer(0)
|
| 364 |
+
)
|
| 365 |
+
)
|
| 366 |
+
assert ls[3] == Declaration(
|
| 367 |
+
Variable(
|
| 368 |
+
Symbol('d'),
|
| 369 |
+
type = IntBaseType(String('integer')),
|
| 370 |
+
value = Integer(0)
|
| 371 |
+
)
|
| 372 |
+
)
|
| 373 |
+
assert ls[4] == Declaration(
|
| 374 |
+
Variable(
|
| 375 |
+
Symbol('p'),
|
| 376 |
+
type = FloatBaseType(String('real')),
|
| 377 |
+
value = Float(0.0)
|
| 378 |
+
)
|
| 379 |
+
)
|
| 380 |
+
assert ls[5] == Declaration(
|
| 381 |
+
Variable(
|
| 382 |
+
Symbol('q'),
|
| 383 |
+
type = FloatBaseType(String('real')),
|
| 384 |
+
value = Float(0.0)
|
| 385 |
+
)
|
| 386 |
+
)
|
| 387 |
+
assert ls[6] == Declaration(
|
| 388 |
+
Variable(
|
| 389 |
+
Symbol('r'),
|
| 390 |
+
type = FloatBaseType(String('real')),
|
| 391 |
+
value = Float(0.0)
|
| 392 |
+
)
|
| 393 |
+
)
|
| 394 |
+
assert ls[7] == Declaration(
|
| 395 |
+
Variable(
|
| 396 |
+
Symbol('s'),
|
| 397 |
+
type = FloatBaseType(String('real')),
|
| 398 |
+
value = Float(0.0)
|
| 399 |
+
)
|
| 400 |
+
)
|
| 401 |
+
|
| 402 |
+
else:
|
| 403 |
+
def test_raise():
|
| 404 |
+
from sympy.parsing.fortran.fortran_parser import ASR2PyVisitor
|
| 405 |
+
raises(ImportError, lambda: ASR2PyVisitor())
|
| 406 |
+
raises(ImportError, lambda: SymPyExpression(' ', mode = 'f'))
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_implicit_multiplication_application.py
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sympy
|
| 2 |
+
from sympy.parsing.sympy_parser import (
|
| 3 |
+
parse_expr,
|
| 4 |
+
standard_transformations,
|
| 5 |
+
convert_xor,
|
| 6 |
+
implicit_multiplication_application,
|
| 7 |
+
implicit_multiplication,
|
| 8 |
+
implicit_application,
|
| 9 |
+
function_exponentiation,
|
| 10 |
+
split_symbols,
|
| 11 |
+
split_symbols_custom,
|
| 12 |
+
_token_splittable
|
| 13 |
+
)
|
| 14 |
+
from sympy.testing.pytest import raises
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def test_implicit_multiplication():
|
| 18 |
+
cases = {
|
| 19 |
+
'5x': '5*x',
|
| 20 |
+
'abc': 'a*b*c',
|
| 21 |
+
'3sin(x)': '3*sin(x)',
|
| 22 |
+
'(x+1)(x+2)': '(x+1)*(x+2)',
|
| 23 |
+
'(5 x**2)sin(x)': '(5*x**2)*sin(x)',
|
| 24 |
+
'2 sin(x) cos(x)': '2*sin(x)*cos(x)',
|
| 25 |
+
'pi x': 'pi*x',
|
| 26 |
+
'x pi': 'x*pi',
|
| 27 |
+
'E x': 'E*x',
|
| 28 |
+
'EulerGamma y': 'EulerGamma*y',
|
| 29 |
+
'E pi': 'E*pi',
|
| 30 |
+
'pi (x + 2)': 'pi*(x+2)',
|
| 31 |
+
'(x + 2) pi': '(x+2)*pi',
|
| 32 |
+
'pi sin(x)': 'pi*sin(x)',
|
| 33 |
+
}
|
| 34 |
+
transformations = standard_transformations + (convert_xor,)
|
| 35 |
+
transformations2 = transformations + (split_symbols,
|
| 36 |
+
implicit_multiplication)
|
| 37 |
+
for case in cases:
|
| 38 |
+
implicit = parse_expr(case, transformations=transformations2)
|
| 39 |
+
normal = parse_expr(cases[case], transformations=transformations)
|
| 40 |
+
assert(implicit == normal)
|
| 41 |
+
|
| 42 |
+
application = ['sin x', 'cos 2*x', 'sin cos x']
|
| 43 |
+
for case in application:
|
| 44 |
+
raises(SyntaxError,
|
| 45 |
+
lambda: parse_expr(case, transformations=transformations2))
|
| 46 |
+
raises(TypeError,
|
| 47 |
+
lambda: parse_expr('sin**2(x)', transformations=transformations2))
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def test_implicit_application():
|
| 51 |
+
cases = {
|
| 52 |
+
'factorial': 'factorial',
|
| 53 |
+
'sin x': 'sin(x)',
|
| 54 |
+
'tan y**3': 'tan(y**3)',
|
| 55 |
+
'cos 2*x': 'cos(2*x)',
|
| 56 |
+
'(cot)': 'cot',
|
| 57 |
+
'sin cos tan x': 'sin(cos(tan(x)))'
|
| 58 |
+
}
|
| 59 |
+
transformations = standard_transformations + (convert_xor,)
|
| 60 |
+
transformations2 = transformations + (implicit_application,)
|
| 61 |
+
for case in cases:
|
| 62 |
+
implicit = parse_expr(case, transformations=transformations2)
|
| 63 |
+
normal = parse_expr(cases[case], transformations=transformations)
|
| 64 |
+
assert(implicit == normal), (implicit, normal)
|
| 65 |
+
|
| 66 |
+
multiplication = ['x y', 'x sin x', '2x']
|
| 67 |
+
for case in multiplication:
|
| 68 |
+
raises(SyntaxError,
|
| 69 |
+
lambda: parse_expr(case, transformations=transformations2))
|
| 70 |
+
raises(TypeError,
|
| 71 |
+
lambda: parse_expr('sin**2(x)', transformations=transformations2))
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
def test_function_exponentiation():
|
| 75 |
+
cases = {
|
| 76 |
+
'sin**2(x)': 'sin(x)**2',
|
| 77 |
+
'exp^y(z)': 'exp(z)^y',
|
| 78 |
+
'sin**2(E^(x))': 'sin(E^(x))**2'
|
| 79 |
+
}
|
| 80 |
+
transformations = standard_transformations + (convert_xor,)
|
| 81 |
+
transformations2 = transformations + (function_exponentiation,)
|
| 82 |
+
for case in cases:
|
| 83 |
+
implicit = parse_expr(case, transformations=transformations2)
|
| 84 |
+
normal = parse_expr(cases[case], transformations=transformations)
|
| 85 |
+
assert(implicit == normal)
|
| 86 |
+
|
| 87 |
+
other_implicit = ['x y', 'x sin x', '2x', 'sin x',
|
| 88 |
+
'cos 2*x', 'sin cos x']
|
| 89 |
+
for case in other_implicit:
|
| 90 |
+
raises(SyntaxError,
|
| 91 |
+
lambda: parse_expr(case, transformations=transformations2))
|
| 92 |
+
|
| 93 |
+
assert parse_expr('x**2', local_dict={ 'x': sympy.Symbol('x') },
|
| 94 |
+
transformations=transformations2) == parse_expr('x**2')
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def test_symbol_splitting():
|
| 98 |
+
# By default Greek letter names should not be split (lambda is a keyword
|
| 99 |
+
# so skip it)
|
| 100 |
+
transformations = standard_transformations + (split_symbols,)
|
| 101 |
+
greek_letters = ('alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta',
|
| 102 |
+
'eta', 'theta', 'iota', 'kappa', 'mu', 'nu', 'xi',
|
| 103 |
+
'omicron', 'pi', 'rho', 'sigma', 'tau', 'upsilon',
|
| 104 |
+
'phi', 'chi', 'psi', 'omega')
|
| 105 |
+
|
| 106 |
+
for letter in greek_letters:
|
| 107 |
+
assert(parse_expr(letter, transformations=transformations) ==
|
| 108 |
+
parse_expr(letter))
|
| 109 |
+
|
| 110 |
+
# Make sure symbol splitting resolves names
|
| 111 |
+
transformations += (implicit_multiplication,)
|
| 112 |
+
local_dict = { 'e': sympy.E }
|
| 113 |
+
cases = {
|
| 114 |
+
'xe': 'E*x',
|
| 115 |
+
'Iy': 'I*y',
|
| 116 |
+
'ee': 'E*E',
|
| 117 |
+
}
|
| 118 |
+
for case, expected in cases.items():
|
| 119 |
+
assert(parse_expr(case, local_dict=local_dict,
|
| 120 |
+
transformations=transformations) ==
|
| 121 |
+
parse_expr(expected))
|
| 122 |
+
|
| 123 |
+
# Make sure custom splitting works
|
| 124 |
+
def can_split(symbol):
|
| 125 |
+
if symbol not in ('unsplittable', 'names'):
|
| 126 |
+
return _token_splittable(symbol)
|
| 127 |
+
return False
|
| 128 |
+
transformations = standard_transformations
|
| 129 |
+
transformations += (split_symbols_custom(can_split),
|
| 130 |
+
implicit_multiplication)
|
| 131 |
+
|
| 132 |
+
assert(parse_expr('unsplittable', transformations=transformations) ==
|
| 133 |
+
parse_expr('unsplittable'))
|
| 134 |
+
assert(parse_expr('names', transformations=transformations) ==
|
| 135 |
+
parse_expr('names'))
|
| 136 |
+
assert(parse_expr('xy', transformations=transformations) ==
|
| 137 |
+
parse_expr('x*y'))
|
| 138 |
+
for letter in greek_letters:
|
| 139 |
+
assert(parse_expr(letter, transformations=transformations) ==
|
| 140 |
+
parse_expr(letter))
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
def test_all_implicit_steps():
|
| 144 |
+
cases = {
|
| 145 |
+
'2x': '2*x', # implicit multiplication
|
| 146 |
+
'x y': 'x*y',
|
| 147 |
+
'xy': 'x*y',
|
| 148 |
+
'sin x': 'sin(x)', # add parentheses
|
| 149 |
+
'2sin x': '2*sin(x)',
|
| 150 |
+
'x y z': 'x*y*z',
|
| 151 |
+
'sin(2 * 3x)': 'sin(2 * 3 * x)',
|
| 152 |
+
'sin(x) (1 + cos(x))': 'sin(x) * (1 + cos(x))',
|
| 153 |
+
'(x + 2) sin(x)': '(x + 2) * sin(x)',
|
| 154 |
+
'(x + 2) sin x': '(x + 2) * sin(x)',
|
| 155 |
+
'sin(sin x)': 'sin(sin(x))',
|
| 156 |
+
'sin x!': 'sin(factorial(x))',
|
| 157 |
+
'sin x!!': 'sin(factorial2(x))',
|
| 158 |
+
'factorial': 'factorial', # don't apply a bare function
|
| 159 |
+
'x sin x': 'x * sin(x)', # both application and multiplication
|
| 160 |
+
'xy sin x': 'x * y * sin(x)',
|
| 161 |
+
'(x+2)(x+3)': '(x + 2) * (x+3)',
|
| 162 |
+
'x**2 + 2xy + y**2': 'x**2 + 2 * x * y + y**2', # split the xy
|
| 163 |
+
'pi': 'pi', # don't mess with constants
|
| 164 |
+
'None': 'None',
|
| 165 |
+
'ln sin x': 'ln(sin(x))', # multiple implicit function applications
|
| 166 |
+
'sin x**2': 'sin(x**2)', # implicit application to an exponential
|
| 167 |
+
'alpha': 'Symbol("alpha")', # don't split Greek letters/subscripts
|
| 168 |
+
'x_2': 'Symbol("x_2")',
|
| 169 |
+
'sin^2 x**2': 'sin(x**2)**2', # function raised to a power
|
| 170 |
+
'sin**3(x)': 'sin(x)**3',
|
| 171 |
+
'(factorial)': 'factorial',
|
| 172 |
+
'tan 3x': 'tan(3*x)',
|
| 173 |
+
'sin^2(3*E^(x))': 'sin(3*E**(x))**2',
|
| 174 |
+
'sin**2(E^(3x))': 'sin(E**(3*x))**2',
|
| 175 |
+
'sin^2 (3x*E^(x))': 'sin(3*x*E^x)**2',
|
| 176 |
+
'pi sin x': 'pi*sin(x)',
|
| 177 |
+
}
|
| 178 |
+
transformations = standard_transformations + (convert_xor,)
|
| 179 |
+
transformations2 = transformations + (implicit_multiplication_application,)
|
| 180 |
+
for case in cases:
|
| 181 |
+
implicit = parse_expr(case, transformations=transformations2)
|
| 182 |
+
normal = parse_expr(cases[case], transformations=transformations)
|
| 183 |
+
assert(implicit == normal)
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
def test_no_methods_implicit_multiplication():
|
| 187 |
+
# Issue 21020
|
| 188 |
+
u = sympy.Symbol('u')
|
| 189 |
+
transformations = standard_transformations + \
|
| 190 |
+
(implicit_multiplication,)
|
| 191 |
+
expr = parse_expr('x.is_polynomial(x)', transformations=transformations)
|
| 192 |
+
assert expr == True
|
| 193 |
+
expr = parse_expr('(exp(x) / (1 + exp(2x))).subs(exp(x), u)',
|
| 194 |
+
transformations=transformations)
|
| 195 |
+
assert expr == u/(u**2 + 1)
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_latex.py
ADDED
|
@@ -0,0 +1,358 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sympy.testing.pytest import raises, XFAIL
|
| 2 |
+
from sympy.external import import_module
|
| 3 |
+
|
| 4 |
+
from sympy.concrete.products import Product
|
| 5 |
+
from sympy.concrete.summations import Sum
|
| 6 |
+
from sympy.core.add import Add
|
| 7 |
+
from sympy.core.function import (Derivative, Function)
|
| 8 |
+
from sympy.core.mul import Mul
|
| 9 |
+
from sympy.core.numbers import (E, oo)
|
| 10 |
+
from sympy.core.power import Pow
|
| 11 |
+
from sympy.core.relational import (GreaterThan, LessThan, StrictGreaterThan, StrictLessThan, Unequality)
|
| 12 |
+
from sympy.core.symbol import Symbol
|
| 13 |
+
from sympy.functions.combinatorial.factorials import (binomial, factorial)
|
| 14 |
+
from sympy.functions.elementary.complexes import (Abs, conjugate)
|
| 15 |
+
from sympy.functions.elementary.exponential import (exp, log)
|
| 16 |
+
from sympy.functions.elementary.integers import (ceiling, floor)
|
| 17 |
+
from sympy.functions.elementary.miscellaneous import (root, sqrt)
|
| 18 |
+
from sympy.functions.elementary.trigonometric import (asin, cos, csc, sec, sin, tan)
|
| 19 |
+
from sympy.integrals.integrals import Integral
|
| 20 |
+
from sympy.series.limits import Limit
|
| 21 |
+
|
| 22 |
+
from sympy.core.relational import Eq, Ne, Lt, Le, Gt, Ge
|
| 23 |
+
from sympy.physics.quantum.state import Bra, Ket
|
| 24 |
+
from sympy.abc import x, y, z, a, b, c, t, k, n
|
| 25 |
+
antlr4 = import_module("antlr4")
|
| 26 |
+
|
| 27 |
+
# disable tests if antlr4-python3-runtime is not present
|
| 28 |
+
disabled = antlr4 is None
|
| 29 |
+
|
| 30 |
+
theta = Symbol('theta')
|
| 31 |
+
f = Function('f')
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
# shorthand definitions
|
| 35 |
+
def _Add(a, b):
|
| 36 |
+
return Add(a, b, evaluate=False)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def _Mul(a, b):
|
| 40 |
+
return Mul(a, b, evaluate=False)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def _Pow(a, b):
|
| 44 |
+
return Pow(a, b, evaluate=False)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def _Sqrt(a):
|
| 48 |
+
return sqrt(a, evaluate=False)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def _Conjugate(a):
|
| 52 |
+
return conjugate(a, evaluate=False)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def _Abs(a):
|
| 56 |
+
return Abs(a, evaluate=False)
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
def _factorial(a):
|
| 60 |
+
return factorial(a, evaluate=False)
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def _exp(a):
|
| 64 |
+
return exp(a, evaluate=False)
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def _log(a, b):
|
| 68 |
+
return log(a, b, evaluate=False)
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def _binomial(n, k):
|
| 72 |
+
return binomial(n, k, evaluate=False)
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def test_import():
|
| 76 |
+
from sympy.parsing.latex._build_latex_antlr import (
|
| 77 |
+
build_parser,
|
| 78 |
+
check_antlr_version,
|
| 79 |
+
dir_latex_antlr
|
| 80 |
+
)
|
| 81 |
+
# XXX: It would be better to come up with a test for these...
|
| 82 |
+
del build_parser, check_antlr_version, dir_latex_antlr
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
# These LaTeX strings should parse to the corresponding SymPy expression
|
| 86 |
+
GOOD_PAIRS = [
|
| 87 |
+
(r"0", 0),
|
| 88 |
+
(r"1", 1),
|
| 89 |
+
(r"-3.14", -3.14),
|
| 90 |
+
(r"(-7.13)(1.5)", _Mul(-7.13, 1.5)),
|
| 91 |
+
(r"x", x),
|
| 92 |
+
(r"2x", 2*x),
|
| 93 |
+
(r"x^2", x**2),
|
| 94 |
+
(r"x^\frac{1}{2}", _Pow(x, _Pow(2, -1))),
|
| 95 |
+
(r"x^{3 + 1}", x**_Add(3, 1)),
|
| 96 |
+
(r"-c", -c),
|
| 97 |
+
(r"a \cdot b", a * b),
|
| 98 |
+
(r"a / b", a / b),
|
| 99 |
+
(r"a \div b", a / b),
|
| 100 |
+
(r"a + b", a + b),
|
| 101 |
+
(r"a + b - a", _Add(a+b, -a)),
|
| 102 |
+
(r"a^2 + b^2 = c^2", Eq(a**2 + b**2, c**2)),
|
| 103 |
+
(r"(x + y) z", _Mul(_Add(x, y), z)),
|
| 104 |
+
(r"a'b+ab'", _Add(_Mul(Symbol("a'"), b), _Mul(a, Symbol("b'")))),
|
| 105 |
+
(r"y''_1", Symbol("y_{1}''")),
|
| 106 |
+
(r"y_1''", Symbol("y_{1}''")),
|
| 107 |
+
(r"\left(x + y\right) z", _Mul(_Add(x, y), z)),
|
| 108 |
+
(r"\left( x + y\right ) z", _Mul(_Add(x, y), z)),
|
| 109 |
+
(r"\left( x + y\right ) z", _Mul(_Add(x, y), z)),
|
| 110 |
+
(r"\left[x + y\right] z", _Mul(_Add(x, y), z)),
|
| 111 |
+
(r"\left\{x + y\right\} z", _Mul(_Add(x, y), z)),
|
| 112 |
+
(r"1+1", _Add(1, 1)),
|
| 113 |
+
(r"0+1", _Add(0, 1)),
|
| 114 |
+
(r"1*2", _Mul(1, 2)),
|
| 115 |
+
(r"0*1", _Mul(0, 1)),
|
| 116 |
+
(r"1 \times 2 ", _Mul(1, 2)),
|
| 117 |
+
(r"x = y", Eq(x, y)),
|
| 118 |
+
(r"x \neq y", Ne(x, y)),
|
| 119 |
+
(r"x < y", Lt(x, y)),
|
| 120 |
+
(r"x > y", Gt(x, y)),
|
| 121 |
+
(r"x \leq y", Le(x, y)),
|
| 122 |
+
(r"x \geq y", Ge(x, y)),
|
| 123 |
+
(r"x \le y", Le(x, y)),
|
| 124 |
+
(r"x \ge y", Ge(x, y)),
|
| 125 |
+
(r"\lfloor x \rfloor", floor(x)),
|
| 126 |
+
(r"\lceil x \rceil", ceiling(x)),
|
| 127 |
+
(r"\langle x |", Bra('x')),
|
| 128 |
+
(r"| x \rangle", Ket('x')),
|
| 129 |
+
(r"\sin \theta", sin(theta)),
|
| 130 |
+
(r"\sin(\theta)", sin(theta)),
|
| 131 |
+
(r"\sin^{-1} a", asin(a)),
|
| 132 |
+
(r"\sin a \cos b", _Mul(sin(a), cos(b))),
|
| 133 |
+
(r"\sin \cos \theta", sin(cos(theta))),
|
| 134 |
+
(r"\sin(\cos \theta)", sin(cos(theta))),
|
| 135 |
+
(r"\frac{a}{b}", a / b),
|
| 136 |
+
(r"\dfrac{a}{b}", a / b),
|
| 137 |
+
(r"\tfrac{a}{b}", a / b),
|
| 138 |
+
(r"\frac12", _Pow(2, -1)),
|
| 139 |
+
(r"\frac12y", _Mul(_Pow(2, -1), y)),
|
| 140 |
+
(r"\frac1234", _Mul(_Pow(2, -1), 34)),
|
| 141 |
+
(r"\frac2{3}", _Mul(2, _Pow(3, -1))),
|
| 142 |
+
(r"\frac{\sin{x}}2", _Mul(sin(x), _Pow(2, -1))),
|
| 143 |
+
(r"\frac{a + b}{c}", _Mul(a + b, _Pow(c, -1))),
|
| 144 |
+
(r"\frac{7}{3}", _Mul(7, _Pow(3, -1))),
|
| 145 |
+
(r"(\csc x)(\sec y)", csc(x)*sec(y)),
|
| 146 |
+
(r"\lim_{x \to 3} a", Limit(a, x, 3, dir='+-')),
|
| 147 |
+
(r"\lim_{x \rightarrow 3} a", Limit(a, x, 3, dir='+-')),
|
| 148 |
+
(r"\lim_{x \Rightarrow 3} a", Limit(a, x, 3, dir='+-')),
|
| 149 |
+
(r"\lim_{x \longrightarrow 3} a", Limit(a, x, 3, dir='+-')),
|
| 150 |
+
(r"\lim_{x \Longrightarrow 3} a", Limit(a, x, 3, dir='+-')),
|
| 151 |
+
(r"\lim_{x \to 3^{+}} a", Limit(a, x, 3, dir='+')),
|
| 152 |
+
(r"\lim_{x \to 3^{-}} a", Limit(a, x, 3, dir='-')),
|
| 153 |
+
(r"\lim_{x \to 3^+} a", Limit(a, x, 3, dir='+')),
|
| 154 |
+
(r"\lim_{x \to 3^-} a", Limit(a, x, 3, dir='-')),
|
| 155 |
+
(r"\infty", oo),
|
| 156 |
+
(r"\lim_{x \to \infty} \frac{1}{x}", Limit(_Pow(x, -1), x, oo)),
|
| 157 |
+
(r"\frac{d}{dx} x", Derivative(x, x)),
|
| 158 |
+
(r"\frac{d}{dt} x", Derivative(x, t)),
|
| 159 |
+
(r"f(x)", f(x)),
|
| 160 |
+
(r"f(x, y)", f(x, y)),
|
| 161 |
+
(r"f(x, y, z)", f(x, y, z)),
|
| 162 |
+
(r"f'_1(x)", Function("f_{1}'")(x)),
|
| 163 |
+
(r"f_{1}''(x+y)", Function("f_{1}''")(x+y)),
|
| 164 |
+
(r"\frac{d f(x)}{dx}", Derivative(f(x), x)),
|
| 165 |
+
(r"\frac{d\theta(x)}{dx}", Derivative(Function('theta')(x), x)),
|
| 166 |
+
(r"x \neq y", Unequality(x, y)),
|
| 167 |
+
(r"|x|", _Abs(x)),
|
| 168 |
+
(r"||x||", _Abs(Abs(x))),
|
| 169 |
+
(r"|x||y|", _Abs(x)*_Abs(y)),
|
| 170 |
+
(r"||x||y||", _Abs(_Abs(x)*_Abs(y))),
|
| 171 |
+
(r"\pi^{|xy|}", Symbol('pi')**_Abs(x*y)),
|
| 172 |
+
(r"\int x dx", Integral(x, x)),
|
| 173 |
+
(r"\int x d\theta", Integral(x, theta)),
|
| 174 |
+
(r"\int (x^2 - y)dx", Integral(x**2 - y, x)),
|
| 175 |
+
(r"\int x + a dx", Integral(_Add(x, a), x)),
|
| 176 |
+
(r"\int da", Integral(1, a)),
|
| 177 |
+
(r"\int_0^7 dx", Integral(1, (x, 0, 7))),
|
| 178 |
+
(r"\int\limits_{0}^{1} x dx", Integral(x, (x, 0, 1))),
|
| 179 |
+
(r"\int_a^b x dx", Integral(x, (x, a, b))),
|
| 180 |
+
(r"\int^b_a x dx", Integral(x, (x, a, b))),
|
| 181 |
+
(r"\int_{a}^b x dx", Integral(x, (x, a, b))),
|
| 182 |
+
(r"\int^{b}_a x dx", Integral(x, (x, a, b))),
|
| 183 |
+
(r"\int_{a}^{b} x dx", Integral(x, (x, a, b))),
|
| 184 |
+
(r"\int^{b}_{a} x dx", Integral(x, (x, a, b))),
|
| 185 |
+
(r"\int_{f(a)}^{f(b)} f(z) dz", Integral(f(z), (z, f(a), f(b)))),
|
| 186 |
+
(r"\int (x+a)", Integral(_Add(x, a), x)),
|
| 187 |
+
(r"\int a + b + c dx", Integral(_Add(_Add(a, b), c), x)),
|
| 188 |
+
(r"\int \frac{dz}{z}", Integral(Pow(z, -1), z)),
|
| 189 |
+
(r"\int \frac{3 dz}{z}", Integral(3*Pow(z, -1), z)),
|
| 190 |
+
(r"\int \frac{1}{x} dx", Integral(Pow(x, -1), x)),
|
| 191 |
+
(r"\int \frac{1}{a} + \frac{1}{b} dx",
|
| 192 |
+
Integral(_Add(_Pow(a, -1), Pow(b, -1)), x)),
|
| 193 |
+
(r"\int \frac{3 \cdot d\theta}{\theta}",
|
| 194 |
+
Integral(3*_Pow(theta, -1), theta)),
|
| 195 |
+
(r"\int \frac{1}{x} + 1 dx", Integral(_Add(_Pow(x, -1), 1), x)),
|
| 196 |
+
(r"x_0", Symbol('x_{0}')),
|
| 197 |
+
(r"x_{1}", Symbol('x_{1}')),
|
| 198 |
+
(r"x_a", Symbol('x_{a}')),
|
| 199 |
+
(r"x_{b}", Symbol('x_{b}')),
|
| 200 |
+
(r"h_\theta", Symbol('h_{theta}')),
|
| 201 |
+
(r"h_{\theta}", Symbol('h_{theta}')),
|
| 202 |
+
(r"h_{\theta}(x_0, x_1)",
|
| 203 |
+
Function('h_{theta}')(Symbol('x_{0}'), Symbol('x_{1}'))),
|
| 204 |
+
(r"x!", _factorial(x)),
|
| 205 |
+
(r"100!", _factorial(100)),
|
| 206 |
+
(r"\theta!", _factorial(theta)),
|
| 207 |
+
(r"(x + 1)!", _factorial(_Add(x, 1))),
|
| 208 |
+
(r"(x!)!", _factorial(_factorial(x))),
|
| 209 |
+
(r"x!!!", _factorial(_factorial(_factorial(x)))),
|
| 210 |
+
(r"5!7!", _Mul(_factorial(5), _factorial(7))),
|
| 211 |
+
(r"\sqrt{x}", sqrt(x)),
|
| 212 |
+
(r"\sqrt{x + b}", sqrt(_Add(x, b))),
|
| 213 |
+
(r"\sqrt[3]{\sin x}", root(sin(x), 3)),
|
| 214 |
+
(r"\sqrt[y]{\sin x}", root(sin(x), y)),
|
| 215 |
+
(r"\sqrt[\theta]{\sin x}", root(sin(x), theta)),
|
| 216 |
+
(r"\sqrt{\frac{12}{6}}", _Sqrt(_Mul(12, _Pow(6, -1)))),
|
| 217 |
+
(r"\overline{z}", _Conjugate(z)),
|
| 218 |
+
(r"\overline{\overline{z}}", _Conjugate(_Conjugate(z))),
|
| 219 |
+
(r"\overline{x + y}", _Conjugate(_Add(x, y))),
|
| 220 |
+
(r"\overline{x} + \overline{y}", _Conjugate(x) + _Conjugate(y)),
|
| 221 |
+
(r"x < y", StrictLessThan(x, y)),
|
| 222 |
+
(r"x \leq y", LessThan(x, y)),
|
| 223 |
+
(r"x > y", StrictGreaterThan(x, y)),
|
| 224 |
+
(r"x \geq y", GreaterThan(x, y)),
|
| 225 |
+
(r"\mathit{x}", Symbol('x')),
|
| 226 |
+
(r"\mathit{test}", Symbol('test')),
|
| 227 |
+
(r"\mathit{TEST}", Symbol('TEST')),
|
| 228 |
+
(r"\mathit{HELLO world}", Symbol('HELLO world')),
|
| 229 |
+
(r"\sum_{k = 1}^{3} c", Sum(c, (k, 1, 3))),
|
| 230 |
+
(r"\sum_{k = 1}^3 c", Sum(c, (k, 1, 3))),
|
| 231 |
+
(r"\sum^{3}_{k = 1} c", Sum(c, (k, 1, 3))),
|
| 232 |
+
(r"\sum^3_{k = 1} c", Sum(c, (k, 1, 3))),
|
| 233 |
+
(r"\sum_{k = 1}^{10} k^2", Sum(k**2, (k, 1, 10))),
|
| 234 |
+
(r"\sum_{n = 0}^{\infty} \frac{1}{n!}",
|
| 235 |
+
Sum(_Pow(_factorial(n), -1), (n, 0, oo))),
|
| 236 |
+
(r"\prod_{a = b}^{c} x", Product(x, (a, b, c))),
|
| 237 |
+
(r"\prod_{a = b}^c x", Product(x, (a, b, c))),
|
| 238 |
+
(r"\prod^{c}_{a = b} x", Product(x, (a, b, c))),
|
| 239 |
+
(r"\prod^c_{a = b} x", Product(x, (a, b, c))),
|
| 240 |
+
(r"\exp x", _exp(x)),
|
| 241 |
+
(r"\exp(x)", _exp(x)),
|
| 242 |
+
(r"\lg x", _log(x, 10)),
|
| 243 |
+
(r"\ln x", _log(x, E)),
|
| 244 |
+
(r"\ln xy", _log(x*y, E)),
|
| 245 |
+
(r"\log x", _log(x, E)),
|
| 246 |
+
(r"\log xy", _log(x*y, E)),
|
| 247 |
+
(r"\log_{2} x", _log(x, 2)),
|
| 248 |
+
(r"\log_{a} x", _log(x, a)),
|
| 249 |
+
(r"\log_{11} x", _log(x, 11)),
|
| 250 |
+
(r"\log_{a^2} x", _log(x, _Pow(a, 2))),
|
| 251 |
+
(r"[x]", x),
|
| 252 |
+
(r"[a + b]", _Add(a, b)),
|
| 253 |
+
(r"\frac{d}{dx} [ \tan x ]", Derivative(tan(x), x)),
|
| 254 |
+
(r"\binom{n}{k}", _binomial(n, k)),
|
| 255 |
+
(r"\tbinom{n}{k}", _binomial(n, k)),
|
| 256 |
+
(r"\dbinom{n}{k}", _binomial(n, k)),
|
| 257 |
+
(r"\binom{n}{0}", _binomial(n, 0)),
|
| 258 |
+
(r"x^\binom{n}{k}", _Pow(x, _binomial(n, k))),
|
| 259 |
+
(r"a \, b", _Mul(a, b)),
|
| 260 |
+
(r"a \thinspace b", _Mul(a, b)),
|
| 261 |
+
(r"a \: b", _Mul(a, b)),
|
| 262 |
+
(r"a \medspace b", _Mul(a, b)),
|
| 263 |
+
(r"a \; b", _Mul(a, b)),
|
| 264 |
+
(r"a \thickspace b", _Mul(a, b)),
|
| 265 |
+
(r"a \quad b", _Mul(a, b)),
|
| 266 |
+
(r"a \qquad b", _Mul(a, b)),
|
| 267 |
+
(r"a \! b", _Mul(a, b)),
|
| 268 |
+
(r"a \negthinspace b", _Mul(a, b)),
|
| 269 |
+
(r"a \negmedspace b", _Mul(a, b)),
|
| 270 |
+
(r"a \negthickspace b", _Mul(a, b)),
|
| 271 |
+
(r"\int x \, dx", Integral(x, x)),
|
| 272 |
+
(r"\log_2 x", _log(x, 2)),
|
| 273 |
+
(r"\log_a x", _log(x, a)),
|
| 274 |
+
(r"5^0 - 4^0", _Add(_Pow(5, 0), _Mul(-1, _Pow(4, 0)))),
|
| 275 |
+
(r"3x - 1", _Add(_Mul(3, x), -1))
|
| 276 |
+
]
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
def test_parseable():
|
| 280 |
+
from sympy.parsing.latex import parse_latex
|
| 281 |
+
for latex_str, sympy_expr in GOOD_PAIRS:
|
| 282 |
+
assert parse_latex(latex_str) == sympy_expr, latex_str
|
| 283 |
+
|
| 284 |
+
# These bad LaTeX strings should raise a LaTeXParsingError when parsed
|
| 285 |
+
BAD_STRINGS = [
|
| 286 |
+
r"(",
|
| 287 |
+
r")",
|
| 288 |
+
r"\frac{d}{dx}",
|
| 289 |
+
r"(\frac{d}{dx})",
|
| 290 |
+
r"\sqrt{}",
|
| 291 |
+
r"\sqrt",
|
| 292 |
+
r"\overline{}",
|
| 293 |
+
r"\overline",
|
| 294 |
+
r"{",
|
| 295 |
+
r"}",
|
| 296 |
+
r"\mathit{x + y}",
|
| 297 |
+
r"\mathit{21}",
|
| 298 |
+
r"\frac{2}{}",
|
| 299 |
+
r"\frac{}{2}",
|
| 300 |
+
r"\int",
|
| 301 |
+
r"!",
|
| 302 |
+
r"!0",
|
| 303 |
+
r"_",
|
| 304 |
+
r"^",
|
| 305 |
+
r"|",
|
| 306 |
+
r"||x|",
|
| 307 |
+
r"()",
|
| 308 |
+
r"((((((((((((((((()))))))))))))))))",
|
| 309 |
+
r"-",
|
| 310 |
+
r"\frac{d}{dx} + \frac{d}{dt}",
|
| 311 |
+
r"f(x,,y)",
|
| 312 |
+
r"f(x,y,",
|
| 313 |
+
r"\sin^x",
|
| 314 |
+
r"\cos^2",
|
| 315 |
+
r"@",
|
| 316 |
+
r"#",
|
| 317 |
+
r"$",
|
| 318 |
+
r"%",
|
| 319 |
+
r"&",
|
| 320 |
+
r"*",
|
| 321 |
+
r"" "\\",
|
| 322 |
+
r"~",
|
| 323 |
+
r"\frac{(2 + x}{1 - x)}",
|
| 324 |
+
]
|
| 325 |
+
|
| 326 |
+
def test_not_parseable():
|
| 327 |
+
from sympy.parsing.latex import parse_latex, LaTeXParsingError
|
| 328 |
+
for latex_str in BAD_STRINGS:
|
| 329 |
+
with raises(LaTeXParsingError):
|
| 330 |
+
parse_latex(latex_str)
|
| 331 |
+
|
| 332 |
+
# At time of migration from latex2sympy, should fail but doesn't
|
| 333 |
+
FAILING_BAD_STRINGS = [
|
| 334 |
+
r"\cos 1 \cos",
|
| 335 |
+
r"f(,",
|
| 336 |
+
r"f()",
|
| 337 |
+
r"a \div \div b",
|
| 338 |
+
r"a \cdot \cdot b",
|
| 339 |
+
r"a // b",
|
| 340 |
+
r"a +",
|
| 341 |
+
r"1.1.1",
|
| 342 |
+
r"1 +",
|
| 343 |
+
r"a / b /",
|
| 344 |
+
]
|
| 345 |
+
|
| 346 |
+
@XFAIL
|
| 347 |
+
def test_failing_not_parseable():
|
| 348 |
+
from sympy.parsing.latex import parse_latex, LaTeXParsingError
|
| 349 |
+
for latex_str in FAILING_BAD_STRINGS:
|
| 350 |
+
with raises(LaTeXParsingError):
|
| 351 |
+
parse_latex(latex_str)
|
| 352 |
+
|
| 353 |
+
# In strict mode, FAILING_BAD_STRINGS would fail
|
| 354 |
+
def test_strict_mode():
|
| 355 |
+
from sympy.parsing.latex import parse_latex, LaTeXParsingError
|
| 356 |
+
for latex_str in FAILING_BAD_STRINGS:
|
| 357 |
+
with raises(LaTeXParsingError):
|
| 358 |
+
parse_latex(latex_str, strict=True)
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_latex_deps.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sympy.external import import_module
|
| 2 |
+
from sympy.testing.pytest import ignore_warnings, raises
|
| 3 |
+
|
| 4 |
+
antlr4 = import_module("antlr4", warn_not_installed=False)
|
| 5 |
+
|
| 6 |
+
# disable tests if antlr4-python3-runtime is not present
|
| 7 |
+
if antlr4:
|
| 8 |
+
disabled = True
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def test_no_import():
|
| 12 |
+
from sympy.parsing.latex import parse_latex
|
| 13 |
+
|
| 14 |
+
with ignore_warnings(UserWarning):
|
| 15 |
+
with raises(ImportError):
|
| 16 |
+
parse_latex('1 + 1')
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_latex_lark.py
ADDED
|
@@ -0,0 +1,872 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sympy.testing.pytest import XFAIL
|
| 2 |
+
from sympy.parsing.latex.lark import parse_latex_lark
|
| 3 |
+
from sympy.external import import_module
|
| 4 |
+
|
| 5 |
+
from sympy.concrete.products import Product
|
| 6 |
+
from sympy.concrete.summations import Sum
|
| 7 |
+
from sympy.core.function import Derivative, Function
|
| 8 |
+
from sympy.core.numbers import E, oo, Rational
|
| 9 |
+
from sympy.core.power import Pow
|
| 10 |
+
from sympy.core.parameters import evaluate
|
| 11 |
+
from sympy.core.relational import GreaterThan, LessThan, StrictGreaterThan, StrictLessThan, Unequality
|
| 12 |
+
from sympy.core.symbol import Symbol
|
| 13 |
+
from sympy.functions.combinatorial.factorials import binomial, factorial
|
| 14 |
+
from sympy.functions.elementary.complexes import Abs, conjugate
|
| 15 |
+
from sympy.functions.elementary.exponential import exp, log
|
| 16 |
+
from sympy.functions.elementary.integers import ceiling, floor
|
| 17 |
+
from sympy.functions.elementary.miscellaneous import root, sqrt, Min, Max
|
| 18 |
+
from sympy.functions.elementary.trigonometric import asin, cos, csc, sec, sin, tan
|
| 19 |
+
from sympy.integrals.integrals import Integral
|
| 20 |
+
from sympy.series.limits import Limit
|
| 21 |
+
from sympy import Matrix, MatAdd, MatMul, Transpose, Trace
|
| 22 |
+
from sympy import I
|
| 23 |
+
|
| 24 |
+
from sympy.core.relational import Eq, Ne, Lt, Le, Gt, Ge
|
| 25 |
+
from sympy.physics.quantum import Bra, Ket, InnerProduct
|
| 26 |
+
from sympy.abc import x, y, z, a, b, c, d, t, k, n
|
| 27 |
+
|
| 28 |
+
from .test_latex import theta, f, _Add, _Mul, _Pow, _Sqrt, _Conjugate, _Abs, _factorial, _exp, _binomial
|
| 29 |
+
|
| 30 |
+
lark = import_module("lark")
|
| 31 |
+
|
| 32 |
+
# disable tests if lark is not present
|
| 33 |
+
disabled = lark is None
|
| 34 |
+
|
| 35 |
+
# shorthand definitions that are only needed for the Lark LaTeX parser
|
| 36 |
+
def _Min(*args):
|
| 37 |
+
return Min(*args, evaluate=False)
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def _Max(*args):
|
| 41 |
+
return Max(*args, evaluate=False)
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def _log(a, b=E):
|
| 45 |
+
if b == E:
|
| 46 |
+
return log(a, evaluate=False)
|
| 47 |
+
else:
|
| 48 |
+
return log(a, b, evaluate=False)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def _MatAdd(a, b):
|
| 52 |
+
return MatAdd(a, b, evaluate=False)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def _MatMul(a, b):
|
| 56 |
+
return MatMul(a, b, evaluate=False)
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
# These LaTeX strings should parse to the corresponding SymPy expression
|
| 60 |
+
SYMBOL_EXPRESSION_PAIRS = [
|
| 61 |
+
(r"x_0", Symbol('x_{0}')),
|
| 62 |
+
(r"x_{1}", Symbol('x_{1}')),
|
| 63 |
+
(r"x_a", Symbol('x_{a}')),
|
| 64 |
+
(r"x_{b}", Symbol('x_{b}')),
|
| 65 |
+
(r"h_\theta", Symbol('h_{theta}')),
|
| 66 |
+
(r"h_{\theta}", Symbol('h_{theta}')),
|
| 67 |
+
(r"y''_1", Symbol("y''_{1}")),
|
| 68 |
+
(r"y_1''", Symbol("y_{1}''")),
|
| 69 |
+
(r"\mathit{x}", Symbol('x')),
|
| 70 |
+
(r"\mathit{test}", Symbol('test')),
|
| 71 |
+
(r"\mathit{TEST}", Symbol('TEST')),
|
| 72 |
+
(r"\mathit{HELLO world}", Symbol('HELLO world')),
|
| 73 |
+
(r"a'", Symbol("a'")),
|
| 74 |
+
(r"a''", Symbol("a''")),
|
| 75 |
+
(r"\alpha'", Symbol("alpha'")),
|
| 76 |
+
(r"\alpha''", Symbol("alpha''")),
|
| 77 |
+
(r"a_b", Symbol("a_{b}")),
|
| 78 |
+
(r"a_b'", Symbol("a_{b}'")),
|
| 79 |
+
(r"a'_b", Symbol("a'_{b}")),
|
| 80 |
+
(r"a'_b'", Symbol("a'_{b}'")),
|
| 81 |
+
(r"a_{b'}", Symbol("a_{b'}")),
|
| 82 |
+
(r"a_{b'}'", Symbol("a_{b'}'")),
|
| 83 |
+
(r"a'_{b'}", Symbol("a'_{b'}")),
|
| 84 |
+
(r"a'_{b'}'", Symbol("a'_{b'}'")),
|
| 85 |
+
(r"\mathit{foo}'", Symbol("foo'")),
|
| 86 |
+
(r"\mathit{foo'}", Symbol("foo'")),
|
| 87 |
+
(r"\mathit{foo'}'", Symbol("foo''")),
|
| 88 |
+
(r"a_b''", Symbol("a_{b}''")),
|
| 89 |
+
(r"a''_b", Symbol("a''_{b}")),
|
| 90 |
+
(r"a''_b'''", Symbol("a''_{b}'''")),
|
| 91 |
+
(r"a_{b''}", Symbol("a_{b''}")),
|
| 92 |
+
(r"a_{b''}''", Symbol("a_{b''}''")),
|
| 93 |
+
(r"a''_{b''}", Symbol("a''_{b''}")),
|
| 94 |
+
(r"a''_{b''}'''", Symbol("a''_{b''}'''")),
|
| 95 |
+
(r"\mathit{foo}''", Symbol("foo''")),
|
| 96 |
+
(r"\mathit{foo''}", Symbol("foo''")),
|
| 97 |
+
(r"\mathit{foo''}'''", Symbol("foo'''''")),
|
| 98 |
+
(r"a_\alpha", Symbol("a_{alpha}")),
|
| 99 |
+
(r"a_\alpha'", Symbol("a_{alpha}'")),
|
| 100 |
+
(r"a'_\alpha", Symbol("a'_{alpha}")),
|
| 101 |
+
(r"a'_\alpha'", Symbol("a'_{alpha}'")),
|
| 102 |
+
(r"a_{\alpha'}", Symbol("a_{alpha'}")),
|
| 103 |
+
(r"a_{\alpha'}'", Symbol("a_{alpha'}'")),
|
| 104 |
+
(r"a'_{\alpha'}", Symbol("a'_{alpha'}")),
|
| 105 |
+
(r"a'_{\alpha'}'", Symbol("a'_{alpha'}'")),
|
| 106 |
+
(r"a_\alpha''", Symbol("a_{alpha}''")),
|
| 107 |
+
(r"a''_\alpha", Symbol("a''_{alpha}")),
|
| 108 |
+
(r"a''_\alpha'''", Symbol("a''_{alpha}'''")),
|
| 109 |
+
(r"a_{\alpha''}", Symbol("a_{alpha''}")),
|
| 110 |
+
(r"a_{\alpha''}''", Symbol("a_{alpha''}''")),
|
| 111 |
+
(r"a''_{\alpha''}", Symbol("a''_{alpha''}")),
|
| 112 |
+
(r"a''_{\alpha''}'''", Symbol("a''_{alpha''}'''")),
|
| 113 |
+
(r"\alpha_b", Symbol("alpha_{b}")),
|
| 114 |
+
(r"\alpha_b'", Symbol("alpha_{b}'")),
|
| 115 |
+
(r"\alpha'_b", Symbol("alpha'_{b}")),
|
| 116 |
+
(r"\alpha'_b'", Symbol("alpha'_{b}'")),
|
| 117 |
+
(r"\alpha_{b'}", Symbol("alpha_{b'}")),
|
| 118 |
+
(r"\alpha_{b'}'", Symbol("alpha_{b'}'")),
|
| 119 |
+
(r"\alpha'_{b'}", Symbol("alpha'_{b'}")),
|
| 120 |
+
(r"\alpha'_{b'}'", Symbol("alpha'_{b'}'")),
|
| 121 |
+
(r"\alpha_b''", Symbol("alpha_{b}''")),
|
| 122 |
+
(r"\alpha''_b", Symbol("alpha''_{b}")),
|
| 123 |
+
(r"\alpha''_b'''", Symbol("alpha''_{b}'''")),
|
| 124 |
+
(r"\alpha_{b''}", Symbol("alpha_{b''}")),
|
| 125 |
+
(r"\alpha_{b''}''", Symbol("alpha_{b''}''")),
|
| 126 |
+
(r"\alpha''_{b''}", Symbol("alpha''_{b''}")),
|
| 127 |
+
(r"\alpha''_{b''}'''", Symbol("alpha''_{b''}'''")),
|
| 128 |
+
(r"\alpha_\beta", Symbol("alpha_{beta}")),
|
| 129 |
+
(r"\alpha_{\beta}", Symbol("alpha_{beta}")),
|
| 130 |
+
(r"\alpha_{\beta'}", Symbol("alpha_{beta'}")),
|
| 131 |
+
(r"\alpha_{\beta''}", Symbol("alpha_{beta''}")),
|
| 132 |
+
(r"\alpha'_\beta", Symbol("alpha'_{beta}")),
|
| 133 |
+
(r"\alpha'_{\beta}", Symbol("alpha'_{beta}")),
|
| 134 |
+
(r"\alpha'_{\beta'}", Symbol("alpha'_{beta'}")),
|
| 135 |
+
(r"\alpha'_{\beta''}", Symbol("alpha'_{beta''}")),
|
| 136 |
+
(r"\alpha''_\beta", Symbol("alpha''_{beta}")),
|
| 137 |
+
(r"\alpha''_{\beta}", Symbol("alpha''_{beta}")),
|
| 138 |
+
(r"\alpha''_{\beta'}", Symbol("alpha''_{beta'}")),
|
| 139 |
+
(r"\alpha''_{\beta''}", Symbol("alpha''_{beta''}")),
|
| 140 |
+
(r"\alpha_\beta'", Symbol("alpha_{beta}'")),
|
| 141 |
+
(r"\alpha_{\beta}'", Symbol("alpha_{beta}'")),
|
| 142 |
+
(r"\alpha_{\beta'}'", Symbol("alpha_{beta'}'")),
|
| 143 |
+
(r"\alpha_{\beta''}'", Symbol("alpha_{beta''}'")),
|
| 144 |
+
(r"\alpha'_\beta'", Symbol("alpha'_{beta}'")),
|
| 145 |
+
(r"\alpha'_{\beta}'", Symbol("alpha'_{beta}'")),
|
| 146 |
+
(r"\alpha'_{\beta'}'", Symbol("alpha'_{beta'}'")),
|
| 147 |
+
(r"\alpha'_{\beta''}'", Symbol("alpha'_{beta''}'")),
|
| 148 |
+
(r"\alpha''_\beta'", Symbol("alpha''_{beta}'")),
|
| 149 |
+
(r"\alpha''_{\beta}'", Symbol("alpha''_{beta}'")),
|
| 150 |
+
(r"\alpha''_{\beta'}'", Symbol("alpha''_{beta'}'")),
|
| 151 |
+
(r"\alpha''_{\beta''}'", Symbol("alpha''_{beta''}'")),
|
| 152 |
+
(r"\alpha_\beta''", Symbol("alpha_{beta}''")),
|
| 153 |
+
(r"\alpha_{\beta}''", Symbol("alpha_{beta}''")),
|
| 154 |
+
(r"\alpha_{\beta'}''", Symbol("alpha_{beta'}''")),
|
| 155 |
+
(r"\alpha_{\beta''}''", Symbol("alpha_{beta''}''")),
|
| 156 |
+
(r"\alpha'_\beta''", Symbol("alpha'_{beta}''")),
|
| 157 |
+
(r"\alpha'_{\beta}''", Symbol("alpha'_{beta}''")),
|
| 158 |
+
(r"\alpha'_{\beta'}''", Symbol("alpha'_{beta'}''")),
|
| 159 |
+
(r"\alpha'_{\beta''}''", Symbol("alpha'_{beta''}''")),
|
| 160 |
+
(r"\alpha''_\beta''", Symbol("alpha''_{beta}''")),
|
| 161 |
+
(r"\alpha''_{\beta}''", Symbol("alpha''_{beta}''")),
|
| 162 |
+
(r"\alpha''_{\beta'}''", Symbol("alpha''_{beta'}''")),
|
| 163 |
+
(r"\alpha''_{\beta''}''", Symbol("alpha''_{beta''}''"))
|
| 164 |
+
|
| 165 |
+
]
|
| 166 |
+
|
| 167 |
+
UNEVALUATED_SIMPLE_EXPRESSION_PAIRS = [
|
| 168 |
+
(r"0", 0),
|
| 169 |
+
(r"1", 1),
|
| 170 |
+
(r"-3.14", -3.14),
|
| 171 |
+
(r"(-7.13)(1.5)", _Mul(-7.13, 1.5)),
|
| 172 |
+
(r"1+1", _Add(1, 1)),
|
| 173 |
+
(r"0+1", _Add(0, 1)),
|
| 174 |
+
(r"1*2", _Mul(1, 2)),
|
| 175 |
+
(r"0*1", _Mul(0, 1)),
|
| 176 |
+
(r"x", x),
|
| 177 |
+
(r"2x", 2 * x),
|
| 178 |
+
(r"3x - 1", _Add(_Mul(3, x), -1)),
|
| 179 |
+
(r"-c", -c),
|
| 180 |
+
(r"\infty", oo),
|
| 181 |
+
(r"a \cdot b", a * b),
|
| 182 |
+
(r"1 \times 2 ", _Mul(1, 2)),
|
| 183 |
+
(r"a / b", a / b),
|
| 184 |
+
(r"a \div b", a / b),
|
| 185 |
+
(r"a + b", a + b),
|
| 186 |
+
(r"a + b - a", _Add(a + b, -a)),
|
| 187 |
+
(r"(x + y) z", _Mul(_Add(x, y), z)),
|
| 188 |
+
(r"a'b+ab'", _Add(_Mul(Symbol("a'"), b), _Mul(a, Symbol("b'"))))
|
| 189 |
+
]
|
| 190 |
+
|
| 191 |
+
EVALUATED_SIMPLE_EXPRESSION_PAIRS = [
|
| 192 |
+
(r"(-7.13)(1.5)", -10.695),
|
| 193 |
+
(r"1+1", 2),
|
| 194 |
+
(r"0+1", 1),
|
| 195 |
+
(r"1*2", 2),
|
| 196 |
+
(r"0*1", 0),
|
| 197 |
+
(r"2x", 2 * x),
|
| 198 |
+
(r"3x - 1", 3 * x - 1),
|
| 199 |
+
(r"-c", -c),
|
| 200 |
+
(r"a \cdot b", a * b),
|
| 201 |
+
(r"1 \times 2 ", 2),
|
| 202 |
+
(r"a / b", a / b),
|
| 203 |
+
(r"a \div b", a / b),
|
| 204 |
+
(r"a + b", a + b),
|
| 205 |
+
(r"a + b - a", b),
|
| 206 |
+
(r"(x + y) z", (x + y) * z),
|
| 207 |
+
]
|
| 208 |
+
|
| 209 |
+
UNEVALUATED_FRACTION_EXPRESSION_PAIRS = [
|
| 210 |
+
(r"\frac{a}{b}", a / b),
|
| 211 |
+
(r"\dfrac{a}{b}", a / b),
|
| 212 |
+
(r"\tfrac{a}{b}", a / b),
|
| 213 |
+
(r"\frac12", _Mul(1, _Pow(2, -1))),
|
| 214 |
+
(r"\frac12y", _Mul(_Mul(1, _Pow(2, -1)), y)),
|
| 215 |
+
(r"\frac1234", _Mul(_Mul(1, _Pow(2, -1)), 34)),
|
| 216 |
+
(r"\frac2{3}", _Mul(2, _Pow(3, -1))),
|
| 217 |
+
(r"\frac{a + b}{c}", _Mul(a + b, _Pow(c, -1))),
|
| 218 |
+
(r"\frac{7}{3}", _Mul(7, _Pow(3, -1)))
|
| 219 |
+
]
|
| 220 |
+
|
| 221 |
+
EVALUATED_FRACTION_EXPRESSION_PAIRS = [
|
| 222 |
+
(r"\frac{a}{b}", a / b),
|
| 223 |
+
(r"\dfrac{a}{b}", a / b),
|
| 224 |
+
(r"\tfrac{a}{b}", a / b),
|
| 225 |
+
(r"\frac12", Rational(1, 2)),
|
| 226 |
+
(r"\frac12y", y / 2),
|
| 227 |
+
(r"\frac1234", 17),
|
| 228 |
+
(r"\frac2{3}", Rational(2, 3)),
|
| 229 |
+
(r"\frac{a + b}{c}", (a + b) / c),
|
| 230 |
+
(r"\frac{7}{3}", Rational(7, 3))
|
| 231 |
+
]
|
| 232 |
+
|
| 233 |
+
RELATION_EXPRESSION_PAIRS = [
|
| 234 |
+
(r"x = y", Eq(x, y)),
|
| 235 |
+
(r"x \neq y", Ne(x, y)),
|
| 236 |
+
(r"x < y", Lt(x, y)),
|
| 237 |
+
(r"x > y", Gt(x, y)),
|
| 238 |
+
(r"x \leq y", Le(x, y)),
|
| 239 |
+
(r"x \geq y", Ge(x, y)),
|
| 240 |
+
(r"x \le y", Le(x, y)),
|
| 241 |
+
(r"x \ge y", Ge(x, y)),
|
| 242 |
+
(r"x < y", StrictLessThan(x, y)),
|
| 243 |
+
(r"x \leq y", LessThan(x, y)),
|
| 244 |
+
(r"x > y", StrictGreaterThan(x, y)),
|
| 245 |
+
(r"x \geq y", GreaterThan(x, y)),
|
| 246 |
+
(r"x \neq y", Unequality(x, y)), # same as 2nd one in the list
|
| 247 |
+
(r"a^2 + b^2 = c^2", Eq(a**2 + b**2, c**2))
|
| 248 |
+
]
|
| 249 |
+
|
| 250 |
+
UNEVALUATED_POWER_EXPRESSION_PAIRS = [
|
| 251 |
+
(r"x^2", x ** 2),
|
| 252 |
+
(r"x^\frac{1}{2}", _Pow(x, _Mul(1, _Pow(2, -1)))),
|
| 253 |
+
(r"x^{3 + 1}", x ** _Add(3, 1)),
|
| 254 |
+
(r"\pi^{|xy|}", Symbol('pi') ** _Abs(x * y)),
|
| 255 |
+
(r"5^0 - 4^0", _Add(_Pow(5, 0), _Mul(-1, _Pow(4, 0))))
|
| 256 |
+
]
|
| 257 |
+
|
| 258 |
+
EVALUATED_POWER_EXPRESSION_PAIRS = [
|
| 259 |
+
(r"x^2", x ** 2),
|
| 260 |
+
(r"x^\frac{1}{2}", sqrt(x)),
|
| 261 |
+
(r"x^{3 + 1}", x ** 4),
|
| 262 |
+
(r"\pi^{|xy|}", Symbol('pi') ** _Abs(x * y)),
|
| 263 |
+
(r"5^0 - 4^0", 0)
|
| 264 |
+
]
|
| 265 |
+
|
| 266 |
+
UNEVALUATED_INTEGRAL_EXPRESSION_PAIRS = [
|
| 267 |
+
(r"\int x dx", Integral(_Mul(1, x), x)),
|
| 268 |
+
(r"\int x \, dx", Integral(_Mul(1, x), x)),
|
| 269 |
+
(r"\int x d\theta", Integral(_Mul(1, x), theta)),
|
| 270 |
+
(r"\int (x^2 - y)dx", Integral(_Mul(1, x ** 2 - y), x)),
|
| 271 |
+
(r"\int x + a dx", Integral(_Mul(1, _Add(x, a)), x)),
|
| 272 |
+
(r"\int da", Integral(_Mul(1, 1), a)),
|
| 273 |
+
(r"\int_0^7 dx", Integral(_Mul(1, 1), (x, 0, 7))),
|
| 274 |
+
(r"\int\limits_{0}^{1} x dx", Integral(_Mul(1, x), (x, 0, 1))),
|
| 275 |
+
(r"\int_a^b x dx", Integral(_Mul(1, x), (x, a, b))),
|
| 276 |
+
(r"\int^b_a x dx", Integral(_Mul(1, x), (x, a, b))),
|
| 277 |
+
(r"\int_{a}^b x dx", Integral(_Mul(1, x), (x, a, b))),
|
| 278 |
+
(r"\int^{b}_a x dx", Integral(_Mul(1, x), (x, a, b))),
|
| 279 |
+
(r"\int_{a}^{b} x dx", Integral(_Mul(1, x), (x, a, b))),
|
| 280 |
+
(r"\int^{b}_{a} x dx", Integral(_Mul(1, x), (x, a, b))),
|
| 281 |
+
(r"\int_{f(a)}^{f(b)} f(z) dz", Integral(f(z), (z, f(a), f(b)))),
|
| 282 |
+
(r"\int a + b + c dx", Integral(_Mul(1, _Add(_Add(a, b), c)), x)),
|
| 283 |
+
(r"\int \frac{dz}{z}", Integral(_Mul(1, _Mul(1, Pow(z, -1))), z)),
|
| 284 |
+
(r"\int \frac{3 dz}{z}", Integral(_Mul(1, _Mul(3, _Pow(z, -1))), z)),
|
| 285 |
+
(r"\int \frac{1}{x} dx", Integral(_Mul(1, _Mul(1, Pow(x, -1))), x)),
|
| 286 |
+
(r"\int \frac{1}{a} + \frac{1}{b} dx",
|
| 287 |
+
Integral(_Mul(1, _Add(_Mul(1, _Pow(a, -1)), _Mul(1, Pow(b, -1)))), x)),
|
| 288 |
+
(r"\int \frac{1}{x} + 1 dx", Integral(_Mul(1, _Add(_Mul(1, _Pow(x, -1)), 1)), x))
|
| 289 |
+
]
|
| 290 |
+
|
| 291 |
+
EVALUATED_INTEGRAL_EXPRESSION_PAIRS = [
|
| 292 |
+
(r"\int x dx", Integral(x, x)),
|
| 293 |
+
(r"\int x \, dx", Integral(x, x)),
|
| 294 |
+
(r"\int x d\theta", Integral(x, theta)),
|
| 295 |
+
(r"\int (x^2 - y)dx", Integral(x ** 2 - y, x)),
|
| 296 |
+
(r"\int x + a dx", Integral(x + a, x)),
|
| 297 |
+
(r"\int da", Integral(1, a)),
|
| 298 |
+
(r"\int_0^7 dx", Integral(1, (x, 0, 7))),
|
| 299 |
+
(r"\int\limits_{0}^{1} x dx", Integral(x, (x, 0, 1))),
|
| 300 |
+
(r"\int_a^b x dx", Integral(x, (x, a, b))),
|
| 301 |
+
(r"\int^b_a x dx", Integral(x, (x, a, b))),
|
| 302 |
+
(r"\int_{a}^b x dx", Integral(x, (x, a, b))),
|
| 303 |
+
(r"\int^{b}_a x dx", Integral(x, (x, a, b))),
|
| 304 |
+
(r"\int_{a}^{b} x dx", Integral(x, (x, a, b))),
|
| 305 |
+
(r"\int^{b}_{a} x dx", Integral(x, (x, a, b))),
|
| 306 |
+
(r"\int_{f(a)}^{f(b)} f(z) dz", Integral(f(z), (z, f(a), f(b)))),
|
| 307 |
+
(r"\int a + b + c dx", Integral(a + b + c, x)),
|
| 308 |
+
(r"\int \frac{dz}{z}", Integral(Pow(z, -1), z)),
|
| 309 |
+
(r"\int \frac{3 dz}{z}", Integral(3 * Pow(z, -1), z)),
|
| 310 |
+
(r"\int \frac{1}{x} dx", Integral(1 / x, x)),
|
| 311 |
+
(r"\int \frac{1}{a} + \frac{1}{b} dx", Integral(1 / a + 1 / b, x)),
|
| 312 |
+
(r"\int \frac{1}{a} - \frac{1}{b} dx", Integral(1 / a - 1 / b, x)),
|
| 313 |
+
(r"\int \frac{1}{x} + 1 dx", Integral(1 / x + 1, x))
|
| 314 |
+
]
|
| 315 |
+
|
| 316 |
+
DERIVATIVE_EXPRESSION_PAIRS = [
|
| 317 |
+
(r"\frac{d}{dx} x", Derivative(x, x)),
|
| 318 |
+
(r"\frac{d}{dt} x", Derivative(x, t)),
|
| 319 |
+
(r"\frac{d}{dx} ( \tan x )", Derivative(tan(x), x)),
|
| 320 |
+
(r"\frac{d f(x)}{dx}", Derivative(f(x), x)),
|
| 321 |
+
(r"\frac{d\theta(x)}{dx}", Derivative(Function('theta')(x), x))
|
| 322 |
+
]
|
| 323 |
+
|
| 324 |
+
TRIGONOMETRIC_EXPRESSION_PAIRS = [
|
| 325 |
+
(r"\sin \theta", sin(theta)),
|
| 326 |
+
(r"\sin(\theta)", sin(theta)),
|
| 327 |
+
(r"\sin^{-1} a", asin(a)),
|
| 328 |
+
(r"\sin a \cos b", _Mul(sin(a), cos(b))),
|
| 329 |
+
(r"\sin \cos \theta", sin(cos(theta))),
|
| 330 |
+
(r"\sin(\cos \theta)", sin(cos(theta))),
|
| 331 |
+
(r"(\csc x)(\sec y)", csc(x) * sec(y)),
|
| 332 |
+
(r"\frac{\sin{x}}2", _Mul(sin(x), _Pow(2, -1)))
|
| 333 |
+
]
|
| 334 |
+
|
| 335 |
+
UNEVALUATED_LIMIT_EXPRESSION_PAIRS = [
|
| 336 |
+
(r"\lim_{x \to 3} a", Limit(a, x, 3, dir="+-")),
|
| 337 |
+
(r"\lim_{x \rightarrow 3} a", Limit(a, x, 3, dir="+-")),
|
| 338 |
+
(r"\lim_{x \Rightarrow 3} a", Limit(a, x, 3, dir="+-")),
|
| 339 |
+
(r"\lim_{x \longrightarrow 3} a", Limit(a, x, 3, dir="+-")),
|
| 340 |
+
(r"\lim_{x \Longrightarrow 3} a", Limit(a, x, 3, dir="+-")),
|
| 341 |
+
(r"\lim_{x \to 3^{+}} a", Limit(a, x, 3, dir="+")),
|
| 342 |
+
(r"\lim_{x \to 3^{-}} a", Limit(a, x, 3, dir="-")),
|
| 343 |
+
(r"\lim_{x \to 3^+} a", Limit(a, x, 3, dir="+")),
|
| 344 |
+
(r"\lim_{x \to 3^-} a", Limit(a, x, 3, dir="-")),
|
| 345 |
+
(r"\lim_{x \to \infty} \frac{1}{x}", Limit(_Mul(1, _Pow(x, -1)), x, oo))
|
| 346 |
+
]
|
| 347 |
+
|
| 348 |
+
EVALUATED_LIMIT_EXPRESSION_PAIRS = [
|
| 349 |
+
(r"\lim_{x \to \infty} \frac{1}{x}", Limit(1 / x, x, oo))
|
| 350 |
+
]
|
| 351 |
+
|
| 352 |
+
UNEVALUATED_SQRT_EXPRESSION_PAIRS = [
|
| 353 |
+
(r"\sqrt{x}", sqrt(x)),
|
| 354 |
+
(r"\sqrt{x + b}", sqrt(_Add(x, b))),
|
| 355 |
+
(r"\sqrt[3]{\sin x}", _Pow(sin(x), _Pow(3, -1))),
|
| 356 |
+
# the above test needed to be handled differently than the ones below because root
|
| 357 |
+
# acts differently if its second argument is a number
|
| 358 |
+
(r"\sqrt[y]{\sin x}", root(sin(x), y)),
|
| 359 |
+
(r"\sqrt[\theta]{\sin x}", root(sin(x), theta)),
|
| 360 |
+
(r"\sqrt{\frac{12}{6}}", _Sqrt(_Mul(12, _Pow(6, -1))))
|
| 361 |
+
]
|
| 362 |
+
|
| 363 |
+
EVALUATED_SQRT_EXPRESSION_PAIRS = [
|
| 364 |
+
(r"\sqrt{x}", sqrt(x)),
|
| 365 |
+
(r"\sqrt{x + b}", sqrt(x + b)),
|
| 366 |
+
(r"\sqrt[3]{\sin x}", root(sin(x), 3)),
|
| 367 |
+
(r"\sqrt[y]{\sin x}", root(sin(x), y)),
|
| 368 |
+
(r"\sqrt[\theta]{\sin x}", root(sin(x), theta)),
|
| 369 |
+
(r"\sqrt{\frac{12}{6}}", sqrt(2))
|
| 370 |
+
]
|
| 371 |
+
|
| 372 |
+
UNEVALUATED_FACTORIAL_EXPRESSION_PAIRS = [
|
| 373 |
+
(r"x!", _factorial(x)),
|
| 374 |
+
(r"100!", _factorial(100)),
|
| 375 |
+
(r"\theta!", _factorial(theta)),
|
| 376 |
+
(r"(x + 1)!", _factorial(_Add(x, 1))),
|
| 377 |
+
(r"(x!)!", _factorial(_factorial(x))),
|
| 378 |
+
(r"x!!!", _factorial(_factorial(_factorial(x)))),
|
| 379 |
+
(r"5!7!", _Mul(_factorial(5), _factorial(7)))
|
| 380 |
+
]
|
| 381 |
+
|
| 382 |
+
EVALUATED_FACTORIAL_EXPRESSION_PAIRS = [
|
| 383 |
+
(r"x!", factorial(x)),
|
| 384 |
+
(r"100!", factorial(100)),
|
| 385 |
+
(r"\theta!", factorial(theta)),
|
| 386 |
+
(r"(x + 1)!", factorial(x + 1)),
|
| 387 |
+
(r"(x!)!", factorial(factorial(x))),
|
| 388 |
+
(r"x!!!", factorial(factorial(factorial(x)))),
|
| 389 |
+
(r"5!7!", factorial(5) * factorial(7)),
|
| 390 |
+
(r"24! \times 24!", factorial(24) * factorial(24))
|
| 391 |
+
]
|
| 392 |
+
|
| 393 |
+
UNEVALUATED_SUM_EXPRESSION_PAIRS = [
|
| 394 |
+
(r"\sum_{k = 1}^{3} c", Sum(_Mul(1, c), (k, 1, 3))),
|
| 395 |
+
(r"\sum_{k = 1}^3 c", Sum(_Mul(1, c), (k, 1, 3))),
|
| 396 |
+
(r"\sum^{3}_{k = 1} c", Sum(_Mul(1, c), (k, 1, 3))),
|
| 397 |
+
(r"\sum^3_{k = 1} c", Sum(_Mul(1, c), (k, 1, 3))),
|
| 398 |
+
(r"\sum_{k = 1}^{10} k^2", Sum(_Mul(1, k ** 2), (k, 1, 10))),
|
| 399 |
+
(r"\sum_{n = 0}^{\infty} \frac{1}{n!}",
|
| 400 |
+
Sum(_Mul(1, _Mul(1, _Pow(_factorial(n), -1))), (n, 0, oo)))
|
| 401 |
+
]
|
| 402 |
+
|
| 403 |
+
EVALUATED_SUM_EXPRESSION_PAIRS = [
|
| 404 |
+
(r"\sum_{k = 1}^{3} c", Sum(c, (k, 1, 3))),
|
| 405 |
+
(r"\sum_{k = 1}^3 c", Sum(c, (k, 1, 3))),
|
| 406 |
+
(r"\sum^{3}_{k = 1} c", Sum(c, (k, 1, 3))),
|
| 407 |
+
(r"\sum^3_{k = 1} c", Sum(c, (k, 1, 3))),
|
| 408 |
+
(r"\sum_{k = 1}^{10} k^2", Sum(k ** 2, (k, 1, 10))),
|
| 409 |
+
(r"\sum_{n = 0}^{\infty} \frac{1}{n!}", Sum(1 / factorial(n), (n, 0, oo)))
|
| 410 |
+
]
|
| 411 |
+
|
| 412 |
+
UNEVALUATED_PRODUCT_EXPRESSION_PAIRS = [
|
| 413 |
+
(r"\prod_{a = b}^{c} x", Product(x, (a, b, c))),
|
| 414 |
+
(r"\prod_{a = b}^c x", Product(x, (a, b, c))),
|
| 415 |
+
(r"\prod^{c}_{a = b} x", Product(x, (a, b, c))),
|
| 416 |
+
(r"\prod^c_{a = b} x", Product(x, (a, b, c)))
|
| 417 |
+
]
|
| 418 |
+
|
| 419 |
+
APPLIED_FUNCTION_EXPRESSION_PAIRS = [
|
| 420 |
+
(r"f(x)", f(x)),
|
| 421 |
+
(r"f(x, y)", f(x, y)),
|
| 422 |
+
(r"f(x, y, z)", f(x, y, z)),
|
| 423 |
+
(r"f'_1(x)", Function("f_{1}'")(x)),
|
| 424 |
+
(r"f_{1}''(x+y)", Function("f_{1}''")(x + y)),
|
| 425 |
+
(r"h_{\theta}(x_0, x_1)",
|
| 426 |
+
Function('h_{theta}')(Symbol('x_{0}'), Symbol('x_{1}')))
|
| 427 |
+
]
|
| 428 |
+
|
| 429 |
+
UNEVALUATED_COMMON_FUNCTION_EXPRESSION_PAIRS = [
|
| 430 |
+
(r"|x|", _Abs(x)),
|
| 431 |
+
(r"||x||", _Abs(Abs(x))),
|
| 432 |
+
(r"|x||y|", _Abs(x) * _Abs(y)),
|
| 433 |
+
(r"||x||y||", _Abs(_Abs(x) * _Abs(y))),
|
| 434 |
+
(r"\lfloor x \rfloor", floor(x)),
|
| 435 |
+
(r"\lceil x \rceil", ceiling(x)),
|
| 436 |
+
(r"\exp x", _exp(x)),
|
| 437 |
+
(r"\exp(x)", _exp(x)),
|
| 438 |
+
(r"\lg x", _log(x, 10)),
|
| 439 |
+
(r"\ln x", _log(x)),
|
| 440 |
+
(r"\ln xy", _log(x * y)),
|
| 441 |
+
(r"\log x", _log(x)),
|
| 442 |
+
(r"\log xy", _log(x * y)),
|
| 443 |
+
(r"\log_{2} x", _log(x, 2)),
|
| 444 |
+
(r"\log_{a} x", _log(x, a)),
|
| 445 |
+
(r"\log_{11} x", _log(x, 11)),
|
| 446 |
+
(r"\log_{a^2} x", _log(x, _Pow(a, 2))),
|
| 447 |
+
(r"\log_2 x", _log(x, 2)),
|
| 448 |
+
(r"\log_a x", _log(x, a)),
|
| 449 |
+
(r"\overline{z}", _Conjugate(z)),
|
| 450 |
+
(r"\overline{\overline{z}}", _Conjugate(_Conjugate(z))),
|
| 451 |
+
(r"\overline{x + y}", _Conjugate(_Add(x, y))),
|
| 452 |
+
(r"\overline{x} + \overline{y}", _Conjugate(x) + _Conjugate(y)),
|
| 453 |
+
(r"\min(a, b)", _Min(a, b)),
|
| 454 |
+
(r"\min(a, b, c - d, xy)", _Min(a, b, c - d, x * y)),
|
| 455 |
+
(r"\max(a, b)", _Max(a, b)),
|
| 456 |
+
(r"\max(a, b, c - d, xy)", _Max(a, b, c - d, x * y)),
|
| 457 |
+
# physics things don't have an `evaluate=False` variant
|
| 458 |
+
(r"\langle x |", Bra('x')),
|
| 459 |
+
(r"| x \rangle", Ket('x')),
|
| 460 |
+
(r"\langle x | y \rangle", InnerProduct(Bra('x'), Ket('y'))),
|
| 461 |
+
]
|
| 462 |
+
|
| 463 |
+
EVALUATED_COMMON_FUNCTION_EXPRESSION_PAIRS = [
|
| 464 |
+
(r"|x|", Abs(x)),
|
| 465 |
+
(r"||x||", Abs(Abs(x))),
|
| 466 |
+
(r"|x||y|", Abs(x) * Abs(y)),
|
| 467 |
+
(r"||x||y||", Abs(Abs(x) * Abs(y))),
|
| 468 |
+
(r"\lfloor x \rfloor", floor(x)),
|
| 469 |
+
(r"\lceil x \rceil", ceiling(x)),
|
| 470 |
+
(r"\exp x", exp(x)),
|
| 471 |
+
(r"\exp(x)", exp(x)),
|
| 472 |
+
(r"\lg x", log(x, 10)),
|
| 473 |
+
(r"\ln x", log(x)),
|
| 474 |
+
(r"\ln xy", log(x * y)),
|
| 475 |
+
(r"\log x", log(x)),
|
| 476 |
+
(r"\log xy", log(x * y)),
|
| 477 |
+
(r"\log_{2} x", log(x, 2)),
|
| 478 |
+
(r"\log_{a} x", log(x, a)),
|
| 479 |
+
(r"\log_{11} x", log(x, 11)),
|
| 480 |
+
(r"\log_{a^2} x", log(x, _Pow(a, 2))),
|
| 481 |
+
(r"\log_2 x", log(x, 2)),
|
| 482 |
+
(r"\log_a x", log(x, a)),
|
| 483 |
+
(r"\overline{z}", conjugate(z)),
|
| 484 |
+
(r"\overline{\overline{z}}", conjugate(conjugate(z))),
|
| 485 |
+
(r"\overline{x + y}", conjugate(x + y)),
|
| 486 |
+
(r"\overline{x} + \overline{y}", conjugate(x) + conjugate(y)),
|
| 487 |
+
(r"\min(a, b)", Min(a, b)),
|
| 488 |
+
(r"\min(a, b, c - d, xy)", Min(a, b, c - d, x * y)),
|
| 489 |
+
(r"\max(a, b)", Max(a, b)),
|
| 490 |
+
(r"\max(a, b, c - d, xy)", Max(a, b, c - d, x * y)),
|
| 491 |
+
(r"\langle x |", Bra('x')),
|
| 492 |
+
(r"| x \rangle", Ket('x')),
|
| 493 |
+
(r"\langle x | y \rangle", InnerProduct(Bra('x'), Ket('y'))),
|
| 494 |
+
]
|
| 495 |
+
|
| 496 |
+
SPACING_RELATED_EXPRESSION_PAIRS = [
|
| 497 |
+
(r"a \, b", _Mul(a, b)),
|
| 498 |
+
(r"a \thinspace b", _Mul(a, b)),
|
| 499 |
+
(r"a \: b", _Mul(a, b)),
|
| 500 |
+
(r"a \medspace b", _Mul(a, b)),
|
| 501 |
+
(r"a \; b", _Mul(a, b)),
|
| 502 |
+
(r"a \thickspace b", _Mul(a, b)),
|
| 503 |
+
(r"a \quad b", _Mul(a, b)),
|
| 504 |
+
(r"a \qquad b", _Mul(a, b)),
|
| 505 |
+
(r"a \! b", _Mul(a, b)),
|
| 506 |
+
(r"a \negthinspace b", _Mul(a, b)),
|
| 507 |
+
(r"a \negmedspace b", _Mul(a, b)),
|
| 508 |
+
(r"a \negthickspace b", _Mul(a, b))
|
| 509 |
+
]
|
| 510 |
+
|
| 511 |
+
UNEVALUATED_BINOMIAL_EXPRESSION_PAIRS = [
|
| 512 |
+
(r"\binom{n}{k}", _binomial(n, k)),
|
| 513 |
+
(r"\tbinom{n}{k}", _binomial(n, k)),
|
| 514 |
+
(r"\dbinom{n}{k}", _binomial(n, k)),
|
| 515 |
+
(r"\binom{n}{0}", _binomial(n, 0)),
|
| 516 |
+
(r"x^\binom{n}{k}", _Pow(x, _binomial(n, k)))
|
| 517 |
+
]
|
| 518 |
+
|
| 519 |
+
EVALUATED_BINOMIAL_EXPRESSION_PAIRS = [
|
| 520 |
+
(r"\binom{n}{k}", binomial(n, k)),
|
| 521 |
+
(r"\tbinom{n}{k}", binomial(n, k)),
|
| 522 |
+
(r"\dbinom{n}{k}", binomial(n, k)),
|
| 523 |
+
(r"\binom{n}{0}", binomial(n, 0)),
|
| 524 |
+
(r"x^\binom{n}{k}", x ** binomial(n, k))
|
| 525 |
+
]
|
| 526 |
+
|
| 527 |
+
MISCELLANEOUS_EXPRESSION_PAIRS = [
|
| 528 |
+
(r"\left(x + y\right) z", _Mul(_Add(x, y), z)),
|
| 529 |
+
(r"\left( x + y\right ) z", _Mul(_Add(x, y), z)),
|
| 530 |
+
(r"\left( x + y\right ) z", _Mul(_Add(x, y), z)),
|
| 531 |
+
]
|
| 532 |
+
|
| 533 |
+
UNEVALUATED_LITERAL_COMPLEX_NUMBER_EXPRESSION_PAIRS = [
|
| 534 |
+
(r"\imaginaryunit^2", _Pow(I, 2)),
|
| 535 |
+
(r"|\imaginaryunit|", _Abs(I)),
|
| 536 |
+
(r"\overline{\imaginaryunit}", _Conjugate(I)),
|
| 537 |
+
(r"\imaginaryunit+\imaginaryunit", _Add(I, I)),
|
| 538 |
+
(r"\imaginaryunit-\imaginaryunit", _Add(I, -I)),
|
| 539 |
+
(r"\imaginaryunit*\imaginaryunit", _Mul(I, I)),
|
| 540 |
+
(r"\imaginaryunit/\imaginaryunit", _Mul(I, _Pow(I, -1))),
|
| 541 |
+
(r"(1+\imaginaryunit)/|1+\imaginaryunit|", _Mul(_Add(1, I), _Pow(_Abs(_Add(1, I)), -1)))
|
| 542 |
+
]
|
| 543 |
+
|
| 544 |
+
UNEVALUATED_MATRIX_EXPRESSION_PAIRS = [
|
| 545 |
+
(r"\begin{pmatrix}a & b \\x & y\end{pmatrix}",
|
| 546 |
+
Matrix([[a, b], [x, y]])),
|
| 547 |
+
(r"\begin{pmatrix}a & b \\x & y\\\end{pmatrix}",
|
| 548 |
+
Matrix([[a, b], [x, y]])),
|
| 549 |
+
(r"\begin{bmatrix}a & b \\x & y\end{bmatrix}",
|
| 550 |
+
Matrix([[a, b], [x, y]])),
|
| 551 |
+
(r"\left(\begin{matrix}a & b \\x & y\end{matrix}\right)",
|
| 552 |
+
Matrix([[a, b], [x, y]])),
|
| 553 |
+
(r"\left[\begin{matrix}a & b \\x & y\end{matrix}\right]",
|
| 554 |
+
Matrix([[a, b], [x, y]])),
|
| 555 |
+
(r"\left[\begin{array}{cc}a & b \\x & y\end{array}\right]",
|
| 556 |
+
Matrix([[a, b], [x, y]])),
|
| 557 |
+
(r"\left(\begin{array}{cc}a & b \\x & y\end{array}\right)",
|
| 558 |
+
Matrix([[a, b], [x, y]])),
|
| 559 |
+
(r"\left( { \begin{array}{cc}a & b \\x & y\end{array} } \right)",
|
| 560 |
+
Matrix([[a, b], [x, y]])),
|
| 561 |
+
(r"+\begin{pmatrix}a & b \\x & y\end{pmatrix}",
|
| 562 |
+
Matrix([[a, b], [x, y]])),
|
| 563 |
+
((r"\begin{pmatrix}x & y \\a & b\end{pmatrix}+"
|
| 564 |
+
r"\begin{pmatrix}a & b \\x & y\end{pmatrix}"),
|
| 565 |
+
_MatAdd(Matrix([[x, y], [a, b]]), Matrix([[a, b], [x, y]]))),
|
| 566 |
+
(r"-\begin{pmatrix}a & b \\x & y\end{pmatrix}",
|
| 567 |
+
_MatMul(-1, Matrix([[a, b], [x, y]]))),
|
| 568 |
+
((r"\begin{pmatrix}x & y \\a & b\end{pmatrix}-"
|
| 569 |
+
r"\begin{pmatrix}a & b \\x & y\end{pmatrix}"),
|
| 570 |
+
_MatAdd(Matrix([[x, y], [a, b]]), _MatMul(-1, Matrix([[a, b], [x, y]])))),
|
| 571 |
+
((r"\begin{pmatrix}a & b & c \\x & y & z \\a & b & c \end{pmatrix}*"
|
| 572 |
+
r"\begin{pmatrix}x & y & z \\a & b & c \\a & b & c \end{pmatrix}*"
|
| 573 |
+
r"\begin{pmatrix}a & b & c \\x & y & z \\x & y & z \end{pmatrix}"),
|
| 574 |
+
_MatMul(_MatMul(Matrix([[a, b, c], [x, y, z], [a, b, c]]),
|
| 575 |
+
Matrix([[x, y, z], [a, b, c], [a, b, c]])),
|
| 576 |
+
Matrix([[a, b, c], [x, y, z], [x, y, z]]))),
|
| 577 |
+
(r"\begin{pmatrix}a & b \\x & y\end{pmatrix}/2",
|
| 578 |
+
_MatMul(Matrix([[a, b], [x, y]]), _Pow(2, -1))),
|
| 579 |
+
(r"\begin{pmatrix}a & b \\x & y\end{pmatrix}^2",
|
| 580 |
+
_Pow(Matrix([[a, b], [x, y]]), 2)),
|
| 581 |
+
(r"\begin{pmatrix}a & b \\x & y\end{pmatrix}^{-1}",
|
| 582 |
+
_Pow(Matrix([[a, b], [x, y]]), -1)),
|
| 583 |
+
(r"\begin{pmatrix}a & b \\x & y\end{pmatrix}^T",
|
| 584 |
+
Transpose(Matrix([[a, b], [x, y]]))),
|
| 585 |
+
(r"\begin{pmatrix}a & b \\x & y\end{pmatrix}^{T}",
|
| 586 |
+
Transpose(Matrix([[a, b], [x, y]]))),
|
| 587 |
+
(r"\begin{pmatrix}a & b \\x & y\end{pmatrix}^\mathit{T}",
|
| 588 |
+
Transpose(Matrix([[a, b], [x, y]]))),
|
| 589 |
+
(r"\begin{pmatrix}1 & 2 \\3 & 4\end{pmatrix}^T",
|
| 590 |
+
Transpose(Matrix([[1, 2], [3, 4]]))),
|
| 591 |
+
((r"(\begin{pmatrix}1 & 2 \\3 & 4\end{pmatrix}+"
|
| 592 |
+
r"\begin{pmatrix}1 & 2 \\3 & 4\end{pmatrix}^T)*"
|
| 593 |
+
r"\begin{bmatrix}1\\0\end{bmatrix}"),
|
| 594 |
+
_MatMul(_MatAdd(Matrix([[1, 2], [3, 4]]),
|
| 595 |
+
Transpose(Matrix([[1, 2], [3, 4]]))),
|
| 596 |
+
Matrix([[1], [0]]))),
|
| 597 |
+
((r"(\begin{pmatrix}a & b \\x & y\end{pmatrix}+"
|
| 598 |
+
r"\begin{pmatrix}x & y \\a & b\end{pmatrix})^2"),
|
| 599 |
+
_Pow(_MatAdd(Matrix([[a, b], [x, y]]),
|
| 600 |
+
Matrix([[x, y], [a, b]])), 2)),
|
| 601 |
+
((r"(\begin{pmatrix}a & b \\x & y\end{pmatrix}+"
|
| 602 |
+
r"\begin{pmatrix}x & y \\a & b\end{pmatrix})^T"),
|
| 603 |
+
Transpose(_MatAdd(Matrix([[a, b], [x, y]]),
|
| 604 |
+
Matrix([[x, y], [a, b]])))),
|
| 605 |
+
(r"\overline{\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}}",
|
| 606 |
+
_Conjugate(_MatAdd(Matrix([[I, 2], [3, 4]]),
|
| 607 |
+
Matrix([[I, 2], [3, 4]]))))
|
| 608 |
+
]
|
| 609 |
+
|
| 610 |
+
EVALUATED_MATRIX_EXPRESSION_PAIRS = [
|
| 611 |
+
(r"\det\left(\left[ { \begin{array}{cc}a&b\\x&y\end{array} } \right]\right)",
|
| 612 |
+
Matrix([[a, b], [x, y]]).det()),
|
| 613 |
+
(r"\det \begin{pmatrix}1&2\\3&4\end{pmatrix}", -2),
|
| 614 |
+
(r"\det{\begin{pmatrix}1&2\\3&4\end{pmatrix}}", -2),
|
| 615 |
+
(r"\det(\begin{pmatrix}1&2\\3&4\end{pmatrix})", -2),
|
| 616 |
+
(r"\det\left(\begin{pmatrix}1&2\\3&4\end{pmatrix}\right)", -2),
|
| 617 |
+
(r"\begin{pmatrix}a & b \\x & y\end{pmatrix}/\begin{vmatrix}a & b \\x & y\end{vmatrix}",
|
| 618 |
+
_MatMul(Matrix([[a, b], [x, y]]), _Pow(Matrix([[a, b], [x, y]]).det(), -1))),
|
| 619 |
+
(r"\begin{pmatrix}a & b \\x & y\end{pmatrix}/|\begin{matrix}a & b \\x & y\end{matrix}|",
|
| 620 |
+
_MatMul(Matrix([[a, b], [x, y]]), _Pow(Matrix([[a, b], [x, y]]).det(), -1))),
|
| 621 |
+
(r"\frac{\begin{pmatrix}a & b \\x & y\end{pmatrix}}{| { \begin{matrix}a & b \\x & y\end{matrix} } |}",
|
| 622 |
+
_MatMul(Matrix([[a, b], [x, y]]), _Pow(Matrix([[a, b], [x, y]]).det(), -1))),
|
| 623 |
+
(r"\overline{\begin{pmatrix}\imaginaryunit & 1+\imaginaryunit \\-\imaginaryunit & 4\end{pmatrix}}",
|
| 624 |
+
Matrix([[-I, 1-I], [I, 4]])),
|
| 625 |
+
(r"\begin{pmatrix}\imaginaryunit & 1+\imaginaryunit \\-\imaginaryunit & 4\end{pmatrix}^H",
|
| 626 |
+
Matrix([[-I, I], [1-I, 4]])),
|
| 627 |
+
(r"\trace(\begin{pmatrix}\imaginaryunit & 1+\imaginaryunit \\-\imaginaryunit & 4\end{pmatrix})",
|
| 628 |
+
Trace(Matrix([[I, 1+I], [-I, 4]]))),
|
| 629 |
+
(r"\adjugate(\begin{pmatrix}1 & 2 \\3 & 4\end{pmatrix})",
|
| 630 |
+
Matrix([[4, -2], [-3, 1]])),
|
| 631 |
+
(r"(\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix})^\ast",
|
| 632 |
+
Matrix([[-2*I, 6], [4, 8]])),
|
| 633 |
+
(r"(\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix})^{\ast}",
|
| 634 |
+
Matrix([[-2*I, 6], [4, 8]])),
|
| 635 |
+
(r"(\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix})^{\ast\ast}",
|
| 636 |
+
Matrix([[2*I, 4], [6, 8]])),
|
| 637 |
+
(r"(\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix})^{\ast\ast\ast}",
|
| 638 |
+
Matrix([[-2*I, 6], [4, 8]])),
|
| 639 |
+
(r"(\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix})^{*}",
|
| 640 |
+
Matrix([[-2*I, 6], [4, 8]])),
|
| 641 |
+
(r"(\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix})^{**}",
|
| 642 |
+
Matrix([[2*I, 4], [6, 8]])),
|
| 643 |
+
(r"(\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix})^{***}",
|
| 644 |
+
Matrix([[-2*I, 6], [4, 8]])),
|
| 645 |
+
(r"(\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix})^\prime",
|
| 646 |
+
Transpose(_MatAdd(Matrix([[I, 2], [3, 4]]),
|
| 647 |
+
Matrix([[I, 2], [3, 4]])))),
|
| 648 |
+
(r"(\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix})^{\prime}",
|
| 649 |
+
Transpose(_MatAdd(Matrix([[I, 2], [3, 4]]),
|
| 650 |
+
Matrix([[I, 2], [3, 4]])))),
|
| 651 |
+
(r"(\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix})^{\prime\prime}",
|
| 652 |
+
_MatAdd(Matrix([[I, 2], [3, 4]]),
|
| 653 |
+
Matrix([[I, 2], [3, 4]]))),
|
| 654 |
+
(r"(\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix})^{\prime\prime\prime}",
|
| 655 |
+
Transpose(_MatAdd(Matrix([[I, 2], [3, 4]]),
|
| 656 |
+
Matrix([[I, 2], [3, 4]])))),
|
| 657 |
+
(r"(\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix})^{'}",
|
| 658 |
+
Transpose(_MatAdd(Matrix([[I, 2], [3, 4]]),
|
| 659 |
+
Matrix([[I, 2], [3, 4]])))),
|
| 660 |
+
(r"(\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix})^{''}",
|
| 661 |
+
_MatAdd(Matrix([[I, 2], [3, 4]]),
|
| 662 |
+
Matrix([[I, 2], [3, 4]]))),
|
| 663 |
+
(r"(\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix})^{'''}",
|
| 664 |
+
Transpose(_MatAdd(Matrix([[I, 2], [3, 4]]),
|
| 665 |
+
Matrix([[I, 2], [3, 4]])))),
|
| 666 |
+
(r"(\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix})'",
|
| 667 |
+
Transpose(_MatAdd(Matrix([[I, 2], [3, 4]]),
|
| 668 |
+
Matrix([[I, 2], [3, 4]])))),
|
| 669 |
+
(r"(\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix})''",
|
| 670 |
+
_MatAdd(Matrix([[I, 2], [3, 4]]),
|
| 671 |
+
Matrix([[I, 2], [3, 4]]))),
|
| 672 |
+
(r"(\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix})'''",
|
| 673 |
+
Transpose(_MatAdd(Matrix([[I, 2], [3, 4]]),
|
| 674 |
+
Matrix([[I, 2], [3, 4]])))),
|
| 675 |
+
(r"\det(\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix})",
|
| 676 |
+
(_MatAdd(Matrix([[I, 2], [3, 4]]),
|
| 677 |
+
Matrix([[I, 2], [3, 4]]))).det()),
|
| 678 |
+
(r"\trace(\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix})",
|
| 679 |
+
Trace(_MatAdd(Matrix([[I, 2], [3, 4]]),
|
| 680 |
+
Matrix([[I, 2], [3, 4]])))),
|
| 681 |
+
(r"\adjugate(\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix})",
|
| 682 |
+
(Matrix([[8, -4], [-6, 2*I]]))),
|
| 683 |
+
(r"(\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix})^T",
|
| 684 |
+
Transpose(_MatAdd(Matrix([[I, 2], [3, 4]]),
|
| 685 |
+
Matrix([[I, 2], [3, 4]])))),
|
| 686 |
+
(r"(\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix}+\begin{pmatrix}\imaginaryunit&2\\3&4\end{pmatrix})^H",
|
| 687 |
+
(Matrix([[-2*I, 6], [4, 8]])))
|
| 688 |
+
]
|
| 689 |
+
|
| 690 |
+
|
| 691 |
+
def test_symbol_expressions():
|
| 692 |
+
expected_failures = {6, 7}
|
| 693 |
+
for i, (latex_str, sympy_expr) in enumerate(SYMBOL_EXPRESSION_PAIRS):
|
| 694 |
+
if i in expected_failures:
|
| 695 |
+
continue
|
| 696 |
+
with evaluate(False):
|
| 697 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 698 |
+
|
| 699 |
+
|
| 700 |
+
def test_simple_expressions():
|
| 701 |
+
expected_failures = {20}
|
| 702 |
+
for i, (latex_str, sympy_expr) in enumerate(UNEVALUATED_SIMPLE_EXPRESSION_PAIRS):
|
| 703 |
+
if i in expected_failures:
|
| 704 |
+
continue
|
| 705 |
+
with evaluate(False):
|
| 706 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 707 |
+
|
| 708 |
+
for i, (latex_str, sympy_expr) in enumerate(EVALUATED_SIMPLE_EXPRESSION_PAIRS):
|
| 709 |
+
if i in expected_failures:
|
| 710 |
+
continue
|
| 711 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 712 |
+
|
| 713 |
+
|
| 714 |
+
def test_fraction_expressions():
|
| 715 |
+
for latex_str, sympy_expr in UNEVALUATED_FRACTION_EXPRESSION_PAIRS:
|
| 716 |
+
with evaluate(False):
|
| 717 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 718 |
+
|
| 719 |
+
for latex_str, sympy_expr in EVALUATED_FRACTION_EXPRESSION_PAIRS:
|
| 720 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 721 |
+
|
| 722 |
+
|
| 723 |
+
def test_relation_expressions():
|
| 724 |
+
for latex_str, sympy_expr in RELATION_EXPRESSION_PAIRS:
|
| 725 |
+
with evaluate(False):
|
| 726 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 727 |
+
|
| 728 |
+
def test_power_expressions():
|
| 729 |
+
expected_failures = {3}
|
| 730 |
+
for i, (latex_str, sympy_expr) in enumerate(UNEVALUATED_POWER_EXPRESSION_PAIRS):
|
| 731 |
+
if i in expected_failures:
|
| 732 |
+
continue
|
| 733 |
+
with evaluate(False):
|
| 734 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 735 |
+
|
| 736 |
+
for i, (latex_str, sympy_expr) in enumerate(EVALUATED_POWER_EXPRESSION_PAIRS):
|
| 737 |
+
if i in expected_failures:
|
| 738 |
+
continue
|
| 739 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 740 |
+
|
| 741 |
+
|
| 742 |
+
def test_integral_expressions():
|
| 743 |
+
expected_failures = {14}
|
| 744 |
+
for i, (latex_str, sympy_expr) in enumerate(UNEVALUATED_INTEGRAL_EXPRESSION_PAIRS):
|
| 745 |
+
if i in expected_failures:
|
| 746 |
+
continue
|
| 747 |
+
with evaluate(False):
|
| 748 |
+
assert parse_latex_lark(latex_str) == sympy_expr, i
|
| 749 |
+
|
| 750 |
+
for i, (latex_str, sympy_expr) in enumerate(EVALUATED_INTEGRAL_EXPRESSION_PAIRS):
|
| 751 |
+
if i in expected_failures:
|
| 752 |
+
continue
|
| 753 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 754 |
+
|
| 755 |
+
|
| 756 |
+
def test_derivative_expressions():
|
| 757 |
+
expected_failures = {3, 4}
|
| 758 |
+
for i, (latex_str, sympy_expr) in enumerate(DERIVATIVE_EXPRESSION_PAIRS):
|
| 759 |
+
if i in expected_failures:
|
| 760 |
+
continue
|
| 761 |
+
with evaluate(False):
|
| 762 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 763 |
+
|
| 764 |
+
for i, (latex_str, sympy_expr) in enumerate(DERIVATIVE_EXPRESSION_PAIRS):
|
| 765 |
+
if i in expected_failures:
|
| 766 |
+
continue
|
| 767 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 768 |
+
|
| 769 |
+
|
| 770 |
+
def test_trigonometric_expressions():
|
| 771 |
+
expected_failures = {3}
|
| 772 |
+
for i, (latex_str, sympy_expr) in enumerate(TRIGONOMETRIC_EXPRESSION_PAIRS):
|
| 773 |
+
if i in expected_failures:
|
| 774 |
+
continue
|
| 775 |
+
with evaluate(False):
|
| 776 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 777 |
+
|
| 778 |
+
|
| 779 |
+
def test_limit_expressions():
|
| 780 |
+
for latex_str, sympy_expr in UNEVALUATED_LIMIT_EXPRESSION_PAIRS:
|
| 781 |
+
with evaluate(False):
|
| 782 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 783 |
+
|
| 784 |
+
|
| 785 |
+
def test_square_root_expressions():
|
| 786 |
+
for latex_str, sympy_expr in UNEVALUATED_SQRT_EXPRESSION_PAIRS:
|
| 787 |
+
with evaluate(False):
|
| 788 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 789 |
+
|
| 790 |
+
for latex_str, sympy_expr in EVALUATED_SQRT_EXPRESSION_PAIRS:
|
| 791 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 792 |
+
|
| 793 |
+
|
| 794 |
+
def test_factorial_expressions():
|
| 795 |
+
for latex_str, sympy_expr in UNEVALUATED_FACTORIAL_EXPRESSION_PAIRS:
|
| 796 |
+
with evaluate(False):
|
| 797 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 798 |
+
|
| 799 |
+
for latex_str, sympy_expr in EVALUATED_FACTORIAL_EXPRESSION_PAIRS:
|
| 800 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 801 |
+
|
| 802 |
+
|
| 803 |
+
def test_sum_expressions():
|
| 804 |
+
for latex_str, sympy_expr in UNEVALUATED_SUM_EXPRESSION_PAIRS:
|
| 805 |
+
with evaluate(False):
|
| 806 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 807 |
+
|
| 808 |
+
for latex_str, sympy_expr in EVALUATED_SUM_EXPRESSION_PAIRS:
|
| 809 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 810 |
+
|
| 811 |
+
|
| 812 |
+
def test_product_expressions():
|
| 813 |
+
for latex_str, sympy_expr in UNEVALUATED_PRODUCT_EXPRESSION_PAIRS:
|
| 814 |
+
with evaluate(False):
|
| 815 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 816 |
+
|
| 817 |
+
@XFAIL
|
| 818 |
+
def test_applied_function_expressions():
|
| 819 |
+
expected_failures = {0, 3, 4} # 0 is ambiguous, and the others require not-yet-added features
|
| 820 |
+
# not sure why 1, and 2 are failing
|
| 821 |
+
for i, (latex_str, sympy_expr) in enumerate(APPLIED_FUNCTION_EXPRESSION_PAIRS):
|
| 822 |
+
if i in expected_failures:
|
| 823 |
+
continue
|
| 824 |
+
with evaluate(False):
|
| 825 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 826 |
+
|
| 827 |
+
|
| 828 |
+
def test_common_function_expressions():
|
| 829 |
+
for latex_str, sympy_expr in UNEVALUATED_COMMON_FUNCTION_EXPRESSION_PAIRS:
|
| 830 |
+
with evaluate(False):
|
| 831 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 832 |
+
|
| 833 |
+
for latex_str, sympy_expr in EVALUATED_COMMON_FUNCTION_EXPRESSION_PAIRS:
|
| 834 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 835 |
+
|
| 836 |
+
|
| 837 |
+
# unhandled bug causing these to fail
|
| 838 |
+
@XFAIL
|
| 839 |
+
def test_spacing():
|
| 840 |
+
for latex_str, sympy_expr in SPACING_RELATED_EXPRESSION_PAIRS:
|
| 841 |
+
with evaluate(False):
|
| 842 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 843 |
+
|
| 844 |
+
|
| 845 |
+
def test_binomial_expressions():
|
| 846 |
+
for latex_str, sympy_expr in UNEVALUATED_BINOMIAL_EXPRESSION_PAIRS:
|
| 847 |
+
with evaluate(False):
|
| 848 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 849 |
+
|
| 850 |
+
for latex_str, sympy_expr in EVALUATED_BINOMIAL_EXPRESSION_PAIRS:
|
| 851 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 852 |
+
|
| 853 |
+
|
| 854 |
+
def test_miscellaneous_expressions():
|
| 855 |
+
for latex_str, sympy_expr in MISCELLANEOUS_EXPRESSION_PAIRS:
|
| 856 |
+
with evaluate(False):
|
| 857 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 858 |
+
|
| 859 |
+
|
| 860 |
+
def test_literal_complex_number_expressions():
|
| 861 |
+
for latex_str, sympy_expr in UNEVALUATED_LITERAL_COMPLEX_NUMBER_EXPRESSION_PAIRS:
|
| 862 |
+
with evaluate(False):
|
| 863 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 864 |
+
|
| 865 |
+
|
| 866 |
+
def test_matrix_expressions():
|
| 867 |
+
for latex_str, sympy_expr in UNEVALUATED_MATRIX_EXPRESSION_PAIRS:
|
| 868 |
+
with evaluate(False):
|
| 869 |
+
assert parse_latex_lark(latex_str) == sympy_expr, latex_str
|
| 870 |
+
|
| 871 |
+
for latex_str, sympy_expr in EVALUAT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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sympy import sin, Function, symbols, Dummy, Lambda, cos
|
| 2 |
+
from sympy.parsing.mathematica import parse_mathematica, MathematicaParser
|
| 3 |
+
from sympy.core.sympify import sympify
|
| 4 |
+
from sympy.abc import n, w, x, y, z
|
| 5 |
+
from sympy.testing.pytest import raises
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def test_mathematica():
|
| 9 |
+
d = {
|
| 10 |
+
'- 6x': '-6*x',
|
| 11 |
+
'Sin[x]^2': 'sin(x)**2',
|
| 12 |
+
'2(x-1)': '2*(x-1)',
|
| 13 |
+
'3y+8': '3*y+8',
|
| 14 |
+
'ArcSin[2x+9(4-x)^2]/x': 'asin(2*x+9*(4-x)**2)/x',
|
| 15 |
+
'x+y': 'x+y',
|
| 16 |
+
'355/113': '355/113',
|
| 17 |
+
'2.718281828': '2.718281828',
|
| 18 |
+
'Cos(1/2 * π)': 'Cos(π/2)',
|
| 19 |
+
'Sin[12]': 'sin(12)',
|
| 20 |
+
'Exp[Log[4]]': 'exp(log(4))',
|
| 21 |
+
'(x+1)(x+3)': '(x+1)*(x+3)',
|
| 22 |
+
'Cos[ArcCos[3.6]]': 'cos(acos(3.6))',
|
| 23 |
+
'Cos[x]==Sin[y]': 'Eq(cos(x), sin(y))',
|
| 24 |
+
'2*Sin[x+y]': '2*sin(x+y)',
|
| 25 |
+
'Sin[x]+Cos[y]': 'sin(x)+cos(y)',
|
| 26 |
+
'Sin[Cos[x]]': 'sin(cos(x))',
|
| 27 |
+
'2*Sqrt[x+y]': '2*sqrt(x+y)', # Test case from the issue 4259
|
| 28 |
+
'+Sqrt[2]': 'sqrt(2)',
|
| 29 |
+
'-Sqrt[2]': '-sqrt(2)',
|
| 30 |
+
'-1/Sqrt[2]': '-1/sqrt(2)',
|
| 31 |
+
'-(1/Sqrt[3])': '-(1/sqrt(3))',
|
| 32 |
+
'1/(2*Sqrt[5])': '1/(2*sqrt(5))',
|
| 33 |
+
'Mod[5,3]': 'Mod(5,3)',
|
| 34 |
+
'-Mod[5,3]': '-Mod(5,3)',
|
| 35 |
+
'(x+1)y': '(x+1)*y',
|
| 36 |
+
'x(y+1)': 'x*(y+1)',
|
| 37 |
+
'Sin[x]Cos[y]': 'sin(x)*cos(y)',
|
| 38 |
+
'Sin[x]^2Cos[y]^2': 'sin(x)**2*cos(y)**2',
|
| 39 |
+
'Cos[x]^2(1 - Cos[y]^2)': 'cos(x)**2*(1-cos(y)**2)',
|
| 40 |
+
'x y': 'x*y',
|
| 41 |
+
'x y': 'x*y',
|
| 42 |
+
'2 x': '2*x',
|
| 43 |
+
'x 8': 'x*8',
|
| 44 |
+
'2 8': '2*8',
|
| 45 |
+
'4.x': '4.*x',
|
| 46 |
+
'4. 3': '4.*3',
|
| 47 |
+
'4. 3.': '4.*3.',
|
| 48 |
+
'1 2 3': '1*2*3',
|
| 49 |
+
' - 2 * Sqrt[ 2 3 * ( 1 + 5 ) ] ': '-2*sqrt(2*3*(1+5))',
|
| 50 |
+
'Log[2,4]': 'log(4,2)',
|
| 51 |
+
'Log[Log[2,4],4]': 'log(4,log(4,2))',
|
| 52 |
+
'Exp[Sqrt[2]^2Log[2, 8]]': 'exp(sqrt(2)**2*log(8,2))',
|
| 53 |
+
'ArcSin[Cos[0]]': 'asin(cos(0))',
|
| 54 |
+
'Log2[16]': 'log(16,2)',
|
| 55 |
+
'Max[1,-2,3,-4]': 'Max(1,-2,3,-4)',
|
| 56 |
+
'Min[1,-2,3]': 'Min(1,-2,3)',
|
| 57 |
+
'Exp[I Pi/2]': 'exp(I*pi/2)',
|
| 58 |
+
'ArcTan[x,y]': 'atan2(y,x)',
|
| 59 |
+
'Pochhammer[x,y]': 'rf(x,y)',
|
| 60 |
+
'ExpIntegralEi[x]': 'Ei(x)',
|
| 61 |
+
'SinIntegral[x]': 'Si(x)',
|
| 62 |
+
'CosIntegral[x]': 'Ci(x)',
|
| 63 |
+
'AiryAi[x]': 'airyai(x)',
|
| 64 |
+
'AiryAiPrime[5]': 'airyaiprime(5)',
|
| 65 |
+
'AiryBi[x]': 'airybi(x)',
|
| 66 |
+
'AiryBiPrime[7]': 'airybiprime(7)',
|
| 67 |
+
'LogIntegral[4]': ' li(4)',
|
| 68 |
+
'PrimePi[7]': 'primepi(7)',
|
| 69 |
+
'Prime[5]': 'prime(5)',
|
| 70 |
+
'PrimeQ[5]': 'isprime(5)',
|
| 71 |
+
'Rational[2,19]': 'Rational(2,19)', # test case for issue 25716
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
for e in d:
|
| 75 |
+
assert parse_mathematica(e) == sympify(d[e])
|
| 76 |
+
|
| 77 |
+
# The parsed form of this expression should not evaluate the Lambda object:
|
| 78 |
+
assert parse_mathematica("Sin[#]^2 + Cos[#]^2 &[x]") == sin(x)**2 + cos(x)**2
|
| 79 |
+
|
| 80 |
+
d1, d2, d3 = symbols("d1:4", cls=Dummy)
|
| 81 |
+
assert parse_mathematica("Sin[#] + Cos[#3] &").dummy_eq(Lambda((d1, d2, d3), sin(d1) + cos(d3)))
|
| 82 |
+
assert parse_mathematica("Sin[#^2] &").dummy_eq(Lambda(d1, sin(d1**2)))
|
| 83 |
+
assert parse_mathematica("Function[x, x^3]") == Lambda(x, x**3)
|
| 84 |
+
assert parse_mathematica("Function[{x, y}, x^2 + y^2]") == Lambda((x, y), x**2 + y**2)
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
def test_parser_mathematica_tokenizer():
|
| 88 |
+
parser = MathematicaParser()
|
| 89 |
+
|
| 90 |
+
chain = lambda expr: parser._from_tokens_to_fullformlist(parser._from_mathematica_to_tokens(expr))
|
| 91 |
+
|
| 92 |
+
# Basic patterns
|
| 93 |
+
assert chain("x") == "x"
|
| 94 |
+
assert chain("42") == "42"
|
| 95 |
+
assert chain(".2") == ".2"
|
| 96 |
+
assert chain("+x") == "x"
|
| 97 |
+
assert chain("-1") == "-1"
|
| 98 |
+
assert chain("- 3") == "-3"
|
| 99 |
+
assert chain("α") == "α"
|
| 100 |
+
assert chain("+Sin[x]") == ["Sin", "x"]
|
| 101 |
+
assert chain("-Sin[x]") == ["Times", "-1", ["Sin", "x"]]
|
| 102 |
+
assert chain("x(a+1)") == ["Times", "x", ["Plus", "a", "1"]]
|
| 103 |
+
assert chain("(x)") == "x"
|
| 104 |
+
assert chain("(+x)") == "x"
|
| 105 |
+
assert chain("-a") == ["Times", "-1", "a"]
|
| 106 |
+
assert chain("(-x)") == ["Times", "-1", "x"]
|
| 107 |
+
assert chain("(x + y)") == ["Plus", "x", "y"]
|
| 108 |
+
assert chain("3 + 4") == ["Plus", "3", "4"]
|
| 109 |
+
assert chain("a - 3") == ["Plus", "a", "-3"]
|
| 110 |
+
assert chain("a - b") == ["Plus", "a", ["Times", "-1", "b"]]
|
| 111 |
+
assert chain("7 * 8") == ["Times", "7", "8"]
|
| 112 |
+
assert chain("a + b*c") == ["Plus", "a", ["Times", "b", "c"]]
|
| 113 |
+
assert chain("a + b* c* d + 2 * e") == ["Plus", "a", ["Times", "b", "c", "d"], ["Times", "2", "e"]]
|
| 114 |
+
assert chain("a / b") == ["Times", "a", ["Power", "b", "-1"]]
|
| 115 |
+
|
| 116 |
+
# Missing asterisk (*) patterns:
|
| 117 |
+
assert chain("x y") == ["Times", "x", "y"]
|
| 118 |
+
assert chain("3 4") == ["Times", "3", "4"]
|
| 119 |
+
assert chain("a[b] c") == ["Times", ["a", "b"], "c"]
|
| 120 |
+
assert chain("(x) (y)") == ["Times", "x", "y"]
|
| 121 |
+
assert chain("3 (a)") == ["Times", "3", "a"]
|
| 122 |
+
assert chain("(a) b") == ["Times", "a", "b"]
|
| 123 |
+
assert chain("4.2") == "4.2"
|
| 124 |
+
assert chain("4 2") == ["Times", "4", "2"]
|
| 125 |
+
assert chain("4 2") == ["Times", "4", "2"]
|
| 126 |
+
assert chain("3 . 4") == ["Dot", "3", "4"]
|
| 127 |
+
assert chain("4. 2") == ["Times", "4.", "2"]
|
| 128 |
+
assert chain("x.y") == ["Dot", "x", "y"]
|
| 129 |
+
assert chain("4.y") == ["Times", "4.", "y"]
|
| 130 |
+
assert chain("4 .y") == ["Dot", "4", "y"]
|
| 131 |
+
assert chain("x.4") == ["Times", "x", ".4"]
|
| 132 |
+
assert chain("x0.3") == ["Times", "x0", ".3"]
|
| 133 |
+
assert chain("x. 4") == ["Dot", "x", "4"]
|
| 134 |
+
|
| 135 |
+
# Comments
|
| 136 |
+
assert chain("a (* +b *) + c") == ["Plus", "a", "c"]
|
| 137 |
+
assert chain("a (* + b *) + (**)c (* +d *) + e") == ["Plus", "a", "c", "e"]
|
| 138 |
+
assert chain("""a + (*
|
| 139 |
+
+ b
|
| 140 |
+
*) c + (* d
|
| 141 |
+
*) e
|
| 142 |
+
""") == ["Plus", "a", "c", "e"]
|
| 143 |
+
|
| 144 |
+
# Operators couples + and -, * and / are mutually associative:
|
| 145 |
+
# (i.e. expression gets flattened when mixing these operators)
|
| 146 |
+
assert chain("a*b/c") == ["Times", "a", "b", ["Power", "c", "-1"]]
|
| 147 |
+
assert chain("a/b*c") == ["Times", "a", ["Power", "b", "-1"], "c"]
|
| 148 |
+
assert chain("a+b-c") == ["Plus", "a", "b", ["Times", "-1", "c"]]
|
| 149 |
+
assert chain("a-b+c") == ["Plus", "a", ["Times", "-1", "b"], "c"]
|
| 150 |
+
assert chain("-a + b -c ") == ["Plus", ["Times", "-1", "a"], "b", ["Times", "-1", "c"]]
|
| 151 |
+
assert chain("a/b/c*d") == ["Times", "a", ["Power", "b", "-1"], ["Power", "c", "-1"], "d"]
|
| 152 |
+
assert chain("a/b/c") == ["Times", "a", ["Power", "b", "-1"], ["Power", "c", "-1"]]
|
| 153 |
+
assert chain("a-b-c") == ["Plus", "a", ["Times", "-1", "b"], ["Times", "-1", "c"]]
|
| 154 |
+
assert chain("1/a") == ["Times", "1", ["Power", "a", "-1"]]
|
| 155 |
+
assert chain("1/a/b") == ["Times", "1", ["Power", "a", "-1"], ["Power", "b", "-1"]]
|
| 156 |
+
assert chain("-1/a*b") == ["Times", "-1", ["Power", "a", "-1"], "b"]
|
| 157 |
+
|
| 158 |
+
# Enclosures of various kinds, i.e. ( ) [ ] [[ ]] { }
|
| 159 |
+
assert chain("(a + b) + c") == ["Plus", ["Plus", "a", "b"], "c"]
|
| 160 |
+
assert chain(" a + (b + c) + d ") == ["Plus", "a", ["Plus", "b", "c"], "d"]
|
| 161 |
+
assert chain("a * (b + c)") == ["Times", "a", ["Plus", "b", "c"]]
|
| 162 |
+
assert chain("a b (c d)") == ["Times", "a", "b", ["Times", "c", "d"]]
|
| 163 |
+
assert chain("{a, b, 2, c}") == ["List", "a", "b", "2", "c"]
|
| 164 |
+
assert chain("{a, {b, c}}") == ["List", "a", ["List", "b", "c"]]
|
| 165 |
+
assert chain("{{a}}") == ["List", ["List", "a"]]
|
| 166 |
+
assert chain("a[b, c]") == ["a", "b", "c"]
|
| 167 |
+
assert chain("a[[b, c]]") == ["Part", "a", "b", "c"]
|
| 168 |
+
assert chain("a[b[c]]") == ["a", ["b", "c"]]
|
| 169 |
+
assert chain("a[[b, c[[d, {e,f}]]]]") == ["Part", "a", "b", ["Part", "c", "d", ["List", "e", "f"]]]
|
| 170 |
+
assert chain("a[b[[c,d]]]") == ["a", ["Part", "b", "c", "d"]]
|
| 171 |
+
assert chain("a[[b[c]]]") == ["Part", "a", ["b", "c"]]
|
| 172 |
+
assert chain("a[[b[[c]]]]") == ["Part", "a", ["Part", "b", "c"]]
|
| 173 |
+
assert chain("a[[b[c[[d]]]]]") == ["Part", "a", ["b", ["Part", "c", "d"]]]
|
| 174 |
+
assert chain("a[b[[c[d]]]]") == ["a", ["Part", "b", ["c", "d"]]]
|
| 175 |
+
assert chain("x[[a+1, b+2, c+3]]") == ["Part", "x", ["Plus", "a", "1"], ["Plus", "b", "2"], ["Plus", "c", "3"]]
|
| 176 |
+
assert chain("x[a+1, b+2, c+3]") == ["x", ["Plus", "a", "1"], ["Plus", "b", "2"], ["Plus", "c", "3"]]
|
| 177 |
+
assert chain("{a+1, b+2, c+3}") == ["List", ["Plus", "a", "1"], ["Plus", "b", "2"], ["Plus", "c", "3"]]
|
| 178 |
+
|
| 179 |
+
# Flat operator:
|
| 180 |
+
assert chain("a*b*c*d*e") == ["Times", "a", "b", "c", "d", "e"]
|
| 181 |
+
assert chain("a +b + c+ d+e") == ["Plus", "a", "b", "c", "d", "e"]
|
| 182 |
+
|
| 183 |
+
# Right priority operator:
|
| 184 |
+
assert chain("a^b") == ["Power", "a", "b"]
|
| 185 |
+
assert chain("a^b^c") == ["Power", "a", ["Power", "b", "c"]]
|
| 186 |
+
assert chain("a^b^c^d") == ["Power", "a", ["Power", "b", ["Power", "c", "d"]]]
|
| 187 |
+
|
| 188 |
+
# Left priority operator:
|
| 189 |
+
assert chain("a/.b") == ["ReplaceAll", "a", "b"]
|
| 190 |
+
assert chain("a/.b/.c/.d") == ["ReplaceAll", ["ReplaceAll", ["ReplaceAll", "a", "b"], "c"], "d"]
|
| 191 |
+
|
| 192 |
+
assert chain("a//b") == ["a", "b"]
|
| 193 |
+
assert chain("a//b//c") == [["a", "b"], "c"]
|
| 194 |
+
assert chain("a//b//c//d") == [[["a", "b"], "c"], "d"]
|
| 195 |
+
|
| 196 |
+
# Compound expressions
|
| 197 |
+
assert chain("a;b") == ["CompoundExpression", "a", "b"]
|
| 198 |
+
assert chain("a;") == ["CompoundExpression", "a", "Null"]
|
| 199 |
+
assert chain("a;b;") == ["CompoundExpression", "a", "b", "Null"]
|
| 200 |
+
assert chain("a[b;c]") == ["a", ["CompoundExpression", "b", "c"]]
|
| 201 |
+
assert chain("a[b,c;d,e]") == ["a", "b", ["CompoundExpression", "c", "d"], "e"]
|
| 202 |
+
assert chain("a[b,c;,d]") == ["a", "b", ["CompoundExpression", "c", "Null"], "d"]
|
| 203 |
+
|
| 204 |
+
# New lines
|
| 205 |
+
assert chain("a\nb\n") == ["CompoundExpression", "a", "b"]
|
| 206 |
+
assert chain("a\n\nb\n (c \nd) \n") == ["CompoundExpression", "a", "b", ["Times", "c", "d"]]
|
| 207 |
+
assert chain("\na; b\nc") == ["CompoundExpression", "a", "b", "c"]
|
| 208 |
+
assert chain("a + \nb\n") == ["Plus", "a", "b"]
|
| 209 |
+
assert chain("a\nb; c; d\n e; (f \n g); h + \n i") == ["CompoundExpression", "a", "b", "c", "d", "e", ["Times", "f", "g"], ["Plus", "h", "i"]]
|
| 210 |
+
assert chain("\n{\na\nb; c; d\n e (f \n g); h + \n i\n\n}\n") == ["List", ["CompoundExpression", ["Times", "a", "b"], "c", ["Times", "d", "e", ["Times", "f", "g"]], ["Plus", "h", "i"]]]
|
| 211 |
+
|
| 212 |
+
# Patterns
|
| 213 |
+
assert chain("y_") == ["Pattern", "y", ["Blank"]]
|
| 214 |
+
assert chain("y_.") == ["Optional", ["Pattern", "y", ["Blank"]]]
|
| 215 |
+
assert chain("y__") == ["Pattern", "y", ["BlankSequence"]]
|
| 216 |
+
assert chain("y___") == ["Pattern", "y", ["BlankNullSequence"]]
|
| 217 |
+
assert chain("a[b_.,c_]") == ["a", ["Optional", ["Pattern", "b", ["Blank"]]], ["Pattern", "c", ["Blank"]]]
|
| 218 |
+
assert chain("b_. c") == ["Times", ["Optional", ["Pattern", "b", ["Blank"]]], "c"]
|
| 219 |
+
|
| 220 |
+
# Slots for lambda functions
|
| 221 |
+
assert chain("#") == ["Slot", "1"]
|
| 222 |
+
assert chain("#3") == ["Slot", "3"]
|
| 223 |
+
assert chain("#n") == ["Slot", "n"]
|
| 224 |
+
assert chain("##") == ["SlotSequence", "1"]
|
| 225 |
+
assert chain("##a") == ["SlotSequence", "a"]
|
| 226 |
+
|
| 227 |
+
# Lambda functions
|
| 228 |
+
assert chain("x&") == ["Function", "x"]
|
| 229 |
+
assert chain("#&") == ["Function", ["Slot", "1"]]
|
| 230 |
+
assert chain("#+3&") == ["Function", ["Plus", ["Slot", "1"], "3"]]
|
| 231 |
+
assert chain("#1 + #2&") == ["Function", ["Plus", ["Slot", "1"], ["Slot", "2"]]]
|
| 232 |
+
assert chain("# + #&") == ["Function", ["Plus", ["Slot", "1"], ["Slot", "1"]]]
|
| 233 |
+
assert chain("#&[x]") == [["Function", ["Slot", "1"]], "x"]
|
| 234 |
+
assert chain("#1 + #2 & [x, y]") == [["Function", ["Plus", ["Slot", "1"], ["Slot", "2"]]], "x", "y"]
|
| 235 |
+
assert chain("#1^2#2^3&") == ["Function", ["Times", ["Power", ["Slot", "1"], "2"], ["Power", ["Slot", "2"], "3"]]]
|
| 236 |
+
|
| 237 |
+
# Strings inside Mathematica expressions:
|
| 238 |
+
assert chain('"abc"') == ["_Str", "abc"]
|
| 239 |
+
assert chain('"a\\"b"') == ["_Str", 'a"b']
|
| 240 |
+
# This expression does not make sense mathematically, it's just testing the parser:
|
| 241 |
+
assert chain('x + "abc" ^ 3') == ["Plus", "x", ["Power", ["_Str", "abc"], "3"]]
|
| 242 |
+
assert chain('"a (* b *) c"') == ["_Str", "a (* b *) c"]
|
| 243 |
+
assert chain('"a" (* b *) ') == ["_Str", "a"]
|
| 244 |
+
assert chain('"a [ b] "') == ["_Str", "a [ b] "]
|
| 245 |
+
raises(SyntaxError, lambda: chain('"'))
|
| 246 |
+
raises(SyntaxError, lambda: chain('"\\"'))
|
| 247 |
+
raises(SyntaxError, lambda: chain('"abc'))
|
| 248 |
+
raises(SyntaxError, lambda: chain('"abc\\"def'))
|
| 249 |
+
|
| 250 |
+
# Invalid expressions:
|
| 251 |
+
raises(SyntaxError, lambda: chain("(,"))
|
| 252 |
+
raises(SyntaxError, lambda: chain("()"))
|
| 253 |
+
raises(SyntaxError, lambda: chain("a (* b"))
|
| 254 |
+
|
| 255 |
+
|
| 256 |
+
def test_parser_mathematica_exp_alt():
|
| 257 |
+
parser = MathematicaParser()
|
| 258 |
+
|
| 259 |
+
convert_chain2 = lambda expr: parser._from_fullformlist_to_fullformsympy(parser._from_fullform_to_fullformlist(expr))
|
| 260 |
+
convert_chain3 = lambda expr: parser._from_fullformsympy_to_sympy(convert_chain2(expr))
|
| 261 |
+
|
| 262 |
+
Sin, Times, Plus, Power = symbols("Sin Times Plus Power", cls=Function)
|
| 263 |
+
|
| 264 |
+
full_form1 = "Sin[Times[x, y]]"
|
| 265 |
+
full_form2 = "Plus[Times[x, y], z]"
|
| 266 |
+
full_form3 = "Sin[Times[x, Plus[y, z], Power[w, n]]]]"
|
| 267 |
+
full_form4 = "Rational[Rational[x, y], z]"
|
| 268 |
+
|
| 269 |
+
assert parser._from_fullform_to_fullformlist(full_form1) == ["Sin", ["Times", "x", "y"]]
|
| 270 |
+
assert parser._from_fullform_to_fullformlist(full_form2) == ["Plus", ["Times", "x", "y"], "z"]
|
| 271 |
+
assert parser._from_fullform_to_fullformlist(full_form3) == ["Sin", ["Times", "x", ["Plus", "y", "z"], ["Power", "w", "n"]]]
|
| 272 |
+
assert parser._from_fullform_to_fullformlist(full_form4) == ["Rational", ["Rational", "x", "y"], "z"]
|
| 273 |
+
|
| 274 |
+
assert convert_chain2(full_form1) == Sin(Times(x, y))
|
| 275 |
+
assert convert_chain2(full_form2) == Plus(Times(x, y), z)
|
| 276 |
+
assert convert_chain2(full_form3) == Sin(Times(x, Plus(y, z), Power(w, n)))
|
| 277 |
+
|
| 278 |
+
assert convert_chain3(full_form1) == sin(x*y)
|
| 279 |
+
assert convert_chain3(full_form2) == x*y + z
|
| 280 |
+
assert convert_chain3(full_form3) == sin(x*(y + z)*w**n)
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_maxima.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sympy.parsing.maxima import parse_maxima
|
| 2 |
+
from sympy.core.numbers import (E, Rational, oo)
|
| 3 |
+
from sympy.core.symbol import Symbol
|
| 4 |
+
from sympy.functions.combinatorial.factorials import factorial
|
| 5 |
+
from sympy.functions.elementary.complexes import Abs
|
| 6 |
+
from sympy.functions.elementary.exponential import log
|
| 7 |
+
from sympy.functions.elementary.trigonometric import (cos, sin)
|
| 8 |
+
from sympy.abc import x
|
| 9 |
+
|
| 10 |
+
n = Symbol('n', integer=True)
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def test_parser():
|
| 14 |
+
assert Abs(parse_maxima('float(1/3)') - 0.333333333) < 10**(-5)
|
| 15 |
+
assert parse_maxima('13^26') == 91733330193268616658399616009
|
| 16 |
+
assert parse_maxima('sin(%pi/2) + cos(%pi/3)') == Rational(3, 2)
|
| 17 |
+
assert parse_maxima('log(%e)') == 1
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def test_injection():
|
| 21 |
+
parse_maxima('c: x+1', globals=globals())
|
| 22 |
+
# c created by parse_maxima
|
| 23 |
+
assert c == x + 1 # noqa:F821
|
| 24 |
+
|
| 25 |
+
parse_maxima('g: sqrt(81)', globals=globals())
|
| 26 |
+
# g created by parse_maxima
|
| 27 |
+
assert g == 9 # noqa:F821
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def test_maxima_functions():
|
| 31 |
+
assert parse_maxima('expand( (x+1)^2)') == x**2 + 2*x + 1
|
| 32 |
+
assert parse_maxima('factor( x**2 + 2*x + 1)') == (x + 1)**2
|
| 33 |
+
assert parse_maxima('2*cos(x)^2 + sin(x)^2') == 2*cos(x)**2 + sin(x)**2
|
| 34 |
+
assert parse_maxima('trigexpand(sin(2*x)+cos(2*x))') == \
|
| 35 |
+
-1 + 2*cos(x)**2 + 2*cos(x)*sin(x)
|
| 36 |
+
assert parse_maxima('solve(x^2-4,x)') == [-2, 2]
|
| 37 |
+
assert parse_maxima('limit((1+1/x)^x,x,inf)') == E
|
| 38 |
+
assert parse_maxima('limit(sqrt(-x)/x,x,0,minus)') is -oo
|
| 39 |
+
assert parse_maxima('diff(x^x, x)') == x**x*(1 + log(x))
|
| 40 |
+
assert parse_maxima('sum(k, k, 1, n)', name_dict={
|
| 41 |
+
"n": Symbol('n', integer=True),
|
| 42 |
+
"k": Symbol('k', integer=True)
|
| 43 |
+
}) == (n**2 + n)/2
|
| 44 |
+
assert parse_maxima('product(k, k, 1, n)', name_dict={
|
| 45 |
+
"n": Symbol('n', integer=True),
|
| 46 |
+
"k": Symbol('k', integer=True)
|
| 47 |
+
}) == factorial(n)
|
| 48 |
+
assert parse_maxima('ratsimp((x^2-1)/(x+1))') == x - 1
|
| 49 |
+
assert Abs( parse_maxima(
|
| 50 |
+
'float(sec(%pi/3) + csc(%pi/3))') - 3.154700538379252) < 10**(-5)
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_sym_expr.py
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sympy.parsing.sym_expr import SymPyExpression
|
| 2 |
+
from sympy.testing.pytest import raises
|
| 3 |
+
from sympy.external import import_module
|
| 4 |
+
|
| 5 |
+
lfortran = import_module('lfortran')
|
| 6 |
+
cin = import_module('clang.cindex', import_kwargs = {'fromlist': ['cindex']})
|
| 7 |
+
|
| 8 |
+
if lfortran and cin:
|
| 9 |
+
from sympy.codegen.ast import (Variable, IntBaseType, FloatBaseType, String,
|
| 10 |
+
Declaration, FloatType)
|
| 11 |
+
from sympy.core import Integer, Float
|
| 12 |
+
from sympy.core.symbol import Symbol
|
| 13 |
+
|
| 14 |
+
expr1 = SymPyExpression()
|
| 15 |
+
src = """\
|
| 16 |
+
integer :: a, b, c, d
|
| 17 |
+
real :: p, q, r, s
|
| 18 |
+
"""
|
| 19 |
+
|
| 20 |
+
def test_c_parse():
|
| 21 |
+
src1 = """\
|
| 22 |
+
int a, b = 4;
|
| 23 |
+
float c, d = 2.4;
|
| 24 |
+
"""
|
| 25 |
+
expr1.convert_to_expr(src1, 'c')
|
| 26 |
+
ls = expr1.return_expr()
|
| 27 |
+
|
| 28 |
+
assert ls[0] == Declaration(
|
| 29 |
+
Variable(
|
| 30 |
+
Symbol('a'),
|
| 31 |
+
type=IntBaseType(String('intc'))
|
| 32 |
+
)
|
| 33 |
+
)
|
| 34 |
+
assert ls[1] == Declaration(
|
| 35 |
+
Variable(
|
| 36 |
+
Symbol('b'),
|
| 37 |
+
type=IntBaseType(String('intc')),
|
| 38 |
+
value=Integer(4)
|
| 39 |
+
)
|
| 40 |
+
)
|
| 41 |
+
assert ls[2] == Declaration(
|
| 42 |
+
Variable(
|
| 43 |
+
Symbol('c'),
|
| 44 |
+
type=FloatType(
|
| 45 |
+
String('float32'),
|
| 46 |
+
nbits=Integer(32),
|
| 47 |
+
nmant=Integer(23),
|
| 48 |
+
nexp=Integer(8)
|
| 49 |
+
)
|
| 50 |
+
)
|
| 51 |
+
)
|
| 52 |
+
assert ls[3] == Declaration(
|
| 53 |
+
Variable(
|
| 54 |
+
Symbol('d'),
|
| 55 |
+
type=FloatType(
|
| 56 |
+
String('float32'),
|
| 57 |
+
nbits=Integer(32),
|
| 58 |
+
nmant=Integer(23),
|
| 59 |
+
nexp=Integer(8)
|
| 60 |
+
),
|
| 61 |
+
value=Float('2.3999999999999999', precision=53)
|
| 62 |
+
)
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def test_fortran_parse():
|
| 67 |
+
expr = SymPyExpression(src, 'f')
|
| 68 |
+
ls = expr.return_expr()
|
| 69 |
+
|
| 70 |
+
assert ls[0] == Declaration(
|
| 71 |
+
Variable(
|
| 72 |
+
Symbol('a'),
|
| 73 |
+
type=IntBaseType(String('integer')),
|
| 74 |
+
value=Integer(0)
|
| 75 |
+
)
|
| 76 |
+
)
|
| 77 |
+
assert ls[1] == Declaration(
|
| 78 |
+
Variable(
|
| 79 |
+
Symbol('b'),
|
| 80 |
+
type=IntBaseType(String('integer')),
|
| 81 |
+
value=Integer(0)
|
| 82 |
+
)
|
| 83 |
+
)
|
| 84 |
+
assert ls[2] == Declaration(
|
| 85 |
+
Variable(
|
| 86 |
+
Symbol('c'),
|
| 87 |
+
type=IntBaseType(String('integer')),
|
| 88 |
+
value=Integer(0)
|
| 89 |
+
)
|
| 90 |
+
)
|
| 91 |
+
assert ls[3] == Declaration(
|
| 92 |
+
Variable(
|
| 93 |
+
Symbol('d'),
|
| 94 |
+
type=IntBaseType(String('integer')),
|
| 95 |
+
value=Integer(0)
|
| 96 |
+
)
|
| 97 |
+
)
|
| 98 |
+
assert ls[4] == Declaration(
|
| 99 |
+
Variable(
|
| 100 |
+
Symbol('p'),
|
| 101 |
+
type=FloatBaseType(String('real')),
|
| 102 |
+
value=Float('0.0', precision=53)
|
| 103 |
+
)
|
| 104 |
+
)
|
| 105 |
+
assert ls[5] == Declaration(
|
| 106 |
+
Variable(
|
| 107 |
+
Symbol('q'),
|
| 108 |
+
type=FloatBaseType(String('real')),
|
| 109 |
+
value=Float('0.0', precision=53)
|
| 110 |
+
)
|
| 111 |
+
)
|
| 112 |
+
assert ls[6] == Declaration(
|
| 113 |
+
Variable(
|
| 114 |
+
Symbol('r'),
|
| 115 |
+
type=FloatBaseType(String('real')),
|
| 116 |
+
value=Float('0.0', precision=53)
|
| 117 |
+
)
|
| 118 |
+
)
|
| 119 |
+
assert ls[7] == Declaration(
|
| 120 |
+
Variable(
|
| 121 |
+
Symbol('s'),
|
| 122 |
+
type=FloatBaseType(String('real')),
|
| 123 |
+
value=Float('0.0', precision=53)
|
| 124 |
+
)
|
| 125 |
+
)
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
def test_convert_py():
|
| 129 |
+
src1 = (
|
| 130 |
+
src +
|
| 131 |
+
"""\
|
| 132 |
+
a = b + c
|
| 133 |
+
s = p * q / r
|
| 134 |
+
"""
|
| 135 |
+
)
|
| 136 |
+
expr1.convert_to_expr(src1, 'f')
|
| 137 |
+
exp_py = expr1.convert_to_python()
|
| 138 |
+
assert exp_py == [
|
| 139 |
+
'a = 0',
|
| 140 |
+
'b = 0',
|
| 141 |
+
'c = 0',
|
| 142 |
+
'd = 0',
|
| 143 |
+
'p = 0.0',
|
| 144 |
+
'q = 0.0',
|
| 145 |
+
'r = 0.0',
|
| 146 |
+
's = 0.0',
|
| 147 |
+
'a = b + c',
|
| 148 |
+
's = p*q/r'
|
| 149 |
+
]
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
def test_convert_fort():
|
| 153 |
+
src1 = (
|
| 154 |
+
src +
|
| 155 |
+
"""\
|
| 156 |
+
a = b + c
|
| 157 |
+
s = p * q / r
|
| 158 |
+
"""
|
| 159 |
+
)
|
| 160 |
+
expr1.convert_to_expr(src1, 'f')
|
| 161 |
+
exp_fort = expr1.convert_to_fortran()
|
| 162 |
+
assert exp_fort == [
|
| 163 |
+
' integer*4 a',
|
| 164 |
+
' integer*4 b',
|
| 165 |
+
' integer*4 c',
|
| 166 |
+
' integer*4 d',
|
| 167 |
+
' real*8 p',
|
| 168 |
+
' real*8 q',
|
| 169 |
+
' real*8 r',
|
| 170 |
+
' real*8 s',
|
| 171 |
+
' a = b + c',
|
| 172 |
+
' s = p*q/r'
|
| 173 |
+
]
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
def test_convert_c():
|
| 177 |
+
src1 = (
|
| 178 |
+
src +
|
| 179 |
+
"""\
|
| 180 |
+
a = b + c
|
| 181 |
+
s = p * q / r
|
| 182 |
+
"""
|
| 183 |
+
)
|
| 184 |
+
expr1.convert_to_expr(src1, 'f')
|
| 185 |
+
exp_c = expr1.convert_to_c()
|
| 186 |
+
assert exp_c == [
|
| 187 |
+
'int a = 0',
|
| 188 |
+
'int b = 0',
|
| 189 |
+
'int c = 0',
|
| 190 |
+
'int d = 0',
|
| 191 |
+
'double p = 0.0',
|
| 192 |
+
'double q = 0.0',
|
| 193 |
+
'double r = 0.0',
|
| 194 |
+
'double s = 0.0',
|
| 195 |
+
'a = b + c;',
|
| 196 |
+
's = p*q/r;'
|
| 197 |
+
]
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
def test_exceptions():
|
| 201 |
+
src = 'int a;'
|
| 202 |
+
raises(ValueError, lambda: SymPyExpression(src))
|
| 203 |
+
raises(ValueError, lambda: SymPyExpression(mode = 'c'))
|
| 204 |
+
raises(NotImplementedError, lambda: SymPyExpression(src, mode = 'd'))
|
| 205 |
+
|
| 206 |
+
elif not lfortran and not cin:
|
| 207 |
+
def test_raise():
|
| 208 |
+
raises(ImportError, lambda: SymPyExpression('int a;', 'c'))
|
| 209 |
+
raises(ImportError, lambda: SymPyExpression('integer :: a', 'f'))
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/parsing/tests/test_sympy_parser.py
ADDED
|
@@ -0,0 +1,371 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
import builtins
|
| 5 |
+
import types
|
| 6 |
+
|
| 7 |
+
from sympy.assumptions import Q
|
| 8 |
+
from sympy.core import Symbol, Function, Float, Rational, Integer, I, Mul, Pow, Eq, Lt, Le, Gt, Ge, Ne
|
| 9 |
+
from sympy.functions import exp, factorial, factorial2, sin, Min, Max
|
| 10 |
+
from sympy.logic import And
|
| 11 |
+
from sympy.series import Limit
|
| 12 |
+
from sympy.testing.pytest import raises
|
| 13 |
+
|
| 14 |
+
from sympy.parsing.sympy_parser import (
|
| 15 |
+
parse_expr, standard_transformations, rationalize, TokenError,
|
| 16 |
+
split_symbols, implicit_multiplication, convert_equals_signs,
|
| 17 |
+
convert_xor, function_exponentiation, lambda_notation, auto_symbol,
|
| 18 |
+
repeated_decimals, implicit_multiplication_application,
|
| 19 |
+
auto_number, factorial_notation, implicit_application,
|
| 20 |
+
_transformation, T
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def test_sympy_parser():
|
| 25 |
+
x = Symbol('x')
|
| 26 |
+
inputs = {
|
| 27 |
+
'2*x': 2 * x,
|
| 28 |
+
'3.00': Float(3),
|
| 29 |
+
'22/7': Rational(22, 7),
|
| 30 |
+
'2+3j': 2 + 3*I,
|
| 31 |
+
'exp(x)': exp(x),
|
| 32 |
+
'x!': factorial(x),
|
| 33 |
+
'x!!': factorial2(x),
|
| 34 |
+
'(x + 1)! - 1': factorial(x + 1) - 1,
|
| 35 |
+
'3.[3]': Rational(10, 3),
|
| 36 |
+
'.0[3]': Rational(1, 30),
|
| 37 |
+
'3.2[3]': Rational(97, 30),
|
| 38 |
+
'1.3[12]': Rational(433, 330),
|
| 39 |
+
'1 + 3.[3]': Rational(13, 3),
|
| 40 |
+
'1 + .0[3]': Rational(31, 30),
|
| 41 |
+
'1 + 3.2[3]': Rational(127, 30),
|
| 42 |
+
'.[0011]': Rational(1, 909),
|
| 43 |
+
'0.1[00102] + 1': Rational(366697, 333330),
|
| 44 |
+
'1.[0191]': Rational(10190, 9999),
|
| 45 |
+
'10!': 3628800,
|
| 46 |
+
'-(2)': -Integer(2),
|
| 47 |
+
'[-1, -2, 3]': [Integer(-1), Integer(-2), Integer(3)],
|
| 48 |
+
'Symbol("x").free_symbols': x.free_symbols,
|
| 49 |
+
"S('S(3).n(n=3)')": Float(3, 3),
|
| 50 |
+
'factorint(12, visual=True)': Mul(
|
| 51 |
+
Pow(2, 2, evaluate=False),
|
| 52 |
+
Pow(3, 1, evaluate=False),
|
| 53 |
+
evaluate=False),
|
| 54 |
+
'Limit(sin(x), x, 0, dir="-")': Limit(sin(x), x, 0, dir='-'),
|
| 55 |
+
'Q.even(x)': Q.even(x),
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
}
|
| 59 |
+
for text, result in inputs.items():
|
| 60 |
+
assert parse_expr(text) == result
|
| 61 |
+
|
| 62 |
+
raises(TypeError, lambda:
|
| 63 |
+
parse_expr('x', standard_transformations))
|
| 64 |
+
raises(TypeError, lambda:
|
| 65 |
+
parse_expr('x', transformations=lambda x,y: 1))
|
| 66 |
+
raises(TypeError, lambda:
|
| 67 |
+
parse_expr('x', transformations=(lambda x,y: 1,)))
|
| 68 |
+
raises(TypeError, lambda: parse_expr('x', transformations=((),)))
|
| 69 |
+
raises(TypeError, lambda: parse_expr('x', {}, [], []))
|
| 70 |
+
raises(TypeError, lambda: parse_expr('x', [], [], {}))
|
| 71 |
+
raises(TypeError, lambda: parse_expr('x', [], [], {}))
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
def test_rationalize():
|
| 75 |
+
inputs = {
|
| 76 |
+
'0.123': Rational(123, 1000)
|
| 77 |
+
}
|
| 78 |
+
transformations = standard_transformations + (rationalize,)
|
| 79 |
+
for text, result in inputs.items():
|
| 80 |
+
assert parse_expr(text, transformations=transformations) == result
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
def test_factorial_fail():
|
| 84 |
+
inputs = ['x!!!', 'x!!!!', '(!)']
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
for text in inputs:
|
| 88 |
+
try:
|
| 89 |
+
parse_expr(text)
|
| 90 |
+
assert False
|
| 91 |
+
except TokenError:
|
| 92 |
+
assert True
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
def test_repeated_fail():
|
| 96 |
+
inputs = ['1[1]', '.1e1[1]', '0x1[1]', '1.1j[1]', '1.1[1 + 1]',
|
| 97 |
+
'0.1[[1]]', '0x1.1[1]']
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
# All are valid Python, so only raise TypeError for invalid indexing
|
| 101 |
+
for text in inputs:
|
| 102 |
+
raises(TypeError, lambda: parse_expr(text))
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
inputs = ['0.1[', '0.1[1', '0.1[]']
|
| 106 |
+
for text in inputs:
|
| 107 |
+
raises((TokenError, SyntaxError), lambda: parse_expr(text))
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
def test_repeated_dot_only():
|
| 111 |
+
assert parse_expr('.[1]') == Rational(1, 9)
|
| 112 |
+
assert parse_expr('1 + .[1]') == Rational(10, 9)
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
def test_local_dict():
|
| 116 |
+
local_dict = {
|
| 117 |
+
'my_function': lambda x: x + 2
|
| 118 |
+
}
|
| 119 |
+
inputs = {
|
| 120 |
+
'my_function(2)': Integer(4)
|
| 121 |
+
}
|
| 122 |
+
for text, result in inputs.items():
|
| 123 |
+
assert parse_expr(text, local_dict=local_dict) == result
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
def test_local_dict_split_implmult():
|
| 127 |
+
t = standard_transformations + (split_symbols, implicit_multiplication,)
|
| 128 |
+
w = Symbol('w', real=True)
|
| 129 |
+
y = Symbol('y')
|
| 130 |
+
assert parse_expr('yx', local_dict={'x':w}, transformations=t) == y*w
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def test_local_dict_symbol_to_fcn():
|
| 134 |
+
x = Symbol('x')
|
| 135 |
+
d = {'foo': Function('bar')}
|
| 136 |
+
assert parse_expr('foo(x)', local_dict=d) == d['foo'](x)
|
| 137 |
+
d = {'foo': Symbol('baz')}
|
| 138 |
+
raises(TypeError, lambda: parse_expr('foo(x)', local_dict=d))
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
def test_global_dict():
|
| 142 |
+
global_dict = {
|
| 143 |
+
'Symbol': Symbol
|
| 144 |
+
}
|
| 145 |
+
inputs = {
|
| 146 |
+
'Q & S': And(Symbol('Q'), Symbol('S'))
|
| 147 |
+
}
|
| 148 |
+
for text, result in inputs.items():
|
| 149 |
+
assert parse_expr(text, global_dict=global_dict) == result
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
def test_no_globals():
|
| 153 |
+
|
| 154 |
+
# Replicate creating the default global_dict:
|
| 155 |
+
default_globals = {}
|
| 156 |
+
exec('from sympy import *', default_globals)
|
| 157 |
+
builtins_dict = vars(builtins)
|
| 158 |
+
for name, obj in builtins_dict.items():
|
| 159 |
+
if isinstance(obj, types.BuiltinFunctionType):
|
| 160 |
+
default_globals[name] = obj
|
| 161 |
+
default_globals['max'] = Max
|
| 162 |
+
default_globals['min'] = Min
|
| 163 |
+
|
| 164 |
+
# Need to include Symbol or parse_expr will not work:
|
| 165 |
+
default_globals.pop('Symbol')
|
| 166 |
+
global_dict = {'Symbol':Symbol}
|
| 167 |
+
|
| 168 |
+
for name in default_globals:
|
| 169 |
+
obj = parse_expr(name, global_dict=global_dict)
|
| 170 |
+
assert obj == Symbol(name)
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
def test_issue_2515():
|
| 174 |
+
raises(TokenError, lambda: parse_expr('(()'))
|
| 175 |
+
raises(TokenError, lambda: parse_expr('"""'))
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
def test_issue_7663():
|
| 179 |
+
x = Symbol('x')
|
| 180 |
+
e = '2*(x+1)'
|
| 181 |
+
assert parse_expr(e, evaluate=False) == parse_expr(e, evaluate=False)
|
| 182 |
+
assert parse_expr(e, evaluate=False).equals(2*(x+1))
|
| 183 |
+
|
| 184 |
+
def test_recursive_evaluate_false_10560():
|
| 185 |
+
inputs = {
|
| 186 |
+
'4*-3' : '4*-3',
|
| 187 |
+
'-4*3' : '(-4)*3',
|
| 188 |
+
"-2*x*y": '(-2)*x*y',
|
| 189 |
+
"x*-4*x": "x*(-4)*x"
|
| 190 |
+
}
|
| 191 |
+
for text, result in inputs.items():
|
| 192 |
+
assert parse_expr(text, evaluate=False) == parse_expr(result, evaluate=False)
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
def test_function_evaluate_false():
|
| 196 |
+
inputs = [
|
| 197 |
+
'Abs(0)', 'im(0)', 're(0)', 'sign(0)', 'arg(0)', 'conjugate(0)',
|
| 198 |
+
'acos(0)', 'acot(0)', 'acsc(0)', 'asec(0)', 'asin(0)', 'atan(0)',
|
| 199 |
+
'acosh(0)', 'acoth(0)', 'acsch(0)', 'asech(0)', 'asinh(0)', 'atanh(0)',
|
| 200 |
+
'cos(0)', 'cot(0)', 'csc(0)', 'sec(0)', 'sin(0)', 'tan(0)',
|
| 201 |
+
'cosh(0)', 'coth(0)', 'csch(0)', 'sech(0)', 'sinh(0)', 'tanh(0)',
|
| 202 |
+
'exp(0)', 'log(0)', 'sqrt(0)',
|
| 203 |
+
]
|
| 204 |
+
for case in inputs:
|
| 205 |
+
expr = parse_expr(case, evaluate=False)
|
| 206 |
+
assert case == str(expr) != str(expr.doit())
|
| 207 |
+
assert str(parse_expr('ln(0)', evaluate=False)) == 'log(0)'
|
| 208 |
+
assert str(parse_expr('cbrt(0)', evaluate=False)) == '0**(1/3)'
|
| 209 |
+
|
| 210 |
+
|
| 211 |
+
def test_issue_10773():
|
| 212 |
+
inputs = {
|
| 213 |
+
'-10/5': '(-10)/5',
|
| 214 |
+
'-10/-5' : '(-10)/(-5)',
|
| 215 |
+
}
|
| 216 |
+
for text, result in inputs.items():
|
| 217 |
+
assert parse_expr(text, evaluate=False) == parse_expr(result, evaluate=False)
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
def test_split_symbols():
|
| 221 |
+
transformations = standard_transformations + \
|
| 222 |
+
(split_symbols, implicit_multiplication,)
|
| 223 |
+
x = Symbol('x')
|
| 224 |
+
y = Symbol('y')
|
| 225 |
+
xy = Symbol('xy')
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
assert parse_expr("xy") == xy
|
| 229 |
+
assert parse_expr("xy", transformations=transformations) == x*y
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
def test_split_symbols_function():
|
| 233 |
+
transformations = standard_transformations + \
|
| 234 |
+
(split_symbols, implicit_multiplication,)
|
| 235 |
+
x = Symbol('x')
|
| 236 |
+
y = Symbol('y')
|
| 237 |
+
a = Symbol('a')
|
| 238 |
+
f = Function('f')
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
assert parse_expr("ay(x+1)", transformations=transformations) == a*y*(x+1)
|
| 242 |
+
assert parse_expr("af(x+1)", transformations=transformations,
|
| 243 |
+
local_dict={'f':f}) == a*f(x+1)
|
| 244 |
+
|
| 245 |
+
|
| 246 |
+
def test_functional_exponent():
|
| 247 |
+
t = standard_transformations + (convert_xor, function_exponentiation)
|
| 248 |
+
x = Symbol('x')
|
| 249 |
+
y = Symbol('y')
|
| 250 |
+
a = Symbol('a')
|
| 251 |
+
yfcn = Function('y')
|
| 252 |
+
assert parse_expr("sin^2(x)", transformations=t) == (sin(x))**2
|
| 253 |
+
assert parse_expr("sin^y(x)", transformations=t) == (sin(x))**y
|
| 254 |
+
assert parse_expr("exp^y(x)", transformations=t) == (exp(x))**y
|
| 255 |
+
assert parse_expr("E^y(x)", transformations=t) == exp(yfcn(x))
|
| 256 |
+
assert parse_expr("a^y(x)", transformations=t) == a**(yfcn(x))
|
| 257 |
+
|
| 258 |
+
|
| 259 |
+
def test_match_parentheses_implicit_multiplication():
|
| 260 |
+
transformations = standard_transformations + \
|
| 261 |
+
(implicit_multiplication,)
|
| 262 |
+
raises(TokenError, lambda: parse_expr('(1,2),(3,4]',transformations=transformations))
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
def test_convert_equals_signs():
|
| 266 |
+
transformations = standard_transformations + \
|
| 267 |
+
(convert_equals_signs, )
|
| 268 |
+
x = Symbol('x')
|
| 269 |
+
y = Symbol('y')
|
| 270 |
+
assert parse_expr("1*2=x", transformations=transformations) == Eq(2, x)
|
| 271 |
+
assert parse_expr("y = x", transformations=transformations) == Eq(y, x)
|
| 272 |
+
assert parse_expr("(2*y = x) = False",
|
| 273 |
+
transformations=transformations) == Eq(Eq(2*y, x), False)
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
def test_parse_function_issue_3539():
|
| 277 |
+
x = Symbol('x')
|
| 278 |
+
f = Function('f')
|
| 279 |
+
assert parse_expr('f(x)') == f(x)
|
| 280 |
+
|
| 281 |
+
def test_issue_24288():
|
| 282 |
+
assert parse_expr("1 < 2", evaluate=False) == Lt(1, 2, evaluate=False)
|
| 283 |
+
assert parse_expr("1 <= 2", evaluate=False) == Le(1, 2, evaluate=False)
|
| 284 |
+
assert parse_expr("1 > 2", evaluate=False) == Gt(1, 2, evaluate=False)
|
| 285 |
+
assert parse_expr("1 >= 2", evaluate=False) == Ge(1, 2, evaluate=False)
|
| 286 |
+
assert parse_expr("1 != 2", evaluate=False) == Ne(1, 2, evaluate=False)
|
| 287 |
+
assert parse_expr("1 == 2", evaluate=False) == Eq(1, 2, evaluate=False)
|
| 288 |
+
assert parse_expr("1 < 2 < 3", evaluate=False) == And(Lt(1, 2, evaluate=False), Lt(2, 3, evaluate=False), evaluate=False)
|
| 289 |
+
assert parse_expr("1 <= 2 <= 3", evaluate=False) == And(Le(1, 2, evaluate=False), Le(2, 3, evaluate=False), evaluate=False)
|
| 290 |
+
assert parse_expr("1 < 2 <= 3 < 4", evaluate=False) == \
|
| 291 |
+
And(Lt(1, 2, evaluate=False), Le(2, 3, evaluate=False), Lt(3, 4, evaluate=False), evaluate=False)
|
| 292 |
+
# Valid Python relational operators that SymPy does not decide how to handle them yet
|
| 293 |
+
raises(ValueError, lambda: parse_expr("1 in 2", evaluate=False))
|
| 294 |
+
raises(ValueError, lambda: parse_expr("1 is 2", evaluate=False))
|
| 295 |
+
raises(ValueError, lambda: parse_expr("1 not in 2", evaluate=False))
|
| 296 |
+
raises(ValueError, lambda: parse_expr("1 is not 2", evaluate=False))
|
| 297 |
+
|
| 298 |
+
def test_split_symbols_numeric():
|
| 299 |
+
transformations = (
|
| 300 |
+
standard_transformations +
|
| 301 |
+
(implicit_multiplication_application,))
|
| 302 |
+
|
| 303 |
+
n = Symbol('n')
|
| 304 |
+
expr1 = parse_expr('2**n * 3**n')
|
| 305 |
+
expr2 = parse_expr('2**n3**n', transformations=transformations)
|
| 306 |
+
assert expr1 == expr2 == 2**n*3**n
|
| 307 |
+
|
| 308 |
+
expr1 = parse_expr('n12n34', transformations=transformations)
|
| 309 |
+
assert expr1 == n*12*n*34
|
| 310 |
+
|
| 311 |
+
|
| 312 |
+
def test_unicode_names():
|
| 313 |
+
assert parse_expr('α') == Symbol('α')
|
| 314 |
+
|
| 315 |
+
|
| 316 |
+
def test_python3_features():
|
| 317 |
+
assert parse_expr("123_456") == 123456
|
| 318 |
+
assert parse_expr("1.2[3_4]") == parse_expr("1.2[34]") == Rational(611, 495)
|
| 319 |
+
assert parse_expr("1.2[012_012]") == parse_expr("1.2[012012]") == Rational(400, 333)
|
| 320 |
+
assert parse_expr('.[3_4]') == parse_expr('.[34]') == Rational(34, 99)
|
| 321 |
+
assert parse_expr('.1[3_4]') == parse_expr('.1[34]') == Rational(133, 990)
|
| 322 |
+
assert parse_expr('123_123.123_123[3_4]') == parse_expr('123123.123123[34]') == Rational(12189189189211, 99000000)
|
| 323 |
+
|
| 324 |
+
|
| 325 |
+
def test_issue_19501():
|
| 326 |
+
x = Symbol('x')
|
| 327 |
+
eq = parse_expr('E**x(1+x)', local_dict={'x': x}, transformations=(
|
| 328 |
+
standard_transformations +
|
| 329 |
+
(implicit_multiplication_application,)))
|
| 330 |
+
assert eq.free_symbols == {x}
|
| 331 |
+
|
| 332 |
+
|
| 333 |
+
def test_parsing_definitions():
|
| 334 |
+
from sympy.abc import x
|
| 335 |
+
assert len(_transformation) == 12 # if this changes, extend below
|
| 336 |
+
assert _transformation[0] == lambda_notation
|
| 337 |
+
assert _transformation[1] == auto_symbol
|
| 338 |
+
assert _transformation[2] == repeated_decimals
|
| 339 |
+
assert _transformation[3] == auto_number
|
| 340 |
+
assert _transformation[4] == factorial_notation
|
| 341 |
+
assert _transformation[5] == implicit_multiplication_application
|
| 342 |
+
assert _transformation[6] == convert_xor
|
| 343 |
+
assert _transformation[7] == implicit_application
|
| 344 |
+
assert _transformation[8] == implicit_multiplication
|
| 345 |
+
assert _transformation[9] == convert_equals_signs
|
| 346 |
+
assert _transformation[10] == function_exponentiation
|
| 347 |
+
assert _transformation[11] == rationalize
|
| 348 |
+
assert T[:5] == T[0,1,2,3,4] == standard_transformations
|
| 349 |
+
t = _transformation
|
| 350 |
+
assert T[-1, 0] == (t[len(t) - 1], t[0])
|
| 351 |
+
assert T[:5, 8] == standard_transformations + (t[8],)
|
| 352 |
+
assert parse_expr('0.3x^2', transformations='all') == 3*x**2/10
|
| 353 |
+
assert parse_expr('sin 3x', transformations='implicit') == sin(3*x)
|
| 354 |
+
|
| 355 |
+
|
| 356 |
+
def test_builtins():
|
| 357 |
+
cases = [
|
| 358 |
+
('abs(x)', 'Abs(x)'),
|
| 359 |
+
('max(x, y)', 'Max(x, y)'),
|
| 360 |
+
('min(x, y)', 'Min(x, y)'),
|
| 361 |
+
('pow(x, y)', 'Pow(x, y)'),
|
| 362 |
+
]
|
| 363 |
+
for built_in_func_call, sympy_func_call in cases:
|
| 364 |
+
assert parse_expr(built_in_func_call) == parse_expr(sympy_func_call)
|
| 365 |
+
assert str(parse_expr('pow(38, -1, 97)')) == '23'
|
| 366 |
+
|
| 367 |
+
|
| 368 |
+
def test_issue_22822():
|
| 369 |
+
raises(ValueError, lambda: parse_expr('x', {'': 1}))
|
| 370 |
+
data = {'some_parameter': None}
|
| 371 |
+
assert parse_expr('some_parameter is None', data) is True
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/physics/__init__.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
A module that helps solving problems in physics.
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
from . import units
|
| 6 |
+
from .matrices import mgamma, msigma, minkowski_tensor, mdft
|
| 7 |
+
|
| 8 |
+
__all__ = [
|
| 9 |
+
'units',
|
| 10 |
+
|
| 11 |
+
'mgamma', 'msigma', 'minkowski_tensor', 'mdft',
|
| 12 |
+
]
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/physics/biomechanics/__init__.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Biomechanics extension for SymPy.
|
| 2 |
+
|
| 3 |
+
Includes biomechanics-related constructs which allows users to extend multibody
|
| 4 |
+
models created using `sympy.physics.mechanics` into biomechanical or
|
| 5 |
+
musculoskeletal models involding musculotendons and activation dynamics.
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
from .activation import (
|
| 10 |
+
ActivationBase,
|
| 11 |
+
FirstOrderActivationDeGroote2016,
|
| 12 |
+
ZerothOrderActivation,
|
| 13 |
+
)
|
| 14 |
+
from .curve import (
|
| 15 |
+
CharacteristicCurveCollection,
|
| 16 |
+
CharacteristicCurveFunction,
|
| 17 |
+
FiberForceLengthActiveDeGroote2016,
|
| 18 |
+
FiberForceLengthPassiveDeGroote2016,
|
| 19 |
+
FiberForceLengthPassiveInverseDeGroote2016,
|
| 20 |
+
FiberForceVelocityDeGroote2016,
|
| 21 |
+
FiberForceVelocityInverseDeGroote2016,
|
| 22 |
+
TendonForceLengthDeGroote2016,
|
| 23 |
+
TendonForceLengthInverseDeGroote2016,
|
| 24 |
+
)
|
| 25 |
+
from .musculotendon import (
|
| 26 |
+
MusculotendonBase,
|
| 27 |
+
MusculotendonDeGroote2016,
|
| 28 |
+
MusculotendonFormulation,
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
__all__ = [
|
| 33 |
+
# Musculotendon characteristic curve functions
|
| 34 |
+
'CharacteristicCurveCollection',
|
| 35 |
+
'CharacteristicCurveFunction',
|
| 36 |
+
'FiberForceLengthActiveDeGroote2016',
|
| 37 |
+
'FiberForceLengthPassiveDeGroote2016',
|
| 38 |
+
'FiberForceLengthPassiveInverseDeGroote2016',
|
| 39 |
+
'FiberForceVelocityDeGroote2016',
|
| 40 |
+
'FiberForceVelocityInverseDeGroote2016',
|
| 41 |
+
'TendonForceLengthDeGroote2016',
|
| 42 |
+
'TendonForceLengthInverseDeGroote2016',
|
| 43 |
+
|
| 44 |
+
# Activation dynamics classes
|
| 45 |
+
'ActivationBase',
|
| 46 |
+
'FirstOrderActivationDeGroote2016',
|
| 47 |
+
'ZerothOrderActivation',
|
| 48 |
+
|
| 49 |
+
# Musculotendon classes
|
| 50 |
+
'MusculotendonBase',
|
| 51 |
+
'MusculotendonDeGroote2016',
|
| 52 |
+
'MusculotendonFormulation',
|
| 53 |
+
]
|
ScaleDF_rebuttal/python_dedup_pkgs/sympy/physics/biomechanics/_mixin.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Mixin classes for sharing functionality between unrelated classes.
|
| 2 |
+
|
| 3 |
+
This module is named with a leading underscore to signify to users that it's
|
| 4 |
+
"private" and only intended for internal use by the biomechanics module.
|
| 5 |
+
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
__all__ = ['_NamedMixin']
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
class _NamedMixin:
|
| 13 |
+
"""Mixin class for adding `name` properties.
|
| 14 |
+
|
| 15 |
+
Valid names, as will typically be used by subclasses as a suffix when
|
| 16 |
+
naming automatically-instantiated symbol attributes, must be nonzero length
|
| 17 |
+
strings.
|
| 18 |
+
|
| 19 |
+
Attributes
|
| 20 |
+
==========
|
| 21 |
+
|
| 22 |
+
name : str
|
| 23 |
+
The name identifier associated with the instance. Must be a string of
|
| 24 |
+
length at least 1.
|
| 25 |
+
|
| 26 |
+
"""
|
| 27 |
+
|
| 28 |
+
@property
|
| 29 |
+
def name(self) -> str:
|
| 30 |
+
"""The name associated with the class instance."""
|
| 31 |
+
return self._name
|
| 32 |
+
|
| 33 |
+
@name.setter
|
| 34 |
+
def name(self, name: str) -> None:
|
| 35 |
+
if hasattr(self, '_name'):
|
| 36 |
+
msg = (
|
| 37 |
+
f'Can\'t set attribute `name` to {repr(name)} as it is '
|
| 38 |
+
f'immutable.'
|
| 39 |
+
)
|
| 40 |
+
raise AttributeError(msg)
|
| 41 |
+
if not isinstance(name, str):
|
| 42 |
+
msg = (
|
| 43 |
+
f'Name {repr(name)} passed to `name` was of type '
|
| 44 |
+
f'{type(name)}, must be {str}.'
|
| 45 |
+
)
|
| 46 |
+
raise TypeError(msg)
|
| 47 |
+
if name in {''}:
|
| 48 |
+
msg = (
|
| 49 |
+
f'Name {repr(name)} is invalid, must be a nonzero length '
|
| 50 |
+
f'{type(str)}.'
|
| 51 |
+
)
|
| 52 |
+
raise ValueError(msg)
|
| 53 |
+
self._name = name
|