Upload folder using huggingface_hub (part 15)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- .gitattributes+19
- .venv/lib/python3.12/site-packages/sympy-1.14.0.dist-info/INSTALLERAdded+1
- .venv/lib/python3.12/site-packages/sympy-1.14.0.dist-info/METADATAAdded+319
- .venv/lib/python3.12/site-packages/sympy-1.14.0.dist-info/RECORDAdded
- .venv/lib/python3.12/site-packages/sympy-1.14.0.dist-info/REQUESTEDAdded
- .venv/lib/python3.12/site-packages/sympy-1.14.0.dist-info/WHEELAdded+5
- .venv/lib/python3.12/site-packages/sympy-1.14.0.dist-info/entry_points.txtAdded+2
- .venv/lib/python3.12/site-packages/sympy-1.14.0.dist-info/licenses/AUTHORSAdded+1379
- .venv/lib/python3.12/site-packages/sympy-1.14.0.dist-info/licenses/LICENSEAdded+153
- .venv/lib/python3.12/site-packages/sympy-1.14.0.dist-info/top_level.txtAdded+2
- .venv/lib/python3.12/site-packages/sympy/vector/functions.pyAdded+513
- .venv/lib/python3.12/site-packages/sympy/vector/implicitregion.pyAdded+506
- .venv/lib/python3.12/site-packages/sympy/vector/integrals.pyAdded+206
- .venv/lib/python3.12/site-packages/sympy/vector/kind.pyAdded+67
- .venv/lib/python3.12/site-packages/sympy/vector/operators.pyAdded+335
- .venv/lib/python3.12/site-packages/sympy/vector/orienters.pyAdded+398
- .venv/lib/python3.12/site-packages/sympy/vector/parametricregion.pyAdded+189
- .venv/lib/python3.12/site-packages/sympy/vector/point.pyAdded+148
- .venv/lib/python3.12/site-packages/sympy/vector/scalar.pyAdded+72
- .venv/lib/python3.12/site-packages/sympy/vector/tests/__init__.pyAdded
- .venv/lib/python3.12/site-packages/sympy/vector/tests/test_coordsysrect.pyAdded+464
- .venv/lib/python3.12/site-packages/sympy/vector/tests/test_dyadic.pyAdded+134
- .venv/lib/python3.12/site-packages/sympy/vector/tests/test_field_functions.pyAdded+321
- .venv/lib/python3.12/site-packages/sympy/vector/tests/test_functions.pyAdded+184
- .venv/lib/python3.12/site-packages/sympy/vector/tests/test_implicitregion.pyAdded+90
- .venv/lib/python3.12/site-packages/sympy/vector/tests/test_integrals.pyAdded+106
- .venv/lib/python3.12/site-packages/sympy/vector/tests/test_operators.pyAdded+43
- .venv/lib/python3.12/site-packages/sympy/vector/tests/test_parametricregion.pyAdded+97
- .venv/lib/python3.12/site-packages/sympy/vector/tests/test_printing.pyAdded+221
- .venv/lib/python3.12/site-packages/sympy/vector/tests/test_vector.pyAdded+342
- .venv/lib/python3.12/site-packages/sympy/vector/vector.pyAdded+714
- .venv/lib/python3.12/site-packages/tokenizers-0.21.2.dist-info/INSTALLERAdded+1
- .venv/lib/python3.12/site-packages/tokenizers-0.21.2.dist-info/METADATAAdded+210
- .venv/lib/python3.12/site-packages/tokenizers-0.21.2.dist-info/RECORDAdded+30
- .venv/lib/python3.12/site-packages/tokenizers-0.21.2.dist-info/REQUESTEDAdded
- .venv/lib/python3.12/site-packages/tokenizers-0.21.2.dist-info/WHEELAdded+4
- .venv/lib/python3.12/site-packages/tokenizers/__init__.pyAdded+100
- .venv/lib/python3.12/site-packages/tokenizers/__init__.pyiAdded+1238
- .venv/lib/python3.12/site-packages/tokenizers/__pycache__/__init__.cpython-312.pycAdded
- .venv/lib/python3.12/site-packages/tokenizers/decoders/__init__.pyAdded+15
- .venv/lib/python3.12/site-packages/tokenizers/decoders/__init__.pyiAdded+279
- .venv/lib/python3.12/site-packages/tokenizers/decoders/__pycache__/__init__.cpython-312.pycAdded
- .venv/lib/python3.12/site-packages/tokenizers/implementations/__init__.pyAdded+6
- .venv/lib/python3.12/site-packages/tokenizers/implementations/__pycache__/__init__.cpython-312.pycAdded
- .venv/lib/python3.12/site-packages/tokenizers/implementations/__pycache__/base_tokenizer.cpython-312.pycAdded
- .venv/lib/python3.12/site-packages/tokenizers/implementations/__pycache__/bert_wordpiece.cpython-312.pycAdded
- .venv/lib/python3.12/site-packages/tokenizers/implementations/__pycache__/byte_level_bpe.cpython-312.pycAdded
- .venv/lib/python3.12/site-packages/tokenizers/implementations/__pycache__/char_level_bpe.cpython-312.pycAdded
- .venv/lib/python3.12/site-packages/tokenizers/implementations/__pycache__/sentencepiece_bpe.cpython-312.pycAdded
- .venv/lib/python3.12/site-packages/tokenizers/implementations/__pycache__/sentencepiece_unigram.cpython-312.pycAdded
193 unmodified lines194195196193 unmodified lines.venv/lib/python3.12/site-packages/sympy/solvers/ode/__pycache__/ode.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/sympy/solvers/ode/__pycache__/single.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/sympy/utilities/__pycache__/iterables.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text193 unmodified lines194195196197198199200201202203204205206207208209210211212213214215193 unmodified lines.venv/lib/python3.12/site-packages/sympy/solvers/ode/__pycache__/ode.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/sympy/solvers/ode/__pycache__/single.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/sympy/utilities/__pycache__/iterables.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/tokenizers/tokenizers.abi3.so filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/torch/__pycache__/__init__.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/torch/__pycache__/_meta_registrations.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/torch/__pycache__/_tensor_docs.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/torch/__pycache__/_torch_docs.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/torch/__pycache__/overrides.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/torch/_decomp/__pycache__/decompositions.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/torch/_dynamo/__pycache__/guards.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/torch/_dynamo/__pycache__/output_graph.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/torch/_dynamo/__pycache__/symbolic_convert.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/torch/_dynamo/__pycache__/trace_rules.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/torch/_dynamo/__pycache__/utils.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/torch/_dynamo/variables/__pycache__/builder.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/torch/_dynamo/variables/__pycache__/builtin.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/torch/_dynamo/variables/__pycache__/functions.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/torch/_dynamo/variables/__pycache__/higher_order_ops.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/torch/_inductor/__pycache__/utils.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/torch/_refs/__pycache__/__init__.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text.venv/lib/python3.12/site-packages/torch/_subclasses/__pycache__/fake_tensor.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
1uv123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319Metadata-Version: 2.4Name: sympyVersion: 1.14.0Summary: Computer algebra system (CAS) in PythonHome-page: https://sympy.orgAuthor: SymPy development teamAuthor-email: sympy@googlegroups.comLicense: BSDProject-URL: Source, https://github.com/sympy/sympyKeywords: Math CASClassifier: License :: OSI Approved :: BSD LicenseClassifier: Operating System :: OS IndependentClassifier: Programming Language :: PythonClassifier: Topic :: Scientific/EngineeringClassifier: Topic :: Scientific/Engineering :: MathematicsClassifier: Topic :: Scientific/Engineering :: PhysicsClassifier: Programming Language :: Python :: 3Classifier: Programming Language :: Python :: 3.9Classifier: Programming Language :: Python :: 3.10Classifier: Programming Language :: Python :: 3.11Classifier: Programming Language :: Python :: 3.12Classifier: Programming Language :: Python :: 3.13Classifier: Programming Language :: Python :: 3 :: OnlyClassifier: Programming Language :: Python :: Implementation :: CPythonClassifier: Programming Language :: Python :: Implementation :: PyPyRequires-Python: >=3.9Description-Content-Type: text/markdownLicense-File: LICENSELicense-File: AUTHORSRequires-Dist: mpmath<1.4,>=1.1.0Provides-Extra: devRequires-Dist: pytest>=7.1.0; extra == "dev"Requires-Dist: hypothesis>=6.70.0; extra == "dev"Dynamic: authorDynamic: author-emailDynamic: classifierDynamic: descriptionDynamic: description-content-typeDynamic: home-pageDynamic: keywordsDynamic: licenseDynamic: license-fileDynamic: project-urlDynamic: provides-extraDynamic: requires-distDynamic: requires-pythonDynamic: summary
# SymPy
[](https://pypi.python.org/pypi/sympy)[](https://gitter.im/sympy/sympy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)[](https://zenodo.org/badge/latestdoi/18918/sympy/sympy)[](https://pepy.tech/project/sympy)[](https://github.com/sympy/sympy/issues)[](https://git-scm.com/book/en/v2/GitHub-Contributing-to-a-Project)[](https://numfocus.org)[](https://github.com/sympy/sympy/releases)
[](https://sympy.org/)
See the [AUTHORS](AUTHORS) file for the list of authors.
And many more people helped on the SymPy mailing list, reported bugs,helped organize SymPy's participation in the Google Summer of Code, theGoogle Highly Open Participation Contest, Google Code-In, wrote andblogged about SymPy...
License: New BSD License (see the [LICENSE](LICENSE) file for details) covers allfiles in the sympy repository unless stated otherwise.
Our mailing list is at<https://groups.google.com/forum/?fromgroups#!forum/sympy>.
We have a community chat at [Gitter](https://gitter.im/sympy/sympy). Feelfree to ask us anything there. We have a very welcoming and helpfulcommunity.
## Download
The recommended installation method is through Anaconda,<https://www.anaconda.com/products/distribution>
You can also get the latest version of SymPy from<https://pypi.python.org/pypi/sympy/>
To get the git version do
$ git clone https://github.com/sympy/sympy.git
For other options (tarballs, debs, etc.), see<https://docs.sympy.org/dev/install.html>.
## Documentation and Usage
For in-depth instructions on installation and building thedocumentation, see the [SymPy Documentation Style Guide](https://docs.sympy.org/dev/documentation-style-guide.html).
Everything is at:
<https://docs.sympy.org/>
You can generate everything at the above site in your local copy ofSymPy by:
$ cd doc $ make html
Then the docs will be in <span class="title-ref">\_build/html</span>. Ifyou don't want to read that, here is a short usage:
From this directory, start Python and:
``` python>>> from sympy import Symbol, cos>>> x = Symbol('x')>>> e = 1/cos(x)>>> print(e.series(x, 0, 10))1 + x**2/2 + 5*x**4/24 + 61*x**6/720 + 277*x**8/8064 + O(x**10)```
SymPy also comes with a console that is a simple wrapper around theclassic python console (or IPython when available) that loads the SymPynamespace and executes some common commands for you.
To start it, issue:
$ bin/isympy
from this directory, if SymPy is not installed or simply:
$ isympy
if SymPy is installed.
## Installation
To install SymPy using PyPI, run the following command:
$ pip install sympy
To install SymPy using Anaconda, run the following command:
$ conda install -c anaconda sympy
To install SymPy from GitHub source, first clone SymPy using `git`:
$ git clone https://github.com/sympy/sympy.git
Then, in the `sympy` repository that you cloned, simply run:
$ pip install .
See <https://docs.sympy.org/dev/install.html> for more information.
## Contributing
We welcome contributions from anyone, even if you are new to opensource. Please read our [Introduction to Contributing](https://docs.sympy.org/dev/contributing/introduction-to-contributing.html)page and the [SymPy Documentation Style Guide](https://docs.sympy.org/dev/documentation-style-guide.html). If youare new and looking for some way to contribute, a good place to start isto 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).
Please note that all participants in this project are expected to followour Code of Conduct. By participating in this project you agree to abideby its terms. See [CODE\_OF\_CONDUCT.md](CODE_OF_CONDUCT.md).
## Tests
To execute all tests, run:
$./setup.py test
in the current directory.
For the more fine-grained running of tests or doctests, use `bin/test`or respectively `bin/doctest`. The master branch is automatically testedby GitHub Actions.
To test pull requests, use[sympy-bot](https://github.com/sympy/sympy-bot).
## Regenerate Experimental <span class="title-ref">LaTeX</span> Parser/Lexer
The parser and lexer were generated with the [ANTLR4](http://antlr4.org)toolchain in `sympy/parsing/latex/_antlr` and checked into the repo.Presently, most users should not need to regenerate these files, butif you plan to work on this feature, you will need the `antlr4`command-line tool (and you must ensure that it is in your `PATH`).One way to get it is:
$ conda install -c conda-forge antlr=4.11.1
Alternatively, follow the instructions on the ANTLR website and downloadthe `antlr-4.11.1-complete.jar`. Then export the `CLASSPATH` as instructedand instead of creating `antlr4` as an alias, make it an executable filewith the following contents:``` bash#!/bin/bashjava -jar /usr/local/lib/antlr-4.11.1-complete.jar "$@"```
After making changes to `sympy/parsing/latex/LaTeX.g4`, run:
$ ./setup.py antlr
## Clean
To clean everything (thus getting the same tree as in the repository):
$ git clean -Xdf
which will clear everything ignored by `.gitignore`, and:
$ git clean -df
to clear all untracked files. You can revert the most recent changes ingit with:
$ git reset --hard
WARNING: The above commands will all clear changes you may have made,and you will lose them forever. Be sure to check things with `gitstatus`, `git diff`, `git clean -Xn`, and `git clean -n` before doing anyof those.
## Bugs
Our issue tracker is at <https://github.com/sympy/sympy/issues>. Pleasereport any bugs that you find. Or, even better, fork the repository onGitHub and create a pull request. We welcome all changes, big or small,and we will help you make the pull request if you are new to git (justask on our mailing list or Gitter Channel). If you further have any queries, you can find answerson Stack Overflow using the [sympy](https://stackoverflow.com/questions/tagged/sympy) tag.
## Brief History
SymPy was started by Ondřej Čertík in 2005, he wrote some code duringthe summer, then he wrote some more code during summer 2006. In February2007, Fabian Pedregosa joined the project and helped fix many things,contributed documentation, and made it alive again. 5 students (MateuszPaprocki, Brian Jorgensen, Jason Gedge, Robert Schwarz, and Chris Wu)improved SymPy incredibly during summer 2007 as part of the GoogleSummer of Code. Pearu Peterson joined the development during the summer2007 and he has made SymPy much more competitive by rewriting the corefrom scratch, which has made it from 10x to 100x faster. Jurjen N.E. Boshas contributed pretty-printing and other patches. Fredrik Johansson haswritten mpmath and contributed a lot of patches.
SymPy has participated in every Google Summer of Code since 2007. Youcan see <https://github.com/sympy/sympy/wiki#google-summer-of-code> forfull details. Each year has improved SymPy by bounds. Most of SymPy'sdevelopment has come from Google Summer of Code students.
In 2011, Ondřej Čertík stepped down as lead developer, with AaronMeurer, who also started as a Google Summer of Code student, taking hisplace. Ondřej Čertík is still active in the community but is too busywith work and family to play a lead development role.
Since then, a lot more people have joined the development and somepeople have also left. You can see the full list in doc/src/aboutus.rst,or online at:
<https://docs.sympy.org/dev/aboutus.html#sympy-development-team>
The git history goes back to 2007 when development moved from svn to hg.To see the history before that point, look at<https://github.com/sympy/sympy-old>.
You can use git to see the biggest developers. The command:
$ git shortlog -ns
will show each developer, sorted by commits to the project. The command:
$ git shortlog -ns --since="1 year"
will show the top developers from the last year.
## Citation
To cite SymPy in publications use
> Meurer A, Smith CP, Paprocki M, Čertík O, Kirpichev SB, Rocklin M,> Kumar A, Ivanov S, Moore JK, Singh S, Rathnayake T, Vig S, Granger BE,> Muller RP, Bonazzi F, Gupta H, Vats S, Johansson F, Pedregosa F, Curry> MJ, Terrel AR, Roučka Š, Saboo A, Fernando I, Kulal S, Cimrman R,> Scopatz A. (2017) SymPy: symbolic computing in Python. *PeerJ Computer> Science* 3:e103 <https://doi.org/10.7717/peerj-cs.103>
A BibTeX entry for LaTeX users is
``` bibtex@article{10.7717/peerj-cs.103, title = {SymPy: symbolic computing in Python}, 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}, year = 2017, month = Jan, keywords = {Python, Computer algebra system, Symbolics}, abstract = { 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. }, volume = 3, pages = {e103}, journal = {PeerJ Computer Science}, issn = {2376-5992}, url = {https://doi.org/10.7717/peerj-cs.103}, doi = {10.7717/peerj-cs.103}}```
SymPy is BSD licensed, so you are free to use it whatever you like, beit academic, commercial, creating forks or derivatives, as long as youcopy the BSD statement if you redistribute it (see the LICENSE file fordetails). That said, although not required by the SymPy license, if itis convenient for you, please cite SymPy when using it in your work andalso consider contributing all your changes back, so that we canincorporate it and all of us will benefit in the end.12345Wheel-Version: 1.0Generator: setuptools (79.0.1)Root-Is-Purelib: trueTag: py3-none-any
12[console_scripts]isympy = isympy:main12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379All people who contributed to SymPy by sending at least a patch ormore (in the order of the date of their first contribution), exceptthose who explicitly didn't want to be mentioned. People with a * nextto their names are not found in the metadata of the git history. Thisfile is generated automatically by running `./bin/authors_update.py`.
There are a total of 1371 authors.
Ondřej Čertík <ondrej@certik.cz>Fabian Pedregosa <fabian@fseoane.net>Jurjen N.E. Bos <jnebos@gmail.com>Mateusz Paprocki <mattpap@gmail.com>*Marc-Etienne M.Leveille <protonyc@gmail.com>Brian Jorgensen <brian.jorgensen@gmail.com>Jason Gedge <inferno1386@gmail.com>Robert Schwarz <lethargo@googlemail.com>Pearu Peterson <pearu.peterson@gmail.com>Fredrik Johansson <fredrik.johansson@gmail.com>Chris Wu <chris.wu@gmail.com>*Ulrich Hecht <ulrich.hecht@gmail.com>Goutham Lakshminarayan <dl.goutham@gmail.com>David Lawrence <dmlawrence@gmail.com>Jaroslaw Tworek <dev.jrx@gmail.com>David Marek <h4wk.cz@gmail.com>Bernhard R. Link <brlink@debian.org>Andrej Tokarčík <androsis@gmail.com>Or Dvory <gidesa@gmail.com>Saroj Adhikari <adh.saroj@gmail.com>Pauli Virtanen <pav@iki.fi>Robert Kern <robert.kern@gmail.com>James Aspnes <aspnes@cs.yale.edu>Nimish Telang <ntelang@gmail.com>Abderrahim Kitouni <a.kitouni@gmail.com>Pan Peng <pengpanster@gmail.com>Friedrich Hagedorn <friedrich_h@gmx.de>Elrond der Elbenfuerst <elrond+sympy.org@samba-tng.org>Rizgar Mella <rizgar.mella@gmail.com>Felix Kaiser <felix.kaiser@fxkr.net>Roberto Nobrega <rwnobrega@gmail.com>David Roberts <dvdr18@gmail.com>Sebastian Krämer <basti.kr@gmail.com>Vinzent Steinberg <vinzent.steinberg@gmail.com>Riccardo Gori <goriccardo@gmail.com>Case Van Horsen <casevh@gmail.com>Stepan Roucka <stepan@roucka.eu>Ali Raza Syed <arsyed@gmail.com>Stefano Maggiolo <s.maggiolo@gmail.com>Robert Cimrman <cimrman3@ntc.zcu.cz>Bastian Weber <bastian.weber@gmx-topmail.de>Sebastian Krause <sebastian.krause@gmx.de>Sebastian Kreft <skreft@gmail.com>*Dan <coolg49964@gmail.com>Alan Bromborsky <abrombo@verizon.net>Boris Timokhin <qoqenator@gmail.com>Robert <average.programmer@gmail.com>Andy R. Terrel <aterrel@uchicago.edu>Hubert Tsang <intsangity@gmail.com>Konrad Meyer <konrad.meyer@gmail.com>Henrik Johansson <henjo2006@gmail.com>Priit Laes <plaes@plaes.org>Freddie Witherden <freddie@witherden.org>Brian E. Granger <ellisonbg@gmail.com>Andrew Straw <strawman@astraw.com>Kaifeng Zhu <cafeeee@gmail.com>Ted Horst <ted.horst@earthlink.net>Andrew Docherty <andrewd@maths.usyd.edu.au>Akshay Srinivasan <akshaysrinivasan@gmail.com>Aaron Meurer <asmeurer@gmail.com>Barry Wardell <barry.wardell@gmail.com>Tomasz Buchert <thinred@gmail.com>Vinay Kumar <gnulinooks@gmail.com>Johann Cohen-Tanugi <johann.cohentanugi@gmail.com>Jochen Voss <voss@seehuhn.de>Luke Peterson <hazelnusse@gmail.com>Chris Smith <smichr@gmail.com>Thomas Sidoti <TSidoti@gmail.com>Florian Mickler <florian@mickler.org>Nicolas Pourcelot <nicolas.pourcelot@gmail.com>Ben Goodrich <goodrich.ben@gmail.com>Toon Verstraelen <Toon.Verstraelen@UGent.be>Ronan Lamy <ronan.lamy@gmail.com>James Abbatiello <abbeyj@gmail.com>Ryan Krauss <ryanlists@gmail.com>Bill Flynn <wflynny@gmail.com>Kevin Goodsell <kevin-opensource@omegacrash.net>Jorn Baayen <jorn.baayen@gmail.com>Eh Tan <tan2tan2@gmail.com>Renato Coutinho <renato.coutinho@gmail.com>Oscar Benjamin <oscar.j.benjamin@gmail.com>Øyvind Jensen <jensen.oyvind@gmail.com>Julio Idichekop Filho <idichekop@yahoo.com.br>Łukasz Pankowski <lukpank@o2.pl>*Chu-Ching Huang <cchuang@mail.cgu.edu.tw>Fernando Perez <Fernando.Perez@berkeley.edu>Raffaele De Feo <alberthilbert@gmail.com>Christian Muise <christian.muise@gmail.com>Matt Curry <mattjcurry@gmail.com>Kazuo Thow <kazuo.thow@gmail.com>Christian Schubert <chr.schubert@gmx.de>Jezreel Ng <jezreel@gmail.com>James Pearson <xiong.chiamiov@gmail.com>Matthew Brett <matthew.brett@gmail.com>Addison Cugini <ajcugini@gmail.com>Nicholas J.S. Kinar <n.kinar@usask.ca>Harold Erbin <harold.erbin@gmail.com>Thomas Dixon <thom@thomdixon.org>Cristóvão Sousa <crisjss@gmail.com>Andre de Fortier Smit <freevryheid@gmail.com>Mark Dewing <markdewing@gmail.com>Alexey U. Gudchenko <proga@goodok.ru>Gary Kerr <gary.kerr@blueyonder.co.uk>Sherjil Ozair <sherjilozair@gmail.com>Oleksandr Gituliar <gituliar@gmail.com>Sean Vig <sean.v.775@gmail.com>Prafullkumar P. Tale <hector1618@gmail.com>Vladimir Perić <vlada.peric@gmail.com>Tom Bachmann <e_mc_h2@web.de>Yuri Karadzhov <yuri.karadzhov@gmail.com>Vladimir Lagunov <werehuman@gmail.com>Matthew Rocklin <mrocklin@cs.uchicago.edu>Saptarshi Mandal <sapta.iitkgp@gmail.com>Gilbert Gede <gilbertgede@gmail.com>Anatolii Koval <weralwolf@gmail.com>Tomo Lazovich <lazovich@gmail.com>Pavel Fedotov <fedotovp@gmail.com>Jack McCaffery <jpmccaffery@gmail.com>Jeremias Yehdegho <j.yehdegho@gmail.com>Kibeom Kim <kk1674@nyu.edu>Gregory Ksionda <ksiondag846@gmail.com>Tomáš Bambas <tomas.bambas@gmail.com>Raymond Wong <rayman_407@yahoo.com>Luca Weihs <astronomicalcuriosity@gmail.com>Shai 'Deshe' Wyborski <shaide@cs.huji.ac.il>Thomas Wiecki <thomas.wiecki@gmail.com>Óscar Nájera <najera.oscar@gmail.com>Mario Pernici <mario.pernici@gmail.com>Benjamin McDonald <mcdonald.ben@gmail.com>Sam Magura <samtheman132@gmail.com>Stefan Krastanov <krastanov.stefan@gmail.com>Bradley Froehle <brad.froehle@gmail.com>Min Ragan-Kelley <benjaminrk@gmail.com>Emma Hogan <ehogan@gemini.edu>Nikhil Sarda <diff.operator@gmail.com>Julien Rioux <julien.rioux@gmail.com>Roberto Colistete, Jr. <roberto.colistete@gmail.com>Raoul Bourquin <raoulb@bluewin.ch>Gert-Ludwig Ingold <gert.ingold@physik.uni-augsburg.de>Srinivas Vasudevan <srvasude@gmail.com>Jason Moore <moorepants@gmail.com>Miha Marolt <tloramus@gmail.com>Tim Lahey <tim.lahey@gmail.com>Luis Garcia <ppn.online@me.com>Matt Rajca <matt.rajca@me.com>David Li <l33tnerd.li@gmail.com>Alexandr Gudulin <alexandr.gudulin@gmail.com>Bilal Akhtar <bilalakhtar@ubuntu.com>Grzegorz Świrski <sognat@gmail.com>Matt Habel <habelinc@gmail.com>David Ju <Sgtmook314@gmail.com>Nichita Utiu <nikita.utiu+github@gmail.com>Nikolay Lazarov <qwerqwerqwer@abv.bg>Steve Anton <anxuiz.nx@gmail.com>Imran Ahmed Manzoor <imran.manzoor31@gmail.com>Ljubiša Moćić <3rdslasher@gmail.com>Piotr Korgul <p.korgul@gmail.com>Jim Zhang <Hyriodula@gmail.com>Sam Sleight <samuel.sleight@gmail.com>tborisova <ts.borisova3@gmail.com>Chancellor Arkantos <Chancellor_Arkantos@hotmail.co.uk>Stepan Simsa <simsa.st@gmail.com>Tobias Lenz <t_lenz94@web.de>Siddhanathan Shanmugam <siddhanathan@gmail.com>Tiffany Zhu <bubble.wubble.303@gmail.com>Tristan Hume <tris.hume@gmail.com>Alexey Subach <alexey.subach@gmail.com>Joan Creus <joan.creus.c@gmail.com>Geoffry Song <goffrie@gmail.com>Puneeth Chaganti <punchagan@gmail.com>Marcin Kostrzewa <>Natalia Nawara <fankalemura@gmail.com>vishal <vishal.panjwani15@gmail.com>Shruti Mangipudi <shruti2395@gmail.com>Davy Mao <e_equals_mass_speed_light_squared@hotmail.com>Swapnil Agarwal <swapnilag29@gmail.com>Dhia Kennouche <kendhia@gmail.com>jerryma1121 <jerryma1121@gmail.com>Joachim Durchholz <jo@durchholz.org>Martin Povišer <martin.povik@gmail.com>Siddhant Jain <getsiddhant@gmail.com>Kevin Hunter <hunteke@earlham.edu>Michael Mayorov <marchael@kb.csu.ru>Nathan Alison <nathan.f.alison@gmail.com>Christian Bühler <christian@cbuehler.de>Carsten Knoll <CarstenKnoll@gmx.de>Bharath M R <catchmrbharath@gmail.com>Matthias Toews <mat.toews@googlemail.com>Sergiu Ivanov <unlimitedscolobb@gmail.com>Jorge E. Cardona <jorgeecardona@gmail.com>Sanket Agarwal <sanket@sanketagarwal.com>Manoj Babu K. <manoj.babu2378@gmail.com>Sai Nikhil <tsnlegend@gmail.com>Aleksandar Makelov <amakelov@college.harvard.edu>Sachin Irukula <sachin.irukula@gmail.com>Raphael Michel <webmaster@raphaelmichel.de>Ashwini Oruganti <ashwini.oruganti@gmail.com>Andreas Klöckner <inform@tiker.net>Prateek Papriwal <papriwalprateek@gmail.com>Arpit Goyal <agmps18@gmail.com>Angadh Nanjangud <angadh.n@gmail.com>Comer Duncan <comer.duncan@gmail.com>Jens H. Nielsen <jenshnielsen@gmail.com>Joseph Dougherty <Github@JWDougherty.com>Elliot Marshall <Marshall2389@gmail.com>Guru Devanla <grdvnl@gmail.com>George Waksman <waksman@gwax.com>Alexandr Popov <alexandr.s.popov@gmail.com>Tarun Gaba <tarun.gaba7@gmail.com>Takafumi Arakaki <aka.tkf@gmail.com>Saurabh Jha <saurabh.jhaa@gmail.com>Rom le Clair <jacen.guardian@gmail.com>Angus Griffith <16sn6uv@gmail.com>Timothy Reluga <treluga@math.psu.edu>Brian Stephanik <xoedusk@gmail.com>Alexander Eberspächer <alex.eberspaecher@gmail.com>Sachin Joglekar <srjoglekar246@gmail.com>Tyler Pirtle <teeler@gmail.com>Vasily Povalyaev <vapovalyaev@gmail.com>Colleen Lee <colleenclee@gmail.com>Matthew Hoff <mhoff14@gmail.com>Niklas Thörne <notrupertthorne@gmail.com>Huijun Mai <m.maihuijun@gmail.com>Marek Šuppa <mr@shu.io>Ramana Venkata <idlike2dream@gmail.com>Prasoon Shukla <prasoon92.iitr@gmail.com>Stefen Yin <zqyin@ucdavis.edu>Thomas Hisch <t.hisch@gmail.com>Madeleine Ball <mpball@gmail.com>Mary Clark <mary.spriteling@gmail.com>Rishabh Dixit <rishabhdixit11@gmail.com>Manoj Kumar <manojkumarsivaraj334@gmail.com>Akshit Agarwal <akshit.jiit@gmail.com>CJ Carey <perimosocordiae@gmail.com>Patrick Lacasse <patrick.m.lacasse@gmail.com>Ananya H <ananyaha93@gmail.com>Tarang Patel <tarangrockr@gmail.com>Christopher Dembia <cld72@cornell.edu>Benjamin Fishbein <fishbeinb@gmail.com>Sean Ge <seange727@gmail.com>Amit Jamadagni <bitsjamadagni@gmail.com>Ankit Agrawal <aaaagrawal@iitb.ac.in>Björn Dahlgren <bjodah@gmail.com>Christophe Saint-Jean <christophe.saint-jean@univ-lr.fr>Demian Wassermann <demian@bwh.harvard.edu>Khagesh Patel <khageshpatel93@gmail.com>Stephen Loo <shikil@yahoo.com>hm <hacman0@gmail.com>Patrick Poitras <acebulf@gmail.com>Katja Sophie Hotz <katja.sophie.hotz@student.tuwien.ac.at>Varun Joshi <joshi.142@osu.edu>Chetna Gupta <cheta.gup@gmail.com>Thilina Rathnayake <thilinarmtb@gmail.com>Max Hutchinson <maxhutch@gmail.com>Shravas K Rao <shravas@gmail.com>Matthew Tadd <matt.tadd@gmail.com>Alexander Hirzel <alex@hirzel.us>Randy Heydon <randy.heydon@clockworklab.net>Oliver Lee <oliverzlee@gmail.com>Seshagiri Prabhu <seshagiriprabhu@gmail.com>Pradyumna <pradyu1993@gmail.com>Erik Welch <erik.n.welch@gmail.com>Eric Nelson <eric.the.red.XLII@gmail.com>Roland Puntaier <roland.puntaier@chello.at>Chris Conley <chrisconley15@gmail.com>Tim Swast <tswast@gmail.com>Dmitry Batkovich <batya239@gmail.com>Francesco Bonazzi <franz.bonazzi@gmail.com>Yuriy Demidov <iurii.demidov@gmail.com>Rick Muller <rpmuller@gmail.com>Manish Gill <gill.manish90@gmail.com>Markus Müller <markus.mueller.1.g@googlemail.com>Amit Saha <amitsaha.in@gmail.com>Jeremy <twobitlogic@gmail.com>QuaBoo <kisonchristian@gmail.com>Stefan van der Walt <stefan@sun.ac.za>David Joyner <wdjoyner@gmail.com>Lars Buitinck <larsmans@gmail.com>Alkiviadis G. Akritas <akritas@uth.gr>Vinit Ravishankar <vinit.ravishankar@gmail.com>Michael Boyle <michael.oliver.boyle@gmail.com>Heiner Kirchhoffer <Heiner.Kirchhoffer@gmail.com>Pablo Puente <ppuedom@gmail.com>James Fiedler <jrfiedler@gmail.com>Harsh Gupta <mail@hargup.in>Tuomas Airaksinen <tuomas.airaksinen@gmail.com>Paul Strickland <p.e.strickland@gmail.com>James Goppert <james.goppert@gmail.com>rathmann <rathmann.os@gmail.com>Avichal Dayal <avichal.dayal@gmail.com>Paul Scott <paul.scott@nicta.com.au>Shipra Banga <bangashipra@gmail.com>Pramod Ch <pramodch14@gmail.com>Akshay <akshaynukala95@gmail.com>Buck Shlegeris <buck2@bruceh15.anu.edu.au>Jonathan Miller <jdmiller93@gmail.com>Edward Schembor <eschemb1@jhu.edu>Rajath Shashidhara <rajaths.rajaths@gmail.com>Zamrath Nizam <zamiguy_ni@yahoo.com>Aditya Shah <adityashah30@gmail.com>Rajat Aggarwal <rajataggarwal1975@gmail.com>Sambuddha Basu <sammygamer@live.com>Zeel Shah <kshah215@gmail.com>Abhinav Chanda <abhinavchanda01@gmail.com>Jim Crist <crist042@umn.edu>Sudhanshu Mishra <mrsud94@gmail.com>Anurag Sharma <anurags92@gmail.com>Soumya Dipta Biswas <sdb1323@gmail.com>Sushant Hiray <hiraysushant@gmail.com>Ben Lucato <ben.lucato@gmail.com>Kunal Arora <kunalarora.135@gmail.com>Henry Gebhardt <hsggebhardt@gmail.com>Dammina Sahabandu <dmsahabandu@gmail.com>Manish Shukla <manish.shukla393@gmail>Ralph Bean <rbean@redhat.com>richierichrawr <richierichrawr@users.noreply.github.com>John Connor <john.theman.connor@gmail.com>Juan Luis Cano Rodríguez <juanlu001@gmail.com>Sahil Shekhawat <sahilshekhawat01@gmail.com>Kundan Kumar <kundankumar18581@gmail.com>Stas Kelvich <stanconn@gmail.com>sevaader <sevaader@gmail.com>Dhruvesh Vijay Parikh <parikhdhruvesh1@gmail.com>Venkatesh Halli <venkatesh.fatality@gmail.com>Lennart Fricke <lennart@die-frickes.eu>Vlad Seghete <vlad.seghete@gmail.com>Shashank Agarwal <shashank.agarwal94@gmail.com>carstimon <carstimon@gmail.com>Pierre Haessig <pierre.haessig@crans.org>Maciej Baranski <getrox.sc@gmail.com>Benjamin Gudehus <hastebrot@gmail.com>Faisal Anees <faisal.iiit@gmail.com>Mark Shoulson <mark@kli.org>Robert Johansson <jrjohansson@gmail.com>Kalevi Suominen <jksuom@gmail.com>Kaushik Varanasi <kaushik.varanasi1@gmail.com>Fawaz Alazemi <Mba7eth@gmail.com>Ambar Mehrotra <mehrotraambar@gmail.com>David P. Sanders <dpsanders@gmail.com>Peter Brady <petertbrady@gmail.com>John V. Siratt <jvsiratt@gmail.com>Sarwar Chahal <chahal.sarwar98@gmail.com>Nathan Woods <charlesnwoods@gmail.com>Colin B. Macdonald <cbm@m.fsf.org>Marcus Näslund <naslundx@gmail.com>Clemens Novak <clemens@familie-novak.net>Mridul Seth <seth.mridul@gmail.com>Craig A. Stoudt <craig.stoudt@gmail.com>Raj <raj454raj@gmail.com>Mihai A. Ionescu <ionescu.a.mihai@gmail.com>immerrr <immerrr@gmail.com>Chai Wah Wu <cwwuieee@gmail.com>Leonid Blouvshtein <leonidbl91@gmail.com>Peleg Michaeli <freepeleg@gmail.com>ck Lux <lux.r.ck@gmail.com>zsc347 <zsc347@gmail.com>Hamish Dickson <hamish.dickson@gmail.com>Michael Gallaspy <gallaspy.michael@gmail.com>Roman Inflianskas <infroma@gmail.com>Duane Nykamp <nykamp@umn.edu>Ted Dokos <tdokos@gmail.com>Sunny Aggarwal <sunnyaggarwal1994@gmail.com>Victor Brebenar <v.brebenar@gmail.com>Akshat Jain <akshat.jain@students.iiit.ac.in>Shivam Vats <shivamvats.iitkgp@gmail.com>Longqi Wang <iqgnol@gmail.com>Juan Felipe Osorio <jfosorio@gmail.com>Ray Cathcart <github@cathcart.us>Lukas Zorich <lukas.zorich@gmail.com>Eric Miller <emiller42@gmail.com>Cody Herbst <cyherbst@gmail.com>Nishith Shah <nishithshah.2211@gmail.com>Amit Kumar <dtu.amit@gmail.com>Yury G. Kudryashov <urkud.urkud@gmail.com>Guillaume Gay <contact@damcb.com>Mihir Wadwekar <m.mihirw@gmail.com>Tuan Manh Lai <laituan245@gmail.com>Asish Panda <asishrocks95@gmail.com>Darshan Chaudhary <deathbullet@gmail.com>Alec Kalinin <alec.kalinin@gmail.com>Ralf Stephan <ralf@ark.in-berlin.de>Aaditya Nair <aadityanair6494@gmail.com>Jayesh Lahori <jlahori92@gmail.com>Harshil Goel <harshil158@gmail.com>Luv Agarwal <agarwal.iiit@gmail.com>Jason Ly <jason.ly@gmail.com>Lokesh Sharma <lokeshhsharma@gmail.com>Sartaj Singh <singhsartaj94@gmail.com>Chris Swierczewski <cswiercz@gmail.com>Konstantin Togoi <konstantin.togoi@gmail.com>Param Singh <paramsingh258@gmail.com>Sumith Kulal <sumith1896@gmail.com>Juha Remes <jremes@outlook.com>Philippe Bouafia <philippe.bouafia@ensea.fr>Peter Schmidt <peter@peterjs.com>Jiaxing Liang <liangjiaxing57@gmail.com>Lucas Jones <lucas@lucasjones.co.uk>Gregory Ashton <gash789@gmail.com>Jennifer White <jcrw122@googlemail.com>Renato Orsino <renato.orsino@gmail.com>Alistair Lynn <arplynn@gmail.com>Govind Sahai <gsiitbhu@gmail.com>Adam Bloomston <adam@glitterfram.es>Kyle McDaniel <mcdanie5@illinois.edu>Nguyen Truong Duy <truongduy134@yahoo.com>Alex Lindsay <adlinds3@ncsu.edu>Mathew Chong <mathewchong.dev@gmail.com>Jason Siefken <siefkenj@gmail.com>Gaurav Dhingra <gauravdhingra.gxyd@gmail.com>Gao, Xiang <qasdfgtyuiop@gmail.com>Kevin Ventullo <kevin.ventullo@gmail.com>mao8 <thisisma08@gmail.com>Isuru Fernando <isuruf@gmail.com>Shivam Tyagi <shivam.tyagi.apm13@itbhu.ac.in>Richard Otis <richard.otis@outlook.com>Rich LaSota <rjlasota@gmail.com>dustyrockpyle <dustyrockpyle@gmail.com>Anton Akhmerov <anton.akhmerov@gmail.com>Michael Zingale <michael.zingale@stonybrook.edu>Chak-Pong Chung <chakpongchung@gmail.com>David T <derDavidT@users.noreply.github.com>Phil Ruffwind <rf@rufflewind.com>Sebastian Koslowski <koslowski@kit.edu>Kumar Krishna Agrawal <kumar.1994.14@gmail.com>Dustin Gadal <Dustin.Gadal@gmail.com>João Moura <operte@gmail.com>Yu Kobayashi <yukoba@accelart.jp>Shashank Kumar <shashank.kumar.apc13@iitbhu.ac.in>Timothy Cyrus <tcyrus@users.noreply.github.com>Devyani Kota <devyanikota@gmail.com>Keval Shah <kevalshah_96@yahoo.co.in>Dzhelil Rufat <drufat@caltech.edu>Pastafarianist <mr.pastafarianist@gmail.com>Sourav Singh <souravsingh@users.noreply.github.com>Jacob Garber <jgarber1@ualberta.ca>Vinay Singh <csvinay.d@gmail.com>GolimarOurHero <metalera94@hotmail.com>Prashant Tyagi <prashanttyagi221295@gmail.com>Matthew Davis <davisml.md@gmail.com>Tschijnmo TSCHAU <tschijnmotschau@gmail.com>Alexander Bentkamp <bentkamp@gmail.com>Jack Kemp <metaknightdrake-git@yahoo.co.uk>Kshitij Saraogi <KshitijSaraogi@gmail.com>Thomas Baruchel <baruchel@gmx.com>Nicolás Guarín-Zapata <nicoguarin@gmail.com>Jens Jørgen Mortensen <jj@smoerhul.dk>Sampad Kumar Saha <sampadsaha5@gmail.com>Eva Charlotte Mayer <eva-charlotte.mayer@posteo.de>Laura Domine <temigo@gmx.com>Justin Blythe <jblythe29@gmail.com>Meghana Madhyastha <meghana.madhyastha@gmail.com>Tanu Hari Dixit <tokencolour@gmail.com>Shekhar Prasad Rajak <shekharrajak@live.com>Aqnouch Mohammed <aqnouch.mohammed@gmail.com>Arafat Dad Khan <arafat.da.khan@gmail.com>Boris Atamanovskiy <shaomoron@gmail.com>Sam Tygier <sam.tygier@hep.manchester.ac.uk>Jai Luthra <me@jailuthra.in>Guo Xingjian <Seeker1995@gmail.com>Sandeep Veethu <sandeep.veethu@gmail.com>Archit Verma <architv07@gmail.com>Shubham Tibra <shubh.tibra@gmail.com>Ashutosh Saboo <ashutosh.saboo96@gmail.com>Michael S. Hansen <michael.hansen@nih.gov>Anish Shah <shah.anish07@gmail.com>Guillaume Jacquenot <guillaume.jacquenot@gmail.com>Bhautik Mavani <mavanibhautik@gmail.com>Michał Radwański <enedil.isildur@gmail.com>Jerry Li <jerry@jerryli.ca>Pablo Zubieta <pabloferz@yahoo.com.mx>Shivam Agarwal <knowthyself2503@gmail.com>Chaitanya Sai Alaparthi <achaitanyasai@gmail.com>Arihant Parsoya <parsoyaarihant@gmail.com>Ruslan Pisarev <rpisarev@cloudlinux.com>Akash Trehan <akash.trehan123@gmail.com>Nishant Nikhil <nishantiam@gmail.com>Vladimir Poluhsin <vovapolu@gmail.com>Akshay Nagar <awesomeay13@yahoo.com>James Brandon Milam <jmilam343@gmail.com>Abhinav Agarwal <abhinavagarwal1996@gmail.com>Rishabh Daal <rishabhdaal@gmail.com>Sanya Khurana <sanya@monica.in>Aman Deep <amandeep1024@gmail.com>Aravind Reddy <aravindreddy255@gmail.com>Abhishek Verma <iamvermaabhishek@gmail.com>Matthew Parnell <matt@parnmatt.co.uk>Thomas Hickman <Thomas.Hickman42@gmail.com>Akshay Siramdas <akshaysiramdas@gmail.com>YiDing Jiang <yidinggjiangg@gmail.com>Jatin Yadav <jatinyadav25@gmail.com>Matthew Thomas <mnmt@users.noreply.github.com>Rehas Sachdeva <aquannie@gmail.com>Michael Mueller <michaeldmueller7@gmail.com>Srajan Garg <srajan.garg@gmail.com>Prabhjot Singh <prabhjot.nith@gmail.com>Haruki Moriguchi <harukimoriguchi@gmail.com>Tom Gijselinck <tomgijselinck@gmail.com>Nitin Chaudhary <nitinmax1000@gmail.com>Alex Argunov <sajkoooo@gmail.com>Nathan Musoke <nathan.musoke@gmail.com>Abhishek Garg <abhishekgarg119@gmail.com>Dana Jacobsen <dana@acm.org>Vasiliy Dommes <vasdommes@gmail.com>Phillip Berndt <phillip.berndt@googlemail.com>Haimo Zhang <zh.hammer.dev@gmail.com>Anthony Scopatz <scopatz@gmail.com>bluebrook <perl4logic@gmail.com>Leonid Kovalev <leonidvkovalev@gmail.com>Josh Burkart <jburkart@gmail.com>Dimitra Konomi <t8130064@dias.aueb.gr>Christina Zografou <t8130048@dias.aueb.gr>Fiach Antaw <fiach.antaw+github@gmail.com>Langston Barrett <langston.barrett@gmail.com>Krit Karan <kritkaran.b13@iiits.in>G. D. McBain <gdmcbain@protonmail.com>Prempal Singh <prempal.42@gmail.com>Gabriel Orisaka <orisaka@gmail.com>Matthias Bussonnier <bussonniermatthias@gmail.com>rahuldan <rahul02013@gmail.com>Colin Marquardt <github@marquardt-home.de>Andrew Taber <andrew.e.taber@gmail.com>Yash Reddy <write2yashreddy@gmail.com>Peter Stangl <peter.stangl@ph.tum.de>elvis-sik <e.sikora@grad.ufsc.br>Nikos Karagiannakis <nikoskaragiannakis@gmail.com>Jainul Vaghasia <jainulvaghasia@gmail.com>Dennis Meckel <meckel@datenschuppen.de>Harshil Meena <harshil.7535@gmail.com>Micky <mickydroch@gmail.com>Nick Curtis <nicholas.curtis@uconn.edu>Michele Zaffalon <michele.zaffalon@gmail.com>Martha Giannoudovardi <maapxa@gmail.com>Devang Kulshreshtha <devang.kulshreshtha.cse14@itbhu.ac.in>Steph Papanik <spapanik21@gmail.com>Mohammad Sadeq Dousti <msdousti@gmail.com>Arif Ahmed <arif.ahmed.5.10.1995@gmail.com>Abdullah Javed Nesar <abduljaved1994@gmail.com>Lakshya Agrawal <zeeshan.lakshya@gmail.com>shruti <shrutishrm512@gmail.com>Rohit Rango <rohit.rango@gmail.com>Hong Xu <hong@topbug.net>Ivan Petuhov <ivan@ostrovok.ru>Alsheh <alsheh@rpi.edu>Marcel Stimberg <marcel.stimberg@ens.fr>Alexey Pakhocmhik <cool.Bakov@yandex.ru>Tommy Olofsson <tommy.olofsson.90@gmail.com>Zulfikar <zulfikar97@gmail.com>Blair Azzopardi <blairuk@gmail.com>Danny Hermes <daniel.j.hermes@gmail.com>Sergey Pestov <pestov-sa@yandex.ru>Mohit Chandra <mohit.chandra@research.iiit.ac.in>Karthik Chintapalli <karthik.chintapalli@students.iiit.ac.in>Marcin Briański <marcin.brianski@student.uj.edu.pl>andreo <andrey.torba@gmail.com>Flamy Owl <flamyowl@protonmail.ch>Yicong Guo <guoyicong100@gmail.com>Varun Garg <varun.garg03@gmail.com>Rishabh Madan <rishabhmadan96@gmail.com>Aditya Kapoor <aditya.kapoor.apm12@itbhu.ac.in>Karan Sharma <karan1276@gmail.com>Vedant Rathore <vedantr1998@gmail.com>Johan Blåbäck <johan_bluecreek@riseup.net>Pranjal Tale <pranjaltale16@gmail.com>Jason Tokayer <jason.tokayer@gmail.com>Raghav Jajodia <jajodia.raghav@gmail.com>Rajat Thakur <rajatthakur1997@gmail.com>Dhruv Bhanushali <dhruv_b@live.com>Anjul Kumar Tyagi <anjul.ten@gmail.com>Barun Parruck <barun.parruck@gmail.com>Bao Chau <chauquocbao0907@gmail.com>Tanay Agrawal <tanay_agrawal@hotmail.com>Ranjith Kumar <ranjith.dakshana2015@gmail.com>Shikhar Makhija <shikharmakhija2@gmail.com>Yathartha Joshi <yathartha32@gmail.com>Valeriia Gladkova <valeriia.gladkova@gmail.com>Sagar Bharadwaj <sagarbharadwaj50@gmail.com>Daniel Mahler <dmahler@gmail.com>Ka Yi <chua.kayi@yahoo.com.sg>Rishat Iskhakov <iskhakov@frtk.ru>Szymon Mieszczak <szymon.mieszczak@gmail.com>Sachin Agarwal <sachinagarwal0499@gmail.com>Priyank Patel <pspbot7@gmail.com>Satya Prakash Dwibedi <akash581050@gmail.com>tools4origins <tools4origins@gmail.com>Nico Schlömer <nico.schloemer@gmail.com>Fermi Paradox <FermiParadox@users.noreply.github.com>Ekansh Purohit <purohit.e15@gmail.com>Vedarth Sharma <vedarth.sharma@gmail.com>Peeyush Kushwaha <peeyush.p97@gmail.com>Jayjayyy <vfhsln8s3l4b87t4c3@byom.de>Christopher J. Wright <cjwright4242gh@gmail.com>Jakub Wilk <jwilk@jwilk.net>Mauro Garavello <mauro.garavello@unimib.it>Chris Tefer <ctefer@gmail.com>Shikhar Jaiswal <jaiswalshikhar87@gmail.com>Chiu-Hsiang Hsu <wdv4758h@gmail.com>Carlos Cordoba <ccordoba12@gmail.com>Fabian Ball <fabian.ball@kit.edu>Yerniyaz <yerniyaz.nurgabylov@nu.edu.kz>Christiano Anderson <canderson@riseup.net>Robin Neatherway <robin.neatherway@gmail.com>Thomas Hunt <thomashunt13@gmail.com>Theodore Han <theodorehan@hotmail.com>Duc-Minh Phan <alephvn@gmail.com>Lejla Metohajrova <l.metohajrova@gmail.com>Samyak Jain <samyak.jain2016a@vitstudent.ac.in>Aditya Rohan <riyuzakiiitk@gmail.com>Vincent Delecroix <vincent.delecroix@labri.fr>Michael Sparapany <msparapa@purdue.edu>Harsh Jain <harshjniitr@gmail.com>Nathan Goldbaum <ngoldbau@illinois.edu>latot <felipematas@yahoo.com>Kenneth Lyons <ixjlyons@gmail.com>Stan Schymanski <stan.schymanski@env.ethz.ch>David Daly <david.daly12@kzoo.edu>Ayush Shridhar <ayush.shridhar1999@gmail.com>Javed Nissar <javednissar@gmail.com>Jiri Kuncar <jiri.kuncar@gmail.com>vedantc98 <vedantc98@gmail.com>Rupesh Harode <rupeshharode@gmail.com>Rob Zinkov <rob@zinkov.com>James Harrop <ebc121@gmail.com>James Taylor <user234683@tutanota.com>Ishan Joshi <ishanaj98@gmail.com>Marco Mancini <marco.mancini@obspm.fr>Boris Ettinger <ettinger.boris@gmail.com>Micah Fitch <micahscopes@gmail.com>Daniel Wennberg <daniel.wennberg@gmail.com>ylemkimon <ylemkimon@naver.com>Akash Vaish <akash.9712@gmail.com>Peter Enenkel <peter.enenkel+git@gmail.com>Waldir Pimenta <waldyrious@gmail.com>Jithin D. George <jithindgeorge93@gmail.com>Lev Chelyadinov <leva181777@gmail.com>Lucas Wiman <lucas.wiman@gmail.com>Rhea Parekh <rheaparekh12@gmail.com>James Cotton <peabody124@gmail.com>Robert Pollak <robert.pollak@posteo.net>anca-mc <anca-mc@users.noreply.github.com>Sourav Ghosh <souravghosh2197@gmail.com>Jonathan Allan <jjallan@users.noreply.github.com>Nikhil Pappu <nkhlpappu@gmail.com>Ethan Ward <etkewa@gmail.com>Cezary Marczak <zeddq1@gmail.com>dps7ud <dps7ud@virginia.edu>Nilabja Bhattacharya <nilabja10201992@gmail.com>Itay4 <31018228+Itay4@users.noreply.github.com>Poom Chiarawongse <eight1911@gmail.com>Yang Yang <wdscxsj@gmail.com>Cavendish McKay <cmckay@tachycline.com>Bradley Gannon <bradley.m.gannon@gmail.com>B McG <bmcg0890@gmail.com>Rob Drynkin <rob.drynkin@gmail.com>Seth Ebner <murgrehk@gmail.com>Akash Kundu <sk.sayakkundu1997@gmail.com>Mark Jeromin <mark.jeromin@sysfrog.net>Roberto Díaz Pérez <r.r.1994a@gmail.com>Gleb Siroki <g.shiroki@gmail.com>Segev Finer <segev208@gmail.com>Alex Lubbock <code@alexlubbock.com>Ayodeji Ige <ayodeji18@outlook.com>Matthew Wardrop <matthew.wardrop@airbnb.com>Hugo van Kemenade <hugovk@users.noreply.github.com>Austin Palmer <ap4000@nyu.edu>der-blaue-elefant <github@kklein.de>Filip Gokstorp <filip@gokstorp.se>Yuki Matsuda <yuki.matsuda.w@gmail.com>Aaron Miller <acmiller273@gmail.com>Salil Vishnu Kapur <salilvishnukapur@gmail.com>Atharva Khare <khareatharva@gmail.com>Shubham Maheshwari <rmaheshwari05@gmail.com>Pavel Tkachenko <paveltkachenko@email.com>Ashish Kumar Gaurav <ashishkg0022@gmail.com>Rajeev Singh <rajs2010@gmail.com>Keno Goertz <keno@goertz-berlin.com>Lucas Gallindo <lgallindo@gmail.com>Himanshu <hs80941@gmail.com>David Menéndez Hurtado <david.menendez.hurtado@scilifelab.se>Amit Manchanda <amitdelhi1995@gmail.com>Rohit Jain <rohitjain3241@gmail.com>Jonathan A. Gross <jarthurgross@gmail.com>Unknown <kunda@scribus.net>Sayan Goswami <Sayan98@users.noreply.github.com>Subhash Saurabh <subhashsaurabh419@gmail.com>Rastislav Rabatin <rastislav.rabatin@gmail.com>Vishal <vishalg2235@gmail.com>Jeremey Gluck <jeremygluck@yahoo.com>Akshat Maheshwari <akshat14714@gmail.com>symbolique <symbolique@users.noreply.github.com>Saloni Jain <tosalonijain@gmail.com>Arighna Chakrabarty <arighna.chakrabarty100@gmail.com>Abhigyan Khaund <mail@abhigyan.xyz>Jashanpreet Singh <jashansingh.4398@gmail.com>Saurabh Agarwal <shourabh.agarwal@gmail.com>luzpaz <luzpaz@users.noreply.github.com>P. Sai Prasanth <psai.prasanth.min16@itbhu.ac.in>Nirmal Sarswat <nirmalsarswat400@gmail.com>Cristian Di Pietrantonio <cristiandipietrantonio@gmail.com>Ravi charan <ravicharan.vsp@gmail.com>Nityananda Gohain <nityanandagohain@gmail.com>Cédric Travelletti <cedrictravelletti@gmail.com>Nicholas Bollweg <nick.bollweg@gmail.com>Himanshu Ladia <hladia199811@gmail.com>Adwait Baokar <adwaitbaokar18@gmail.com>Mihail Tarigradschi <m.tarigradschi@gmail.com>Saketh <alurusaisaketh@gmail.com>rushyam <rushyamsonu@gmail.com>sfoo <sfoohei@gmail.com>Rahil Hastu <rahilhastu@gmail.com>Zach Raines <raineszm@gmail.com>Sidhant Nagpal <sidhantnagpal97@gmail.com>Gagandeep Singh <singh.23@iitj.ac.in>Rishav Chakraborty <annonymousxyz@outlook.com>Malkhan Singh <malkhansinghrathaur@gmail.com>Joaquim Monserrat <qmonserrat@mailoo.org>Mayank Singh <mayank.singh081997@gmail.com>Rémy Léone <rleone@online.net>Maxence Mayrand <35958639+maxencemayrand@users.noreply.github.com>Nikoleta Glynatsi <GlynatsiNE@cardiff.ac.uk>helo9 <helo9@users.noreply.github.com>Ken Wakita <wakita@is.titech.ac.jp>Carl Sandrock <carl.sandrock@up.ac.za>Fredrik Eriksson <freeriks@student.chalmers.se>Ian Swire <oversizedpenguin@gmail.com>Bulat <daianovich@mail.ru>Ehren Metcalfe <ehren.m@gmail.com>Dmitry Savransky <dsavransky@gmail.com>Kiyohito Yamazaki <kyamaz@openql.org>Caley Finn <caleyreuben@gmail.com>Zhi-Qiang Zhou <zzq_890709@hotmail.com>Alexander Pozdneev <pozdneev@users.noreply.github.com>Wes Turner <50891+westurner@users.noreply.github.com>JMSS-Unknown <31131631+JMSS-Unknown@users.noreply.github.com>Arshdeep Singh <singh.arshdeep1999@gmail.com>cym1 <16437732+cym1@users.noreply.github.com>Stewart Wadsworth <stewart.wadsworth@gmail.com>Jared Lumpe <mjlumpe@gmail.com>Avi Shrivastava <shrivastavaavi123@gmail.com>ramvenkat98 <ramvenkat98@gmail.com>Bilal Ahmed <b.ahmed0918@gmail.com>Dimas Abreu Archanjo Dutra <dimasad@ufmg.br>Yatna Verma <yatnavermaa@gmail.com>S.Y. Lee <sylee957@gmail.com>Miro Hrončok <miro@hroncok.cz>Sudarshan Kamath <sudarshan.kamath97@gmail.com>Ayushman Koul <ayushmankoul4570@gmail.com>Robert Dougherty-Bliss <robert.w.bliss@gmail.com>Andrey Grozin <A.G.Grozin@inp.nsk.su>Bavish Kulur <bavishkulur@gmail.com>Arun Singh <arunsin997@gmail.com>sirnicolaf <43586954+sirnicolaf@users.noreply.github.com>Zachariah Etienne <zachetie@gmail.com>Prayush Dawda <35144226+iamprayush@users.noreply.github.com>2torus <boris.ettinger@gmail.com>Faisal Riyaz <faisalriyaz011@gmail.com>Martin Roelfs <u0114255@kuleuven.be>SirJohnFranklin <sirjfu@googlemail.com>Anthony Sottile <asottile@umich.edu>ViacheslavP <public.viacheslav@gmail.com>Safiya03 <safiyanesar@gmail.com>Alexander Dunlap <alexander.dunlap@gmail.com>Rohit Sharma <31184621+rohitx007@users.noreply.github.com>Jonathan Warner <warnerjon12@gmail.com>Mohit Balwani <mohitbalwani.ict17@gmail.com>Marduk Bolaños <mardukbp@mac.com>amsuhane <ayushsuhane99@iitkgp.ac.in>Matthias Geier <Matthias.Geier@gmail.com>klaasvanaarsen <44929042+klaasvanaarsen@users.noreply.github.com>Shubham Kumar Jha <skjha832@gmail.com>rationa-kunal <kunalgk1999@gmail.com>Animesh Sinha <animeshsinha1309@gmail.com>Gaurang Tandon <1gaurangtandon@gmail.com>Matthew Craven <clyring@users.noreply.github.com>Daniel Ingram <ingramds@appstate.edu>Jogi Miglani <jmig5776@gmail.com>Takumasa Nakamura <n.takumasa@gmail.com>Ritu Raj Singh <RituRajSingh878@gmail.com>Rajiv Ranjan Singh <rajivperfect007@gmail.com>Vera Lozhkina <veralozhkina@gmail.com>adhoc-king <46354827+adhoc-king@users.noreply.github.com>Mikel Rouco <mikel.mrm@gmail.com>Oscar Gustafsson <oscar.gustafsson@gmail.com>damianos <damianos@semmle.com>Supreet Agrawal <supreet11agrawal@gmail.com>shiksha11 <shiksharawat01@gmail.com>Martin Ueding <dev@martin-ueding.de>sharma-kunal <kunalsharma6914@gmail.com>Divyanshu Thakur <divyanshu@iiitmanipur.ac.in>Susumu Ishizuka <susumu.ishizuka@kii.com>Samnan Rahee <namanush.rsr.16@gmail.com>Fredrik Andersson <fredrik.andersson@fcc.chalmers.se>Bhavya Srivastava <bhavya17037@iiitd.ac.in>Alpesh Jamgade <alpeshjamgade21@gmail.com>Shubham Abhang <shubhamabhang77@gmail.com>Vishesh Mangla <manglavishesh64@gmail.com>Nicko van Someren <nicko@nicko.org>dandiez <47832466+dandiez@users.noreply.github.com>Frédéric Chapoton <fchapoton2@gmail.com>jhanwar <f2015463@pilani.bits-pilani.ac.in>Noumbissi valere Gille Geovan <noumbissivalere@gmail.com>Salmista-94 <alejandrogroso@hotmail.com>Shivani Kohli <shivanikohli.09@gmail.com>Parker Berry <parkereberry@gmail.com>Pragyan Mehrotra <pragyan18168@iiitd.ac.in>Nabanita Dash <dashnabanita@gmail.com>Gaetano Guerriero <x.guerriero@tin.it>Ankit Raj Pandey <pandeyan@grinnell.edu>Ritesh Kumar <ritesh99rakesh@gmail.com>kangzhiq <709563092@qq.com>Jun Lin <junlin0604@gmail.com>Petr Kungurtsev <corwinat@gmail.com>Anway De <anway1756@gmail.com>znxftw <vishnu2101@gmail.com>Denis Ivanenko <ivanenko@ucu.edu.ua>Orestis Vaggelis <orestisvaggelis@mail.com>Nikhil Maan <nikhilmaan22@gmail.com>Abhinav Anand <abhinav.anand2807@gmail.com>Qingsha Shi <googol.sqs@gmail.com>Juan Barbosa <js.barbosa10@uniandes.edu.co>Prionti Nasir <pdn3628@rit.edu>Bharat Raghunathan <bharatraghunthan9767@gmail.com>arooshiverma <av22@iitbbs.ac.in>Christoph Gohle <ctg@mpq.mpg.de>Charalampos Tsiagkalis <ctsiagkalis@uth.gr>Daniel Sears <highpost@users.noreply.github.com>Megan Ly <megan.ly@learnosity.com>Sean P. Cornelius <spcornelius@gmail.com>Erik R. Gomez <gomez@kth.se>Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>Henry Metlov <genrih.metlov@gmail.com>pekochun <hamburg_hamburger2000@yahoo.co.jp>Bendik Samseth <b.samseth@gmail.com>Vighnesh Shenoy <vighneshq@gmail.com>Versus Void <versusvoid@gmail.com>Denys Rybalka <rybalka.denis@gmail.com>Mark Dickinson <dickinsm@gmail.com>Rimi <rimibis@umich.edu>rimibis <33387803+rimibis@users.noreply.github.com>Steven Lee <stevenlee123@protonmail.com>Gilles Schintgen <gschintgen@hambier.lu>Abhi58 <abhijithbharadwaj58@gmail.com>Tomasz Pytel <tompytel@gmail.com>Aadit Kamat <aadit.k12@gmail.com>Samesh <samesh.lakhotia@gmail.com>Velibor Zeli <velibor@mech.kth.se>Gabriel Bernardino <gabriel.bernardino@upf.edu>Joseph Redfern <joseph@redfern.me>Evelyn King <evelyn.cameron.king@gmail.com>Miguel Marco <mmarco@unizar.es>David Hagen <david@drhagen.com>Hannah Kari <hannah.kari@marquette.edu>Soniya Nayak <soniyanayak51@gmail.com>Harsh Agarwal <hagarwal9200@gmail.com>Enric Florit <efz1005@gmail.com>Yogesh Mishra <ymishra013@gmail.com>Denis Rykov <rykovd@gmail.com>Ivan Tkachenko <me@ratijas.tk>Kenneth Emeka Odoh <kenneth.odoh@gmail.com>Stephan Seitz <stephan.seitz@fau.de>Yeshwanth N <yeshsurya@gmail.com>Oscar Gerardo Lazo Arjona <oscar.lazoarjona@physics.ox.ac.uk>Srinivasa Arun Yeragudipati <ysarun1999@gmail.com>Kirtan Mali <kirtanmali555@gmail.com>TitanSnow <sweeto@live.cn>Pengning Chao <8857165+PengningChao@users.noreply.github.com>Louis Abraham <louis.abraham@yahoo.fr>Morten Olsen Lysgaard <morten@lysgaard.no>Akash Nagaraj (akasnaga) <akasnaga@cisco.com>Akash Nagaraj <grassknoted@gmail.com>Lauren Glattly <laurenglattly@gmail.com>Hou-Rui <houruinus@gmail.com>George Korepanov <gkorepanov.gk@gmail.com>dranknight09 <cbhaavan@gmail.com>aditisingh2362 <aditisingh2362@gmail.com>Gina <Dr-G@users.noreply.github.com>gregmedlock <gmedlo@gmail.com>Georgios Giapitzakis Tzintanos <giorgosgiapis@mail.com>Eric Wieser <wieser.eric@gmail.com>Bradley Dowling <34559056+btdow@users.noreply.github.com>Maria Marginean <33810762+mmargin@users.noreply.github.com>Akash Agrawall <akash.wanted@gmail.com>jgulian <josephdgulian@gmail.com>Sourav Goyal <souravgl0@gmail.com>Zlatan Vasović <zlatanvasovic@gmail.com>Alex Meiburg <timeroot.alex@gmail.com>Smit Lunagariya <smitlunagariya.mat18@itbhu.ac.in>Naman Gera <namangera15@gmail.com>Julien Palard <julien@palard.fr>Dhruv Mendiratta <dhruvmendiratta6@gmail.com>erdOne <36414270+erdOne@users.noreply.github.com>risubaba <risubhjain1010@gmail.com>abhinav28071999 <41710346+abhinav28071999@users.noreply.github.com>Jisoo Song <jeesoo9595@snu.ac.kr>Jaime R <38530589+Jaime02@users.noreply.github.com>Vikrant Malik <vikrantmalik051@gmail.com>Hardik Saini <43683678+Guardianofgotham@users.noreply.github.com>Abhishek <uchiha@pop-os.localdomain>Johannes Hartung <joha2@gmx.net>Milan Jolly <milan.cs16@iitp.ac.in>faizan2700 <syedfaizan824@gmail.com>mohit <39158356+mohitacecode@users.noreply.github.com>Mohit Gupta <mohitgupta@gmail.com>Psycho-Pirate <prakharsaxena.civ18@iitbhu.ac.in>Chanakya-Ekbote <ca10@iitbbs.ac.in>Rashmi Shehana <rashmi.watagedara@syscolabs.com>Jonty16117 <jonty@DESKTOP-J1O6ANP.localdomain>Anubhav Gupta <anubhav.gupta.cse19@itbhu.ac.in>Michal Grňo <m93a.cz@gmail.com>vezeli <37907135+vezeli@users.noreply.github.com>Tim Gates <tim.gates@iress.com>Sandeep Murthy <smurthy@protonmail.ch>Neil <mistersheik@gmail.com>V1krant <46847915+V1krant@users.noreply.github.com>alejandro <amartinhernan@gmail.com>Riyan Dhiman <Riyandhiman14@gmail.com>sbt4104 <sthorat661@gmail.com>Seth Troisi <sethtroisi@google.com>Bhaskar Gupta <guptabhanu1999@gmail.com>Smit Gajjar <smitgajjar.gs@gmail.com>rbl <rlee@grove.co>Ilya Pchelintsev <ilya.pchelintsev@outlook.com>Omar Wagih <o.wagih.ow@gmail.com>prshnt19 <prashant.rawat216@gmail.com>Johan Guzman <jguzm022@ucr.edu>Vasileios Kalos <kalosbasileios@gmail.com>BasileiosKal <61801875+BasileiosKal@users.noreply.github.com>Shubham Thorat <37049710+sbt4104@users.noreply.github.com>Arpan Chattopadhyay <f20180319@pilani.bits-pilani.ac.in>Ashutosh Hathidara <ashutoshhathidara98@gmail.com>Moses Paul R <iammosespaulr@gmail.com>Saanidhya vats <saanidhyavats@gmail.com>tnzl <you@example.com>Vatsal Srivastava <alstav.trivas.sava@gmail.com>Jean-Luc Herren <jlh@gmx.ch>Dhruv Kothari <dhruvkothari22@gmail.com>seadavis <45022599+seadavis@users.noreply.github.com>kamimura <kamimura@live.jp>slacker404 <pchantza@gmail.com>Jaime Resano <gemailpersonal02@gmail.com>Ebrahim Byagowi <ebrahim@gnu.org>wuyudi <wuyudi119@163.com>Akira Kyle <ak@akirakyle.com>Calvin Jay Ross <calvinjayross@gmail.com>Martin Thoma <info@martin-thoma.de>Thomas A Caswell <tcaswell@gmail.com>Lagaras Stelios <stel.lag@hotmail.com>Jerry James <loganjerry@gmail.com>Jan Kruse <janckruse@t-online.de>Nathan Taylor <pecan.pine@gmail.com>Vaishnav Damani <vaishnavdamani3496@gmail.com>Mohit Shah <mohitshah3111999@gmail.com>Mathias Louboutin <mathias.louboutin@gmail.com>Marijan Smetko <marijansmetko123@gmail.com>Dave Witte Morris <Dave.Morris@uleth.ca>soumi7 <soumibardhan10@gmail.com>Zhongshi <zj495@nyu.edu>Wes Galbraith <galbwe92@gmail.com>KaustubhDamania <kaustubh.damania@gmail.com>w495 <w495@yandex-team.ru>Akhil Rajput <akh1lrjput@gmail.com>Markus Mohrhard <markus.mohrhard@googlemail.com>Benjamin Wolba <mail@benjaminwolba.com>彭于斌 <1931127624@qq.com>Rudr Tiwari <rudrtiwari@gmail.com>Aaryan Dewan <aaryandewan@yahoo.com>Benedikt Placke <benedikt.placke@outlook.com>Sneha Goddu <s.goddu@wustl.edu>goddus <39923708+goddus@users.noreply.github.com>Shivang Dubey <shivangdubey8@gmail.com>Michael Greminger <michael.greminger@gmail.com>Peter Cock <p.j.a.cock@googlemail.com>Willem Melching <willem.melching@gmail.com>Elias Basler <e.e.basler@protonmail.com>Brandon David <brandon.david@zoho.com>Abhay_Dhiman <abhaysdhimans@gmail.com>Tasha Kim <jae_young_kim@brown.edu>Ayush Malik <ayushmalik779@gmail.com>Devesh Sawant <devesh47cool@gmail.com>Wolfgang Stöcher <wolfgang@stoecher.com>Sudeep Sidhu <sudeepmanilsidhu@gmail.com>foice <foice.news@gmail.com>Ben Payne <ben.is.located@gmail.com>Muskan Kumar <31043527+muskanvk@users.noreply.github.com>noam simcha finkelstein <noam.finkelstein@protonmail.com>Garrett Folbe <gmfolbe@yahoo.com>Islam Mansour <is3mansour@gmail.com>Sayandip Halder <sayandiph4@gmail.com>Shubham Agrawal <shubham.ag6845@gmail.com>numbermaniac <5206120+numbermaniac@users.noreply.github.com>Sakirul Alam <binarysakir@gmail.com>Mohammed Bilal <r.mohammedbilal@gmail.com>Chris du Plessis <christopherjonduplessis@gmail.com>Coder-RG <rgoel1999@gmail.com>Ansh Mishra <anshmishra471@gmail.com>Alex Malins <github@alexmalins.com>Lorenzo Contento <lorenzo.contento@gmail.com>Naveen Sai <naveensaisreenivas@gmail.com>Shital Mule <shitalmule04@gmail.com>Amanda Dsouza <meezamanda@yahoo.com>Nijso Beishuizen <nijso@koolmees.numerically-related.com>Harry Zheng <harry@harryzheng.com>Felix Yan <felixonmars@archlinux.org>Constantin Mateescu <costica1234@me.com>Eva Tiwari <eva.tiwari@gmail.com>Aditya Kumar Sinha <adityakumar113141@gmail.com>Soumi Bardhan <51290447+Soumi7@users.noreply.github.com>Kaustubh Chaudhari <ckaustubhm06@gmail.com>Kristian Brünn <hello@kristianbrunn.com>Neel Gorasiya <mgorasiya1974@gmail.com>Akshat Sood <68052998+akshatsood2249@users.noreply.github.com>Jose M. Gomez <chemoki@gmail.com>Stefan Petrea <stefan@garage-coding.com>Praveen Sahu <povinsahu@gmail.com>Mark Bell <mark00bell@googlemail.com>AlexCQY <alex_chua@u.nus.edu>Fabian Froehlich <fabian@schaluck.com>Nikhil Gopalam <gopalamn@umich.edu>Kartik Sethi <kartiks31416@gmail.com>Muhammed Abdul Quadir Owais <quadirowais200@gmail.com>Harshit Yadav <harshityadav2k@gmail.com>Sidharth Mundhra <sidharthmundhra16@gmail.com>Suryam Arnav Kalra <suryamkalra35@gmail.com>Prince Gupta <codemastercpp@gmail.com>Kunal Singh <ksingh19136@gmail.com>Mayank Raj <mayank_1901cs35@iitp.ac.in>Achal Jain <2achaljain@gmail.com>Mario Maio <mario.maio@aruba.it>Aaron Stiff <69512633+AaronStiff@users.noreply.github.com>Wyatt Peak <wyattpeak@gmail.com>Bhaskar Joshi <bhaskar.joshi@research.iiit.ac.in>Aditya Jindal <jaditya8889@gmail.com>Vaibhav Bhat <vaibhav.bhat2097@gmail.com>Priyansh Rathi <techiepriyansh@gmail.com>Saket Kumar Singh <saketkumar1202@gmail.com>Yukai Chou <muzimuzhi@gmail.com>Qijia Liu <liumeo@pku.edu.cn>Paul Mandel <paulmandel@google.com>Nisarg Chaudhari <54911392+Nisarg-Chaudhari@users.noreply.github.com>Dominik Stańczak <stanczakdominik@gmail.com>Rodrigo Luger <rodluger@gmail.com>Marco Antônio Habitzreuter <mahabitzreuter@gmail.com>Ayush Bisht <bisht.ayush2001@gmail.com>Akshansh Bhatt <akshansh@tuta.io>Brandon T. Willard <brandonwillard@users.noreply.github.com>Thomas Aarholt <thomasaarholt@gmail.com>Hiren Chalodiya <hirenchalodiya99@gmail.com>Roland Dixon <rols121@gmail.com>dimasvq <dimas.vq.2020@bristol.ac.uk>Sagar231 <sagarfeb298@gmail.com>Michael Chu <michael02chu@gmail.com>Abby Ng <abigailjng@gmail.com>Angad Sandhu <55819847+angadsinghsandhu@users.noreply.github.com>Alexander Cockburn <alexander_cockburn12@hotmail.com>Yaser AlOsh <yaseralosh@outlook.com>Davide Sandonà <sandona.davide@gmail.com>Jonathan Gutow <gutow@uwosh.edu>Nihir Agarwal <f20180701@pilani.bits-pilani.ac.in>Lee Johnston <lee.johnston.100@gmail.com>Zach Carmichael <20629897+craymichael@users.noreply.github.com>Vijairam Ganesh Moorthy <vijairamg@gmail.com>Hanspeter Schmid <hanspeter.schmid@fhnw.ch>Ben Oostendorp <oostben@umich.edu>Nikita <nikita.student.cse19@itbhu.ac.in>Aman <amanmourya295@gmail.com>Shashank KS <shashankks0987@gmail.com>Aman Sharma <amansharma110603@gmail.com>Anup Parikh <parikhanupk@gmail.com>Lucy Mountain <lucymountain1@icloud.com>Miguel Torres Costa <miguelptcosta1995@gmail.com>Rikard Nordgren <rikard.nordgren@farmaci.uu.se>Arun sanganal <74652697+ArunSanganal@users.noreply.github.com>Kamlesh Joshi <72374645+kamleshjoshi8102@users.noreply.github.com>Joseph Rance <56409230+Joseph-Rance@users.noreply.github.com>Huangduirong <huangduirong@huawei.com>Nils Schulte <47043622+Schnilz@users.noreply.github.com>Matt Bogosian <matt@bogosian.net>Elisha Hollander <just4now666666@gmail.com>Aditya Ravuri <infprobscix@gmail.com>Mamidi Ratna Praneeth <praneethratna@gmail.com>Jeffrey Ryan <jeffaryan7@gmail.com>Jonathan Daniel <36337649+jond01@users.noreply.github.com>Robin Richard <raisin@ecomail.fr>Gautam Menghani <gum3ng@protonmail.com>Remco de Boer <29308176+redeboer@users.noreply.github.com>Sebastian East <sebastianeast@ymail.com>Evani Balasubramanyam <balasubramanyam.evani@gmail.com>Rahil Parikh <r.parikh@somaiya.edu>Jason Ross <jasonross1024@gmail.com>Joannah Nanjekye <joannah.nanjekye@ibm.com>Ayush Kumar <ayushk7102@gmail.com>Kshitij <kshitijparwani.mat18@itbhu.ac.in>Daniel Hyams <dhyams@gmail.com>alijosephine <alijosephine@gmail.com>Matthias Köppe <mkoeppe@math.ucdavis.edu>mohajain <mohajain99@gmail.com>Anibal M. Medina-Mardones <ammedmar@gmail.com>Travis Ens <ens.travis@gmail.com>Evgenia Karunus <lakesare@gmail.com>Risiraj Dey <risirajdey@gmail.com>lastcodestanding <rohang71604@gmail.com>Andrey Lekar <andrey_lekar@adoriasoft.com>Abbas Mohammed <42001049+iam-abbas@users.noreply.github.com>Anutosh Bhat <andersonbhat491@gmail.com>Steve Kieffer <sk@skieffer.info>Paul Spiering <paul@spiering.org>Pieter Gijsbers <p.gijsbers@tue.nl>Wang Ran (汪然) <wangr@smail.nju.edu.cn>naelsondouglas <naelson17@gmail.com>Aman Thakur <thakuraman22july@gmail.com>S. Hanko <suzy.hanko@gmail.com>Dennis Sweeney <sweeney.427@osu.edu>Gurpartap Singh <dhaliwal.gurpartap@gmail.com>Hampus Malmberg <hampus.malmberg88@gmail.com>scimax <max.kellermeier@hotmail.de>Nikhil Date <nikhil.s.date@gmail.com>Kuldeep Borkar Jr <kuldeepborkarjr765@gmail.com>AkuBrain <76952313+Franck2111@users.noreply.github.com>Leo Battle <leowbattle@gmail.com>Advait Pote <apote2050@gmail.com>Anurag Bhat <bhat.1@iitj.ac.in>Jeremy Monat <jemonat@calalum.org>Diane Tchuindjo <dtchuindjo@gmail.com>Tom Fryers <61272761+TomFryers@users.noreply.github.com>Zouhair <zouhair.mahboubi@gmail.com>zzj <29055749+zjzh@users.noreply.github.com>shubhayu09 <guptashubhayu601@gmail.com>Siddhant Jain <siddhantashoknagar@gmail.com>Tirthankar Mazumder <63574588+wermos@users.noreply.github.com>Sumit Kumar <mr.sumitkrr@gmail.com>Shivam Sagar <technoshivam12@gmail.com>Gaurav Jain <gjain369@gmail.com>Andrii Oriekhov <andriyorehov@gmail.com>Luis Talavera <luisfertalavera15@gmail.com>Arie Bovenberg <a.c.bovenberg@gmail.com>Carson McManus <carson.mcmanus1@gmail.com>Jack Schmidt <1107865+jackschmidt@users.noreply.github.com>Riley Britten <nrb1324@hotmail.com>Georges Khaznadar <georgesk@debian.org>Donald Wilson <donwilson1029@gmail.com>Timo Stienstra <timostienstra00@gmail.com>dispasha <dispasha@users.noreply.github.com>Saksham Alok <sakshamalok13@gmail.com>Varenyam Bhardwaj <varenyambhardwaj123@gmail.com>oittaa <8972248+oittaa@users.noreply.github.com>Omkaar <79257339+Pysics@users.noreply.github.com>Islem BOUZENIA <fi_bouzenia@esi.dz>extraymond <extraymond@gmail.com>Alexander Behrens <alex.git@gmx.net>user202729 <25191436+user202729@users.noreply.github.com>Pieter Eendebak <pieter.eendebak@gmail.com>Zaz Brown <zazbrown@zazbrown.com>ritikBhandari <ritikbhandari68@gmail.com>viocha <66580331+viocha@users.noreply.github.com>Arthur Ryman <arthur.ryman@gmail.com>Xiang Wu <hsiangwu@fb.com>tttc3 <T.Coxon2@lboro.ac.uk>Seth Poulsen <poulsenseth@yahoo.com>cocolato <haiizhu@outlook.com>Anton Golovanov <agolovanov256@gmail.com>Gareth Ma <grhkm21@gmail.com>Clément M.T. Robert <cr52@protonmail.com>Glenn Horton-Smith <glenn.hortonsmith@gmail.com>Karan <grgkaran03@gmail.com>Stefan Behnle <84378403+behnle@users.noreply.github.com>Shreyash Mishra <72146041+Shreyash-cyber@users.noreply.github.com>Arthur Milchior <arthur@milchior.fr>NotWearingPants <26556598+NotWearingPants@users.noreply.github.com>Ishan Pandhare <ishan9096137017@gmail.com>Carlos García Montoro <TrilceAC@gmail.com>Parcly Taxel <reddeloostw@gmail.com>Saicharan <saicharanhahaha@gmail.com>Kunal Sheth <kunal@kunalsheth.info>Biswadeep Purkayastha <98874428+metabiswadeep@users.noreply.github.com>Jyn Spring 琴春 <me@vx.st>Phil LeMaitre <phil_lemaitre@live.ca>Chris Kerr <chris.kerr@mykolab.ch>José Senart <jose.senart@gmail.com>Uwe L. Korn <uwelk@xhochy.com>ForeverHaibara <69423537+ForeverHaibara@users.noreply.github.com>Yves Tumushimire <yvestumushimire@gmail.com>wookie184 <wookie1840@gmail.com>Costor <pcs2009@web.de>Klaus Rettinghaus <klaus.rettinghaus@enote.com>Sam Brockie <sambrockie@icloud.com>Abhishek Patidar <1e9abhi1e10@gmail.com>Eric Demer <demer@mailbox.org>Pontus von Brömssen <pontus.vonbromssen+github@gmail.com>Victor Immanuel <chrollolucilfer1402@gmail.com>Evandro Bernardes <evbernardes@gmail.com>Michele Ceccacci <michelececcacci1@gmail.com>Ayush Aryan <ayush.aryan71@gmail.com>Kishore Gopalakrishnan <kishore96@gmail.com>Jan-Philipp Hoffmann <sonntagsgesicht@icloud.com>Daiki Takahashi <haru.td@gmail.com>Sayan Mitra <ee18b156@smail.iitm.ac.in>Aman Kumar Shukla <theprofessionalaman@gmail.com>Zoufiné Lauer-Baré <raszoufine@gmail.com>Charles Harris <erdos4d@gmail.com>Tejaswini Sanapathi <sastejaswini2002@gmail.com>Devansh <be19b002@smail.iitm.ac.in>Aaron Gokaslan <aaronGokaslan@gmail.com>Daan Koning (he/him) <daanolivierkoning@gmail.com>Steven Burns <royalstream@hotmail.com>Jay Patankar <patankarjays@gmail.com>Vivek Soni <sonisheela1977@gmail.com>Le Cong Minh Hieu <hieu.lecongminh@gmail.com>Sam Ritchie <sam@mentat.org>Maciej Skórski <maciej.skorski@gmail.com>Tilo Reneau-Cardoso <tiloreneau@gmail.com>Laurence Warne <laurencewarne@gmail.com>Lukas Molleman <Lukas.Molleman@gmail.com>Konstantinos Riganas <kostasriganas24@gmail.com>Grace Su <grace.duansu@gmail.com>Pedro Rosa <pedro_sxbr@usp.br>Abhinav Cillanki <abhinavcillanki@kgpian.iitkgp.ac.in>Baiyuan Qiu <1061688677@qq.com>Liwei Cai <cai.lw123@gmail.com>Daniel Weindl <daniel.weindl@helmholtz-muenchen.de>Isidora Araya <iarayaday@gmail.com>Seb Tiburzio <sebtiburzio@gmail.com>Victory Omole <vtomole2@gmail.com>Abhishek Chaudhary <ac5003@columbia.edu>Alexander Zhura <nice.zhura@list.ru>Shuai Zhou <shuaivzhou@berkeley.edu>Martin Manns <mmanns@gmx.net>John Möller <john.moller@outlook.com>zzc <1378113190@qq.com>Pablo Galindo Salgado <pablogsal@gmail.com>Johannes Kasimir <johannes.kasimir@math.lu.se>Theodore Dias <theodore.dias@hotmail.co.uk>Kaustubh <90597818+kaustubh-765@users.noreply.github.com>Idan Pazi <idan.kp@gmail.com>Bobby Palmer <bobbyp@umich.edu>Saikat Das <saikatdchhe@gmail.com>Suman mondal <smondal.qwerty@gmail.com>Taylan Sahin <info@taylansahin.net>Fabio Luporini <fabio@devitocodes.com>Oriel Malihi <orielmalihi1@gmail.com>Geetika Vadali <geetika.vadali4@gmail.com>Matthias Rettl <matthias.rettl@stud.unileoben.ac.at>Mikhail Remnev <maremnev@gmail.com>philwillnyc <56197213+philwillnyc@users.noreply.github.com>Raphael Lehner <raphael.lehner@gmail.com>Harry Mountain <harrymountain1@icloud.com>Bhavik Sachdev <b.sachdev1904@gmail.com>袁野 (Yuan Ye) <yuanyelele@tutanota.com>fazledyn-or <ataf@openrefactory.com>mohammedouahman <simofun85@gmail.com>K. Kraus <laqueray@googlemail.com>Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>platypus <platypus.computerchip@gmail.com>codecruisader <nnisarg55@gmail.com>James Whitehead <whiteheadj@gmail.com>atharvParlikar <atharvparlikar@gmail.com>Ivan Petukhov <satels@gmail.com>Augusto Borges <borges.augustoar@gmail.com>Han Wei Ang <ang.h.w@u.nus.edu>Congxu Yang <u7189828@anu.edu.au>Saicharan <62512681+saicharan2804@users.noreply.github.com>Arnab Nandi <arnabnandi2002@gmail.com>Harrison Oates <48871176+HarrisonOates@users.noreply.github.com>Corey Cerovsek <corey@cerovsek.com>Harsh Kasat <hkasat@waymore.io>omahs <73983677+omahs@users.noreply.github.com>Pascal Gitz <pascal.gitz@hotmail.ch>Ravindu-Hirimuthugoda <ravindu.18@cse.mrt.ac.lk>Sophia Pustova <tripplezzed@gmail.com>George Pittock <gpittock4@gmail.com>Warren Jacinto <warrenjacinto@gmail.com>Sachin Singh <sachinishu02@gmail.com>Zedmat <104870914+harshkasat@users.noreply.github.com>Soumendra Ganguly <soumendraganguly@gmail.com>Samith Karunathilake <55777141+samithkavishke@users.noreply.github.com>Viraj Vekaria <virajv5593@gmail.com>Shishir Kushwaha <kushwahashishir1112@gmail.com>Ankit Kumar Singh <ankitdiswar10@gmail.com>Abhishek Kumar <abhishek.nitdelhi@gmail.com>Mohak Malviya <mohakmalviya2000@gmail.com>Matthias Liesenfeld <116307294+maliesen@users.noreply.github.com>dodo <palumbododo@gmail.com>Mohamed Rezk <mohrizq895@gmail.com>Tommaso Vaccari <05-gesto-follemente@icloud.com>Alexis Schotte <alexis.schotte@gmail.com>Lauren Yim <31467609+cherryblossom000@users.noreply.github.com>Prey Patel <patel.prey@iitgn.ac.in>Riccardo Di Girolamo <riccardodigirolamo01@gmail.com>Abhishek kumar <kumar325571@gmail.com>Sam Lubelsky <sammy56lt@gmail.com>Henrique Soares <henrique.c.soares@tecnico.ulisboa.pt>Vladimir Sereda <voffch@gmail.com>Hwayeon Kang <hwayeonniii@gmail.com>Raj Sapale <raj4sapale4@gmail.com>Gerald Teschl <gerald.teschl@univie.ac.at>Richard Samuel <98638849+samuelard7@users.noreply.github.com>HeeJae Chang <hechang@microsoft.com>Nick Harder <nharder@umich.edu>Ethan DeGuire <ethandeguire@gmail.com>Lorenz Winkler <lorenz.winkler@tuwien.ac.at>Richard Rodenbusch <rrodenbusch@gmail.com>Zhenxu Zhu <xzdlj@outlook.com>Mark van Gelder <m.j.vangelder@student.tudelft.nl>Mark van Gelder <mvgmvgmvg@live.com>Ishan Pandhare <91841626+Ishanned@users.noreply.github.com>James A. Preiss <jamesalanpreiss@gmail.com>Emile Fourcini <emile.fourcin1@gmail.com>Alberto Jiménez Ruiz <Alberto.Jimenez@uclm.es>João Bravo <joaocgbravo@tecnico.ulisboa.pt>Dean Price <dean1357price1357@gmail.com>Edward Z. Yang <ezyang@mit.edu>James Titus <titusjames299@gmail.com>Zhuoyuan Li <zy.li@stu.pku.edu.cn>Hugo Kerstens <hugo@kerstens.me>Jan Jancar <johny@neuromancer.sk>Andrew Mosson <amosson@yahoo.com>Marek Madejski <marekmadejski@yandex.com>Gonzalo Tornaría <tornaria@cmat.edu.uy>Peter Stahlecker <peter.stahlecker@gmail.com>Jean-François B <2589111+jfbu@users.noreply.github.com>Zexuan Zhou (Bruce) <zzx498636727@gmail.com>George Frolov <gosha@fro.lv>Corbet Elkins <corbet286@gmail.com>Håkon Kvernmoen <haakon.kvernmoen@gmail.com>Muhammad Maaz <mmaaz6004@gmail.com>Shishir Kushwaha <138311586+shishir-11@users.noreply.github.com>Matt Wang <mattwang44@gmail.com>bharatAmeria <21001019007@jcboseust.ac.in>Amir Ebrahimi <github@aebrahimi.com>Steven Esquea <steven.esquea@irreverente.net>Rishabh Kamboj <111004091+VectorNd@users.noreply.github.com>Aasim Ali <aasim250205@gmail.com>Ivan A. Melnikov <iv@altlinux.org>Borek Saheli <boreksaheli@gmail.com>Guido Roncarolo <guido.roncarolo@gmail.com>Quek Zi Yao <ziyaoqzy2001@gmail.com>Roelof Rietbroek <r.rietbroek@utwente.nl>MostafaGalal1 <mostafag649.mg@gmail.com>Au Huishan <huishan_au@outlook.com>Kris Katterjohn <katterjohn@gmail.com>Shiyao Guo <mivikq@gmail.com>Rushabh Mehta <mehtarushabh2005@gmail.com>Temiloluwa Yusuf ytemiloluwa@gmail.com ytemiloluwa <ytemiloluwa@gmail.com>Davi Laerte <davilae011@gmail.com>Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>Harshit Gupta <harshithigh2001@gmail.com>Praveen Perumal <ppraveen98841@gmail.com>Kevin McWhirter <klmcw@yahoo.com>Prayag V <v.prayag2005@gmail.com>Lucas Kletzander <lucas.kletzander@gmail.com>Pratyksh Gupta <pratykshgupta9999@gmail.com>Leonardo Mangani <leomangani4@gmail.com>Karan Anand <anandkarancompsci@gmail.com>Gagan Mishra <simonsimple305@gmail.com>Krishnav Bajoria <bajoriakrishnav@gmail.com>Matt Ord <matthew.ord1@gmail.com>Jatin Bhardwaj <bhardwajjatin093@gmail.com>Prashant Tandon <tandonprashant101@gmail.com>Paramjit Singh <paramjit1071@gmail.com>João Rodrigues <abcjoao@hotmail.com>Alejandro García Prada <114813960+AlexGarciaPrada@users.noreply.github.com>Matthew Treinish <mtreinish@kortar.org>Clayton Rabideau <claytonrabideau@gmail.com>Victoria Koval <bictoriakoval16@gmail.com>Voaides Negustor Robert <134785947+voaidesr@users.noreply.github.com>Ovsk Mendov <bbb23exposed@gmail.com>David Brooks <dave@bcs.co.nz>Nicholas Laustrup <124007393+nicklaustrup@users.noreply.github.com>Harikrishna Srinivasan <harikrishnasri3@gmail.com>Mathis Cros <mathis.cros@telecom-paris.fr>Arnav Mummineni <45217840+RCoder01@users.noreply.github.com>Thangaraju Sibiraj <85477603+t-sibiraj@users.noreply.github.com>KJaybhaye <krushnajaybhaye01@gmail.com>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153Copyright (c) 2006-2023 SymPy Development Team
All rights reserved.
Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions are met:
a. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. b. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. c. Neither the name of SymPy nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSEARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FORANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIALDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ORSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVERCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICTLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAYOUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCHDAMAGE.
--------------------------------------------------------------------------------
Patches that were taken from the Diofant project (https://github.com/diofant/diofant)are licensed as:
Copyright (c) 2006-2018 SymPy Development Team, 2013-2023 Sergey B Kirpichev
All rights reserved.
Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions are met:
a. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. b. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. c. Neither the name of Diofant or SymPy nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSEARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FORANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIALDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ORSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVERCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICTLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAYOUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCHDAMAGE.
--------------------------------------------------------------------------------
Submodules taken from the multipledispatch project (https://github.com/mrocklin/multipledispatch)are licensed as:
Copyright (c) 2014 Matthew Rocklin
All rights reserved.
Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions are met:
a. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. b. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. c. Neither the name of multipledispatch nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSEARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FORANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIALDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ORSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVERCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICTLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAYOUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCHDAMAGE.
--------------------------------------------------------------------------------
The files under the directory sympy/parsing/autolev/tests/pydy-example-repoare directly copied from PyDy project and are licensed as:
Copyright (c) 2009-2023, PyDy AuthorsAll rights reserved.
Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.* Neither the name of this project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ANDANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIEDWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AREDISCLAIMED. IN NO EVENT SHALL PYDY AUTHORS BE LIABLE FOR ANY DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCEOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IFADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
The files under the directory sympy/parsing/latex are directly copied from latex2sympy project and are licensed as:
Copyright 2016, latex2sympy
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.12isympysympy123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513from sympy.vector.coordsysrect import CoordSys3Dfrom sympy.vector.deloperator import Delfrom sympy.vector.scalar import BaseScalarfrom sympy.vector.vector import Vector, BaseVectorfrom sympy.vector.operators import gradient, curl, divergencefrom sympy.core.function import difffrom sympy.core.singleton import Sfrom sympy.integrals.integrals import integratefrom sympy.core import sympifyfrom sympy.vector.dyadic import Dyadic
def express(expr, system, system2=None, variables=False): """ Global function for 'express' functionality.
Re-expresses a Vector, Dyadic or scalar(sympyfiable) in the given coordinate system.
If 'variables' is True, then the coordinate variables (base scalars) of other coordinate systems present in the vector/scalar field or dyadic are also substituted in terms of the base scalars of the given system.
Parameters ==========
expr : Vector/Dyadic/scalar(sympyfiable) The expression to re-express in CoordSys3D 'system'
system: CoordSys3D The coordinate system the expr is to be expressed in
system2: CoordSys3D The other coordinate system required for re-expression (only for a Dyadic Expr)
variables : boolean Specifies whether to substitute the coordinate variables present in expr, in terms of those of parameter system
Examples ========
>>> from sympy.vector import CoordSys3D >>> from sympy import Symbol, cos, sin >>> N = CoordSys3D('N') >>> q = Symbol('q') >>> B = N.orient_new_axis('B', q, N.k) >>> from sympy.vector import express >>> express(B.i, N) (cos(q))*N.i + (sin(q))*N.j >>> express(N.x, B, variables=True) B.x*cos(q) - B.y*sin(q) >>> d = N.i.outer(N.i) >>> express(d, B, N) == (cos(q))*(B.i|N.i) + (-sin(q))*(B.j|N.i) True
"""
if expr in (0, Vector.zero): return expr
if not isinstance(system, CoordSys3D): raise TypeError("system should be a CoordSys3D \ instance")
if isinstance(expr, Vector): if system2 is not None: raise ValueError("system2 should not be provided for \ Vectors") # Given expr is a Vector if variables: # If variables attribute is True, substitute # the coordinate variables in the Vector system_list = {x.system for x in expr.atoms(BaseScalar, BaseVector)} - {system} subs_dict = {} for f in system_list: subs_dict.update(f.scalar_map(system)) expr = expr.subs(subs_dict) # Re-express in this coordinate system outvec = Vector.zero parts = expr.separate() for x in parts: if x != system: temp = system.rotation_matrix(x) * parts[x].to_matrix(x) outvec += matrix_to_vector(temp, system) else: outvec += parts[x] return outvec
elif isinstance(expr, Dyadic): if system2 is None: system2 = system if not isinstance(system2, CoordSys3D): raise TypeError("system2 should be a CoordSys3D \ instance") outdyad = Dyadic.zero var = variables for k, v in expr.components.items(): outdyad += (express(v, system, variables=var) * (express(k.args[0], system, variables=var) | express(k.args[1], system2, variables=var)))
return outdyad
else: if system2 is not None: raise ValueError("system2 should not be provided for \ Vectors") if variables: # Given expr is a scalar field system_set = set() expr = sympify(expr) # Substitute all the coordinate variables for x in expr.atoms(BaseScalar): if x.system != system: system_set.add(x.system) subs_dict = {} for f in system_set: subs_dict.update(f.scalar_map(system)) return expr.subs(subs_dict) return expr
def directional_derivative(field, direction_vector): """ Returns the directional derivative of a scalar or vector field computed along a given vector in coordinate system which parameters are expressed.
Parameters ==========
field : Vector or Scalar The scalar or vector field to compute the directional derivative of
direction_vector : Vector The vector to calculated directional derivative along them.
Examples ========
>>> from sympy.vector import CoordSys3D, directional_derivative >>> R = CoordSys3D('R') >>> f1 = R.x*R.y*R.z >>> v1 = 3*R.i + 4*R.j + R.k >>> directional_derivative(f1, v1) R.x*R.y + 4*R.x*R.z + 3*R.y*R.z >>> f2 = 5*R.x**2*R.z >>> directional_derivative(f2, v1) 5*R.x**2 + 30*R.x*R.z
""" from sympy.vector.operators import _get_coord_systems coord_sys = _get_coord_systems(field) if len(coord_sys) > 0: # TODO: This gets a random coordinate system in case of multiple ones: coord_sys = next(iter(coord_sys)) field = express(field, coord_sys, variables=True) i, j, k = coord_sys.base_vectors() x, y, z = coord_sys.base_scalars() out = Vector.dot(direction_vector, i) * diff(field, x) out += Vector.dot(direction_vector, j) * diff(field, y) out += Vector.dot(direction_vector, k) * diff(field, z) if out == 0 and isinstance(field, Vector): out = Vector.zero return out elif isinstance(field, Vector): return Vector.zero else: return S.Zero
def laplacian(expr): """ Return the laplacian of the given field computed in terms of the base scalars of the given coordinate system.
Parameters ==========
expr : SymPy Expr or Vector expr denotes a scalar or vector field.
Examples ========
>>> from sympy.vector import CoordSys3D, laplacian >>> R = CoordSys3D('R') >>> f = R.x**2*R.y**5*R.z >>> laplacian(f) 20*R.x**2*R.y**3*R.z + 2*R.y**5*R.z >>> f = R.x**2*R.i + R.y**3*R.j + R.z**4*R.k >>> laplacian(f) 2*R.i + 6*R.y*R.j + 12*R.z**2*R.k
"""
delop = Del() if expr.is_Vector: return (gradient(divergence(expr)) - curl(curl(expr))).doit() return delop.dot(delop(expr)).doit()
def is_conservative(field): """ Checks if a field is conservative.
Parameters ==========
field : Vector The field to check for conservative property
Examples ========
>>> from sympy.vector import CoordSys3D >>> from sympy.vector import is_conservative >>> R = CoordSys3D('R') >>> is_conservative(R.y*R.z*R.i + R.x*R.z*R.j + R.x*R.y*R.k) True >>> is_conservative(R.z*R.j) False
"""
# Field is conservative irrespective of system # Take the first coordinate system in the result of the # separate method of Vector if not isinstance(field, Vector): raise TypeError("field should be a Vector") if field == Vector.zero: return True return curl(field).simplify() == Vector.zero
def is_solenoidal(field): """ Checks if a field is solenoidal.
Parameters ==========
field : Vector The field to check for solenoidal property
Examples ========
>>> from sympy.vector import CoordSys3D >>> from sympy.vector import is_solenoidal >>> R = CoordSys3D('R') >>> is_solenoidal(R.y*R.z*R.i + R.x*R.z*R.j + R.x*R.y*R.k) True >>> is_solenoidal(R.y * R.j) False
"""
# Field is solenoidal irrespective of system # Take the first coordinate system in the result of the # separate method in Vector if not isinstance(field, Vector): raise TypeError("field should be a Vector") if field == Vector.zero: return True return divergence(field).simplify() is S.Zero
def scalar_potential(field, coord_sys): """ Returns the scalar potential function of a field in a given coordinate system (without the added integration constant).
Parameters ==========
field : Vector The vector field whose scalar potential function is to be calculated
coord_sys : CoordSys3D The coordinate system to do the calculation in
Examples ========
>>> from sympy.vector import CoordSys3D >>> from sympy.vector import scalar_potential, gradient >>> R = CoordSys3D('R') >>> scalar_potential(R.k, R) == R.z True >>> scalar_field = 2*R.x**2*R.y*R.z >>> grad_field = gradient(scalar_field) >>> scalar_potential(grad_field, R) 2*R.x**2*R.y*R.z
"""
# Check whether field is conservative if not is_conservative(field): raise ValueError("Field is not conservative") if field == Vector.zero: return S.Zero # Express the field exntirely in coord_sys # Substitute coordinate variables also if not isinstance(coord_sys, CoordSys3D): raise TypeError("coord_sys must be a CoordSys3D") field = express(field, coord_sys, variables=True) dimensions = coord_sys.base_vectors() scalars = coord_sys.base_scalars() # Calculate scalar potential function temp_function = integrate(field.dot(dimensions[0]), scalars[0]) for i, dim in enumerate(dimensions[1:]): partial_diff = diff(temp_function, scalars[i + 1]) partial_diff = field.dot(dim) - partial_diff temp_function += integrate(partial_diff, scalars[i + 1]) return temp_function
def scalar_potential_difference(field, coord_sys, point1, point2): """ Returns the scalar potential difference between two points in a certain coordinate system, wrt a given field.
If a scalar field is provided, its values at the two points are considered. If a conservative vector field is provided, the values of its scalar potential function at the two points are used.
Returns (potential at point2) - (potential at point1)
The position vectors of the two Points are calculated wrt the origin of the coordinate system provided.
Parameters ==========
field : Vector/Expr The field to calculate wrt
coord_sys : CoordSys3D The coordinate system to do the calculations in
point1 : Point The initial Point in given coordinate system
position2 : Point The second Point in the given coordinate system
Examples ========
>>> from sympy.vector import CoordSys3D >>> from sympy.vector import scalar_potential_difference >>> R = CoordSys3D('R') >>> P = R.origin.locate_new('P', R.x*R.i + R.y*R.j + R.z*R.k) >>> vectfield = 4*R.x*R.y*R.i + 2*R.x**2*R.j >>> scalar_potential_difference(vectfield, R, R.origin, P) 2*R.x**2*R.y >>> Q = R.origin.locate_new('O', 3*R.i + R.j + 2*R.k) >>> scalar_potential_difference(vectfield, R, P, Q) -2*R.x**2*R.y + 18
"""
if not isinstance(coord_sys, CoordSys3D): raise TypeError("coord_sys must be a CoordSys3D") if isinstance(field, Vector): # Get the scalar potential function scalar_fn = scalar_potential(field, coord_sys) else: # Field is a scalar scalar_fn = field # Express positions in required coordinate system origin = coord_sys.origin position1 = express(point1.position_wrt(origin), coord_sys, variables=True) position2 = express(point2.position_wrt(origin), coord_sys, variables=True) # Get the two positions as substitution dicts for coordinate variables subs_dict1 = {} subs_dict2 = {} scalars = coord_sys.base_scalars() for i, x in enumerate(coord_sys.base_vectors()): subs_dict1[scalars[i]] = x.dot(position1) subs_dict2[scalars[i]] = x.dot(position2) return scalar_fn.subs(subs_dict2) - scalar_fn.subs(subs_dict1)
def matrix_to_vector(matrix, system): """ Converts a vector in matrix form to a Vector instance.
It is assumed that the elements of the Matrix represent the measure numbers of the components of the vector along basis vectors of 'system'.
Parameters ==========
matrix : SymPy Matrix, Dimensions: (3, 1) The matrix to be converted to a vector
system : CoordSys3D The coordinate system the vector is to be defined in
Examples ========
>>> from sympy import ImmutableMatrix as Matrix >>> m = Matrix([1, 2, 3]) >>> from sympy.vector import CoordSys3D, matrix_to_vector >>> C = CoordSys3D('C') >>> v = matrix_to_vector(m, C) >>> v C.i + 2*C.j + 3*C.k >>> v.to_matrix(C) == m True
"""
outvec = Vector.zero vects = system.base_vectors() for i, x in enumerate(matrix): outvec += x * vects[i] return outvec
def _path(from_object, to_object): """ Calculates the 'path' of objects starting from 'from_object' to 'to_object', along with the index of the first common ancestor in the tree.
Returns (index, list) tuple. """
if from_object._root != to_object._root: raise ValueError("No connecting path found between " + str(from_object) + " and " + str(to_object))
other_path = [] obj = to_object while obj._parent is not None: other_path.append(obj) obj = obj._parent other_path.append(obj) object_set = set(other_path) from_path = [] obj = from_object while obj not in object_set: from_path.append(obj) obj = obj._parent index = len(from_path) from_path.extend(other_path[other_path.index(obj)::-1]) return index, from_path
def orthogonalize(*vlist, orthonormal=False): """ Takes a sequence of independent vectors and orthogonalizes them using the Gram - Schmidt process. Returns a list of orthogonal or orthonormal vectors.
Parameters ==========
vlist : sequence of independent vectors to be made orthogonal.
orthonormal : Optional parameter Set to True if the vectors returned should be orthonormal. Default: False
Examples ========
>>> from sympy.vector.coordsysrect import CoordSys3D >>> from sympy.vector.functions import orthogonalize >>> C = CoordSys3D('C') >>> i, j, k = C.base_vectors() >>> v1 = i + 2*j >>> v2 = 2*i + 3*j >>> orthogonalize(v1, v2) [C.i + 2*C.j, 2/5*C.i + (-1/5)*C.j]
References ==========
.. [1] https://en.wikipedia.org/wiki/Gram-Schmidt_process
"""
if not all(isinstance(vec, Vector) for vec in vlist): raise TypeError('Each element must be of Type Vector')
ortho_vlist = [] for i, term in enumerate(vlist): for j in range(i): term -= ortho_vlist[j].projection(vlist[i]) # TODO : The following line introduces a performance issue # and needs to be changed once a good solution for issue #10279 is # found. if term.equals(Vector.zero): raise ValueError("Vector set not linearly independent") ortho_vlist.append(term)
if orthonormal: ortho_vlist = [vec.normalize() for vec in ortho_vlist]
return ortho_vlist123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506from sympy.core.numbers import Rationalfrom sympy.core.singleton import Sfrom sympy.core.symbol import symbolsfrom sympy.functions.elementary.complexes import signfrom sympy.functions.elementary.miscellaneous import sqrtfrom sympy.polys.polytools import gcdfrom sympy.sets.sets import Complementfrom sympy.core import Basic, Tuple, diff, expand, Eq, Integerfrom sympy.core.sorting import orderedfrom sympy.core.symbol import _symbolfrom sympy.solvers import solveset, nonlinsolve, diophantinefrom sympy.polys import total_degreefrom sympy.geometry import Pointfrom sympy.ntheory.factor_ import core
class ImplicitRegion(Basic): """ Represents an implicit region in space.
Examples ========
>>> from sympy import Eq >>> from sympy.abc import x, y, z, t >>> from sympy.vector import ImplicitRegion
>>> ImplicitRegion((x, y), x**2 + y**2 - 4) ImplicitRegion((x, y), x**2 + y**2 - 4) >>> ImplicitRegion((x, y), Eq(y*x, 1)) ImplicitRegion((x, y), x*y - 1)
>>> parabola = ImplicitRegion((x, y), y**2 - 4*x) >>> parabola.degree 2 >>> parabola.equation -4*x + y**2 >>> parabola.rational_parametrization(t) (4/t**2, 4/t)
>>> r = ImplicitRegion((x, y, z), Eq(z, x**2 + y**2)) >>> r.variables (x, y, z) >>> r.singular_points() EmptySet >>> r.regular_point() (-10, -10, 200)
Parameters ==========
variables : tuple to map variables in implicit equation to base scalars.
equation : An expression or Eq denoting the implicit equation of the region.
""" def __new__(cls, variables, equation): if not isinstance(variables, Tuple): variables = Tuple(*variables)
if isinstance(equation, Eq): equation = equation.lhs - equation.rhs
return super().__new__(cls, variables, equation)
@property def variables(self): return self.args[0]
@property def equation(self): return self.args[1]
@property def degree(self): return total_degree(self.equation)
def regular_point(self): """ Returns a point on the implicit region.
Examples ========
>>> from sympy.abc import x, y, z >>> from sympy.vector import ImplicitRegion >>> circle = ImplicitRegion((x, y), (x + 2)**2 + (y - 3)**2 - 16) >>> circle.regular_point() (-2, -1) >>> parabola = ImplicitRegion((x, y), x**2 - 4*y) >>> parabola.regular_point() (0, 0) >>> r = ImplicitRegion((x, y, z), (x + y + z)**4) >>> r.regular_point() (-10, -10, 20)
References ==========
- Erik Hillgarter, "Rational Points on Conics", Diploma Thesis, RISC-Linz, J. Kepler Universitat Linz, 1996. Available: https://www3.risc.jku.at/publications/download/risc_1355/Rational%20Points%20on%20Conics.pdf
""" equation = self.equation
if len(self.variables) == 1: return (list(solveset(equation, self.variables[0], domain=S.Reals))[0],) elif len(self.variables) == 2:
if self.degree == 2: coeffs = a, b, c, d, e, f = conic_coeff(self.variables, equation)
if b**2 == 4*a*c: x_reg, y_reg = self._regular_point_parabola(*coeffs) else: x_reg, y_reg = self._regular_point_ellipse(*coeffs) return x_reg, y_reg
if len(self.variables) == 3: x, y, z = self.variables
for x_reg in range(-10, 10): for y_reg in range(-10, 10): if not solveset(equation.subs({x: x_reg, y: y_reg}), self.variables[2], domain=S.Reals).is_empty: return (x_reg, y_reg, list(solveset(equation.subs({x: x_reg, y: y_reg})))[0])
if len(self.singular_points()) != 0: return list[self.singular_points()][0]
raise NotImplementedError()
def _regular_point_parabola(self, a, b, c, d, e, f): ok = (a, d) != (0, 0) and (c, e) != (0, 0) and b**2 == 4*a*c and (a, c) != (0, 0)
if not ok: raise ValueError("Rational Point on the conic does not exist")
if a != 0: d_dash, f_dash = (4*a*e - 2*b*d, 4*a*f - d**2) if d_dash != 0: y_reg = -f_dash/d_dash x_reg = -(d + b*y_reg)/(2*a) else: ok = False elif c != 0: d_dash, f_dash = (4*c*d - 2*b*e, 4*c*f - e**2) if d_dash != 0: x_reg = -f_dash/d_dash y_reg = -(e + b*x_reg)/(2*c) else: ok = False
if ok: return x_reg, y_reg else: raise ValueError("Rational Point on the conic does not exist")
def _regular_point_ellipse(self, a, b, c, d, e, f): D = 4*a*c - b**2 ok = D
if not ok: raise ValueError("Rational Point on the conic does not exist")
if a == 0 and c == 0: K = -1 L = 4*(d*e - b*f) elif c != 0: K = D L = 4*c**2*d**2 - 4*b*c*d*e + 4*a*c*e**2 + 4*b**2*c*f - 16*a*c**2*f else: K = D L = 4*a**2*e**2 - 4*b*a*d*e + 4*b**2*a*f
ok = L != 0 and not(K > 0 and L < 0) if not ok: raise ValueError("Rational Point on the conic does not exist")
K = Rational(K).limit_denominator(10**12) L = Rational(L).limit_denominator(10**12)
k1, k2 = K.p, K.q l1, l2 = L.p, L.q g = gcd(k2, l2)
a1 = (l2*k2)/g b1 = (k1*l2)/g c1 = -(l1*k2)/g a2 = sign(a1)*core(abs(a1), 2) r1 = sqrt(a1/a2) b2 = sign(b1)*core(abs(b1), 2) r2 = sqrt(b1/b2) c2 = sign(c1)*core(abs(c1), 2) r3 = sqrt(c1/c2)
g = gcd(gcd(a2, b2), c2) a2 = a2/g b2 = b2/g c2 = c2/g
g1 = gcd(a2, b2) a2 = a2/g1 b2 = b2/g1 c2 = c2*g1
g2 = gcd(a2,c2) a2 = a2/g2 b2 = b2*g2 c2 = c2/g2
g3 = gcd(b2, c2) a2 = a2*g3 b2 = b2/g3 c2 = c2/g3
x, y, z = symbols("x y z") eq = a2*x**2 + b2*y**2 + c2*z**2
solutions = diophantine(eq)
if len(solutions) == 0: raise ValueError("Rational Point on the conic does not exist")
flag = False for sol in solutions: syms = Tuple(*sol).free_symbols rep = dict.fromkeys(syms, 3) sol_z = sol[2]
if sol_z == 0: flag = True continue
if not isinstance(sol_z, (int, Integer)): syms_z = sol_z.free_symbols
if len(syms_z) == 1: p = next(iter(syms_z)) p_values = Complement(S.Integers, solveset(Eq(sol_z, 0), p, S.Integers)) rep[p] = next(iter(p_values))
if len(syms_z) == 2: p, q = list(ordered(syms_z))
for i in S.Integers: subs_sol_z = sol_z.subs(p, i) q_values = Complement(S.Integers, solveset(Eq(subs_sol_z, 0), q, S.Integers))
if not q_values.is_empty: rep[p] = i rep[q] = next(iter(q_values)) break
if len(syms) != 0: x, y, z = tuple(s.subs(rep) for s in sol) else: x, y, z = sol flag = False break
if flag: raise ValueError("Rational Point on the conic does not exist")
x = (x*g3)/r1 y = (y*g2)/r2 z = (z*g1)/r3 x = x/z y = y/z
if a == 0 and c == 0: x_reg = (x + y - 2*e)/(2*b) y_reg = (x - y - 2*d)/(2*b) elif c != 0: x_reg = (x - 2*d*c + b*e)/K y_reg = (y - b*x_reg - e)/(2*c) else: y_reg = (x - 2*e*a + b*d)/K x_reg = (y - b*y_reg - d)/(2*a)
return x_reg, y_reg
def singular_points(self): """ Returns a set of singular points of the region.
The singular points are those points on the region where all partial derivatives vanish.
Examples ========
>>> from sympy.abc import x, y >>> from sympy.vector import ImplicitRegion >>> I = ImplicitRegion((x, y), (y-1)**2 -x**3 + 2*x**2 -x) >>> I.singular_points() {(1, 1)}
""" eq_list = [self.equation] for var in self.variables: eq_list += [diff(self.equation, var)]
return nonlinsolve(eq_list, list(self.variables))
def multiplicity(self, point): """ Returns the multiplicity of a singular point on the region.
A singular point (x,y) of region is said to be of multiplicity m if all the partial derivatives off to order m - 1 vanish there.
Examples ========
>>> from sympy.abc import x, y, z >>> from sympy.vector import ImplicitRegion >>> I = ImplicitRegion((x, y, z), x**2 + y**3 - z**4) >>> I.singular_points() {(0, 0, 0)} >>> I.multiplicity((0, 0, 0)) 2
""" if isinstance(point, Point): point = point.args
modified_eq = self.equation
for i, var in enumerate(self.variables): modified_eq = modified_eq.subs(var, var + point[i]) modified_eq = expand(modified_eq)
if len(modified_eq.args) != 0: terms = modified_eq.args m = min(total_degree(term) for term in terms) else: terms = modified_eq m = total_degree(terms)
return m
def rational_parametrization(self, parameters=('t', 's'), reg_point=None): """ Returns the rational parametrization of implicit region.
Examples ========
>>> from sympy import Eq >>> from sympy.abc import x, y, z, s, t >>> from sympy.vector import ImplicitRegion
>>> parabola = ImplicitRegion((x, y), y**2 - 4*x) >>> parabola.rational_parametrization() (4/t**2, 4/t)
>>> circle = ImplicitRegion((x, y), Eq(x**2 + y**2, 4)) >>> circle.rational_parametrization() (4*t/(t**2 + 1), 4*t**2/(t**2 + 1) - 2)
>>> I = ImplicitRegion((x, y), x**3 + x**2 - y**2) >>> I.rational_parametrization() (t**2 - 1, t*(t**2 - 1))
>>> cubic_curve = ImplicitRegion((x, y), x**3 + x**2 - y**2) >>> cubic_curve.rational_parametrization(parameters=(t)) (t**2 - 1, t*(t**2 - 1))
>>> sphere = ImplicitRegion((x, y, z), x**2 + y**2 + z**2 - 4) >>> sphere.rational_parametrization(parameters=(t, s)) (-2 + 4/(s**2 + t**2 + 1), 4*s/(s**2 + t**2 + 1), 4*t/(s**2 + t**2 + 1))
For some conics, regular_points() is unable to find a point on curve. To calulcate the parametric representation in such cases, user need to determine a point on the region and pass it using reg_point.
>>> c = ImplicitRegion((x, y), (x - 1/2)**2 + (y)**2 - (1/4)**2) >>> c.rational_parametrization(reg_point=(3/4, 0)) (0.75 - 0.5/(t**2 + 1), -0.5*t/(t**2 + 1))
References ==========
- Christoph M. Hoffmann, "Conversion Methods between Parametric and Implicit Curves and Surfaces", Purdue e-Pubs, 1990. Available: https://docs.lib.purdue.edu/cgi/viewcontent.cgi?article=1827&context=cstech
""" equation = self.equation degree = self.degree
if degree == 1: if len(self.variables) == 1: return (equation,) elif len(self.variables) == 2: x, y = self.variables y_par = list(solveset(equation, y))[0] return x, y_par else: raise NotImplementedError()
point = ()
# Finding the (n - 1) fold point of the monoid of degree if degree == 2: # For degree 2 curves, either a regular point or a singular point can be used. if reg_point is not None: # Using point provided by the user as regular point point = reg_point else: if len(self.singular_points()) != 0: point = list(self.singular_points())[0] else: point = self.regular_point()
if len(self.singular_points()) != 0: singular_points = self.singular_points() for spoint in singular_points: syms = Tuple(*spoint).free_symbols rep = dict.fromkeys(syms, 2)
if len(syms) != 0: spoint = tuple(s.subs(rep) for s in spoint)
if self.multiplicity(spoint) == degree - 1: point = spoint break
if len(point) == 0: # The region in not a monoid raise NotImplementedError()
modified_eq = equation
# Shifting the region such that fold point moves to origin for i, var in enumerate(self.variables): modified_eq = modified_eq.subs(var, var + point[i]) modified_eq = expand(modified_eq)
hn = hn_1 = 0 for term in modified_eq.args: if total_degree(term) == degree: hn += term else: hn_1 += term
hn_1 = -1*hn_1
if not isinstance(parameters, tuple): parameters = (parameters,)
if len(self.variables) == 2:
parameter1 = parameters[0] if parameter1 == 's': # To avoid name conflict between parameters s = _symbol('s_', real=True) else: s = _symbol('s', real=True) t = _symbol(parameter1, real=True)
hn = hn.subs({self.variables[0]: s, self.variables[1]: t}) hn_1 = hn_1.subs({self.variables[0]: s, self.variables[1]: t})
x_par = (s*(hn_1/hn)).subs(s, 1) + point[0] y_par = (t*(hn_1/hn)).subs(s, 1) + point[1]
return x_par, y_par
elif len(self.variables) == 3:
parameter1, parameter2 = parameters if 'r' in parameters: # To avoid name conflict between parameters r = _symbol('r_', real=True) else: r = _symbol('r', real=True) s = _symbol(parameter2, real=True) t = _symbol(parameter1, real=True)
hn = hn.subs({self.variables[0]: r, self.variables[1]: s, self.variables[2]: t}) hn_1 = hn_1.subs({self.variables[0]: r, self.variables[1]: s, self.variables[2]: t})
x_par = (r*(hn_1/hn)).subs(r, 1) + point[0] y_par = (s*(hn_1/hn)).subs(r, 1) + point[1] z_par = (t*(hn_1/hn)).subs(r, 1) + point[2]
return x_par, y_par, z_par
raise NotImplementedError()
def conic_coeff(variables, equation): if total_degree(equation) != 2: raise ValueError() x = variables[0] y = variables[1]
equation = expand(equation) a = equation.coeff(x**2) b = equation.coeff(x*y) c = equation.coeff(y**2) d = equation.coeff(x, 1).coeff(y, 0) e = equation.coeff(y, 1).coeff(x, 0) f = equation.coeff(x, 0).coeff(y, 0) return a, b, c, d, e, f123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206from sympy.core import Basic, difffrom sympy.core.singleton import Sfrom sympy.core.sorting import default_sort_keyfrom sympy.matrices import Matrixfrom sympy.integrals import Integral, integratefrom sympy.geometry.entity import GeometryEntityfrom sympy.simplify.simplify import simplifyfrom sympy.utilities.iterables import topological_sortfrom sympy.vector import (CoordSys3D, Vector, ParametricRegion, parametric_region_list, ImplicitRegion)from sympy.vector.operators import _get_coord_systems
class ParametricIntegral(Basic): """ Represents integral of a scalar or vector field over a Parametric Region
Examples ========
>>> from sympy import cos, sin, pi >>> from sympy.vector import CoordSys3D, ParametricRegion, ParametricIntegral >>> from sympy.abc import r, t, theta, phi
>>> C = CoordSys3D('C') >>> curve = ParametricRegion((3*t - 2, t + 1), (t, 1, 2)) >>> ParametricIntegral(C.x, curve) 5*sqrt(10)/2 >>> length = ParametricIntegral(1, curve) >>> length sqrt(10) >>> semisphere = ParametricRegion((2*sin(phi)*cos(theta), 2*sin(phi)*sin(theta), 2*cos(phi)),\ (theta, 0, 2*pi), (phi, 0, pi/2)) >>> ParametricIntegral(C.z, semisphere) 8*pi
>>> ParametricIntegral(C.j + C.k, ParametricRegion((r*cos(theta), r*sin(theta)), r, theta)) 0
"""
def __new__(cls, field, parametricregion):
coord_set = _get_coord_systems(field)
if len(coord_set) == 0: coord_sys = CoordSys3D('C') elif len(coord_set) > 1: raise ValueError else: coord_sys = next(iter(coord_set))
if parametricregion.dimensions == 0: return S.Zero
base_vectors = coord_sys.base_vectors() base_scalars = coord_sys.base_scalars()
parametricfield = field
r = Vector.zero for i in range(len(parametricregion.definition)): r += base_vectors[i]*parametricregion.definition[i]
if len(coord_set) != 0: for i in range(len(parametricregion.definition)): parametricfield = parametricfield.subs(base_scalars[i], parametricregion.definition[i])
if parametricregion.dimensions == 1: parameter = parametricregion.parameters[0]
r_diff = diff(r, parameter) lower, upper = parametricregion.limits[parameter][0], parametricregion.limits[parameter][1]
if isinstance(parametricfield, Vector): integrand = simplify(r_diff.dot(parametricfield)) else: integrand = simplify(r_diff.magnitude()*parametricfield)
result = integrate(integrand, (parameter, lower, upper))
elif parametricregion.dimensions == 2: u, v = cls._bounds_case(parametricregion.parameters, parametricregion.limits)
r_u = diff(r, u) r_v = diff(r, v) normal_vector = simplify(r_u.cross(r_v))
if isinstance(parametricfield, Vector): integrand = parametricfield.dot(normal_vector) else: integrand = parametricfield*normal_vector.magnitude()
integrand = simplify(integrand)
lower_u, upper_u = parametricregion.limits[u][0], parametricregion.limits[u][1] lower_v, upper_v = parametricregion.limits[v][0], parametricregion.limits[v][1]
result = integrate(integrand, (u, lower_u, upper_u), (v, lower_v, upper_v))
else: variables = cls._bounds_case(parametricregion.parameters, parametricregion.limits) coeff = Matrix(parametricregion.definition).jacobian(variables).det() integrand = simplify(parametricfield*coeff)
l = [(var, parametricregion.limits[var][0], parametricregion.limits[var][1]) for var in variables] result = integrate(integrand, *l)
if not isinstance(result, Integral): return result else: return super().__new__(cls, field, parametricregion)
@classmethod def _bounds_case(cls, parameters, limits):
V = list(limits.keys()) E = []
for p in V: lower_p = limits[p][0] upper_p = limits[p][1]
lower_p = lower_p.atoms() upper_p = upper_p.atoms() E.extend((p, q) for q in V if p != q and (lower_p.issuperset({q}) or upper_p.issuperset({q})))
if not E: return parameters else: return topological_sort((V, E), key=default_sort_key)
@property def field(self): return self.args[0]
@property def parametricregion(self): return self.args[1]
def vector_integrate(field, *region): """ Compute the integral of a vector/scalar field over a a region or a set of parameters.
Examples ======== >>> from sympy.vector import CoordSys3D, ParametricRegion, vector_integrate >>> from sympy.abc import x, y, t >>> C = CoordSys3D('C')
>>> region = ParametricRegion((t, t**2), (t, 1, 5)) >>> vector_integrate(C.x*C.i, region) 12
Integrals over some objects of geometry module can also be calculated.
>>> from sympy.geometry import Point, Circle, Triangle >>> c = Circle(Point(0, 2), 5) >>> vector_integrate(C.x**2 + C.y**2, c) 290*pi >>> triangle = Triangle(Point(-2, 3), Point(2, 3), Point(0, 5)) >>> vector_integrate(3*C.x**2*C.y*C.i + C.j, triangle) -8
Integrals over some simple implicit regions can be computed. But in most cases, it takes too long to compute over them. This is due to the expressions of parametric representation becoming large.
>>> from sympy.vector import ImplicitRegion >>> c2 = ImplicitRegion((x, y), (x - 2)**2 + (y - 1)**2 - 9) >>> vector_integrate(1, c2) 6*pi
Integral of fields with respect to base scalars:
>>> vector_integrate(12*C.y**3, (C.y, 1, 3)) 240 >>> vector_integrate(C.x**2*C.z, C.x) C.x**3*C.z/3 >>> vector_integrate(C.x*C.i - C.y*C.k, C.x) (Integral(C.x, C.x))*C.i + (Integral(-C.y, C.x))*C.k >>> _.doit() C.x**2/2*C.i + (-C.x*C.y)*C.k
""" if len(region) == 1: if isinstance(region[0], ParametricRegion): return ParametricIntegral(field, region[0])
if isinstance(region[0], ImplicitRegion): region = parametric_region_list(region[0])[0] return vector_integrate(field, region)
if isinstance(region[0], GeometryEntity): regions_list = parametric_region_list(region[0])
result = 0 for reg in regions_list: result += vector_integrate(field, reg) return result
return integrate(field, *region)12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667#sympy.vector.kind
from sympy.core.kind import Kind, _NumberKind, NumberKindfrom sympy.core.mul import Mul
class VectorKind(Kind): """ Kind for all vector objects in SymPy.
Parameters ==========
element_kind : Kind Kind of the element. Default is :class:`sympy.core.kind.NumberKind`, which means that the vector contains only numbers.
Examples ========
Any instance of Vector class has kind ``VectorKind``:
>>> from sympy.vector.coordsysrect import CoordSys3D >>> Sys = CoordSys3D('Sys') >>> Sys.i.kind VectorKind(NumberKind)
Operations between instances of Vector keep also have the kind ``VectorKind``:
>>> from sympy.core.add import Add >>> v1 = Sys.i * 2 + Sys.j * 3 + Sys.k * 4 >>> v2 = Sys.i * Sys.x + Sys.j * Sys.y + Sys.k * Sys.z >>> v1.kind VectorKind(NumberKind) >>> v2.kind VectorKind(NumberKind) >>> Add(v1, v2).kind VectorKind(NumberKind)
Subclasses of Vector also have the kind ``VectorKind``, such as Cross, VectorAdd, VectorMul or VectorZero.
See Also ========
sympy.core.kind.Kind sympy.matrices.kind.MatrixKind
""" def __new__(cls, element_kind=NumberKind): obj = super().__new__(cls, element_kind) obj.element_kind = element_kind return obj
def __repr__(self): return "VectorKind(%s)" % self.element_kind
@Mul._kind_dispatcher.register(_NumberKind, VectorKind)def num_vec_mul(k1, k2): """ The result of a multiplication between a number and a Vector should be of VectorKind. The element kind is selected by recursive dispatching. """ if not isinstance(k2, VectorKind): k1, k2 = k2, k1 elemk = Mul._kind_dispatcher(k1, k2.element_kind) return VectorKind(elemk)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335import collectionsfrom sympy.core.expr import Exprfrom sympy.core import sympify, S, preorder_traversalfrom sympy.vector.coordsysrect import CoordSys3Dfrom sympy.vector.vector import Vector, VectorMul, VectorAdd, Cross, Dotfrom sympy.core.function import Derivativefrom sympy.core.add import Addfrom sympy.core.mul import Mul
def _get_coord_systems(expr): g = preorder_traversal(expr) ret = set() for i in g: if isinstance(i, CoordSys3D): ret.add(i) g.skip() return frozenset(ret)
def _split_mul_args_wrt_coordsys(expr): d = collections.defaultdict(lambda: S.One) for i in expr.args: d[_get_coord_systems(i)] *= i return list(d.values())
class Gradient(Expr): """ Represents unevaluated Gradient.
Examples ========
>>> from sympy.vector import CoordSys3D, Gradient >>> R = CoordSys3D('R') >>> s = R.x*R.y*R.z >>> Gradient(s) Gradient(R.x*R.y*R.z)
"""
def __new__(cls, expr): expr = sympify(expr) obj = Expr.__new__(cls, expr) obj._expr = expr return obj
def doit(self, **hints): return gradient(self._expr, doit=True)
class Divergence(Expr): """ Represents unevaluated Divergence.
Examples ========
>>> from sympy.vector import CoordSys3D, Divergence >>> R = CoordSys3D('R') >>> v = R.y*R.z*R.i + R.x*R.z*R.j + R.x*R.y*R.k >>> Divergence(v) Divergence(R.y*R.z*R.i + R.x*R.z*R.j + R.x*R.y*R.k)
"""
def __new__(cls, expr): expr = sympify(expr) obj = Expr.__new__(cls, expr) obj._expr = expr return obj
def doit(self, **hints): return divergence(self._expr, doit=True)
class Curl(Expr): """ Represents unevaluated Curl.
Examples ========
>>> from sympy.vector import CoordSys3D, Curl >>> R = CoordSys3D('R') >>> v = R.y*R.z*R.i + R.x*R.z*R.j + R.x*R.y*R.k >>> Curl(v) Curl(R.y*R.z*R.i + R.x*R.z*R.j + R.x*R.y*R.k)
"""
def __new__(cls, expr): expr = sympify(expr) obj = Expr.__new__(cls, expr) obj._expr = expr return obj
def doit(self, **hints): return curl(self._expr, doit=True)
def curl(vect, doit=True): """ Returns the curl of a vector field computed wrt the base scalars of the given coordinate system.
Parameters ==========
vect : Vector The vector operand
doit : bool If True, the result is returned after calling .doit() on each component. Else, the returned expression contains Derivative instances
Examples ========
>>> from sympy.vector import CoordSys3D, curl >>> R = CoordSys3D('R') >>> v1 = R.y*R.z*R.i + R.x*R.z*R.j + R.x*R.y*R.k >>> curl(v1) 0 >>> v2 = R.x*R.y*R.z*R.i >>> curl(v2) R.x*R.y*R.j + (-R.x*R.z)*R.k
"""
coord_sys = _get_coord_systems(vect)
if len(coord_sys) == 0: return Vector.zero elif len(coord_sys) == 1: coord_sys = next(iter(coord_sys)) i, j, k = coord_sys.base_vectors() x, y, z = coord_sys.base_scalars() h1, h2, h3 = coord_sys.lame_coefficients() vectx = vect.dot(i) vecty = vect.dot(j) vectz = vect.dot(k) outvec = Vector.zero outvec += (Derivative(vectz * h3, y) - Derivative(vecty * h2, z)) * i / (h2 * h3) outvec += (Derivative(vectx * h1, z) - Derivative(vectz * h3, x)) * j / (h1 * h3) outvec += (Derivative(vecty * h2, x) - Derivative(vectx * h1, y)) * k / (h2 * h1)
if doit: return outvec.doit() return outvec else: if isinstance(vect, (Add, VectorAdd)): from sympy.vector import express try: cs = next(iter(coord_sys)) args = [express(i, cs, variables=True) for i in vect.args] except ValueError: args = vect.args return VectorAdd.fromiter(curl(i, doit=doit) for i in args) elif isinstance(vect, (Mul, VectorMul)): vector = [i for i in vect.args if isinstance(i, (Vector, Cross, Gradient))][0] scalar = Mul.fromiter(i for i in vect.args if not isinstance(i, (Vector, Cross, Gradient))) res = Cross(gradient(scalar), vector).doit() + scalar*curl(vector, doit=doit) if doit: return res.doit() return res elif isinstance(vect, (Cross, Curl, Gradient)): return Curl(vect) else: raise ValueError("Invalid argument for curl")
def divergence(vect, doit=True): """ Returns the divergence of a vector field computed wrt the base scalars of the given coordinate system.
Parameters ==========
vector : Vector The vector operand
doit : bool If True, the result is returned after calling .doit() on each component. Else, the returned expression contains Derivative instances
Examples ========
>>> from sympy.vector import CoordSys3D, divergence >>> R = CoordSys3D('R') >>> v1 = R.x*R.y*R.z * (R.i+R.j+R.k)
>>> divergence(v1) R.x*R.y + R.x*R.z + R.y*R.z >>> v2 = 2*R.y*R.z*R.j >>> divergence(v2) 2*R.z
""" coord_sys = _get_coord_systems(vect) if len(coord_sys) == 0: return S.Zero elif len(coord_sys) == 1: if isinstance(vect, (Cross, Curl, Gradient)): return Divergence(vect) # TODO: is case of many coord systems, this gets a random one: coord_sys = next(iter(coord_sys)) i, j, k = coord_sys.base_vectors() x, y, z = coord_sys.base_scalars() h1, h2, h3 = coord_sys.lame_coefficients() vx = _diff_conditional(vect.dot(i), x, h2, h3) \ / (h1 * h2 * h3) vy = _diff_conditional(vect.dot(j), y, h3, h1) \ / (h1 * h2 * h3) vz = _diff_conditional(vect.dot(k), z, h1, h2) \ / (h1 * h2 * h3) res = vx + vy + vz if doit: return res.doit() return res else: if isinstance(vect, (Add, VectorAdd)): return Add.fromiter(divergence(i, doit=doit) for i in vect.args) elif isinstance(vect, (Mul, VectorMul)): vector = [i for i in vect.args if isinstance(i, (Vector, Cross, Gradient))][0] scalar = Mul.fromiter(i for i in vect.args if not isinstance(i, (Vector, Cross, Gradient))) res = Dot(vector, gradient(scalar)) + scalar*divergence(vector, doit=doit) if doit: return res.doit() return res elif isinstance(vect, (Cross, Curl, Gradient)): return Divergence(vect) else: raise ValueError("Invalid argument for divergence")
def gradient(scalar_field, doit=True): """ Returns the vector gradient of a scalar field computed wrt the base scalars of the given coordinate system.
Parameters ==========
scalar_field : SymPy Expr The scalar field to compute the gradient of
doit : bool If True, the result is returned after calling .doit() on each component. Else, the returned expression contains Derivative instances
Examples ========
>>> from sympy.vector import CoordSys3D, gradient >>> R = CoordSys3D('R') >>> s1 = R.x*R.y*R.z >>> gradient(s1) R.y*R.z*R.i + R.x*R.z*R.j + R.x*R.y*R.k >>> s2 = 5*R.x**2*R.z >>> gradient(s2) 10*R.x*R.z*R.i + 5*R.x**2*R.k
""" coord_sys = _get_coord_systems(scalar_field)
if len(coord_sys) == 0: return Vector.zero elif len(coord_sys) == 1: coord_sys = next(iter(coord_sys)) h1, h2, h3 = coord_sys.lame_coefficients() i, j, k = coord_sys.base_vectors() x, y, z = coord_sys.base_scalars() vx = Derivative(scalar_field, x) / h1 vy = Derivative(scalar_field, y) / h2 vz = Derivative(scalar_field, z) / h3
if doit: return (vx * i + vy * j + vz * k).doit() return vx * i + vy * j + vz * k else: if isinstance(scalar_field, (Add, VectorAdd)): return VectorAdd.fromiter(gradient(i) for i in scalar_field.args) if isinstance(scalar_field, (Mul, VectorMul)): s = _split_mul_args_wrt_coordsys(scalar_field) return VectorAdd.fromiter(scalar_field / i * gradient(i) for i in s) return Gradient(scalar_field)
class Laplacian(Expr): """ Represents unevaluated Laplacian.
Examples ========
>>> from sympy.vector import CoordSys3D, Laplacian >>> R = CoordSys3D('R') >>> v = 3*R.x**3*R.y**2*R.z**3 >>> Laplacian(v) Laplacian(3*R.x**3*R.y**2*R.z**3)
"""
def __new__(cls, expr): expr = sympify(expr) obj = Expr.__new__(cls, expr) obj._expr = expr return obj
def doit(self, **hints): from sympy.vector.functions import laplacian return laplacian(self._expr)
def _diff_conditional(expr, base_scalar, coeff_1, coeff_2): """ First re-expresses expr in the system that base_scalar belongs to. If base_scalar appears in the re-expressed form, differentiates it wrt base_scalar. Else, returns 0 """ from sympy.vector.functions import express new_expr = express(expr, base_scalar.system, variables=True) arg = coeff_1 * coeff_2 * new_expr return Derivative(arg, base_scalar) if arg else S.Zero123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398from sympy.core.basic import Basicfrom sympy.core.sympify import sympifyfrom sympy.functions.elementary.trigonometric import (cos, sin)from sympy.matrices.dense import (eye, rot_axis1, rot_axis2, rot_axis3)from sympy.matrices.immutable import ImmutableDenseMatrix as Matrixfrom sympy.core.cache import cacheitfrom sympy.core.symbol import Strimport sympy.vector
class Orienter(Basic): """ Super-class for all orienter classes. """
def rotation_matrix(self): """ The rotation matrix corresponding to this orienter instance. """ return self._parent_orient
class AxisOrienter(Orienter): """ Class to denote an axis orienter. """
def __new__(cls, angle, axis): if not isinstance(axis, sympy.vector.Vector): raise TypeError("axis should be a Vector") angle = sympify(angle)
obj = super().__new__(cls, angle, axis) obj._angle = angle obj._axis = axis
return obj
def __init__(self, angle, axis): """ Axis rotation is a rotation about an arbitrary axis by some angle. The angle is supplied as a SymPy expr scalar, and the axis is supplied as a Vector.
Parameters ==========
angle : Expr The angle by which the new system is to be rotated
axis : Vector The axis around which the rotation has to be performed
Examples ========
>>> from sympy.vector import CoordSys3D >>> from sympy import symbols >>> q1 = symbols('q1') >>> N = CoordSys3D('N') >>> from sympy.vector import AxisOrienter >>> orienter = AxisOrienter(q1, N.i + 2 * N.j) >>> B = N.orient_new('B', (orienter, ))
""" # Dummy initializer for docstrings pass
@cacheit def rotation_matrix(self, system): """ The rotation matrix corresponding to this orienter instance.
Parameters ==========
system : CoordSys3D The coordinate system wrt which the rotation matrix is to be computed """
axis = sympy.vector.express(self.axis, system).normalize() axis = axis.to_matrix(system) theta = self.angle parent_orient = ((eye(3) - axis * axis.T) * cos(theta) + Matrix([[0, -axis[2], axis[1]], [axis[2], 0, -axis[0]], [-axis[1], axis[0], 0]]) * sin(theta) + axis * axis.T) parent_orient = parent_orient.T return parent_orient
@property def angle(self): return self._angle
@property def axis(self): return self._axis
class ThreeAngleOrienter(Orienter): """ Super-class for Body and Space orienters. """
def __new__(cls, angle1, angle2, angle3, rot_order): if isinstance(rot_order, Str): rot_order = rot_order.name
approved_orders = ('123', '231', '312', '132', '213', '321', '121', '131', '212', '232', '313', '323', '') original_rot_order = rot_order rot_order = str(rot_order).upper() if not (len(rot_order) == 3): raise TypeError('rot_order should be a str of length 3') rot_order = [i.replace('X', '1') for i in rot_order] rot_order = [i.replace('Y', '2') for i in rot_order] rot_order = [i.replace('Z', '3') for i in rot_order] rot_order = ''.join(rot_order) if rot_order not in approved_orders: raise TypeError('Invalid rot_type parameter') a1 = int(rot_order[0]) a2 = int(rot_order[1]) a3 = int(rot_order[2]) angle1 = sympify(angle1) angle2 = sympify(angle2) angle3 = sympify(angle3) if cls._in_order: parent_orient = (_rot(a1, angle1) * _rot(a2, angle2) * _rot(a3, angle3)) else: parent_orient = (_rot(a3, angle3) * _rot(a2, angle2) * _rot(a1, angle1)) parent_orient = parent_orient.T
obj = super().__new__( cls, angle1, angle2, angle3, Str(rot_order)) obj._angle1 = angle1 obj._angle2 = angle2 obj._angle3 = angle3 obj._rot_order = original_rot_order obj._parent_orient = parent_orient
return obj
@property def angle1(self): return self._angle1
@property def angle2(self): return self._angle2
@property def angle3(self): return self._angle3
@property def rot_order(self): return self._rot_order
class BodyOrienter(ThreeAngleOrienter): """ Class to denote a body-orienter. """
_in_order = True
def __new__(cls, angle1, angle2, angle3, rot_order): obj = ThreeAngleOrienter.__new__(cls, angle1, angle2, angle3, rot_order) return obj
def __init__(self, angle1, angle2, angle3, rot_order): """ Body orientation takes this coordinate system through three successive simple rotations.
Body fixed rotations include both Euler Angles and Tait-Bryan Angles, see https://en.wikipedia.org/wiki/Euler_angles.
Parameters ==========
angle1, angle2, angle3 : Expr Three successive angles to rotate the coordinate system by
rotation_order : string String defining the order of axes for rotation
Examples ========
>>> from sympy.vector import CoordSys3D, BodyOrienter >>> from sympy import symbols >>> q1, q2, q3 = symbols('q1 q2 q3') >>> N = CoordSys3D('N')
A 'Body' fixed rotation is described by three angles and three body-fixed rotation axes. To orient a coordinate system D with respect to N, each sequential rotation is always about the orthogonal unit vectors fixed to D. For example, a '123' rotation will specify rotations about N.i, then D.j, then D.k. (Initially, D.i is same as N.i) Therefore,
>>> body_orienter = BodyOrienter(q1, q2, q3, '123') >>> D = N.orient_new('D', (body_orienter, ))
is same as
>>> from sympy.vector import AxisOrienter >>> axis_orienter1 = AxisOrienter(q1, N.i) >>> D = N.orient_new('D', (axis_orienter1, )) >>> axis_orienter2 = AxisOrienter(q2, D.j) >>> D = D.orient_new('D', (axis_orienter2, )) >>> axis_orienter3 = AxisOrienter(q3, D.k) >>> D = D.orient_new('D', (axis_orienter3, ))
Acceptable rotation orders are of length 3, expressed in XYZ or 123, and cannot have a rotation about about an axis twice in a row.
>>> body_orienter1 = BodyOrienter(q1, q2, q3, '123') >>> body_orienter2 = BodyOrienter(q1, q2, 0, 'ZXZ') >>> body_orienter3 = BodyOrienter(0, 0, 0, 'XYX')
""" # Dummy initializer for docstrings pass
class SpaceOrienter(ThreeAngleOrienter): """ Class to denote a space-orienter. """
_in_order = False
def __new__(cls, angle1, angle2, angle3, rot_order): obj = ThreeAngleOrienter.__new__(cls, angle1, angle2, angle3, rot_order) return obj
def __init__(self, angle1, angle2, angle3, rot_order): """ Space rotation is similar to Body rotation, but the rotations are applied in the opposite order.
Parameters ==========
angle1, angle2, angle3 : Expr Three successive angles to rotate the coordinate system by
rotation_order : string String defining the order of axes for rotation
See Also ========
BodyOrienter : Orienter to orient systems wrt Euler angles.
Examples ========
>>> from sympy.vector import CoordSys3D, SpaceOrienter >>> from sympy import symbols >>> q1, q2, q3 = symbols('q1 q2 q3') >>> N = CoordSys3D('N')
To orient a coordinate system D with respect to N, each sequential rotation is always about N's orthogonal unit vectors. For example, a '123' rotation will specify rotations about N.i, then N.j, then N.k. Therefore,
>>> space_orienter = SpaceOrienter(q1, q2, q3, '312') >>> D = N.orient_new('D', (space_orienter, ))
is same as
>>> from sympy.vector import AxisOrienter >>> axis_orienter1 = AxisOrienter(q1, N.i) >>> B = N.orient_new('B', (axis_orienter1, )) >>> axis_orienter2 = AxisOrienter(q2, N.j) >>> C = B.orient_new('C', (axis_orienter2, )) >>> axis_orienter3 = AxisOrienter(q3, N.k) >>> D = C.orient_new('C', (axis_orienter3, ))
""" # Dummy initializer for docstrings pass
class QuaternionOrienter(Orienter): """ Class to denote a quaternion-orienter. """
def __new__(cls, q0, q1, q2, q3): q0 = sympify(q0) q1 = sympify(q1) q2 = sympify(q2) q3 = sympify(q3) parent_orient = (Matrix([[q0 ** 2 + q1 ** 2 - q2 ** 2 - q3 ** 2, 2 * (q1 * q2 - q0 * q3), 2 * (q0 * q2 + q1 * q3)], [2 * (q1 * q2 + q0 * q3), q0 ** 2 - q1 ** 2 + q2 ** 2 - q3 ** 2, 2 * (q2 * q3 - q0 * q1)], [2 * (q1 * q3 - q0 * q2), 2 * (q0 * q1 + q2 * q3), q0 ** 2 - q1 ** 2 - q2 ** 2 + q3 ** 2]])) parent_orient = parent_orient.T
obj = super().__new__(cls, q0, q1, q2, q3) obj._q0 = q0 obj._q1 = q1 obj._q2 = q2 obj._q3 = q3 obj._parent_orient = parent_orient
return obj
def __init__(self, angle1, angle2, angle3, rot_order): """ Quaternion orientation orients the new CoordSys3D with Quaternions, defined as a finite rotation about lambda, a unit vector, by some amount theta.
This orientation is described by four parameters:
q0 = cos(theta/2)
q1 = lambda_x sin(theta/2)
q2 = lambda_y sin(theta/2)
q3 = lambda_z sin(theta/2)
Quaternion does not take in a rotation order.
Parameters ==========
q0, q1, q2, q3 : Expr The quaternions to rotate the coordinate system by
Examples ========
>>> from sympy.vector import CoordSys3D >>> from sympy import symbols >>> q0, q1, q2, q3 = symbols('q0 q1 q2 q3') >>> N = CoordSys3D('N') >>> from sympy.vector import QuaternionOrienter >>> q_orienter = QuaternionOrienter(q0, q1, q2, q3) >>> B = N.orient_new('B', (q_orienter, ))
""" # Dummy initializer for docstrings pass
@property def q0(self): return self._q0
@property def q1(self): return self._q1
@property def q2(self): return self._q2
@property def q3(self): return self._q3
def _rot(axis, angle): """DCM for simple axis 1, 2 or 3 rotations. """ if axis == 1: return Matrix(rot_axis1(angle).T) elif axis == 2: return Matrix(rot_axis2(angle).T) elif axis == 3: return Matrix(rot_axis3(angle).T)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189from functools import singledispatchfrom sympy.core.numbers import pifrom sympy.functions.elementary.trigonometric import tanfrom sympy.simplify import trigsimpfrom sympy.core import Basic, Tuplefrom sympy.core.symbol import _symbolfrom sympy.solvers import solvefrom sympy.geometry import Point, Segment, Curve, Ellipse, Polygonfrom sympy.vector import ImplicitRegion
class ParametricRegion(Basic): """ Represents a parametric region in space.
Examples ========
>>> from sympy import cos, sin, pi >>> from sympy.abc import r, theta, t, a, b, x, y >>> from sympy.vector import ParametricRegion
>>> ParametricRegion((t, t**2), (t, -1, 2)) ParametricRegion((t, t**2), (t, -1, 2)) >>> ParametricRegion((x, y), (x, 3, 4), (y, 5, 6)) ParametricRegion((x, y), (x, 3, 4), (y, 5, 6)) >>> ParametricRegion((r*cos(theta), r*sin(theta)), (r, -2, 2), (theta, 0, pi)) ParametricRegion((r*cos(theta), r*sin(theta)), (r, -2, 2), (theta, 0, pi)) >>> ParametricRegion((a*cos(t), b*sin(t)), t) ParametricRegion((a*cos(t), b*sin(t)), t)
>>> circle = ParametricRegion((r*cos(theta), r*sin(theta)), r, (theta, 0, pi)) >>> circle.parameters (r, theta) >>> circle.definition (r*cos(theta), r*sin(theta)) >>> circle.limits {theta: (0, pi)}
Dimension of a parametric region determines whether a region is a curve, surface or volume region. It does not represent its dimensions in space.
>>> circle.dimensions 1
Parameters ==========
definition : tuple to define base scalars in terms of parameters.
bounds : Parameter or a tuple of length 3 to define parameter and corresponding lower and upper bound.
""" def __new__(cls, definition, *bounds): parameters = () limits = {}
if not isinstance(bounds, Tuple): bounds = Tuple(*bounds)
for bound in bounds: if isinstance(bound, (tuple, Tuple)): if len(bound) != 3: raise ValueError("Tuple should be in the form (parameter, lowerbound, upperbound)") parameters += (bound[0],) limits[bound[0]] = (bound[1], bound[2]) else: parameters += (bound,)
if not isinstance(definition, (tuple, Tuple)): definition = (definition,)
obj = super().__new__(cls, Tuple(*definition), *bounds) obj._parameters = parameters obj._limits = limits
return obj
@property def definition(self): return self.args[0]
@property def limits(self): return self._limits
@property def parameters(self): return self._parameters
@property def dimensions(self): return len(self.limits)
@singledispatchdef parametric_region_list(reg): """ Returns a list of ParametricRegion objects representing the geometric region.
Examples ========
>>> from sympy.abc import t >>> from sympy.vector import parametric_region_list >>> from sympy.geometry import Point, Curve, Ellipse, Segment, Polygon
>>> p = Point(2, 5) >>> parametric_region_list(p) [ParametricRegion((2, 5))]
>>> c = Curve((t**3, 4*t), (t, -3, 4)) >>> parametric_region_list(c) [ParametricRegion((t**3, 4*t), (t, -3, 4))]
>>> e = Ellipse(Point(1, 3), 2, 3) >>> parametric_region_list(e) [ParametricRegion((2*cos(t) + 1, 3*sin(t) + 3), (t, 0, 2*pi))]
>>> s = Segment(Point(1, 3), Point(2, 6)) >>> parametric_region_list(s) [ParametricRegion((t + 1, 3*t + 3), (t, 0, 1))]
>>> p1, p2, p3, p4 = [(0, 1), (2, -3), (5, 3), (-2, 3)] >>> poly = Polygon(p1, p2, p3, p4) >>> parametric_region_list(poly) [ParametricRegion((2*t, 1 - 4*t), (t, 0, 1)), ParametricRegion((3*t + 2, 6*t - 3), (t, 0, 1)),\ ParametricRegion((5 - 7*t, 3), (t, 0, 1)), ParametricRegion((2*t - 2, 3 - 2*t), (t, 0, 1))]
""" raise ValueError("SymPy cannot determine parametric representation of the region.")
@parametric_region_list.register(Point)def _(obj): return [ParametricRegion(obj.args)]
@parametric_region_list.register(Curve) # type: ignoredef _(obj): definition = obj.arbitrary_point(obj.parameter).args bounds = obj.limits return [ParametricRegion(definition, bounds)]
@parametric_region_list.register(Ellipse) # type: ignoredef _(obj, parameter='t'): definition = obj.arbitrary_point(parameter).args t = _symbol(parameter, real=True) bounds = (t, 0, 2*pi) return [ParametricRegion(definition, bounds)]
@parametric_region_list.register(Segment) # type: ignoredef _(obj, parameter='t'): t = _symbol(parameter, real=True) definition = obj.arbitrary_point(t).args
for i in range(0, 3): lower_bound = solve(definition[i] - obj.points[0].args[i], t) upper_bound = solve(definition[i] - obj.points[1].args[i], t)
if len(lower_bound) == 1 and len(upper_bound) == 1: bounds = t, lower_bound[0], upper_bound[0] break
definition_tuple = obj.arbitrary_point(parameter).args return [ParametricRegion(definition_tuple, bounds)]
@parametric_region_list.register(Polygon) # type: ignoredef _(obj, parameter='t'): l = [parametric_region_list(side, parameter)[0] for side in obj.sides] return l
@parametric_region_list.register(ImplicitRegion) # type: ignoredef _(obj, parameters=('t', 's')): definition = obj.rational_parametrization(parameters) bounds = []
for i in range(len(obj.variables) - 1): # Each parameter is replaced by its tangent to simplify integration parameter = _symbol(parameters[i], real=True) definition = [trigsimp(elem.subs(parameter, tan(parameter/2))) for elem in definition] bounds.append((parameter, 0, 2*pi),)
definition = Tuple(*definition) return [ParametricRegion(definition, *bounds)]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148from sympy.core.basic import Basicfrom sympy.core.symbol import Strfrom sympy.vector.vector import Vectorfrom sympy.vector.coordsysrect import CoordSys3Dfrom sympy.vector.functions import _pathfrom sympy.core.cache import cacheit
class Point(Basic): """ Represents a point in 3-D space. """
def __new__(cls, name, position=Vector.zero, parent_point=None): name = str(name) # Check the args first if not isinstance(position, Vector): raise TypeError( "position should be an instance of Vector, not %s" % type( position)) if (not isinstance(parent_point, Point) and parent_point is not None): raise TypeError( "parent_point should be an instance of Point, not %s" % type( parent_point)) # Super class construction if parent_point is None: obj = super().__new__(cls, Str(name), position) else: obj = super().__new__(cls, Str(name), position, parent_point) # Decide the object parameters obj._name = name obj._pos = position if parent_point is None: obj._parent = None obj._root = obj else: obj._parent = parent_point obj._root = parent_point._root # Return object return obj
@cacheit def position_wrt(self, other): """ Returns the position vector of this Point with respect to another Point/CoordSys3D.
Parameters ==========
other : Point/CoordSys3D If other is a Point, the position of this Point wrt it is returned. If its an instance of CoordSyRect, the position wrt its origin is returned.
Examples ========
>>> from sympy.vector import CoordSys3D >>> N = CoordSys3D('N') >>> p1 = N.origin.locate_new('p1', 10 * N.i) >>> N.origin.position_wrt(p1) (-10)*N.i
"""
if (not isinstance(other, Point) and not isinstance(other, CoordSys3D)): raise TypeError(str(other) + "is not a Point or CoordSys3D") if isinstance(other, CoordSys3D): other = other.origin # Handle special cases if other == self: return Vector.zero elif other == self._parent: return self._pos elif other._parent == self: return -1 * other._pos # Else, use point tree to calculate position rootindex, path = _path(self, other) result = Vector.zero for i in range(rootindex): result += path[i]._pos for i in range(rootindex + 1, len(path)): result -= path[i]._pos return result
def locate_new(self, name, position): """ Returns a new Point located at the given position wrt this Point. Thus, the position vector of the new Point wrt this one will be equal to the given 'position' parameter.
Parameters ==========
name : str Name of the new point
position : Vector The position vector of the new Point wrt this one
Examples ========
>>> from sympy.vector import CoordSys3D >>> N = CoordSys3D('N') >>> p1 = N.origin.locate_new('p1', 10 * N.i) >>> p1.position_wrt(N.origin) 10*N.i
""" return Point(name, position, self)
def express_coordinates(self, coordinate_system): """ Returns the Cartesian/rectangular coordinates of this point wrt the origin of the given CoordSys3D instance.
Parameters ==========
coordinate_system : CoordSys3D The coordinate system to express the coordinates of this Point in.
Examples ========
>>> from sympy.vector import CoordSys3D >>> N = CoordSys3D('N') >>> p1 = N.origin.locate_new('p1', 10 * N.i) >>> p2 = p1.locate_new('p2', 5 * N.j) >>> p2.express_coordinates(N) (10, 5, 0)
"""
# Determine the position vector pos_vect = self.position_wrt(coordinate_system.origin) # Express it in the given coordinate system return tuple(pos_vect.to_matrix(coordinate_system))
def _sympystr(self, printer): return self._name123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172from sympy.core import AtomicExpr, Symbol, Sfrom sympy.core.sympify import _sympifyfrom sympy.printing.pretty.stringpict import prettyFormfrom sympy.printing.precedence import PRECEDENCEfrom sympy.core.kind import NumberKind
class BaseScalar(AtomicExpr): """ A coordinate symbol/base scalar.
Ideally, users should not instantiate this class.
"""
kind = NumberKind
def __new__(cls, index, system, pretty_str=None, latex_str=None): from sympy.vector.coordsysrect import CoordSys3D if pretty_str is None: pretty_str = "x{}".format(index) elif isinstance(pretty_str, Symbol): pretty_str = pretty_str.name if latex_str is None: latex_str = "x_{}".format(index) elif isinstance(latex_str, Symbol): latex_str = latex_str.name
index = _sympify(index) system = _sympify(system) obj = super().__new__(cls, index, system) if not isinstance(system, CoordSys3D): raise TypeError("system should be a CoordSys3D") if index not in range(0, 3): raise ValueError("Invalid index specified.") # The _id is used for equating purposes, and for hashing obj._id = (index, system) obj._name = obj.name = system._name + '.' + system._variable_names[index] obj._pretty_form = '' + pretty_str obj._latex_form = latex_str obj._system = system
return obj
is_commutative = True is_symbol = True
@property def free_symbols(self): return {self}
_diff_wrt = True
def _eval_derivative(self, s): if self == s: return S.One return S.Zero
def _latex(self, printer=None): return self._latex_form
def _pretty(self, printer=None): return prettyForm(self._pretty_form)
precedence = PRECEDENCE['Atom']
@property def system(self): return self._system
def _sympystr(self, printer): return self._name123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464from sympy.testing.pytest import raisesfrom sympy.vector.coordsysrect import CoordSys3Dfrom sympy.vector.scalar import BaseScalarfrom sympy.core.function import expandfrom sympy.core.numbers import pifrom sympy.core.symbol import symbolsfrom sympy.functions.elementary.hyperbolic import (cosh, sinh)from sympy.functions.elementary.miscellaneous import sqrtfrom sympy.functions.elementary.trigonometric import (acos, atan2, cos, sin)from sympy.matrices.dense import zerosfrom sympy.matrices.immutable import ImmutableDenseMatrix as Matrixfrom sympy.simplify.simplify import simplifyfrom sympy.vector.functions import expressfrom sympy.vector.point import Pointfrom sympy.vector.vector import Vectorfrom sympy.vector.orienters import (AxisOrienter, BodyOrienter, SpaceOrienter, QuaternionOrienter)
x, y, z = symbols('x y z')a, b, c, q = symbols('a b c q')q1, q2, q3, q4 = symbols('q1 q2 q3 q4')
def test_func_args(): A = CoordSys3D('A') assert A.x.func(*A.x.args) == A.x expr = 3*A.x + 4*A.y assert expr.func(*expr.args) == expr assert A.i.func(*A.i.args) == A.i v = A.x*A.i + A.y*A.j + A.z*A.k assert v.func(*v.args) == v assert A.origin.func(*A.origin.args) == A.origin
def test_coordsys3d_equivalence(): A = CoordSys3D('A') A1 = CoordSys3D('A') assert A1 == A B = CoordSys3D('B') assert A != B
def test_orienters(): A = CoordSys3D('A') axis_orienter = AxisOrienter(a, A.k) body_orienter = BodyOrienter(a, b, c, '123') space_orienter = SpaceOrienter(a, b, c, '123') q_orienter = QuaternionOrienter(q1, q2, q3, q4) assert axis_orienter.rotation_matrix(A) == Matrix([ [ cos(a), sin(a), 0], [-sin(a), cos(a), 0], [ 0, 0, 1]]) assert body_orienter.rotation_matrix() == Matrix([ [ cos(b)*cos(c), sin(a)*sin(b)*cos(c) + sin(c)*cos(a), sin(a)*sin(c) - sin(b)*cos(a)*cos(c)], [-sin(c)*cos(b), -sin(a)*sin(b)*sin(c) + cos(a)*cos(c), sin(a)*cos(c) + sin(b)*sin(c)*cos(a)], [ sin(b), -sin(a)*cos(b), cos(a)*cos(b)]]) assert space_orienter.rotation_matrix() == Matrix([ [cos(b)*cos(c), sin(c)*cos(b), -sin(b)], [sin(a)*sin(b)*cos(c) - sin(c)*cos(a), sin(a)*sin(b)*sin(c) + cos(a)*cos(c), sin(a)*cos(b)], [sin(a)*sin(c) + sin(b)*cos(a)*cos(c), -sin(a)*cos(c) + sin(b)*sin(c)*cos(a), cos(a)*cos(b)]]) assert q_orienter.rotation_matrix() == Matrix([ [q1**2 + q2**2 - q3**2 - q4**2, 2*q1*q4 + 2*q2*q3, -2*q1*q3 + 2*q2*q4], [-2*q1*q4 + 2*q2*q3, q1**2 - q2**2 + q3**2 - q4**2, 2*q1*q2 + 2*q3*q4], [2*q1*q3 + 2*q2*q4, -2*q1*q2 + 2*q3*q4, q1**2 - q2**2 - q3**2 + q4**2]])
def test_coordinate_vars(): """ Tests the coordinate variables functionality with respect to reorientation of coordinate systems. """ A = CoordSys3D('A') # Note that the name given on the lhs is different from A.x._name assert BaseScalar(0, A, 'A_x', r'\mathbf{{x}_{A}}') == A.x assert BaseScalar(1, A, 'A_y', r'\mathbf{{y}_{A}}') == A.y assert BaseScalar(2, A, 'A_z', r'\mathbf{{z}_{A}}') == A.z assert BaseScalar(0, A, 'A_x', r'\mathbf{{x}_{A}}').__hash__() == A.x.__hash__() assert isinstance(A.x, BaseScalar) and \ isinstance(A.y, BaseScalar) and \ isinstance(A.z, BaseScalar) assert A.x*A.y == A.y*A.x assert A.scalar_map(A) == {A.x: A.x, A.y: A.y, A.z: A.z} assert A.x.system == A assert A.x.diff(A.x) == 1 B = A.orient_new_axis('B', q, A.k) assert B.scalar_map(A) == {B.z: A.z, B.y: -A.x*sin(q) + A.y*cos(q), B.x: A.x*cos(q) + A.y*sin(q)} assert A.scalar_map(B) == {A.x: B.x*cos(q) - B.y*sin(q), A.y: B.x*sin(q) + B.y*cos(q), A.z: B.z} assert express(B.x, A, variables=True) == A.x*cos(q) + A.y*sin(q) assert express(B.y, A, variables=True) == -A.x*sin(q) + A.y*cos(q) assert express(B.z, A, variables=True) == A.z assert expand(express(B.x*B.y*B.z, A, variables=True)) == \ expand(A.z*(-A.x*sin(q) + A.y*cos(q))*(A.x*cos(q) + A.y*sin(q))) assert express(B.x*B.i + B.y*B.j + B.z*B.k, A) == \ (B.x*cos(q) - B.y*sin(q))*A.i + (B.x*sin(q) + \ B.y*cos(q))*A.j + B.z*A.k assert simplify(express(B.x*B.i + B.y*B.j + B.z*B.k, A, \ variables=True)) == \ A.x*A.i + A.y*A.j + A.z*A.k assert express(A.x*A.i + A.y*A.j + A.z*A.k, B) == \ (A.x*cos(q) + A.y*sin(q))*B.i + \ (-A.x*sin(q) + A.y*cos(q))*B.j + A.z*B.k assert simplify(express(A.x*A.i + A.y*A.j + A.z*A.k, B, \ variables=True)) == \ B.x*B.i + B.y*B.j + B.z*B.k N = B.orient_new_axis('N', -q, B.k) assert N.scalar_map(A) == \ {N.x: A.x, N.z: A.z, N.y: A.y} C = A.orient_new_axis('C', q, A.i + A.j + A.k) mapping = A.scalar_map(C) assert mapping[A.x].equals(C.x*(2*cos(q) + 1)/3 + C.y*(-2*sin(q + pi/6) + 1)/3 + C.z*(-2*cos(q + pi/3) + 1)/3) assert mapping[A.y].equals(C.x*(-2*cos(q + pi/3) + 1)/3 + C.y*(2*cos(q) + 1)/3 + C.z*(-2*sin(q + pi/6) + 1)/3) assert mapping[A.z].equals(C.x*(-2*sin(q + pi/6) + 1)/3 + C.y*(-2*cos(q + pi/3) + 1)/3 + C.z*(2*cos(q) + 1)/3) D = A.locate_new('D', a*A.i + b*A.j + c*A.k) assert D.scalar_map(A) == {D.z: A.z - c, D.x: A.x - a, D.y: A.y - b} E = A.orient_new_axis('E', a, A.k, a*A.i + b*A.j + c*A.k) assert A.scalar_map(E) == {A.z: E.z + c, A.x: E.x*cos(a) - E.y*sin(a) + a, A.y: E.x*sin(a) + E.y*cos(a) + b} assert E.scalar_map(A) == {E.x: (A.x - a)*cos(a) + (A.y - b)*sin(a), E.y: (-A.x + a)*sin(a) + (A.y - b)*cos(a), E.z: A.z - c} F = A.locate_new('F', Vector.zero) assert A.scalar_map(F) == {A.z: F.z, A.x: F.x, A.y: F.y}
def test_rotation_matrix(): N = CoordSys3D('N') A = N.orient_new_axis('A', q1, N.k) B = A.orient_new_axis('B', q2, A.i) C = B.orient_new_axis('C', q3, B.j) D = N.orient_new_axis('D', q4, N.j) E = N.orient_new_space('E', q1, q2, q3, '123') F = N.orient_new_quaternion('F', q1, q2, q3, q4) G = N.orient_new_body('G', q1, q2, q3, '123') assert N.rotation_matrix(C) == Matrix([ [- sin(q1) * sin(q2) * sin(q3) + cos(q1) * cos(q3), - sin(q1) * cos(q2), sin(q1) * sin(q2) * cos(q3) + sin(q3) * cos(q1)], \ [sin(q1) * cos(q3) + sin(q2) * sin(q3) * cos(q1), \ cos(q1) * cos(q2), sin(q1) * sin(q3) - sin(q2) * cos(q1) * \ cos(q3)], [- sin(q3) * cos(q2), sin(q2), cos(q2) * cos(q3)]]) test_mat = D.rotation_matrix(C) - Matrix( [[cos(q1) * cos(q3) * cos(q4) - sin(q3) * (- sin(q4) * cos(q2) + sin(q1) * sin(q2) * cos(q4)), - sin(q2) * sin(q4) - sin(q1) * cos(q2) * cos(q4), sin(q3) * cos(q1) * cos(q4) + cos(q3) * \ (- sin(q4) * cos(q2) + sin(q1) * sin(q2) * cos(q4))], \ [sin(q1) * cos(q3) + sin(q2) * sin(q3) * cos(q1), cos(q1) * \ cos(q2), sin(q1) * sin(q3) - sin(q2) * cos(q1) * cos(q3)], \ [sin(q4) * cos(q1) * cos(q3) - sin(q3) * (cos(q2) * cos(q4) + \ sin(q1) * sin(q2) * \ sin(q4)), sin(q2) * cos(q4) - sin(q1) * sin(q4) * cos(q2), sin(q3) * \ sin(q4) * cos(q1) + cos(q3) * (cos(q2) * cos(q4) + \ sin(q1) * sin(q2) * sin(q4))]]) assert test_mat.expand() == zeros(3, 3) assert E.rotation_matrix(N) == Matrix( [[cos(q2)*cos(q3), sin(q3)*cos(q2), -sin(q2)], [sin(q1)*sin(q2)*cos(q3) - sin(q3)*cos(q1), \ sin(q1)*sin(q2)*sin(q3) + cos(q1)*cos(q3), sin(q1)*cos(q2)], \ [sin(q1)*sin(q3) + sin(q2)*cos(q1)*cos(q3), - \ sin(q1)*cos(q3) + sin(q2)*sin(q3)*cos(q1), cos(q1)*cos(q2)]]) assert F.rotation_matrix(N) == Matrix([[ q1**2 + q2**2 - q3**2 - q4**2, 2*q1*q4 + 2*q2*q3, -2*q1*q3 + 2*q2*q4],[ -2*q1*q4 + 2*q2*q3, q1**2 - q2**2 + q3**2 - q4**2, 2*q1*q2 + 2*q3*q4], [2*q1*q3 + 2*q2*q4, -2*q1*q2 + 2*q3*q4, q1**2 - q2**2 - q3**2 + q4**2]]) assert G.rotation_matrix(N) == Matrix([[ cos(q2)*cos(q3), sin(q1)*sin(q2)*cos(q3) + sin(q3)*cos(q1), sin(q1)*sin(q3) - sin(q2)*cos(q1)*cos(q3)], [ -sin(q3)*cos(q2), -sin(q1)*sin(q2)*sin(q3) + cos(q1)*cos(q3), sin(q1)*cos(q3) + sin(q2)*sin(q3)*cos(q1)],[ sin(q2), -sin(q1)*cos(q2), cos(q1)*cos(q2)]])
def test_vector_with_orientation(): """ Tests the effects of orientation of coordinate systems on basic vector operations. """ N = CoordSys3D('N') A = N.orient_new_axis('A', q1, N.k) B = A.orient_new_axis('B', q2, A.i) C = B.orient_new_axis('C', q3, B.j)
# Test to_matrix v1 = a*N.i + b*N.j + c*N.k assert v1.to_matrix(A) == Matrix([[ a*cos(q1) + b*sin(q1)], [-a*sin(q1) + b*cos(q1)], [ c]])
# Test dot assert N.i.dot(A.i) == cos(q1) assert N.i.dot(A.j) == -sin(q1) assert N.i.dot(A.k) == 0 assert N.j.dot(A.i) == sin(q1) assert N.j.dot(A.j) == cos(q1) assert N.j.dot(A.k) == 0 assert N.k.dot(A.i) == 0 assert N.k.dot(A.j) == 0 assert N.k.dot(A.k) == 1
assert N.i.dot(A.i + A.j) == -sin(q1) + cos(q1) == \ (A.i + A.j).dot(N.i)
assert A.i.dot(C.i) == cos(q3) assert A.i.dot(C.j) == 0 assert A.i.dot(C.k) == sin(q3) assert A.j.dot(C.i) == sin(q2)*sin(q3) assert A.j.dot(C.j) == cos(q2) assert A.j.dot(C.k) == -sin(q2)*cos(q3) assert A.k.dot(C.i) == -cos(q2)*sin(q3) assert A.k.dot(C.j) == sin(q2) assert A.k.dot(C.k) == cos(q2)*cos(q3)
# Test cross assert N.i.cross(A.i) == sin(q1)*A.k assert N.i.cross(A.j) == cos(q1)*A.k assert N.i.cross(A.k) == -sin(q1)*A.i - cos(q1)*A.j assert N.j.cross(A.i) == -cos(q1)*A.k assert N.j.cross(A.j) == sin(q1)*A.k assert N.j.cross(A.k) == cos(q1)*A.i - sin(q1)*A.j assert N.k.cross(A.i) == A.j assert N.k.cross(A.j) == -A.i assert N.k.cross(A.k) == Vector.zero
assert N.i.cross(A.i) == sin(q1)*A.k assert N.i.cross(A.j) == cos(q1)*A.k assert N.i.cross(A.i + A.j) == sin(q1)*A.k + cos(q1)*A.k assert (A.i + A.j).cross(N.i) == (-sin(q1) - cos(q1))*N.k
assert A.i.cross(C.i) == sin(q3)*C.j assert A.i.cross(C.j) == -sin(q3)*C.i + cos(q3)*C.k assert A.i.cross(C.k) == -cos(q3)*C.j assert C.i.cross(A.i) == (-sin(q3)*cos(q2))*A.j + \ (-sin(q2)*sin(q3))*A.k assert C.j.cross(A.i) == (sin(q2))*A.j + (-cos(q2))*A.k assert express(C.k.cross(A.i), C).trigsimp() == cos(q3)*C.j
def test_orient_new_methods(): N = CoordSys3D('N') orienter1 = AxisOrienter(q4, N.j) orienter2 = SpaceOrienter(q1, q2, q3, '123') orienter3 = QuaternionOrienter(q1, q2, q3, q4) orienter4 = BodyOrienter(q1, q2, q3, '123') D = N.orient_new('D', (orienter1, )) E = N.orient_new('E', (orienter2, )) F = N.orient_new('F', (orienter3, )) G = N.orient_new('G', (orienter4, )) assert D == N.orient_new_axis('D', q4, N.j) assert E == N.orient_new_space('E', q1, q2, q3, '123') assert F == N.orient_new_quaternion('F', q1, q2, q3, q4) assert G == N.orient_new_body('G', q1, q2, q3, '123')
def test_locatenew_point(): """ Tests Point class, and locate_new method in CoordSys3D. """ A = CoordSys3D('A') assert isinstance(A.origin, Point) v = a*A.i + b*A.j + c*A.k C = A.locate_new('C', v) assert C.origin.position_wrt(A) == \ C.position_wrt(A) == \ C.origin.position_wrt(A.origin) == v assert A.origin.position_wrt(C) == \ A.position_wrt(C) == \ A.origin.position_wrt(C.origin) == -v assert A.origin.express_coordinates(C) == (-a, -b, -c) p = A.origin.locate_new('p', -v) assert p.express_coordinates(A) == (-a, -b, -c) assert p.position_wrt(C.origin) == p.position_wrt(C) == \ -2 * v p1 = p.locate_new('p1', 2*v) assert p1.position_wrt(C.origin) == Vector.zero assert p1.express_coordinates(C) == (0, 0, 0) p2 = p.locate_new('p2', A.i) assert p1.position_wrt(p2) == 2*v - A.i assert p2.express_coordinates(C) == (-2*a + 1, -2*b, -2*c)
def test_create_new(): a = CoordSys3D('a') c = a.create_new('c', transformation='spherical') assert c._parent == a assert c.transformation_to_parent() == \ (c.r*sin(c.theta)*cos(c.phi), c.r*sin(c.theta)*sin(c.phi), c.r*cos(c.theta)) assert c.transformation_from_parent() == \ (sqrt(a.x**2 + a.y**2 + a.z**2), acos(a.z/sqrt(a.x**2 + a.y**2 + a.z**2)), atan2(a.y, a.x))
def test_evalf(): A = CoordSys3D('A') v = 3*A.i + 4*A.j + a*A.k assert v.n() == v.evalf() assert v.evalf(subs={a:1}) == v.subs(a, 1).evalf()
def test_lame_coefficients(): a = CoordSys3D('a', 'spherical') assert a.lame_coefficients() == (1, a.r, sin(a.theta)*a.r) a = CoordSys3D('a') assert a.lame_coefficients() == (1, 1, 1) a = CoordSys3D('a', 'cartesian') assert a.lame_coefficients() == (1, 1, 1) a = CoordSys3D('a', 'cylindrical') assert a.lame_coefficients() == (1, a.r, 1)
def test_transformation_equations():
x, y, z = symbols('x y z') # Str a = CoordSys3D('a', transformation='spherical', variable_names=["r", "theta", "phi"]) r, theta, phi = a.base_scalars()
assert r == a.r assert theta == a.theta assert phi == a.phi
raises(AttributeError, lambda: a.x) raises(AttributeError, lambda: a.y) raises(AttributeError, lambda: a.z)
assert a.transformation_to_parent() == ( r*sin(theta)*cos(phi), r*sin(theta)*sin(phi), r*cos(theta) ) assert a.lame_coefficients() == (1, r, r*sin(theta)) assert a.transformation_from_parent_function()(x, y, z) == ( sqrt(x ** 2 + y ** 2 + z ** 2), acos((z) / sqrt(x**2 + y**2 + z**2)), atan2(y, x) ) a = CoordSys3D('a', transformation='cylindrical', variable_names=["r", "theta", "z"]) r, theta, z = a.base_scalars() assert a.transformation_to_parent() == ( r*cos(theta), r*sin(theta), z ) assert a.lame_coefficients() == (1, a.r, 1) assert a.transformation_from_parent_function()(x, y, z) == (sqrt(x**2 + y**2), atan2(y, x), z)
a = CoordSys3D('a', 'cartesian') assert a.transformation_to_parent() == (a.x, a.y, a.z) assert a.lame_coefficients() == (1, 1, 1) assert a.transformation_from_parent_function()(x, y, z) == (x, y, z)
# Variables and expressions
# Cartesian with equation tuple: x, y, z = symbols('x y z') a = CoordSys3D('a', ((x, y, z), (x, y, z))) a._calculate_inv_trans_equations() assert a.transformation_to_parent() == (a.x1, a.x2, a.x3) assert a.lame_coefficients() == (1, 1, 1) assert a.transformation_from_parent_function()(x, y, z) == (x, y, z) r, theta, z = symbols("r theta z")
# Cylindrical with equation tuple: a = CoordSys3D('a', [(r, theta, z), (r*cos(theta), r*sin(theta), z)], variable_names=["r", "theta", "z"]) r, theta, z = a.base_scalars() assert a.transformation_to_parent() == ( r*cos(theta), r*sin(theta), z ) assert a.lame_coefficients() == ( sqrt(sin(theta)**2 + cos(theta)**2), sqrt(r**2*sin(theta)**2 + r**2*cos(theta)**2), 1 ) # ==> this should simplify to (1, r, 1), tests are too slow with `simplify`.
# Definitions with `lambda`:
# Cartesian with `lambda` a = CoordSys3D('a', lambda x, y, z: (x, y, z)) assert a.transformation_to_parent() == (a.x1, a.x2, a.x3) assert a.lame_coefficients() == (1, 1, 1) a._calculate_inv_trans_equations() assert a.transformation_from_parent_function()(x, y, z) == (x, y, z)
# Spherical with `lambda` a = CoordSys3D('a', lambda r, theta, phi: (r*sin(theta)*cos(phi), r*sin(theta)*sin(phi), r*cos(theta)), variable_names=["r", "theta", "phi"]) r, theta, phi = a.base_scalars() assert a.transformation_to_parent() == ( r*sin(theta)*cos(phi), r*sin(phi)*sin(theta), r*cos(theta) ) assert a.lame_coefficients() == ( sqrt(sin(phi)**2*sin(theta)**2 + sin(theta)**2*cos(phi)**2 + cos(theta)**2), sqrt(r**2*sin(phi)**2*cos(theta)**2 + r**2*sin(theta)**2 + r**2*cos(phi)**2*cos(theta)**2), sqrt(r**2*sin(phi)**2*sin(theta)**2 + r**2*sin(theta)**2*cos(phi)**2) ) # ==> this should simplify to (1, r, sin(theta)*r), `simplify` is too slow.
# Cylindrical with `lambda` a = CoordSys3D('a', lambda r, theta, z: (r*cos(theta), r*sin(theta), z), variable_names=["r", "theta", "z"] ) r, theta, z = a.base_scalars() assert a.transformation_to_parent() == (r*cos(theta), r*sin(theta), z) assert a.lame_coefficients() == ( sqrt(sin(theta)**2 + cos(theta)**2), sqrt(r**2*sin(theta)**2 + r**2*cos(theta)**2), 1 ) # ==> this should simplify to (1, a.x, 1)
raises(TypeError, lambda: CoordSys3D('a', transformation={ x: x*sin(y)*cos(z), y:x*sin(y)*sin(z), z: x*cos(y)}))
def test_check_orthogonality(): x, y, z = symbols('x y z') u,v = symbols('u, v') a = CoordSys3D('a', transformation=((x, y, z), (x*sin(y)*cos(z), x*sin(y)*sin(z), x*cos(y)))) assert a._check_orthogonality(a._transformation) is True a = CoordSys3D('a', transformation=((x, y, z), (x * cos(y), x * sin(y), z))) assert a._check_orthogonality(a._transformation) is True a = CoordSys3D('a', transformation=((u, v, z), (cosh(u) * cos(v), sinh(u) * sin(v), z))) assert a._check_orthogonality(a._transformation) is True
raises(ValueError, lambda: CoordSys3D('a', transformation=((x, y, z), (x, x, z)))) raises(ValueError, lambda: CoordSys3D('a', transformation=( (x, y, z), (x*sin(y/2)*cos(z), x*sin(y)*sin(z), x*cos(y)))))
def test_rotation_trans_equations(): a = CoordSys3D('a') from sympy.core.symbol import symbols q0 = symbols('q0') assert a._rotation_trans_equations(a._parent_rotation_matrix, a.base_scalars()) == (a.x, a.y, a.z) assert a._rotation_trans_equations(a._inverse_rotation_matrix(), a.base_scalars()) == (a.x, a.y, a.z) b = a.orient_new_axis('b', 0, -a.k) assert b._rotation_trans_equations(b._parent_rotation_matrix, b.base_scalars()) == (b.x, b.y, b.z) assert b._rotation_trans_equations(b._inverse_rotation_matrix(), b.base_scalars()) == (b.x, b.y, b.z) c = a.orient_new_axis('c', q0, -a.k) assert c._rotation_trans_equations(c._parent_rotation_matrix, c.base_scalars()) == \ (-sin(q0) * c.y + cos(q0) * c.x, sin(q0) * c.x + cos(q0) * c.y, c.z) assert c._rotation_trans_equations(c._inverse_rotation_matrix(), c.base_scalars()) == \ (sin(q0) * c.y + cos(q0) * c.x, -sin(q0) * c.x + cos(q0) * c.y, c.z)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134from sympy.core.numbers import pifrom sympy.core.symbol import symbolsfrom sympy.functions.elementary.trigonometric import (cos, sin)from sympy.matrices.immutable import ImmutableDenseMatrix as Matrixfrom sympy.simplify.simplify import simplifyfrom sympy.vector import (CoordSys3D, Vector, Dyadic, DyadicAdd, DyadicMul, DyadicZero, BaseDyadic, express)
A = CoordSys3D('A')
def test_dyadic(): a, b = symbols('a, b') assert Dyadic.zero != 0 assert isinstance(Dyadic.zero, DyadicZero) assert BaseDyadic(A.i, A.j) != BaseDyadic(A.j, A.i) assert (BaseDyadic(Vector.zero, A.i) == BaseDyadic(A.i, Vector.zero) == Dyadic.zero)
d1 = A.i | A.i d2 = A.j | A.j d3 = A.i | A.j
assert isinstance(d1, BaseDyadic) d_mul = a*d1 assert isinstance(d_mul, DyadicMul) assert d_mul.base_dyadic == d1 assert d_mul.measure_number == a assert isinstance(a*d1 + b*d3, DyadicAdd) assert d1 == A.i.outer(A.i) assert d3 == A.i.outer(A.j) v1 = a*A.i - A.k v2 = A.i + b*A.j assert v1 | v2 == v1.outer(v2) == a * (A.i|A.i) + (a*b) * (A.i|A.j) +\ - (A.k|A.i) - b * (A.k|A.j) assert d1 * 0 == Dyadic.zero assert d1 != Dyadic.zero assert d1 * 2 == 2 * (A.i | A.i) assert d1 / 2. == 0.5 * d1
assert d1.dot(0 * d1) == Vector.zero assert d1 & d2 == Dyadic.zero assert d1.dot(A.i) == A.i == d1 & A.i
assert d1.cross(Vector.zero) == Dyadic.zero assert d1.cross(A.i) == Dyadic.zero assert d1 ^ A.j == d1.cross(A.j) assert d1.cross(A.k) == - A.i | A.j assert d2.cross(A.i) == - A.j | A.k == d2 ^ A.i
assert A.i ^ d1 == Dyadic.zero assert A.j.cross(d1) == - A.k | A.i == A.j ^ d1 assert Vector.zero.cross(d1) == Dyadic.zero assert A.k ^ d1 == A.j | A.i assert A.i.dot(d1) == A.i & d1 == A.i assert A.j.dot(d1) == Vector.zero assert Vector.zero.dot(d1) == Vector.zero assert A.j & d2 == A.j
assert d1.dot(d3) == d1 & d3 == A.i | A.j == d3 assert d3 & d1 == Dyadic.zero
q = symbols('q') B = A.orient_new_axis('B', q, A.k) assert express(d1, B) == express(d1, B, B)
expr1 = ((cos(q)**2) * (B.i | B.i) + (-sin(q) * cos(q)) * (B.i | B.j) + (-sin(q) * cos(q)) * (B.j | B.i) + (sin(q)**2) * (B.j | B.j)) assert (express(d1, B) - expr1).simplify() == Dyadic.zero
expr2 = (cos(q)) * (B.i | A.i) + (-sin(q)) * (B.j | A.i) assert (express(d1, B, A) - expr2).simplify() == Dyadic.zero
expr3 = (cos(q)) * (A.i | B.i) + (-sin(q)) * (A.i | B.j) assert (express(d1, A, B) - expr3).simplify() == Dyadic.zero
assert d1.to_matrix(A) == Matrix([[1, 0, 0], [0, 0, 0], [0, 0, 0]]) assert d1.to_matrix(A, B) == Matrix([[cos(q), -sin(q), 0], [0, 0, 0], [0, 0, 0]]) assert d3.to_matrix(A) == Matrix([[0, 1, 0], [0, 0, 0], [0, 0, 0]]) a, b, c, d, e, f = symbols('a, b, c, d, e, f') v1 = a * A.i + b * A.j + c * A.k v2 = d * A.i + e * A.j + f * A.k d4 = v1.outer(v2) assert d4.to_matrix(A) == Matrix([[a * d, a * e, a * f], [b * d, b * e, b * f], [c * d, c * e, c * f]]) d5 = v1.outer(v1) C = A.orient_new_axis('C', q, A.i) for expected, actual in zip(C.rotation_matrix(A) * d5.to_matrix(A) * \ C.rotation_matrix(A).T, d5.to_matrix(C)): assert (expected - actual).simplify() == 0
def test_dyadic_simplify(): x, y, z, k, n, m, w, f, s, A = symbols('x, y, z, k, n, m, w, f, s, A') N = CoordSys3D('N')
dy = N.i | N.i test1 = (1 / x + 1 / y) * dy assert (N.i & test1 & N.i) != (x + y) / (x * y) test1 = test1.simplify() assert test1.simplify() == simplify(test1) assert (N.i & test1 & N.i) == (x + y) / (x * y)
test2 = (A**2 * s**4 / (4 * pi * k * m**3)) * dy test2 = test2.simplify() assert (N.i & test2 & N.i) == (A**2 * s**4 / (4 * pi * k * m**3))
test3 = ((4 + 4 * x - 2 * (2 + 2 * x)) / (2 + 2 * x)) * dy test3 = test3.simplify() assert (N.i & test3 & N.i) == 0
test4 = ((-4 * x * y**2 - 2 * y**3 - 2 * x**2 * y) / (x + y)**2) * dy test4 = test4.simplify() assert (N.i & test4 & N.i) == -2 * y
def test_dyadic_srepr(): from sympy.printing.repr import srepr N = CoordSys3D('N')
dy = N.i | N.j res = "BaseDyadic(CoordSys3D(Str('N'), Tuple(ImmutableDenseMatrix([["\ "Integer(1), Integer(0), Integer(0)], [Integer(0), Integer(1), "\ "Integer(0)], [Integer(0), Integer(0), Integer(1)]]), "\ "VectorZero())).i, CoordSys3D(Str('N'), Tuple(ImmutableDenseMatrix("\ "[[Integer(1), Integer(0), Integer(0)], [Integer(0), Integer(1), "\ "Integer(0)], [Integer(0), Integer(0), Integer(1)]]), VectorZero())).j)" assert srepr(dy) == res123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321from sympy.core.function import Derivativefrom sympy.vector.vector import Vectorfrom sympy.vector.coordsysrect import CoordSys3Dfrom sympy.simplify import simplifyfrom sympy.core.symbol import symbolsfrom sympy.core import Sfrom sympy.functions.elementary.trigonometric import (cos, sin)from sympy.vector.vector import Dotfrom sympy.vector.operators import curl, divergence, gradient, Gradient, Divergence, Crossfrom sympy.vector.deloperator import Delfrom sympy.vector.functions import (is_conservative, is_solenoidal, scalar_potential, directional_derivative, laplacian, scalar_potential_difference)from sympy.testing.pytest import raises
C = CoordSys3D('C')i, j, k = C.base_vectors()x, y, z = C.base_scalars()delop = Del()a, b, c, q = symbols('a b c q')
def test_del_operator(): # Tests for curl
assert delop ^ Vector.zero == Vector.zero assert ((delop ^ Vector.zero).doit() == Vector.zero == curl(Vector.zero)) assert delop.cross(Vector.zero) == delop ^ Vector.zero assert (delop ^ i).doit() == Vector.zero assert delop.cross(2*y**2*j, doit=True) == Vector.zero assert delop.cross(2*y**2*j) == delop ^ 2*y**2*j v = x*y*z * (i + j + k) assert ((delop ^ v).doit() == (-x*y + x*z)*i + (x*y - y*z)*j + (-x*z + y*z)*k == curl(v)) assert delop ^ v == delop.cross(v) assert (delop.cross(2*x**2*j) == (Derivative(0, C.y) - Derivative(2*C.x**2, C.z))*C.i + (-Derivative(0, C.x) + Derivative(0, C.z))*C.j + (-Derivative(0, C.y) + Derivative(2*C.x**2, C.x))*C.k) assert (delop.cross(2*x**2*j, doit=True) == 4*x*k == curl(2*x**2*j))
#Tests for divergence assert delop & Vector.zero is S.Zero == divergence(Vector.zero) assert (delop & Vector.zero).doit() is S.Zero assert delop.dot(Vector.zero) == delop & Vector.zero assert (delop & i).doit() is S.Zero assert (delop & x**2*i).doit() == 2*x == divergence(x**2*i) assert (delop.dot(v, doit=True) == x*y + y*z + z*x == divergence(v)) assert delop & v == delop.dot(v) assert delop.dot(1/(x*y*z) * (i + j + k), doit=True) == \ - 1 / (x*y*z**2) - 1 / (x*y**2*z) - 1 / (x**2*y*z) v = x*i + y*j + z*k assert (delop & v == Derivative(C.x, C.x) + Derivative(C.y, C.y) + Derivative(C.z, C.z)) assert delop.dot(v, doit=True) == 3 == divergence(v) assert delop & v == delop.dot(v) assert simplify((delop & v).doit()) == 3
#Tests for gradient assert (delop.gradient(0, doit=True) == Vector.zero == gradient(0)) assert delop.gradient(0) == delop(0) assert (delop(S.Zero)).doit() == Vector.zero assert (delop(x) == (Derivative(C.x, C.x))*C.i + (Derivative(C.x, C.y))*C.j + (Derivative(C.x, C.z))*C.k) assert (delop(x)).doit() == i == gradient(x) assert (delop(x*y*z) == (Derivative(C.x*C.y*C.z, C.x))*C.i + (Derivative(C.x*C.y*C.z, C.y))*C.j + (Derivative(C.x*C.y*C.z, C.z))*C.k) assert (delop.gradient(x*y*z, doit=True) == y*z*i + z*x*j + x*y*k == gradient(x*y*z)) assert delop(x*y*z) == delop.gradient(x*y*z) assert (delop(2*x**2)).doit() == 4*x*i assert ((delop(a*sin(y) / x)).doit() == -a*sin(y)/x**2 * i + a*cos(y)/x * j)
#Tests for directional derivative assert (Vector.zero & delop)(a) is S.Zero assert ((Vector.zero & delop)(a)).doit() is S.Zero assert ((v & delop)(Vector.zero)).doit() == Vector.zero assert ((v & delop)(S.Zero)).doit() is S.Zero assert ((i & delop)(x)).doit() == 1 assert ((j & delop)(y)).doit() == 1 assert ((k & delop)(z)).doit() == 1 assert ((i & delop)(x*y*z)).doit() == y*z assert ((v & delop)(x)).doit() == x assert ((v & delop)(x*y*z)).doit() == 3*x*y*z assert (v & delop)(x + y + z) == C.x + C.y + C.z assert ((v & delop)(x + y + z)).doit() == x + y + z assert ((v & delop)(v)).doit() == v assert ((i & delop)(v)).doit() == i assert ((j & delop)(v)).doit() == j assert ((k & delop)(v)).doit() == k assert ((v & delop)(Vector.zero)).doit() == Vector.zero
# Tests for laplacian on scalar fields assert laplacian(x*y*z) is S.Zero assert laplacian(x**2) == S(2) assert laplacian(x**2*y**2*z**2) == \ 2*y**2*z**2 + 2*x**2*z**2 + 2*x**2*y**2 A = CoordSys3D('A', transformation="spherical", variable_names=["r", "theta", "phi"]) B = CoordSys3D('B', transformation='cylindrical', variable_names=["r", "theta", "z"]) assert laplacian(A.r + A.theta + A.phi) == 2/A.r + cos(A.theta)/(A.r**2*sin(A.theta)) assert laplacian(B.r + B.theta + B.z) == 1/B.r
# Tests for laplacian on vector fields assert laplacian(x*y*z*(i + j + k)) == Vector.zero assert laplacian(x*y**2*z*(i + j + k)) == \ 2*x*z*i + 2*x*z*j + 2*x*z*k
def test_product_rules(): """ Tests the six product rules defined with respect to the Del operator
References ==========
.. [1] https://en.wikipedia.org/wiki/Del
"""
#Define the scalar and vector functions f = 2*x*y*z g = x*y + y*z + z*x u = x**2*i + 4*j - y**2*z*k v = 4*i + x*y*z*k
# First product rule lhs = delop(f * g, doit=True) rhs = (f * delop(g) + g * delop(f)).doit() assert simplify(lhs) == simplify(rhs)
# Second product rule lhs = delop(u & v).doit() rhs = ((u ^ (delop ^ v)) + (v ^ (delop ^ u)) + \ ((u & delop)(v)) + ((v & delop)(u))).doit() assert simplify(lhs) == simplify(rhs)
# Third product rule lhs = (delop & (f*v)).doit() rhs = ((f * (delop & v)) + (v & (delop(f)))).doit() assert simplify(lhs) == simplify(rhs)
# Fourth product rule lhs = (delop & (u ^ v)).doit() rhs = ((v & (delop ^ u)) - (u & (delop ^ v))).doit() assert simplify(lhs) == simplify(rhs)
# Fifth product rule lhs = (delop ^ (f * v)).doit() rhs = (((delop(f)) ^ v) + (f * (delop ^ v))).doit() assert simplify(lhs) == simplify(rhs)
# Sixth product rule lhs = (delop ^ (u ^ v)).doit() rhs = (u * (delop & v) - v * (delop & u) + (v & delop)(u) - (u & delop)(v)).doit() assert simplify(lhs) == simplify(rhs)
P = C.orient_new_axis('P', q, C.k) # type: ignorescalar_field = 2*x**2*y*zgrad_field = gradient(scalar_field)vector_field = y**2*i + 3*x*j + 5*y*z*kcurl_field = curl(vector_field)
def test_conservative(): assert is_conservative(Vector.zero) is True assert is_conservative(i) is True assert is_conservative(2 * i + 3 * j + 4 * k) is True assert (is_conservative(y*z*i + x*z*j + x*y*k) is True) assert is_conservative(x * j) is False assert is_conservative(grad_field) is True assert is_conservative(curl_field) is False assert (is_conservative(4*x*y*z*i + 2*x**2*z*j) is False) assert is_conservative(z*P.i + P.x*k) is True
def test_solenoidal(): assert is_solenoidal(Vector.zero) is True assert is_solenoidal(i) is True assert is_solenoidal(2 * i + 3 * j + 4 * k) is True assert (is_solenoidal(y*z*i + x*z*j + x*y*k) is True) assert is_solenoidal(y * j) is False assert is_solenoidal(grad_field) is False assert is_solenoidal(curl_field) is True assert is_solenoidal((-2*y + 3)*k) is True assert is_solenoidal(cos(q)*i + sin(q)*j + cos(q)*P.k) is True assert is_solenoidal(z*P.i + P.x*k) is True
def test_directional_derivative(): assert directional_derivative(C.x*C.y*C.z, 3*C.i + 4*C.j + C.k) == C.x*C.y + 4*C.x*C.z + 3*C.y*C.z assert directional_derivative(5*C.x**2*C.z, 3*C.i + 4*C.j + C.k) == 5*C.x**2 + 30*C.x*C.z assert directional_derivative(5*C.x**2*C.z, 4*C.j) is S.Zero
D = CoordSys3D("D", "spherical", variable_names=["r", "theta", "phi"], vector_names=["e_r", "e_theta", "e_phi"]) r, theta, phi = D.base_scalars() e_r, e_theta, e_phi = D.base_vectors() assert directional_derivative(r**2*e_r, e_r) == 2*r*e_r assert directional_derivative(5*r**2*phi, 3*e_r + 4*e_theta + e_phi) == 5*r**2 + 30*r*phi
def test_scalar_potential(): assert scalar_potential(Vector.zero, C) == 0 assert scalar_potential(i, C) == x assert scalar_potential(j, C) == y assert scalar_potential(k, C) == z assert scalar_potential(y*z*i + x*z*j + x*y*k, C) == x*y*z assert scalar_potential(grad_field, C) == scalar_field assert scalar_potential(z*P.i + P.x*k, C) == x*z*cos(q) + y*z*sin(q) assert scalar_potential(z*P.i + P.x*k, P) == P.x*P.z raises(ValueError, lambda: scalar_potential(x*j, C))
def test_scalar_potential_difference(): point1 = C.origin.locate_new('P1', 1*i + 2*j + 3*k) point2 = C.origin.locate_new('P2', 4*i + 5*j + 6*k) genericpointC = C.origin.locate_new('RP', x*i + y*j + z*k) genericpointP = P.origin.locate_new('PP', P.x*P.i + P.y*P.j + P.z*P.k) assert scalar_potential_difference(S.Zero, C, point1, point2) == 0 assert (scalar_potential_difference(scalar_field, C, C.origin, genericpointC) == scalar_field) assert (scalar_potential_difference(grad_field, C, C.origin, genericpointC) == scalar_field) assert scalar_potential_difference(grad_field, C, point1, point2) == 948 assert (scalar_potential_difference(y*z*i + x*z*j + x*y*k, C, point1, genericpointC) == x*y*z - 6) potential_diff_P = (2*P.z*(P.x*sin(q) + P.y*cos(q))* (P.x*cos(q) - P.y*sin(q))**2) assert (scalar_potential_difference(grad_field, P, P.origin, genericpointP).simplify() == potential_diff_P.simplify())
def test_differential_operators_curvilinear_system(): A = CoordSys3D('A', transformation="spherical", variable_names=["r", "theta", "phi"]) B = CoordSys3D('B', transformation='cylindrical', variable_names=["r", "theta", "z"]) # Test for spherical coordinate system and gradient assert gradient(3*A.r + 4*A.theta) == 3*A.i + 4/A.r*A.j assert gradient(3*A.r*A.phi + 4*A.theta) == 3*A.phi*A.i + 4/A.r*A.j + (3/sin(A.theta))*A.k assert gradient(0*A.r + 0*A.theta+0*A.phi) == Vector.zero assert gradient(A.r*A.theta*A.phi) == A.theta*A.phi*A.i + A.phi*A.j + (A.theta/sin(A.theta))*A.k # Test for spherical coordinate system and divergence assert divergence(A.r * A.i + A.theta * A.j + A.phi * A.k) == \ (sin(A.theta)*A.r + cos(A.theta)*A.r*A.theta)/(sin(A.theta)*A.r**2) + 3 + 1/(sin(A.theta)*A.r) assert divergence(3*A.r*A.phi*A.i + A.theta*A.j + A.r*A.theta*A.phi*A.k) == \ (sin(A.theta)*A.r + cos(A.theta)*A.r*A.theta)/(sin(A.theta)*A.r**2) + 9*A.phi + A.theta/sin(A.theta) assert divergence(Vector.zero) == 0 assert divergence(0*A.i + 0*A.j + 0*A.k) == 0 # Test for spherical coordinate system and curl assert curl(A.r*A.i + A.theta*A.j + A.phi*A.k) == \ (cos(A.theta)*A.phi/(sin(A.theta)*A.r))*A.i + (-A.phi/A.r)*A.j + A.theta/A.r*A.k assert curl(A.r*A.j + A.phi*A.k) == (cos(A.theta)*A.phi/(sin(A.theta)*A.r))*A.i + (-A.phi/A.r)*A.j + 2*A.k
# Test for cylindrical coordinate system and gradient assert gradient(0*B.r + 0*B.theta+0*B.z) == Vector.zero assert gradient(B.r*B.theta*B.z) == B.theta*B.z*B.i + B.z*B.j + B.r*B.theta*B.k assert gradient(3*B.r) == 3*B.i assert gradient(2*B.theta) == 2/B.r * B.j assert gradient(4*B.z) == 4*B.k # Test for cylindrical coordinate system and divergence assert divergence(B.r*B.i + B.theta*B.j + B.z*B.k) == 3 + 1/B.r assert divergence(B.r*B.j + B.z*B.k) == 1 # Test for cylindrical coordinate system and curl assert curl(B.r*B.j + B.z*B.k) == 2*B.k assert curl(3*B.i + 2/B.r*B.j + 4*B.k) == Vector.zero
def test_mixed_coordinates(): # gradient a = CoordSys3D('a') b = CoordSys3D('b') c = CoordSys3D('c') assert gradient(a.x*b.y) == b.y*a.i + a.x*b.j assert gradient(3*cos(q)*a.x*b.x+a.y*(a.x+(cos(q)+b.x))) ==\ (a.y + 3*b.x*cos(q))*a.i + (a.x + b.x + cos(q))*a.j + (3*a.x*cos(q) + a.y)*b.i # Some tests need further work: # assert gradient(a.x*(cos(a.x+b.x))) == (cos(a.x + b.x))*a.i + a.x*Gradient(cos(a.x + b.x)) # assert gradient(cos(a.x + b.x)*cos(a.x + b.z)) == Gradient(cos(a.x + b.x)*cos(a.x + b.z)) assert gradient(a.x**b.y) == Gradient(a.x**b.y) # assert gradient(cos(a.x+b.y)*a.z) == None assert gradient(cos(a.x*b.y)) == Gradient(cos(a.x*b.y)) assert gradient(3*cos(q)*a.x*b.x*a.z*a.y+ b.y*b.z + cos(a.x+a.y)*b.z) == \ (3*a.y*a.z*b.x*cos(q) - b.z*sin(a.x + a.y))*a.i + \ (3*a.x*a.z*b.x*cos(q) - b.z*sin(a.x + a.y))*a.j + (3*a.x*a.y*b.x*cos(q))*a.k + \ (3*a.x*a.y*a.z*cos(q))*b.i + b.z*b.j + (b.y + cos(a.x + a.y))*b.k # divergence assert divergence(a.i*a.x+a.j*a.y+a.z*a.k + b.i*b.x+b.j*b.y+b.z*b.k + c.i*c.x+c.j*c.y+c.z*c.k) == S(9) # assert divergence(3*a.i*a.x*cos(a.x+b.z) + a.j*b.x*c.z) == None assert divergence(3*a.i*a.x*a.z + b.j*b.x*c.z + 3*a.j*a.z*a.y) == \ 6*a.z + b.x*Dot(b.j, c.k) assert divergence(3*cos(q)*a.x*b.x*b.i*c.x) == \ 3*a.x*b.x*cos(q)*Dot(b.i, c.i) + 3*a.x*c.x*cos(q) + 3*b.x*c.x*cos(q)*Dot(b.i, a.i) assert divergence(a.x*b.x*c.x*Cross(a.x*a.i, a.y*b.j)) ==\ a.x*b.x*c.x*Divergence(Cross(a.x*a.i, a.y*b.j)) + \ b.x*c.x*Dot(Cross(a.x*a.i, a.y*b.j), a.i) + \ a.x*c.x*Dot(Cross(a.x*a.i, a.y*b.j), b.i) + \ a.x*b.x*Dot(Cross(a.x*a.i, a.y*b.j), c.i) assert divergence(a.x*b.x*c.x*(a.x*a.i + b.x*b.i)) == \ 4*a.x*b.x*c.x +\ a.x**2*c.x*Dot(a.i, b.i) +\ a.x**2*b.x*Dot(a.i, c.i) +\ b.x**2*c.x*Dot(b.i, a.i) +\ a.x*b.x**2*Dot(b.i, c.i)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184from sympy.vector.vector import Vectorfrom sympy.vector.coordsysrect import CoordSys3Dfrom sympy.vector.functions import express, matrix_to_vector, orthogonalizefrom sympy.core.numbers import Rationalfrom sympy.core.singleton import Sfrom sympy.core.symbol import symbolsfrom sympy.functions.elementary.miscellaneous import sqrtfrom sympy.functions.elementary.trigonometric import (cos, sin)from sympy.matrices.immutable import ImmutableDenseMatrix as Matrixfrom sympy.testing.pytest import raises
N = CoordSys3D('N')q1, q2, q3, q4, q5 = symbols('q1 q2 q3 q4 q5')A = N.orient_new_axis('A', q1, N.k) # type: ignoreB = A.orient_new_axis('B', q2, A.i)C = B.orient_new_axis('C', q3, B.j)
def test_express(): assert express(Vector.zero, N) == Vector.zero assert express(S.Zero, N) is S.Zero assert express(A.i, C) == cos(q3)*C.i + sin(q3)*C.k assert express(A.j, C) == sin(q2)*sin(q3)*C.i + cos(q2)*C.j - \ sin(q2)*cos(q3)*C.k assert express(A.k, C) == -sin(q3)*cos(q2)*C.i + sin(q2)*C.j + \ cos(q2)*cos(q3)*C.k assert express(A.i, N) == cos(q1)*N.i + sin(q1)*N.j assert express(A.j, N) == -sin(q1)*N.i + cos(q1)*N.j assert express(A.k, N) == N.k assert express(A.i, A) == A.i assert express(A.j, A) == A.j assert express(A.k, A) == A.k assert express(A.i, B) == B.i assert express(A.j, B) == cos(q2)*B.j - sin(q2)*B.k assert express(A.k, B) == sin(q2)*B.j + cos(q2)*B.k assert express(A.i, C) == cos(q3)*C.i + sin(q3)*C.k assert express(A.j, C) == sin(q2)*sin(q3)*C.i + cos(q2)*C.j - \ sin(q2)*cos(q3)*C.k assert express(A.k, C) == -sin(q3)*cos(q2)*C.i + sin(q2)*C.j + \ cos(q2)*cos(q3)*C.k # Check to make sure UnitVectors get converted properly assert express(N.i, N) == N.i assert express(N.j, N) == N.j assert express(N.k, N) == N.k assert express(N.i, A) == (cos(q1)*A.i - sin(q1)*A.j) assert express(N.j, A) == (sin(q1)*A.i + cos(q1)*A.j) assert express(N.k, A) == A.k assert express(N.i, B) == (cos(q1)*B.i - sin(q1)*cos(q2)*B.j + sin(q1)*sin(q2)*B.k) assert express(N.j, B) == (sin(q1)*B.i + cos(q1)*cos(q2)*B.j - sin(q2)*cos(q1)*B.k) assert express(N.k, B) == (sin(q2)*B.j + cos(q2)*B.k) assert express(N.i, C) == ( (cos(q1)*cos(q3) - sin(q1)*sin(q2)*sin(q3))*C.i - sin(q1)*cos(q2)*C.j + (sin(q3)*cos(q1) + sin(q1)*sin(q2)*cos(q3))*C.k) assert express(N.j, C) == ( (sin(q1)*cos(q3) + sin(q2)*sin(q3)*cos(q1))*C.i + cos(q1)*cos(q2)*C.j + (sin(q1)*sin(q3) - sin(q2)*cos(q1)*cos(q3))*C.k) assert express(N.k, C) == (-sin(q3)*cos(q2)*C.i + sin(q2)*C.j + cos(q2)*cos(q3)*C.k)
assert express(A.i, N) == (cos(q1)*N.i + sin(q1)*N.j) assert express(A.j, N) == (-sin(q1)*N.i + cos(q1)*N.j) assert express(A.k, N) == N.k assert express(A.i, A) == A.i assert express(A.j, A) == A.j assert express(A.k, A) == A.k assert express(A.i, B) == B.i assert express(A.j, B) == (cos(q2)*B.j - sin(q2)*B.k) assert express(A.k, B) == (sin(q2)*B.j + cos(q2)*B.k) assert express(A.i, C) == (cos(q3)*C.i + sin(q3)*C.k) assert express(A.j, C) == (sin(q2)*sin(q3)*C.i + cos(q2)*C.j - sin(q2)*cos(q3)*C.k) assert express(A.k, C) == (-sin(q3)*cos(q2)*C.i + sin(q2)*C.j + cos(q2)*cos(q3)*C.k)
assert express(B.i, N) == (cos(q1)*N.i + sin(q1)*N.j) assert express(B.j, N) == (-sin(q1)*cos(q2)*N.i + cos(q1)*cos(q2)*N.j + sin(q2)*N.k) assert express(B.k, N) == (sin(q1)*sin(q2)*N.i - sin(q2)*cos(q1)*N.j + cos(q2)*N.k) assert express(B.i, A) == A.i assert express(B.j, A) == (cos(q2)*A.j + sin(q2)*A.k) assert express(B.k, A) == (-sin(q2)*A.j + cos(q2)*A.k) assert express(B.i, B) == B.i assert express(B.j, B) == B.j assert express(B.k, B) == B.k assert express(B.i, C) == (cos(q3)*C.i + sin(q3)*C.k) assert express(B.j, C) == C.j assert express(B.k, C) == (-sin(q3)*C.i + cos(q3)*C.k)
assert express(C.i, N) == ( (cos(q1)*cos(q3) - sin(q1)*sin(q2)*sin(q3))*N.i + (sin(q1)*cos(q3) + sin(q2)*sin(q3)*cos(q1))*N.j - sin(q3)*cos(q2)*N.k) assert express(C.j, N) == ( -sin(q1)*cos(q2)*N.i + cos(q1)*cos(q2)*N.j + sin(q2)*N.k) assert express(C.k, N) == ( (sin(q3)*cos(q1) + sin(q1)*sin(q2)*cos(q3))*N.i + (sin(q1)*sin(q3) - sin(q2)*cos(q1)*cos(q3))*N.j + cos(q2)*cos(q3)*N.k) assert express(C.i, A) == (cos(q3)*A.i + sin(q2)*sin(q3)*A.j - sin(q3)*cos(q2)*A.k) assert express(C.j, A) == (cos(q2)*A.j + sin(q2)*A.k) assert express(C.k, A) == (sin(q3)*A.i - sin(q2)*cos(q3)*A.j + cos(q2)*cos(q3)*A.k) assert express(C.i, B) == (cos(q3)*B.i - sin(q3)*B.k) assert express(C.j, B) == B.j assert express(C.k, B) == (sin(q3)*B.i + cos(q3)*B.k) assert express(C.i, C) == C.i assert express(C.j, C) == C.j assert express(C.k, C) == C.k == (C.k)
# Check to make sure Vectors get converted back to UnitVectors assert N.i == express((cos(q1)*A.i - sin(q1)*A.j), N).simplify() assert N.j == express((sin(q1)*A.i + cos(q1)*A.j), N).simplify() assert N.i == express((cos(q1)*B.i - sin(q1)*cos(q2)*B.j + sin(q1)*sin(q2)*B.k), N).simplify() assert N.j == express((sin(q1)*B.i + cos(q1)*cos(q2)*B.j - sin(q2)*cos(q1)*B.k), N).simplify() assert N.k == express((sin(q2)*B.j + cos(q2)*B.k), N).simplify()
assert A.i == express((cos(q1)*N.i + sin(q1)*N.j), A).simplify() assert A.j == express((-sin(q1)*N.i + cos(q1)*N.j), A).simplify()
assert A.j == express((cos(q2)*B.j - sin(q2)*B.k), A).simplify() assert A.k == express((sin(q2)*B.j + cos(q2)*B.k), A).simplify()
assert A.i == express((cos(q3)*C.i + sin(q3)*C.k), A).simplify() assert A.j == express((sin(q2)*sin(q3)*C.i + cos(q2)*C.j - sin(q2)*cos(q3)*C.k), A).simplify()
assert A.k == express((-sin(q3)*cos(q2)*C.i + sin(q2)*C.j + cos(q2)*cos(q3)*C.k), A).simplify() assert B.i == express((cos(q1)*N.i + sin(q1)*N.j), B).simplify() assert B.j == express((-sin(q1)*cos(q2)*N.i + cos(q1)*cos(q2)*N.j + sin(q2)*N.k), B).simplify()
assert B.k == express((sin(q1)*sin(q2)*N.i - sin(q2)*cos(q1)*N.j + cos(q2)*N.k), B).simplify()
assert B.j == express((cos(q2)*A.j + sin(q2)*A.k), B).simplify() assert B.k == express((-sin(q2)*A.j + cos(q2)*A.k), B).simplify() assert B.i == express((cos(q3)*C.i + sin(q3)*C.k), B).simplify() assert B.k == express((-sin(q3)*C.i + cos(q3)*C.k), B).simplify() assert C.i == express((cos(q3)*A.i + sin(q2)*sin(q3)*A.j - sin(q3)*cos(q2)*A.k), C).simplify() assert C.j == express((cos(q2)*A.j + sin(q2)*A.k), C).simplify() assert C.k == express((sin(q3)*A.i - sin(q2)*cos(q3)*A.j + cos(q2)*cos(q3)*A.k), C).simplify() assert C.i == express((cos(q3)*B.i - sin(q3)*B.k), C).simplify() assert C.k == express((sin(q3)*B.i + cos(q3)*B.k), C).simplify()
def test_matrix_to_vector(): m = Matrix([[1], [2], [3]]) assert matrix_to_vector(m, C) == C.i + 2*C.j + 3*C.k m = Matrix([[0], [0], [0]]) assert matrix_to_vector(m, N) == matrix_to_vector(m, C) == \ Vector.zero m = Matrix([[q1], [q2], [q3]]) assert matrix_to_vector(m, N) == q1*N.i + q2*N.j + q3*N.k
def test_orthogonalize(): C = CoordSys3D('C') a, b = symbols('a b', integer=True) i, j, k = C.base_vectors() v1 = i + 2*j v2 = 2*i + 3*j v3 = 3*i + 5*j v4 = 3*i + j v5 = 2*i + 2*j v6 = a*i + b*j v7 = 4*a*i + 4*b*j assert orthogonalize(v1, v2) == [C.i + 2*C.j, C.i*Rational(2, 5) + -C.j/5] # from wikipedia assert orthogonalize(v4, v5, orthonormal=True) == \ [(3*sqrt(10))*C.i/10 + (sqrt(10))*C.j/10, (-sqrt(10))*C.i/10 + (3*sqrt(10))*C.j/10] raises(ValueError, lambda: orthogonalize(v1, v2, v3)) raises(ValueError, lambda: orthogonalize(v6, v7))123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990from sympy.core.relational import Eqfrom sympy.core.singleton import Sfrom sympy.abc import x, y, z, s, tfrom sympy.sets import FiniteSet, EmptySetfrom sympy.geometry import Pointfrom sympy.vector import ImplicitRegionfrom sympy.testing.pytest import raises
def test_ImplicitRegion(): ellipse = ImplicitRegion((x, y), (x**2/4 + y**2/16 - 1)) assert ellipse.equation == x**2/4 + y**2/16 - 1 assert ellipse.variables == (x, y) assert ellipse.degree == 2 r = ImplicitRegion((x, y, z), Eq(x**4 + y**2 - x*y, 6)) assert r.equation == x**4 + y**2 - x*y - 6 assert r.variables == (x, y, z) assert r.degree == 4
def test_regular_point(): r1 = ImplicitRegion((x,), x**2 - 16) assert r1.regular_point() == (-4,) c1 = ImplicitRegion((x, y), x**2 + y**2 - 4) assert c1.regular_point() == (0, -2) c2 = ImplicitRegion((x, y), (x - S(5)/2)**2 + y**2 - (S(1)/4)**2) assert c2.regular_point() == (S(5)/2, -S(1)/4) c3 = ImplicitRegion((x, y), (y - 5)**2 - 16*(x - 5)) assert c3.regular_point() == (5, 5) r2 = ImplicitRegion((x, y), x**2 - 4*x*y - 3*y**2 + 4*x + 8*y - 5) assert r2.regular_point() == (S(4)/7, S(9)/7) r3 = ImplicitRegion((x, y), x**2 - 2*x*y + 3*y**2 - 2*x - 5*y + 3/2) raises(ValueError, lambda: r3.regular_point())
def test_singular_points_and_multiplicty(): r1 = ImplicitRegion((x, y, z), Eq(x + y + z, 0)) assert r1.singular_points() == EmptySet r2 = ImplicitRegion((x, y, z), x*y*z + y**4 -x**2*z**2) assert r2.singular_points() == FiniteSet((0, 0, z), (x, 0, 0)) assert r2.multiplicity((0, 0, 0)) == 3 assert r2.multiplicity((0, 0, 6)) == 2 r3 = ImplicitRegion((x, y, z), z**2 - x**2 - y**2) assert r3.singular_points() == FiniteSet((0, 0, 0)) assert r3.multiplicity((0, 0, 0)) == 2 r4 = ImplicitRegion((x, y), x**2 + y**2 - 2*x) assert r4.singular_points() == EmptySet assert r4.multiplicity(Point(1, 3)) == 0
def test_rational_parametrization(): p = ImplicitRegion((x,), x - 2) assert p.rational_parametrization() == (x - 2,)
line = ImplicitRegion((x, y), Eq(y, 3*x + 2)) assert line.rational_parametrization() == (x, 3*x + 2)
circle1 = ImplicitRegion((x, y), (x-2)**2 + (y+3)**2 - 4) assert circle1.rational_parametrization(parameters=t) == (4*t/(t**2 + 1) + 2, 4*t**2/(t**2 + 1) - 5) circle2 = ImplicitRegion((x, y), (x - S.Half)**2 + y**2 - (S(1)/2)**2)
assert circle2.rational_parametrization(parameters=t) == (t/(t**2 + 1) + S(1)/2, t**2/(t**2 + 1) - S(1)/2) circle3 = ImplicitRegion((x, y), Eq(x**2 + y**2, 2*x)) assert circle3.rational_parametrization(parameters=(t,)) == (2*t/(t**2 + 1) + 1, 2*t**2/(t**2 + 1) - 1)
parabola = ImplicitRegion((x, y), (y - 3)**2 - 4*(x + 6)) assert parabola.rational_parametrization(t) == (-6 + 4/t**2, 3 + 4/t)
rect_hyperbola = ImplicitRegion((x, y), x*y - 1) assert rect_hyperbola.rational_parametrization(t) == (-1 + (t + 1)/t, t)
cubic_curve = ImplicitRegion((x, y), x**3 + x**2 - y**2) assert cubic_curve.rational_parametrization(parameters=(t)) == (t**2 - 1, t*(t**2 - 1)) cuspidal = ImplicitRegion((x, y), (x**3 - y**2)) assert cuspidal.rational_parametrization(t) == (t**2, t**3)
I = ImplicitRegion((x, y), x**3 + x**2 - y**2) assert I.rational_parametrization(t) == (t**2 - 1, t*(t**2 - 1))
sphere = ImplicitRegion((x, y, z), Eq(x**2 + y**2 + z**2, 2*x)) assert sphere.rational_parametrization(parameters=(s, t)) == (2/(s**2 + t**2 + 1), 2*t/(s**2 + t**2 + 1), 2*s/(s**2 + t**2 + 1))
conic = ImplicitRegion((x, y), Eq(x**2 + 4*x*y + 3*y**2 + x - y + 10, 0)) assert conic.rational_parametrization(t) == ( S(17)/2 + 4/(3*t**2 + 4*t + 1), 4*t/(3*t**2 + 4*t + 1) - S(11)/2)
r1 = ImplicitRegion((x, y), y**2 - x**3 + x) raises(NotImplementedError, lambda: r1.rational_parametrization()) r2 = ImplicitRegion((x, y), y**2 - x**3 - x**2 + 1) raises(NotImplementedError, lambda: r2.rational_parametrization())123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106from sympy.core.numbers import pifrom sympy.core.singleton import Sfrom sympy.functions.elementary.miscellaneous import sqrtfrom sympy.functions.elementary.trigonometric import (cos, sin)from sympy.testing.pytest import raisesfrom sympy.vector.coordsysrect import CoordSys3Dfrom sympy.vector.integrals import ParametricIntegral, vector_integratefrom sympy.vector.parametricregion import ParametricRegionfrom sympy.vector.implicitregion import ImplicitRegionfrom sympy.abc import x, y, z, u, v, r, t, theta, phifrom sympy.geometry import Point, Segment, Curve, Circle, Polygon, Plane
C = CoordSys3D('C')
def test_parametric_lineintegrals(): halfcircle = ParametricRegion((4*cos(theta), 4*sin(theta)), (theta, -pi/2, pi/2)) assert ParametricIntegral(C.x*C.y**4, halfcircle) == S(8192)/5
curve = ParametricRegion((t, t**2, t**3), (t, 0, 1)) field1 = 8*C.x**2*C.y*C.z*C.i + 5*C.z*C.j - 4*C.x*C.y*C.k assert ParametricIntegral(field1, curve) == 1 line = ParametricRegion((4*t - 1, 2 - 2*t, t), (t, 0, 1)) assert ParametricIntegral(C.x*C.z*C.i - C.y*C.z*C.k, line) == 3
assert ParametricIntegral(4*C.x**3, ParametricRegion((1, t), (t, 0, 2))) == 8
helix = ParametricRegion((cos(t), sin(t), 3*t), (t, 0, 4*pi)) assert ParametricIntegral(C.x*C.y*C.z, helix) == -3*sqrt(10)*pi
field2 = C.y*C.i + C.z*C.j + C.z*C.k assert ParametricIntegral(field2, ParametricRegion((cos(t), sin(t), t**2), (t, 0, pi))) == -5*pi/2 + pi**4/2
def test_parametric_surfaceintegrals():
semisphere = ParametricRegion((2*sin(phi)*cos(theta), 2*sin(phi)*sin(theta), 2*cos(phi)),\ (theta, 0, 2*pi), (phi, 0, pi/2)) assert ParametricIntegral(C.z, semisphere) == 8*pi
cylinder = ParametricRegion((sqrt(3)*cos(theta), sqrt(3)*sin(theta), z), (z, 0, 6), (theta, 0, 2*pi)) assert ParametricIntegral(C.y, cylinder) == 0
cone = ParametricRegion((v*cos(u), v*sin(u), v), (u, 0, 2*pi), (v, 0, 1)) assert ParametricIntegral(C.x*C.i + C.y*C.j + C.z**4*C.k, cone) == pi/3
triangle1 = ParametricRegion((x, y), (x, 0, 2), (y, 0, 10 - 5*x)) triangle2 = ParametricRegion((x, y), (y, 0, 10 - 5*x), (x, 0, 2)) assert ParametricIntegral(-15.6*C.y*C.k, triangle1) == ParametricIntegral(-15.6*C.y*C.k, triangle2) assert ParametricIntegral(C.z, triangle1) == 10*C.z
def test_parametric_volumeintegrals():
cube = ParametricRegion((x, y, z), (x, 0, 1), (y, 0, 1), (z, 0, 1)) assert ParametricIntegral(1, cube) == 1
solidsphere1 = ParametricRegion((r*sin(phi)*cos(theta), r*sin(phi)*sin(theta), r*cos(phi)),\ (r, 0, 2), (theta, 0, 2*pi), (phi, 0, pi)) solidsphere2 = ParametricRegion((r*sin(phi)*cos(theta), r*sin(phi)*sin(theta), r*cos(phi)),\ (r, 0, 2), (phi, 0, pi), (theta, 0, 2*pi)) assert ParametricIntegral(C.x**2 + C.y**2, solidsphere1) == -256*pi/15 assert ParametricIntegral(C.x**2 + C.y**2, solidsphere2) == 256*pi/15
region_under_plane1 = ParametricRegion((x, y, z), (x, 0, 3), (y, 0, -2*x/3 + 2),\ (z, 0, 6 - 2*x - 3*y)) region_under_plane2 = ParametricRegion((x, y, z), (x, 0, 3), (z, 0, 6 - 2*x - 3*y),\ (y, 0, -2*x/3 + 2))
assert ParametricIntegral(C.x*C.i + C.j - 100*C.k, region_under_plane1) == \ ParametricIntegral(C.x*C.i + C.j - 100*C.k, region_under_plane2) assert ParametricIntegral(2*C.x, region_under_plane2) == -9
def test_vector_integrate(): halfdisc = ParametricRegion((r*cos(theta), r* sin(theta)), (r, -2, 2), (theta, 0, pi)) assert vector_integrate(C.x**2, halfdisc) == 4*pi assert vector_integrate(C.x, ParametricRegion((t, t**2), (t, 2, 3))) == -17*sqrt(17)/12 + 37*sqrt(37)/12
assert vector_integrate(C.y**3*C.z, (C.x, 0, 3), (C.y, -1, 4)) == 765*C.z/4
s1 = Segment(Point(0, 0), Point(0, 1)) assert vector_integrate(-15*C.y, s1) == S(-15)/2 s2 = Segment(Point(4, 3, 9), Point(1, 1, 7)) assert vector_integrate(C.y*C.i, s2) == -6
curve = Curve((sin(t), cos(t)), (t, 0, 2)) assert vector_integrate(5*C.z, curve) == 10*C.z
c1 = Circle(Point(2, 3), 6) assert vector_integrate(C.x*C.y, c1) == 72*pi c2 = Circle(Point(0, 0), Point(1, 1), Point(1, 0)) assert vector_integrate(1, c2) == c2.circumference
triangle = Polygon((0, 0), (1, 0), (1, 1)) assert vector_integrate(C.x*C.i - 14*C.y*C.j, triangle) == 0 p1, p2, p3, p4 = [(0, 0), (1, 0), (5, 1), (0, 1)] poly = Polygon(p1, p2, p3, p4) assert vector_integrate(-23*C.z, poly) == -161*C.z - 23*sqrt(17)*C.z
point = Point(2, 3) assert vector_integrate(C.i*C.y, point) == ParametricIntegral(C.y*C.i, ParametricRegion((2, 3)))
c3 = ImplicitRegion((x, y), x**2 + y**2 - 4) assert vector_integrate(45, c3) == 180*pi c4 = ImplicitRegion((x, y), (x - 3)**2 + (y - 4)**2 - 9) assert vector_integrate(1, c4) == 6*pi
pl = Plane(Point(1, 1, 1), Point(2, 3, 4), Point(2, 2, 2)) raises(ValueError, lambda: vector_integrate(C.x*C.z*C.i + C.k, pl))12345678910111213141516171819202122232425262728293031323334353637383940414243from sympy.vector import CoordSys3D, Gradient, Divergence, Curl, VectorZero, Laplacianfrom sympy.printing.repr import srepr
R = CoordSys3D('R')s1 = R.x*R.y*R.z # type: ignores2 = R.x + 3*R.y**2 # type: ignores3 = R.x**2 + R.y**2 + R.z**2 # type: ignorev1 = R.x*R.i + R.z*R.z*R.j # type: ignorev2 = R.x*R.i + R.y*R.j + R.z*R.k # type: ignorev3 = R.x**2*R.i + R.y**2*R.j + R.z**2*R.k # type: ignore
def test_Gradient(): assert Gradient(s1) == Gradient(R.x*R.y*R.z) assert Gradient(s2) == Gradient(R.x + 3*R.y**2) assert Gradient(s1).doit() == R.y*R.z*R.i + R.x*R.z*R.j + R.x*R.y*R.k assert Gradient(s2).doit() == R.i + 6*R.y*R.j
def test_Divergence(): assert Divergence(v1) == Divergence(R.x*R.i + R.z*R.z*R.j) assert Divergence(v2) == Divergence(R.x*R.i + R.y*R.j + R.z*R.k) assert Divergence(v1).doit() == 1 assert Divergence(v2).doit() == 3 # issue 22384 Rc = CoordSys3D('R', transformation='cylindrical') assert Divergence(Rc.i).doit() == 1/Rc.r
def test_Curl(): assert Curl(v1) == Curl(R.x*R.i + R.z*R.z*R.j) assert Curl(v2) == Curl(R.x*R.i + R.y*R.j + R.z*R.k) assert Curl(v1).doit() == (-2*R.z)*R.i assert Curl(v2).doit() == VectorZero()
def test_Laplacian(): assert Laplacian(s3) == Laplacian(R.x**2 + R.y**2 + R.z**2) assert Laplacian(v3) == Laplacian(R.x**2*R.i + R.y**2*R.j + R.z**2*R.k) assert Laplacian(s3).doit() == 6 assert Laplacian(v3).doit() == 2*R.i + 2*R.j + 2*R.k assert srepr(Laplacian(s3)) == \ 'Laplacian(Add(Pow(R.x, Integer(2)), Pow(R.y, Integer(2)), Pow(R.z, Integer(2))))'12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697from sympy.core.numbers import pifrom sympy.functions.elementary.trigonometric import (cos, sin)from sympy.vector.coordsysrect import CoordSys3Dfrom sympy.vector.parametricregion import ParametricRegion, parametric_region_listfrom sympy.geometry import Point, Segment, Curve, Ellipse, Line, Parabola, Polygonfrom sympy.testing.pytest import raisesfrom sympy.abc import a, b, r, t, x, y, z, theta, phi
C = CoordSys3D('C')
def test_ParametricRegion():
point = ParametricRegion((3, 4)) assert point.definition == (3, 4) assert point.parameters == () assert point.limits == {} assert point.dimensions == 0
# line x = y line_xy = ParametricRegion((y, y), (y, 1, 5)) assert line_xy .definition == (y, y) assert line_xy.parameters == (y,) assert line_xy.dimensions == 1
# line y = z line_yz = ParametricRegion((x,t,t), x, (t, 1, 2)) assert line_yz.definition == (x,t,t) assert line_yz.parameters == (x, t) assert line_yz.limits == {t: (1, 2)} assert line_yz.dimensions == 1
p1 = ParametricRegion((9*a, -16*b), (a, 0, 2), (b, -1, 5)) assert p1.definition == (9*a, -16*b) assert p1.parameters == (a, b) assert p1.limits == {a: (0, 2), b: (-1, 5)} assert p1.dimensions == 2
p2 = ParametricRegion((t, t**3), t) assert p2.parameters == (t,) assert p2.limits == {} assert p2.dimensions == 0
circle = ParametricRegion((r*cos(theta), r*sin(theta)), r, (theta, 0, 2*pi)) assert circle.definition == (r*cos(theta), r*sin(theta)) assert circle.dimensions == 1
halfdisc = ParametricRegion((r*cos(theta), r*sin(theta)), (r, -2, 2), (theta, 0, pi)) assert halfdisc.definition == (r*cos(theta), r*sin(theta)) assert halfdisc.parameters == (r, theta) assert halfdisc.limits == {r: (-2, 2), theta: (0, pi)} assert halfdisc.dimensions == 2
ellipse = ParametricRegion((a*cos(t), b*sin(t)), (t, 0, 8)) assert ellipse.parameters == (t,) assert ellipse.limits == {t: (0, 8)} assert ellipse.dimensions == 1
cylinder = ParametricRegion((r*cos(theta), r*sin(theta), z), (r, 0, 1), (theta, 0, 2*pi), (z, 0, 4)) assert cylinder.parameters == (r, theta, z) assert cylinder.dimensions == 3
sphere = ParametricRegion((r*sin(phi)*cos(theta),r*sin(phi)*sin(theta), r*cos(phi)), r, (theta, 0, 2*pi), (phi, 0, pi)) assert sphere.definition == (r*sin(phi)*cos(theta),r*sin(phi)*sin(theta), r*cos(phi)) assert sphere.parameters == (r, theta, phi) assert sphere.dimensions == 2
raises(ValueError, lambda: ParametricRegion((a*t**2, 2*a*t), (a, -2))) raises(ValueError, lambda: ParametricRegion((a, b), (a**2, sin(b)), (a, 2, 4, 6)))
def test_parametric_region_list():
point = Point(-5, 12) assert parametric_region_list(point) == [ParametricRegion((-5, 12))]
e = Ellipse(Point(2, 8), 2, 6) assert parametric_region_list(e, t) == [ParametricRegion((2*cos(t) + 2, 6*sin(t) + 8), (t, 0, 2*pi))]
c = Curve((t, t**3), (t, 5, 3)) assert parametric_region_list(c) == [ParametricRegion((t, t**3), (t, 5, 3))]
s = Segment(Point(2, 11, -6), Point(0, 2, 5)) assert parametric_region_list(s, t) == [ParametricRegion((2 - 2*t, 11 - 9*t, 11*t - 6), (t, 0, 1))] s1 = Segment(Point(0, 0), (1, 0)) assert parametric_region_list(s1, t) == [ParametricRegion((t, 0), (t, 0, 1))] s2 = Segment(Point(1, 2, 3), Point(1, 2, 5)) assert parametric_region_list(s2, t) == [ParametricRegion((1, 2, 2*t + 3), (t, 0, 1))] s3 = Segment(Point(12, 56), Point(12, 56)) assert parametric_region_list(s3) == [ParametricRegion((12, 56))]
poly = Polygon((1,3), (-3, 8), (2, 4)) assert parametric_region_list(poly, t) == [ParametricRegion((1 - 4*t, 5*t + 3), (t, 0, 1)), ParametricRegion((5*t - 3, 8 - 4*t), (t, 0, 1)), ParametricRegion((2 - t, 4 - t), (t, 0, 1))]
p1 = Parabola(Point(0, 0), Line(Point(5, 8), Point(7,8))) raises(ValueError, lambda: parametric_region_list(p1))123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221# -*- coding: utf-8 -*-from sympy.core.function import Functionfrom sympy.integrals.integrals import Integralfrom sympy.printing.latex import latexfrom sympy.printing.pretty import pretty as xprettyfrom sympy.vector import CoordSys3D, Del, Vector, expressfrom sympy.abc import a, b, cfrom sympy.testing.pytest import XFAIL
def pretty(expr): """ASCII pretty-printing""" return xpretty(expr, use_unicode=False, wrap_line=False)
def upretty(expr): """Unicode pretty-printing""" return xpretty(expr, use_unicode=True, wrap_line=False)
# Initialize the basic and tedious vector/dyadic expressions# needed for testing.# Some of the pretty forms shown denote how the expressions just# above them should look with pretty printing.N = CoordSys3D('N')C = N.orient_new_axis('C', a, N.k) # type: ignorev = []d = []v.append(Vector.zero)v.append(N.i) # type: ignorev.append(-N.i) # type: ignorev.append(N.i + N.j) # type: ignorev.append(a*N.i) # type: ignorev.append(a*N.i - b*N.j) # type: ignorev.append((a**2 + N.x)*N.i + N.k) # type: ignorev.append((a**2 + b)*N.i + 3*(C.y - c)*N.k) # type: ignoref = Function('f')v.append(N.j - (Integral(f(b)) - C.x**2)*N.k) # type: ignoreupretty_v_8 = """\ ⎛ 2 ⌠ ⎞ \n\j_N + ⎜x_C - ⎮ f(b) db⎟ k_N\n\ ⎝ ⌡ ⎠ \"""pretty_v_8 = """\j_N + / / \\\n\ | 2 | |\n\ |x_C - | f(b) db|\n\ | | |\n\ \\ / / \"""
v.append(N.i + C.k) # type: ignorev.append(express(N.i, C)) # type: ignorev.append((a**2 + b)*N.i + (Integral(f(b)))*N.k) # type: ignoreupretty_v_11 = """\⎛ 2 ⎞ ⎛⌠ ⎞ \n\⎝a + b⎠ i_N + ⎜⎮ f(b) db⎟ k_N\n\ ⎝⌡ ⎠ \"""pretty_v_11 = """\/ 2 \\ + / / \\\n\\\a + b/ i_N| | |\n\ | | f(b) db|\n\ | | |\n\ \\/ / \"""
for x in v: d.append(x | N.k) # type: ignores = 3*N.x**2*C.y # type: ignoreupretty_s = """\ 2\n\3⋅y_C⋅x_N \"""pretty_s = """\ 2\n\3*y_C*x_N \"""
# This is the pretty form for ((a**2 + b)*N.i + 3*(C.y - c)*N.k) | N.kupretty_d_7 = """\⎛ 2 ⎞ \n\⎝a + b⎠ (i_N|k_N) + (3⋅y_C - 3⋅c) (k_N|k_N)\"""pretty_d_7 = """\/ 2 \\ (i_N|k_N) + (3*y_C - 3*c) (k_N|k_N)\n\\\a + b/ \"""
def test_str_printing(): assert str(v[0]) == '0' assert str(v[1]) == 'N.i' assert str(v[2]) == '(-1)*N.i' assert str(v[3]) == 'N.i + N.j' assert str(v[8]) == 'N.j + (C.x**2 - Integral(f(b), b))*N.k' assert str(v[9]) == 'C.k + N.i' assert str(s) == '3*C.y*N.x**2' assert str(d[0]) == '0' assert str(d[1]) == '(N.i|N.k)' assert str(d[4]) == 'a*(N.i|N.k)' assert str(d[5]) == 'a*(N.i|N.k) + (-b)*(N.j|N.k)' assert str(d[8]) == ('(N.j|N.k) + (C.x**2 - ' + 'Integral(f(b), b))*(N.k|N.k)')
@XFAILdef test_pretty_printing_ascii(): assert pretty(v[0]) == '0' assert pretty(v[1]) == 'i_N' assert pretty(v[5]) == '(a) i_N + (-b) j_N' assert pretty(v[8]) == pretty_v_8 assert pretty(v[2]) == '(-1) i_N' assert pretty(v[11]) == pretty_v_11 assert pretty(s) == pretty_s assert pretty(d[0]) == '(0|0)' assert pretty(d[5]) == '(a) (i_N|k_N) + (-b) (j_N|k_N)' assert pretty(d[7]) == pretty_d_7 assert pretty(d[10]) == '(cos(a)) (i_C|k_N) + (-sin(a)) (j_C|k_N)'
def test_pretty_print_unicode_v(): assert upretty(v[0]) == '0' assert upretty(v[1]) == 'i_N' assert upretty(v[5]) == '(a) i_N + (-b) j_N' # Make sure the printing works in other objects assert upretty(v[5].args) == '((a) i_N, (-b) j_N)' assert upretty(v[8]) == upretty_v_8 assert upretty(v[2]) == '(-1) i_N' assert upretty(v[11]) == upretty_v_11 assert upretty(s) == upretty_s assert upretty(d[0]) == '(0|0)' assert upretty(d[5]) == '(a) (i_N|k_N) + (-b) (j_N|k_N)' assert upretty(d[7]) == upretty_d_7 assert upretty(d[10]) == '(cos(a)) (i_C|k_N) + (-sin(a)) (j_C|k_N)'
def test_latex_printing(): assert latex(v[0]) == '\\mathbf{\\hat{0}}' assert latex(v[1]) == '\\mathbf{\\hat{i}_{N}}' assert latex(v[2]) == '- \\mathbf{\\hat{i}_{N}}' assert latex(v[5]) == ('\\left(a\\right)\\mathbf{\\hat{i}_{N}} + ' + '\\left(- b\\right)\\mathbf{\\hat{j}_{N}}') assert latex(v[6]) == ('\\left(\\mathbf{{x}_{N}} + a^{2}\\right)\\mathbf{\\hat{i}_' + '{N}} + \\mathbf{\\hat{k}_{N}}') assert latex(v[8]) == ('\\mathbf{\\hat{j}_{N}} + \\left(\\mathbf{{x}_' + '{C}}^{2} - \\int f{\\left(b \\right)}\\,' + ' db\\right)\\mathbf{\\hat{k}_{N}}') assert latex(s) == '3 \\mathbf{{y}_{C}} \\mathbf{{x}_{N}}^{2}' assert latex(d[0]) == '(\\mathbf{\\hat{0}}|\\mathbf{\\hat{0}})' assert latex(d[4]) == ('\\left(a\\right)\\left(\\mathbf{\\hat{i}_{N}}{\\middle|}' + '\\mathbf{\\hat{k}_{N}}\\right)') assert latex(d[9]) == ('\\left(\\mathbf{\\hat{k}_{C}}{\\middle|}' + '\\mathbf{\\hat{k}_{N}}\\right) + \\left(' + '\\mathbf{\\hat{i}_{N}}{\\middle|}\\mathbf{' + '\\hat{k}_{N}}\\right)') assert latex(d[11]) == ('\\left(a^{2} + b\\right)\\left(\\mathbf{\\hat{i}_{N}}' + '{\\middle|}\\mathbf{\\hat{k}_{N}}\\right) + ' + '\\left(\\int f{\\left(b \\right)}\\, db\\right)\\left(' + '\\mathbf{\\hat{k}_{N}}{\\middle|}\\mathbf{' + '\\hat{k}_{N}}\\right)')
def test_issue_23058(): from sympy import symbols, sin, cos, pi, UnevaluatedExpr
delop = Del() CC_ = CoordSys3D("C") y = CC_.y xhat = CC_.i
t = symbols("t") ten = symbols("10", positive=True) eps, mu = 4*pi*ten**(-11), ten**(-5)
Bx = 2 * ten**(-4) * cos(ten**5 * t) * sin(ten**(-3) * y) vecB = Bx * xhat vecE = (1/eps) * Integral(delop.cross(vecB/mu).doit(), t) vecE = vecE.doit()
vecB_str = """\⎛ ⎛y_C⎞ ⎛ 5 ⎞⎞ \n\⎜2⋅sin⎜───⎟⋅cos⎝10 ⋅t⎠⎟ i_C\n\⎜ ⎜ 3⎟ ⎟ \n\⎜ ⎝10 ⎠ ⎟ \n\⎜─────────────────────⎟ \n\⎜ 4 ⎟ \n\⎝ 10 ⎠ \""" vecE_str = """\⎛ 4 ⎛ 5 ⎞ ⎛y_C⎞ ⎞ \n\⎜-10 ⋅sin⎝10 ⋅t⎠⋅cos⎜───⎟ ⎟ k_C\n\⎜ ⎜ 3⎟ ⎟ \n\⎜ ⎝10 ⎠ ⎟ \n\⎜─────────────────────────⎟ \n\⎝ 2⋅π ⎠ \"""
assert upretty(vecB) == vecB_str assert upretty(vecE) == vecE_str
ten = UnevaluatedExpr(10) eps, mu = 4*pi*ten**(-11), ten**(-5)
Bx = 2 * ten**(-4) * cos(ten**5 * t) * sin(ten**(-3) * y) vecB = Bx * xhat
vecB_str = """\⎛ -4 ⎛ 5⎞ ⎛ -3⎞⎞ \n\⎝2⋅10 ⋅cos⎝t⋅10 ⎠⋅sin⎝y_C⋅10 ⎠⎠ i_C \""" assert upretty(vecB) == vecB_str
def test_custom_names(): A = CoordSys3D('A', vector_names=['x', 'y', 'z'], variable_names=['i', 'j', 'k']) assert A.i.__str__() == 'A.i' assert A.x.__str__() == 'A.x' assert A.i._pretty_form == 'i_A' assert A.x._pretty_form == 'x_A' assert A.i._latex_form == r'\mathbf{{i}_{A}}' assert A.x._latex_form == r"\mathbf{\hat{x}_{A}}"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342from sympy.core import Rational, S, Add, Mul, Ifrom sympy.simplify import simplify, trigsimpfrom sympy.core.function import (Derivative, Function, diff)from sympy.core.numbers import pifrom sympy.core.symbol import symbolsfrom sympy.functions.elementary.miscellaneous import sqrtfrom sympy.functions.elementary.trigonometric import (cos, sin)from sympy.integrals.integrals import Integralfrom sympy.matrices.immutable import ImmutableDenseMatrix as Matrixfrom sympy.vector.vector import Vector, BaseVector, VectorAdd, \ VectorMul, VectorZerofrom sympy.vector.coordsysrect import CoordSys3Dfrom sympy.vector.vector import Cross, Dot, crossfrom sympy.testing.pytest import raisesfrom sympy.vector.kind import VectorKindfrom sympy.core.kind import NumberKindfrom sympy.testing.pytest import XFAIL
C = CoordSys3D('C')
i, j, k = C.base_vectors()a, b, c = symbols('a b c')
def test_cross(): v1 = C.x * i + C.z * C.z * j v2 = C.x * i + C.y * j + C.z * k assert Cross(v1, v2) == Cross(C.x*C.i + C.z**2*C.j, C.x*C.i + C.y*C.j + C.z*C.k) assert Cross(v1, v2).doit() == C.z**3*C.i + (-C.x*C.z)*C.j + (C.x*C.y - C.x*C.z**2)*C.k assert cross(v1, v2) == C.z**3*C.i + (-C.x*C.z)*C.j + (C.x*C.y - C.x*C.z**2)*C.k assert Cross(v1, v2) == -Cross(v2, v1) # XXX: Cannot use Cross here. See XFAIL test below: assert cross(v1, v2) + cross(v2, v1) == Vector.zero
@XFAILdef test_cross_xfail(): v1 = C.x * i + C.z * C.z * j v2 = C.x * i + C.y * j + C.z * k assert Cross(v1, v2) + Cross(v2, v1) == Vector.zero
def test_dot(): v1 = C.x * i + C.z * C.z * j v2 = C.x * i + C.y * j + C.z * k assert Dot(v1, v2) == Dot(C.x*C.i + C.z**2*C.j, C.x*C.i + C.y*C.j + C.z*C.k) assert Dot(v1, v2).doit() == C.x**2 + C.y*C.z**2 assert Dot(v2, v1).doit() == C.x**2 + C.y*C.z**2 assert Dot(v1, v2) == Dot(v2, v1)
def test_vector_sympy(): """ Test whether the Vector framework confirms to the hashing and equality testing properties of SymPy. """ v1 = 3*j assert v1 == j*3 assert v1.components == {j: 3} v2 = 3*i + 4*j + 5*k v3 = 2*i + 4*j + i + 4*k + k assert v3 == v2 assert v3.__hash__() == v2.__hash__()
def test_kind(): assert C.i.kind is VectorKind(NumberKind) assert C.j.kind is VectorKind(NumberKind) assert C.k.kind is VectorKind(NumberKind)
assert C.x.kind is NumberKind assert C.y.kind is NumberKind assert C.z.kind is NumberKind
assert Mul._kind_dispatcher(NumberKind, VectorKind(NumberKind)) is VectorKind(NumberKind) assert Mul(2, C.i).kind is VectorKind(NumberKind)
v1 = C.x * i + C.z * C.z * j v2 = C.x * i + C.y * j + C.z * k assert v1.kind is VectorKind(NumberKind) assert v2.kind is VectorKind(NumberKind)
assert (v1 + v2).kind is VectorKind(NumberKind) assert Add(v1, v2).kind is VectorKind(NumberKind) assert Cross(v1, v2).doit().kind is VectorKind(NumberKind) assert VectorAdd(v1, v2).kind is VectorKind(NumberKind) assert VectorMul(2, v1).kind is VectorKind(NumberKind) assert VectorZero().kind is VectorKind(NumberKind)
assert v1.projection(v2).kind is VectorKind(NumberKind) assert v2.projection(v1).kind is VectorKind(NumberKind)
def test_vectoradd(): assert isinstance(Add(C.i, C.j), VectorAdd) v1 = C.x * i + C.z * C.z * j v2 = C.x * i + C.y * j + C.z * k assert isinstance(Add(v1, v2), VectorAdd)
# https://github.com/sympy/sympy/issues/26121
E = Matrix([C.i, C.j, C.k]).T a = Matrix([1, 2, 3]) av = E*a
assert av[0].kind == VectorKind() assert isinstance(av[0], VectorAdd)
def test_vector(): assert isinstance(i, BaseVector) assert i != j assert j != k assert k != i assert i - i == Vector.zero assert i + Vector.zero == i assert i - Vector.zero == i assert Vector.zero != 0 assert -Vector.zero == Vector.zero
v1 = a*i + b*j + c*k v2 = a**2*i + b**2*j + c**2*k v3 = v1 + v2 v4 = 2 * v1 v5 = a * i
assert isinstance(v1, VectorAdd) assert v1 - v1 == Vector.zero assert v1 + Vector.zero == v1 assert v1.dot(i) == a assert v1.dot(j) == b assert v1.dot(k) == c assert i.dot(v2) == a**2 assert j.dot(v2) == b**2 assert k.dot(v2) == c**2 assert v3.dot(i) == a**2 + a assert v3.dot(j) == b**2 + b assert v3.dot(k) == c**2 + c
assert v1 + v2 == v2 + v1 assert v1 - v2 == -1 * (v2 - v1) assert a * v1 == v1 * a
assert isinstance(v5, VectorMul) assert v5.base_vector == i assert v5.measure_number == a assert isinstance(v4, Vector) assert isinstance(v4, VectorAdd) assert isinstance(v4, Vector) assert isinstance(Vector.zero, VectorZero) assert isinstance(Vector.zero, Vector) assert isinstance(v1 * 0, VectorZero)
assert v1.to_matrix(C) == Matrix([[a], [b], [c]])
assert i.components == {i: 1} assert v5.components == {i: a} assert v1.components == {i: a, j: b, k: c}
assert VectorAdd(v1, Vector.zero) == v1 assert VectorMul(a, v1) == v1*a assert VectorMul(1, i) == i assert VectorAdd(v1, Vector.zero) == v1 assert VectorMul(0, Vector.zero) == Vector.zero raises(TypeError, lambda: v1.outer(1)) raises(TypeError, lambda: v1.dot(1))
def test_vector_magnitude_normalize(): assert Vector.zero.magnitude() == 0 assert Vector.zero.normalize() == Vector.zero
assert i.magnitude() == 1 assert j.magnitude() == 1 assert k.magnitude() == 1 assert i.normalize() == i assert j.normalize() == j assert k.normalize() == k
v1 = a * i assert v1.normalize() == (a/sqrt(a**2))*i assert v1.magnitude() == sqrt(a**2)
v2 = a*i + b*j + c*k assert v2.magnitude() == sqrt(a**2 + b**2 + c**2) assert v2.normalize() == v2 / v2.magnitude()
v3 = i + j assert v3.normalize() == (sqrt(2)/2)*C.i + (sqrt(2)/2)*C.j
def test_vector_simplify(): A, s, k, m = symbols('A, s, k, m')
test1 = (1 / a + 1 / b) * i assert (test1 & i) != (a + b) / (a * b) test1 = simplify(test1) assert (test1 & i) == (a + b) / (a * b) assert test1.simplify() == simplify(test1)
test2 = (A**2 * s**4 / (4 * pi * k * m**3)) * i test2 = simplify(test2) assert (test2 & i) == (A**2 * s**4 / (4 * pi * k * m**3))
test3 = ((4 + 4 * a - 2 * (2 + 2 * a)) / (2 + 2 * a)) * i test3 = simplify(test3) assert (test3 & i) == 0
test4 = ((-4 * a * b**2 - 2 * b**3 - 2 * a**2 * b) / (a + b)**2) * i test4 = simplify(test4) assert (test4 & i) == -2 * b
v = (sin(a)+cos(a))**2*i - j assert trigsimp(v) == (2*sin(a + pi/4)**2)*i + (-1)*j assert trigsimp(v) == v.trigsimp()
assert simplify(Vector.zero) == Vector.zero
def test_vector_equals(): assert (2*i).equals(j) is False assert i.equals(i) is True
# https://github.com/sympy/sympy/issues/25915 A = (sqrt(2) + sqrt(6)) / sqrt(sqrt(3) + 2) assert (A*i).equals(2*i) is True assert (A*i).equals(3*i) is False
# Test comparing vectors in different coordinate systems D = C.orient_new_axis('D', pi/2, C.k) assert (D.i).equals(C.j) is True assert (D.i).equals(C.i) is False
def test_vector_conjugate(): # https://github.com/sympy/sympy/issues/27094 assert (I*i + (1 + I)*j + 2*k).conjugate() == -I*i + (1 - I)*j + 2*k
def test_vector_dot(): assert i.dot(Vector.zero) == 0 assert Vector.zero.dot(i) == 0 assert i & Vector.zero == 0
assert i.dot(i) == 1 assert i.dot(j) == 0 assert i.dot(k) == 0 assert i & i == 1 assert i & j == 0 assert i & k == 0
assert j.dot(i) == 0 assert j.dot(j) == 1 assert j.dot(k) == 0 assert j & i == 0 assert j & j == 1 assert j & k == 0
assert k.dot(i) == 0 assert k.dot(j) == 0 assert k.dot(k) == 1 assert k & i == 0 assert k & j == 0 assert k & k == 1
raises(TypeError, lambda: k.dot(1))
def test_vector_cross(): assert i.cross(Vector.zero) == Vector.zero assert Vector.zero.cross(i) == Vector.zero
assert i.cross(i) == Vector.zero assert i.cross(j) == k assert i.cross(k) == -j assert i ^ i == Vector.zero assert i ^ j == k assert i ^ k == -j
assert j.cross(i) == -k assert j.cross(j) == Vector.zero assert j.cross(k) == i assert j ^ i == -k assert j ^ j == Vector.zero assert j ^ k == i
assert k.cross(i) == j assert k.cross(j) == -i assert k.cross(k) == Vector.zero assert k ^ i == j assert k ^ j == -i assert k ^ k == Vector.zero
assert k.cross(1) == Cross(k, 1)
def test_projection(): v1 = i + j + k v2 = 3*i + 4*j v3 = 0*i + 0*j assert v1.projection(v1) == i + j + k assert v1.projection(v2) == Rational(7, 3)*C.i + Rational(7, 3)*C.j + Rational(7, 3)*C.k assert v1.projection(v1, scalar=True) == S.One assert v1.projection(v2, scalar=True) == Rational(7, 3) assert v3.projection(v1) == Vector.zero assert v3.projection(v1, scalar=True) == S.Zero
def test_vector_diff_integrate(): f = Function('f') v = f(a)*C.i + a**2*C.j - C.k assert Derivative(v, a) == Derivative((f(a))*C.i + a**2*C.j + (-1)*C.k, a) assert (diff(v, a) == v.diff(a) == Derivative(v, a).doit() == (Derivative(f(a), a))*C.i + 2*a*C.j) assert (Integral(v, a) == (Integral(f(a), a))*C.i + (Integral(a**2, a))*C.j + (Integral(-1, a))*C.k)
def test_vector_args(): raises(ValueError, lambda: BaseVector(3, C)) raises(TypeError, lambda: BaseVector(0, Vector.zero))
def test_srepr(): from sympy.printing.repr import srepr res = "CoordSys3D(Str('C'), Tuple(ImmutableDenseMatrix([[Integer(1), "\ "Integer(0), Integer(0)], [Integer(0), Integer(1), Integer(0)], "\ "[Integer(0), Integer(0), Integer(1)]]), VectorZero())).i" assert srepr(C.i) == res
def test_scalar(): from sympy.vector import CoordSys3D C = CoordSys3D('C') v1 = 3*C.i + 4*C.j + 5*C.k v2 = 3*C.i - 4*C.j + 5*C.k assert v1.is_Vector is True assert v1.is_scalar is False assert (v1.dot(v2)).is_scalar is True assert (v1.cross(v2)).is_scalar is False123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714from __future__ import annotationsfrom itertools import product
from sympy.core import Add, Basicfrom sympy.core.assumptions import StdFactKBfrom sympy.core.expr import AtomicExpr, Exprfrom sympy.core.power import Powfrom sympy.core.singleton import Sfrom sympy.core.sorting import default_sort_keyfrom sympy.core.sympify import sympifyfrom sympy.functions.elementary.miscellaneous import sqrtfrom sympy.matrices.immutable import ImmutableDenseMatrix as Matrixfrom sympy.vector.basisdependent import (BasisDependentZero, BasisDependent, BasisDependentMul, BasisDependentAdd)from sympy.vector.coordsysrect import CoordSys3Dfrom sympy.vector.dyadic import Dyadic, BaseDyadic, DyadicAddfrom sympy.vector.kind import VectorKind
class Vector(BasisDependent): """ Super class for all Vector classes. Ideally, neither this class nor any of its subclasses should be instantiated by the user. """
is_scalar = False is_Vector = True _op_priority = 12.0
_expr_type: type[Vector] _mul_func: type[Vector] _add_func: type[Vector] _zero_func: type[Vector] _base_func: type[Vector] zero: VectorZero
kind: VectorKind = VectorKind()
@property def components(self): """ Returns the components of this vector in the form of a Python dictionary mapping BaseVector instances to the corresponding measure numbers.
Examples ========
>>> from sympy.vector import CoordSys3D >>> C = CoordSys3D('C') >>> v = 3*C.i + 4*C.j + 5*C.k >>> v.components {C.i: 3, C.j: 4, C.k: 5}
""" # The '_components' attribute is defined according to the # subclass of Vector the instance belongs to. return self._components
def magnitude(self): """ Returns the magnitude of this vector. """ return sqrt(self & self)
def normalize(self): """ Returns the normalized version of this vector. """ return self / self.magnitude()
def equals(self, other): """ Check if ``self`` and ``other`` are identically equal vectors.
Explanation ===========
Checks if two vector expressions are equal for all possible values of the symbols present in the expressions.
Examples ========
>>> from sympy.vector import CoordSys3D >>> from sympy.abc import x, y >>> from sympy import pi >>> C = CoordSys3D('C')
Compare vectors that are equal or not:
>>> C.i.equals(C.j) False >>> C.i.equals(C.i) True
These two vectors are equal if `x = y` but are not identically equal as expressions since for some values of `x` and `y` they are unequal:
>>> v1 = x*C.i + C.j >>> v2 = y*C.i + C.j >>> v1.equals(v1) True >>> v1.equals(v2) False
Vectors from different coordinate systems can be compared:
>>> D = C.orient_new_axis('D', pi/2, C.i) >>> D.j.equals(C.j) False >>> D.j.equals(C.k) True
Parameters ==========
other: Vector The other vector expression to compare with.
Returns =======
``True``, ``False`` or ``None``. A return value of ``True`` indicates that the two vectors are identically equal. A return value of ``False`` indicates that they are not. In some cases it is not possible to determine if the two vectors are identically equal and ``None`` is returned.
See Also ========
sympy.core.expr.Expr.equals """ diff = self - other diff_mag2 = diff.dot(diff) return diff_mag2.equals(0)
def dot(self, other): """ Returns the dot product of this Vector, either with another Vector, or a Dyadic, or a Del operator. If 'other' is a Vector, returns the dot product scalar (SymPy expression). If 'other' is a Dyadic, the dot product is returned as a Vector. If 'other' is an instance of Del, returns the directional derivative operator as a Python function. If this function is applied to a scalar expression, it returns the directional derivative of the scalar field wrt this Vector.
Parameters ==========
other: Vector/Dyadic/Del The Vector or Dyadic we are dotting with, or a Del operator .
Examples ========
>>> from sympy.vector import CoordSys3D, Del >>> C = CoordSys3D('C') >>> delop = Del() >>> C.i.dot(C.j) 0 >>> C.i & C.i 1 >>> v = 3*C.i + 4*C.j + 5*C.k >>> v.dot(C.k) 5 >>> (C.i & delop)(C.x*C.y*C.z) C.y*C.z >>> d = C.i.outer(C.i) >>> C.i.dot(d) C.i
"""
# Check special cases if isinstance(other, Dyadic): if isinstance(self, VectorZero): return Vector.zero outvec = Vector.zero for k, v in other.components.items(): vect_dot = k.args[0].dot(self) outvec += vect_dot * v * k.args[1] return outvec from sympy.vector.deloperator import Del if not isinstance(other, (Del, Vector)): raise TypeError(str(other) + " is not a vector, dyadic or " + "del operator")
# Check if the other is a del operator if isinstance(other, Del): def directional_derivative(field): from sympy.vector.functions import directional_derivative return directional_derivative(field, self) return directional_derivative
return dot(self, other)
def __and__(self, other): return self.dot(other)
__and__.__doc__ = dot.__doc__
def cross(self, other): """ Returns the cross product of this Vector with another Vector or Dyadic instance. The cross product is a Vector, if 'other' is a Vector. If 'other' is a Dyadic, this returns a Dyadic instance.
Parameters ==========
other: Vector/Dyadic The Vector or Dyadic we are crossing with.
Examples ========
>>> from sympy.vector import CoordSys3D >>> C = CoordSys3D('C') >>> C.i.cross(C.j) C.k >>> C.i ^ C.i 0 >>> v = 3*C.i + 4*C.j + 5*C.k >>> v ^ C.i 5*C.j + (-4)*C.k >>> d = C.i.outer(C.i) >>> C.j.cross(d) (-1)*(C.k|C.i)
"""
# Check special cases if isinstance(other, Dyadic): if isinstance(self, VectorZero): return Dyadic.zero outdyad = Dyadic.zero for k, v in other.components.items(): cross_product = self.cross(k.args[0]) outer = cross_product.outer(k.args[1]) outdyad += v * outer return outdyad
return cross(self, other)
def __xor__(self, other): return self.cross(other)
__xor__.__doc__ = cross.__doc__
def outer(self, other): """ Returns the outer product of this vector with another, in the form of a Dyadic instance.
Parameters ==========
other : Vector The Vector with respect to which the outer product is to be computed.
Examples ========
>>> from sympy.vector import CoordSys3D >>> N = CoordSys3D('N') >>> N.i.outer(N.j) (N.i|N.j)
"""
# Handle the special cases if not isinstance(other, Vector): raise TypeError("Invalid operand for outer product") elif (isinstance(self, VectorZero) or isinstance(other, VectorZero)): return Dyadic.zero
# Iterate over components of both the vectors to generate # the required Dyadic instance args = [(v1 * v2) * BaseDyadic(k1, k2) for (k1, v1), (k2, v2) in product(self.components.items(), other.components.items())]
return DyadicAdd(*args)
def projection(self, other, scalar=False): """ Returns the vector or scalar projection of the 'other' on 'self'.
Examples ========
>>> from sympy.vector.coordsysrect import CoordSys3D >>> C = CoordSys3D('C') >>> i, j, k = C.base_vectors() >>> v1 = i + j + k >>> v2 = 3*i + 4*j >>> v1.projection(v2) 7/3*C.i + 7/3*C.j + 7/3*C.k >>> v1.projection(v2, scalar=True) 7/3
""" if self.equals(Vector.zero): return S.Zero if scalar else Vector.zero
if scalar: return self.dot(other) / self.dot(self) else: return self.dot(other) / self.dot(self) * self
@property def _projections(self): """ Returns the components of this vector but the output includes also zero values components.
Examples ========
>>> from sympy.vector import CoordSys3D, Vector >>> C = CoordSys3D('C') >>> v1 = 3*C.i + 4*C.j + 5*C.k >>> v1._projections (3, 4, 5) >>> v2 = C.x*C.y*C.z*C.i >>> v2._projections (C.x*C.y*C.z, 0, 0) >>> v3 = Vector.zero >>> v3._projections (0, 0, 0) """
from sympy.vector.operators import _get_coord_systems if isinstance(self, VectorZero): return (S.Zero, S.Zero, S.Zero) base_vec = next(iter(_get_coord_systems(self))).base_vectors() return tuple([self.dot(i) for i in base_vec])
def __or__(self, other): return self.outer(other)
__or__.__doc__ = outer.__doc__
def to_matrix(self, system): """ Returns the matrix form of this vector with respect to the specified coordinate system.
Parameters ==========
system : CoordSys3D The system wrt which the matrix form is to be computed
Examples ========
>>> from sympy.vector import CoordSys3D >>> C = CoordSys3D('C') >>> from sympy.abc import a, b, c >>> v = a*C.i + b*C.j + c*C.k >>> v.to_matrix(C) Matrix([ [a], [b], [c]])
"""
return Matrix([self.dot(unit_vec) for unit_vec in system.base_vectors()])
def separate(self): """ The constituents of this vector in different coordinate systems, as per its definition.
Returns a dict mapping each CoordSys3D to the corresponding constituent Vector.
Examples ========
>>> from sympy.vector import CoordSys3D >>> R1 = CoordSys3D('R1') >>> R2 = CoordSys3D('R2') >>> v = R1.i + R2.i >>> v.separate() == {R1: R1.i, R2: R2.i} True
"""
parts = {} for vect, measure in self.components.items(): parts[vect.system] = (parts.get(vect.system, Vector.zero) + vect * measure) return parts
def _div_helper(one, other): """ Helper for division involving vectors. """ if isinstance(one, Vector) and isinstance(other, Vector): raise TypeError("Cannot divide two vectors") elif isinstance(one, Vector): if other == S.Zero: raise ValueError("Cannot divide a vector by zero") return VectorMul(one, Pow(other, S.NegativeOne)) else: raise TypeError("Invalid division involving a vector")
# The following is adapted from the matrices.expressions.matexpr file
def get_postprocessor(cls): def _postprocessor(expr): vec_class = {Add: VectorAdd}[cls] vectors = [] for term in expr.args: if isinstance(term.kind, VectorKind): vectors.append(term)
if vec_class == VectorAdd: return VectorAdd(*vectors).doit(deep=False) return _postprocessor
Basic._constructor_postprocessor_mapping[Vector] = { "Add": [get_postprocessor(Add)],}
class BaseVector(Vector, AtomicExpr): """ Class to denote a base vector.
"""
def __new__(cls, index, system, pretty_str=None, latex_str=None): if pretty_str is None: pretty_str = "x{}".format(index) if latex_str is None: latex_str = "x_{}".format(index) pretty_str = str(pretty_str) latex_str = str(latex_str) # Verify arguments if index not in range(0, 3): raise ValueError("index must be 0, 1 or 2") if not isinstance(system, CoordSys3D): raise TypeError("system should be a CoordSys3D") name = system._vector_names[index] # Initialize an object obj = super().__new__(cls, S(index), system) # Assign important attributes obj._base_instance = obj obj._components = {obj: S.One} obj._measure_number = S.One obj._name = system._name + '.' + name obj._pretty_form = '' + pretty_str obj._latex_form = latex_str obj._system = system # The _id is used for printing purposes obj._id = (index, system) assumptions = {'commutative': True} obj._assumptions = StdFactKB(assumptions)
# This attr is used for re-expression to one of the systems # involved in the definition of the Vector. Applies to # VectorMul and VectorAdd too. obj._sys = system
return obj
@property def system(self): return self._system
def _sympystr(self, printer): return self._name
def _sympyrepr(self, printer): index, system = self._id return printer._print(system) + '.' + system._vector_names[index]
@property def free_symbols(self): return {self}
def _eval_conjugate(self): return self
class VectorAdd(BasisDependentAdd, Vector): """ Class to denote sum of Vector instances. """
def __new__(cls, *args, **options): obj = BasisDependentAdd.__new__(cls, *args, **options) return obj
def _sympystr(self, printer): ret_str = '' items = list(self.separate().items()) items.sort(key=lambda x: x[0].__str__()) for system, vect in items: base_vects = system.base_vectors() for x in base_vects: if x in vect.components: temp_vect = self.components[x] * x ret_str += printer._print(temp_vect) + " + " return ret_str[:-3]
class VectorMul(BasisDependentMul, Vector): """ Class to denote products of scalars and BaseVectors. """
def __new__(cls, *args, **options): obj = BasisDependentMul.__new__(cls, *args, **options) return obj
@property def base_vector(self): """ The BaseVector involved in the product. """ return self._base_instance
@property def measure_number(self): """ The scalar expression involved in the definition of this VectorMul. """ return self._measure_number
class VectorZero(BasisDependentZero, Vector): """ Class to denote a zero vector """
_op_priority = 12.1 _pretty_form = '0' _latex_form = r'\mathbf{\hat{0}}'
def __new__(cls): obj = BasisDependentZero.__new__(cls) return obj
class Cross(Vector): """ Represents unevaluated Cross product.
Examples ========
>>> from sympy.vector import CoordSys3D, Cross >>> R = CoordSys3D('R') >>> v1 = R.i + R.j + R.k >>> v2 = R.x * R.i + R.y * R.j + R.z * R.k >>> Cross(v1, v2) Cross(R.i + R.j + R.k, R.x*R.i + R.y*R.j + R.z*R.k) >>> Cross(v1, v2).doit() (-R.y + R.z)*R.i + (R.x - R.z)*R.j + (-R.x + R.y)*R.k
"""
def __new__(cls, expr1, expr2): expr1 = sympify(expr1) expr2 = sympify(expr2) if default_sort_key(expr1) > default_sort_key(expr2): return -Cross(expr2, expr1) obj = Expr.__new__(cls, expr1, expr2) obj._expr1 = expr1 obj._expr2 = expr2 return obj
def doit(self, **hints): return cross(self._expr1, self._expr2)
class Dot(Expr): """ Represents unevaluated Dot product.
Examples ========
>>> from sympy.vector import CoordSys3D, Dot >>> from sympy import symbols >>> R = CoordSys3D('R') >>> a, b, c = symbols('a b c') >>> v1 = R.i + R.j + R.k >>> v2 = a * R.i + b * R.j + c * R.k >>> Dot(v1, v2) Dot(R.i + R.j + R.k, a*R.i + b*R.j + c*R.k) >>> Dot(v1, v2).doit() a + b + c
"""
def __new__(cls, expr1, expr2): expr1 = sympify(expr1) expr2 = sympify(expr2) expr1, expr2 = sorted([expr1, expr2], key=default_sort_key) obj = Expr.__new__(cls, expr1, expr2) obj._expr1 = expr1 obj._expr2 = expr2 return obj
def doit(self, **hints): return dot(self._expr1, self._expr2)
def cross(vect1, vect2): """ Returns cross product of two vectors.
Examples ========
>>> from sympy.vector import CoordSys3D >>> from sympy.vector.vector import cross >>> R = CoordSys3D('R') >>> v1 = R.i + R.j + R.k >>> v2 = R.x * R.i + R.y * R.j + R.z * R.k >>> cross(v1, v2) (-R.y + R.z)*R.i + (R.x - R.z)*R.j + (-R.x + R.y)*R.k
""" if isinstance(vect1, Add): return VectorAdd.fromiter(cross(i, vect2) for i in vect1.args) if isinstance(vect2, Add): return VectorAdd.fromiter(cross(vect1, i) for i in vect2.args) if isinstance(vect1, BaseVector) and isinstance(vect2, BaseVector): if vect1._sys == vect2._sys: n1 = vect1.args[0] n2 = vect2.args[0] if n1 == n2: return Vector.zero n3 = ({0,1,2}.difference({n1, n2})).pop() sign = 1 if ((n1 + 1) % 3 == n2) else -1 return sign*vect1._sys.base_vectors()[n3] from .functions import express try: v = express(vect1, vect2._sys) except ValueError: return Cross(vect1, vect2) else: return cross(v, vect2) if isinstance(vect1, VectorZero) or isinstance(vect2, VectorZero): return Vector.zero if isinstance(vect1, VectorMul): v1, m1 = next(iter(vect1.components.items())) return m1*cross(v1, vect2) if isinstance(vect2, VectorMul): v2, m2 = next(iter(vect2.components.items())) return m2*cross(vect1, v2)
return Cross(vect1, vect2)
def dot(vect1, vect2): """ Returns dot product of two vectors.
Examples ========
>>> from sympy.vector import CoordSys3D >>> from sympy.vector.vector import dot >>> R = CoordSys3D('R') >>> v1 = R.i + R.j + R.k >>> v2 = R.x * R.i + R.y * R.j + R.z * R.k >>> dot(v1, v2) R.x + R.y + R.z
""" if isinstance(vect1, Add): return Add.fromiter(dot(i, vect2) for i in vect1.args) if isinstance(vect2, Add): return Add.fromiter(dot(vect1, i) for i in vect2.args) if isinstance(vect1, BaseVector) and isinstance(vect2, BaseVector): if vect1._sys == vect2._sys: return S.One if vect1 == vect2 else S.Zero from .functions import express try: v = express(vect2, vect1._sys) except ValueError: return Dot(vect1, vect2) else: return dot(vect1, v) if isinstance(vect1, VectorZero) or isinstance(vect2, VectorZero): return S.Zero if isinstance(vect1, VectorMul): v1, m1 = next(iter(vect1.components.items())) return m1*dot(v1, vect2) if isinstance(vect2, VectorMul): v2, m2 = next(iter(vect2.components.items())) return m2*dot(vect1, v2)
return Dot(vect1, vect2)
Vector._expr_type = VectorVector._mul_func = VectorMulVector._add_func = VectorAddVector._zero_func = VectorZeroVector._base_func = BaseVectorVector.zero = VectorZero()1uv123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210Metadata-Version: 2.4Name: tokenizersVersion: 0.21.2Classifier: Development Status :: 5 - Production/StableClassifier: Intended Audience :: DevelopersClassifier: Intended Audience :: EducationClassifier: Intended Audience :: Science/ResearchClassifier: License :: OSI Approved :: Apache Software LicenseClassifier: Operating System :: OS IndependentClassifier: Programming Language :: Python :: 3Classifier: Programming Language :: Python :: 3.9Classifier: Programming Language :: Python :: 3.10Classifier: Programming Language :: Python :: 3.11Classifier: Programming Language :: Python :: 3.12Classifier: Programming Language :: Python :: 3.13Classifier: Programming Language :: Python :: 3 :: OnlyClassifier: Topic :: Scientific/Engineering :: Artificial IntelligenceRequires-Dist: huggingface-hub>=0.16.4,<1.0Requires-Dist: pytest ; extra == 'testing'Requires-Dist: requests ; extra == 'testing'Requires-Dist: numpy ; extra == 'testing'Requires-Dist: datasets ; extra == 'testing'Requires-Dist: black==22.3 ; extra == 'testing'Requires-Dist: ruff ; extra == 'testing'Requires-Dist: sphinx ; extra == 'docs'Requires-Dist: sphinx-rtd-theme ; extra == 'docs'Requires-Dist: setuptools-rust ; extra == 'docs'Requires-Dist: tokenizers[testing] ; extra == 'dev'Provides-Extra: testingProvides-Extra: docsProvides-Extra: devKeywords: NLP,tokenizer,BPE,transformer,deep learningAuthor: Anthony MOI <m.anthony.moi@gmail.com>Author-email: Nicolas Patry <patry.nicolas@protonmail.com>, Anthony Moi <anthony@huggingface.co>Requires-Python: >=3.9Description-Content-Type: text/markdown; charset=UTF-8; variant=GFMProject-URL: Homepage, https://github.com/huggingface/tokenizersProject-URL: Source, https://github.com/huggingface/tokenizers
<p align="center"> <br> <img src="https://huggingface.co/landing/assets/tokenizers/tokenizers-logo.png" width="600"/> <br><p><p align="center"> <a href="https://badge.fury.io/py/tokenizers"> <img alt="Build" src="https://badge.fury.io/py/tokenizers.svg"> </a> <a href="https://github.com/huggingface/tokenizers/blob/master/LICENSE"> <img alt="GitHub" src="https://img.shields.io/github/license/huggingface/tokenizers.svg?color=blue"> </a></p><br>
# Tokenizers
Provides an implementation of today's most used tokenizers, with a focus on performance andversatility.
Bindings over the [Rust](https://github.com/huggingface/tokenizers/tree/master/tokenizers) implementation.If you are interested in the High-level design, you can go check it there.
Otherwise, let's dive in!
## Main features:
- Train new vocabularies and tokenize using 4 pre-made tokenizers (Bert WordPiece and the 3 most common BPE versions). - Extremely fast (both training and tokenization), thanks to the Rust implementation. Takes less than 20 seconds to tokenize a GB of text on a server's CPU. - Easy to use, but also extremely versatile. - Designed for research and production. - Normalization comes with alignments tracking. It's always possible to get the part of the original sentence that corresponds to a given token. - Does all the pre-processing: Truncate, Pad, add the special tokens your model needs.
### Installation
#### With pip:
```bashpip install tokenizers```
#### From sources:
To use this method, you need to have the Rust installed:
```bash# Install with:curl https://sh.rustup.rs -sSf | sh -s -- -yexport PATH="$HOME/.cargo/bin:$PATH"```
Once Rust is installed, you can compile doing the following
```bashgit clone https://github.com/huggingface/tokenizerscd tokenizers/bindings/python
# Create a virtual env (you can use yours as well)python -m venv .envsource .env/bin/activate
# Install `tokenizers` in the current virtual envpip install -e .```
### Load a pretrained tokenizer from the Hub
```pythonfrom tokenizers import Tokenizer
tokenizer = Tokenizer.from_pretrained("bert-base-cased")```
### Using the provided Tokenizers
We provide some pre-build tokenizers to cover the most common cases. You can easily load one ofthese using some `vocab.json` and `merges.txt` files:
```pythonfrom tokenizers import CharBPETokenizer
# Initialize a tokenizervocab = "./path/to/vocab.json"merges = "./path/to/merges.txt"tokenizer = CharBPETokenizer(vocab, merges)
# And then encode:encoded = tokenizer.encode("I can feel the magic, can you?")print(encoded.ids)print(encoded.tokens)```
And you can train them just as simply:
```pythonfrom tokenizers import CharBPETokenizer
# Initialize a tokenizertokenizer = CharBPETokenizer()
# Then train it!tokenizer.train([ "./path/to/files/1.txt", "./path/to/files/2.txt" ])
# Now, let's use it:encoded = tokenizer.encode("I can feel the magic, can you?")
# And finally save it somewheretokenizer.save("./path/to/directory/my-bpe.tokenizer.json")```
#### Provided Tokenizers
- `CharBPETokenizer`: The original BPE - `ByteLevelBPETokenizer`: The byte level version of the BPE - `SentencePieceBPETokenizer`: A BPE implementation compatible with the one used by SentencePiece - `BertWordPieceTokenizer`: The famous Bert tokenizer, using WordPiece
All of these can be used and trained as explained above!
### Build your own
Whenever these provided tokenizers don't give you enough freedom, you can build your own tokenizer,by putting all the different parts you need together.You can check how we implemented the [provided tokenizers](https://github.com/huggingface/tokenizers/tree/master/bindings/python/py_src/tokenizers/implementations) and adapt them easily to your own needs.
#### Building a byte-level BPE
Here is an example showing how to build your own byte-level BPE by putting all the different piecestogether, and then saving it to a single file:
```pythonfrom tokenizers import Tokenizer, models, pre_tokenizers, decoders, trainers, processors
# Initialize a tokenizertokenizer = Tokenizer(models.BPE())
# Customize pre-tokenization and decodingtokenizer.pre_tokenizer = pre_tokenizers.ByteLevel(add_prefix_space=True)tokenizer.decoder = decoders.ByteLevel()tokenizer.post_processor = processors.ByteLevel(trim_offsets=True)
# And then traintrainer = trainers.BpeTrainer( vocab_size=20000, min_frequency=2, initial_alphabet=pre_tokenizers.ByteLevel.alphabet())tokenizer.train([ "./path/to/dataset/1.txt", "./path/to/dataset/2.txt", "./path/to/dataset/3.txt"], trainer=trainer)
# And Save ittokenizer.save("byte-level-bpe.tokenizer.json", pretty=True)```
Now, when you want to use this tokenizer, this is as simple as:
```pythonfrom tokenizers import Tokenizer
tokenizer = Tokenizer.from_file("byte-level-bpe.tokenizer.json")
encoded = tokenizer.encode("I can feel the magic, can you?")```
123456789101112131415161718192021222324252627282930tokenizers-0.21.2.dist-info/INSTALLER,sha256=5hhM4Q4mYTT9z6QB6PGpUAW81PGNFrYrdXMj4oM_6ak,2tokenizers-0.21.2.dist-info/METADATA,sha256=AlzT2G4YeORvTV8cUbHrtuWpuo54CX5iZOtBcxq1Qrc,6774tokenizers-0.21.2.dist-info/RECORD,,tokenizers-0.21.2.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0tokenizers-0.21.2.dist-info/WHEEL,sha256=oEr59ZPc2tpVnNJOPDQDxj0Rjot8eiL_zYcSYzWjqyM,127tokenizers/__init__.py,sha256=ZE5ZagUvobBScrHBQdEobhx4wqM0bsq9F9aLYkBNjYQ,2615tokenizers/__init__.pyi,sha256=jw34WZXaYu8NBBJ2_cypfOqJYxI7CXKPzlveisXw4XQ,40182tokenizers/decoders/__init__.py,sha256=hfwM6CFUDvlMGGL4-xsaaYz81K9P5rQI5ZL5UHWK8Y4,372tokenizers/decoders/__init__.pyi,sha256=xHZ2Fa7b4UIQ-vrrTqvfS0jvoN6rmlhZzlFfPeyjxRw,7379tokenizers/implementations/__init__.py,sha256=VzAsplaIo7rl4AFO8Miu7ig7MfZjvonwVblZw01zR6M,310tokenizers/implementations/base_tokenizer.py,sha256=2TFZhLupaJiMDYGJuUNmxYJv-cnR8bDHmbMzaYpFROs,14206tokenizers/implementations/bert_wordpiece.py,sha256=sKCum0FKPYdSgJFJN8LDerVBoTDRSqyqSdrcm-lvQqI,5520tokenizers/implementations/byte_level_bpe.py,sha256=iBepM_z1s5Ky7zFDVrYLc3L5byYrIouk7-k0JGuF10s,4272tokenizers/implementations/char_level_bpe.py,sha256=Nag_HFq8Rvcucqi8MhV1-0xtoR0C7FjHOecFVURL7ss,5449tokenizers/implementations/sentencepiece_bpe.py,sha256=c08fKf6i92E2RsKgsxy7LzZfYX8-MACHSRG8U_I5ytY,3721tokenizers/implementations/sentencepiece_unigram.py,sha256=SYiVXL8ZtqLXKpuqwnwmrfxgGotu8yAkOu7dLztEXIo,7580tokenizers/models/__init__.py,sha256=eJZ4HTAQZpxnKILNylWaTFqxXy-Ba6OKswWN47feeV8,176tokenizers/models/__init__.pyi,sha256=clPTwiyjz7FlVdEuwo_3Wa_TmQrbZhW0SGmnNylepnY,16929tokenizers/normalizers/__init__.py,sha256=_06w4cqRItveEgIddYaLMScgkSOkIAMIzYCesb5AA4U,841tokenizers/normalizers/__init__.pyi,sha256=lSFqDb_lPZBfRxEG99EcFEaU1HlnIhIQUu7zZIyP4AY,20898tokenizers/pre_tokenizers/__init__.py,sha256=KV9-EsAykGENUUzkGWCbv4n6YM6hYa1hfnY-gzBpMNE,598tokenizers/pre_tokenizers/__init__.pyi,sha256=n6BFClhxm8y7miCC0lJd7oVeo8oj3kPg2tU9ObV4PGU,26556tokenizers/processors/__init__.py,sha256=xM2DEKwKtHIumHsszM8AMkq-AlaqvBZFXWgLU8SNhOY,307tokenizers/processors/__init__.pyi,sha256=hx767ZY8SHhxb_hiXPRxm-f_KcoR4XDx7vfK2c0lR-Q,11357tokenizers/tokenizers.abi3.so,sha256=gZfUUQiAoRsQrYMppSeD802KZXkoS5eYBAEHxGz3X1Q,9354560tokenizers/tools/__init__.py,sha256=xG8caB9OHC8cbB01S5vYV14HZxhO6eWbLehsb70ppio,55tokenizers/tools/visualizer-styles.css,sha256=zAydq1oGWD8QEll4-eyL8Llw0B1sty_hpIE3tYxL02k,4850tokenizers/tools/visualizer.py,sha256=0W90s4Qm8Nd6P-npqQX-bCMLQCfAEPk2qgj-K8r7OMc,14624tokenizers/trainers/__init__.py,sha256=UTu22AGcp76IvpW45xLRbJWET04NxPW6NfCb2YYz0EM,248tokenizers/trainers/__init__.pyi,sha256=3TwFKts4me7zQfVRcSTmtXYiP4XwcRjfAYtwqoZVtoQ,53821234Wheel-Version: 1.0Generator: maturin (1.9.0)Root-Is-Purelib: falseTag: cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100from enum import Enumfrom typing import List, Tuple, Union
Offsets = Tuple[int, int]
TextInputSequence = str"""A :obj:`str` that represents an input sequence """
PreTokenizedInputSequence = Union[List[str], Tuple[str]]"""A pre-tokenized input sequence. Can be one of:
- A :obj:`List` of :obj:`str` - A :obj:`Tuple` of :obj:`str`"""
TextEncodeInput = Union[ TextInputSequence, Tuple[TextInputSequence, TextInputSequence], List[TextInputSequence],]"""Represents a textual input for encoding. Can be either:
- A single sequence: :data:`~tokenizers.TextInputSequence` - A pair of sequences:
- A :obj:`Tuple` of :data:`~tokenizers.TextInputSequence` - Or a :obj:`List` of :data:`~tokenizers.TextInputSequence` of size 2"""
PreTokenizedEncodeInput = Union[ PreTokenizedInputSequence, Tuple[PreTokenizedInputSequence, PreTokenizedInputSequence], List[PreTokenizedInputSequence],]"""Represents a pre-tokenized input for encoding. Can be either:
- A single sequence: :data:`~tokenizers.PreTokenizedInputSequence` - A pair of sequences:
- A :obj:`Tuple` of :data:`~tokenizers.PreTokenizedInputSequence` - Or a :obj:`List` of :data:`~tokenizers.PreTokenizedInputSequence` of size 2"""
InputSequence = Union[TextInputSequence, PreTokenizedInputSequence]"""Represents all the possible types of input sequences for encoding. Can be:
- When ``is_pretokenized=False``: :data:`~TextInputSequence` - When ``is_pretokenized=True``: :data:`~PreTokenizedInputSequence`"""
EncodeInput = Union[TextEncodeInput, PreTokenizedEncodeInput]"""Represents all the possible types of input for encoding. Can be:
- When ``is_pretokenized=False``: :data:`~TextEncodeInput` - When ``is_pretokenized=True``: :data:`~PreTokenizedEncodeInput`"""
class OffsetReferential(Enum): ORIGINAL = "original" NORMALIZED = "normalized"
class OffsetType(Enum): BYTE = "byte" CHAR = "char"
class SplitDelimiterBehavior(Enum): REMOVED = "removed" ISOLATED = "isolated" MERGED_WITH_PREVIOUS = "merged_with_previous" MERGED_WITH_NEXT = "merged_with_next" CONTIGUOUS = "contiguous"
from .tokenizers import ( AddedToken, Encoding, NormalizedString, PreTokenizedString, Regex, Token, Tokenizer, decoders, models, normalizers, pre_tokenizers, processors, trainers, __version__,)from .implementations import ( BertWordPieceTokenizer, ByteLevelBPETokenizer, CharBPETokenizer, SentencePieceBPETokenizer, SentencePieceUnigramTokenizer,)12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238# Generated content DO NOT EDITclass AddedToken: """ Represents a token that can be be added to a :class:`~tokenizers.Tokenizer`. It can have special options that defines the way it should behave.
Args: content (:obj:`str`): The content of the token
single_word (:obj:`bool`, defaults to :obj:`False`): Defines whether this token should only match single words. If :obj:`True`, this token will never match inside of a word. For example the token ``ing`` would match on ``tokenizing`` if this option is :obj:`False`, but not if it is :obj:`True`. The notion of "`inside of a word`" is defined by the word boundaries pattern in regular expressions (ie. the token should start and end with word boundaries).
lstrip (:obj:`bool`, defaults to :obj:`False`): Defines whether this token should strip all potential whitespaces on its left side. If :obj:`True`, this token will greedily match any whitespace on its left. For example if we try to match the token ``[MASK]`` with ``lstrip=True``, in the text ``"I saw a [MASK]"``, we would match on ``" [MASK]"``. (Note the space on the left).
rstrip (:obj:`bool`, defaults to :obj:`False`): Defines whether this token should strip all potential whitespaces on its right side. If :obj:`True`, this token will greedily match any whitespace on its right. It works just like :obj:`lstrip` but on the right.
normalized (:obj:`bool`, defaults to :obj:`True` with :meth:`~tokenizers.Tokenizer.add_tokens` and :obj:`False` with :meth:`~tokenizers.Tokenizer.add_special_tokens`): Defines whether this token should match against the normalized version of the input text. For example, with the added token ``"yesterday"``, and a normalizer in charge of lowercasing the text, the token could be extract from the input ``"I saw a lion Yesterday"``. special (:obj:`bool`, defaults to :obj:`False` with :meth:`~tokenizers.Tokenizer.add_tokens` and :obj:`False` with :meth:`~tokenizers.Tokenizer.add_special_tokens`): Defines whether this token should be skipped when decoding.
""" def __init__(self, content, single_word=False, lstrip=False, rstrip=False, normalized=True, special=False): pass
@property def content(self): """ Get the content of this :obj:`AddedToken` """ pass
@property def lstrip(self): """ Get the value of the :obj:`lstrip` option """ pass
@property def normalized(self): """ Get the value of the :obj:`normalized` option """ pass
@property def rstrip(self): """ Get the value of the :obj:`rstrip` option """ pass
@property def single_word(self): """ Get the value of the :obj:`single_word` option """ pass
@property def special(self): """ Get the value of the :obj:`special` option """ pass
class Encoding: """ The :class:`~tokenizers.Encoding` represents the output of a :class:`~tokenizers.Tokenizer`. """ @property def attention_mask(self): """ The attention mask
This indicates to the LM which tokens should be attended to, and which should not. This is especially important when batching sequences, where we need to applying padding.
Returns: :obj:`List[int]`: The attention mask """ pass
def char_to_token(self, char_pos, sequence_index=0): """ Get the token that contains the char at the given position in the input sequence.
Args: char_pos (:obj:`int`): The position of a char in the input string sequence_index (:obj:`int`, defaults to :obj:`0`): The index of the sequence that contains the target char
Returns: :obj:`int`: The index of the token that contains this char in the encoded sequence """ pass
def char_to_word(self, char_pos, sequence_index=0): """ Get the word that contains the char at the given position in the input sequence.
Args: char_pos (:obj:`int`): The position of a char in the input string sequence_index (:obj:`int`, defaults to :obj:`0`): The index of the sequence that contains the target char
Returns: :obj:`int`: The index of the word that contains this char in the input sequence """ pass
@property def ids(self): """ The generated IDs
The IDs are the main input to a Language Model. They are the token indices, the numerical representations that a LM understands.
Returns: :obj:`List[int]`: The list of IDs """ pass
@staticmethod def merge(encodings, growing_offsets=True): """ Merge the list of encodings into one final :class:`~tokenizers.Encoding`
Args: encodings (A :obj:`List` of :class:`~tokenizers.Encoding`): The list of encodings that should be merged in one
growing_offsets (:obj:`bool`, defaults to :obj:`True`): Whether the offsets should accumulate while merging
Returns: :class:`~tokenizers.Encoding`: The resulting Encoding """ pass
@property def n_sequences(self): """ The number of sequences represented
Returns: :obj:`int`: The number of sequences in this :class:`~tokenizers.Encoding` """ pass
@property def offsets(self): """ The offsets associated to each token
These offsets let's you slice the input string, and thus retrieve the original part that led to producing the corresponding token.
Returns: A :obj:`List` of :obj:`Tuple[int, int]`: The list of offsets """ pass
@property def overflowing(self): """ A :obj:`List` of overflowing :class:`~tokenizers.Encoding`
When using truncation, the :class:`~tokenizers.Tokenizer` takes care of splitting the output into as many pieces as required to match the specified maximum length. This field lets you retrieve all the subsequent pieces.
When you use pairs of sequences, the overflowing pieces will contain enough variations to cover all the possible combinations, while respecting the provided maximum length. """ pass
def pad(self, length, direction="right", pad_id=0, pad_type_id=0, pad_token="[PAD]"): """ Pad the :class:`~tokenizers.Encoding` at the given length
Args: length (:obj:`int`): The desired length
direction: (:obj:`str`, defaults to :obj:`right`): The expected padding direction. Can be either :obj:`right` or :obj:`left`
pad_id (:obj:`int`, defaults to :obj:`0`): The ID corresponding to the padding token
pad_type_id (:obj:`int`, defaults to :obj:`0`): The type ID corresponding to the padding token
pad_token (:obj:`str`, defaults to `[PAD]`): The pad token to use """ pass
@property def sequence_ids(self): """ The generated sequence indices.
They represent the index of the input sequence associated to each token. The sequence id can be None if the token is not related to any input sequence, like for example with special tokens.
Returns: A :obj:`List` of :obj:`Optional[int]`: A list of optional sequence index. """ pass
def set_sequence_id(self, sequence_id): """ Set the given sequence index
Set the given sequence index for the whole range of tokens contained in this :class:`~tokenizers.Encoding`. """ pass
@property def special_tokens_mask(self): """ The special token mask
This indicates which tokens are special tokens, and which are not.
Returns: :obj:`List[int]`: The special tokens mask """ pass
def token_to_chars(self, token_index): """ Get the offsets of the token at the given index.
The returned offsets are related to the input sequence that contains the token. In order to determine in which input sequence it belongs, you must call :meth:`~tokenizers.Encoding.token_to_sequence()`.
Args: token_index (:obj:`int`): The index of a token in the encoded sequence.
Returns: :obj:`Tuple[int, int]`: The token offsets :obj:`(first, last + 1)` """ pass
def token_to_sequence(self, token_index): """ Get the index of the sequence represented by the given token.
In the general use case, this method returns :obj:`0` for a single sequence or the first sequence of a pair, and :obj:`1` for the second sequence of a pair
Args: token_index (:obj:`int`): The index of a token in the encoded sequence.
Returns: :obj:`int`: The sequence id of the given token """ pass
def token_to_word(self, token_index): """ Get the index of the word that contains the token in one of the input sequences.
The returned word index is related to the input sequence that contains the token. In order to determine in which input sequence it belongs, you must call :meth:`~tokenizers.Encoding.token_to_sequence()`.
Args: token_index (:obj:`int`): The index of a token in the encoded sequence.
Returns: :obj:`int`: The index of the word in the relevant input sequence. """ pass
@property def tokens(self): """ The generated tokens
They are the string representation of the IDs.
Returns: :obj:`List[str]`: The list of tokens """ pass
def truncate(self, max_length, stride=0, direction="right"): """ Truncate the :class:`~tokenizers.Encoding` at the given length
If this :class:`~tokenizers.Encoding` represents multiple sequences, when truncating this information is lost. It will be considered as representing a single sequence.
Args: max_length (:obj:`int`): The desired length
stride (:obj:`int`, defaults to :obj:`0`): The length of previous content to be included in each overflowing piece
direction (:obj:`str`, defaults to :obj:`right`): Truncate direction """ pass
@property def type_ids(self): """ The generated type IDs
Generally used for tasks like sequence classification or question answering, these tokens let the LM know which input sequence corresponds to each tokens.
Returns: :obj:`List[int]`: The list of type ids """ pass
@property def word_ids(self): """ The generated word indices.
They represent the index of the word associated to each token. When the input is pre-tokenized, they correspond to the ID of the given input label, otherwise they correspond to the words indices as defined by the :class:`~tokenizers.pre_tokenizers.PreTokenizer` that was used.
For special tokens and such (any token that was generated from something that was not part of the input), the output is :obj:`None`
Returns: A :obj:`List` of :obj:`Optional[int]`: A list of optional word index. """ pass
def word_to_chars(self, word_index, sequence_index=0): """ Get the offsets of the word at the given index in one of the input sequences.
Args: word_index (:obj:`int`): The index of a word in one of the input sequences. sequence_index (:obj:`int`, defaults to :obj:`0`): The index of the sequence that contains the target word
Returns: :obj:`Tuple[int, int]`: The range of characters (span) :obj:`(first, last + 1)` """ pass
def word_to_tokens(self, word_index, sequence_index=0): """ Get the encoded tokens corresponding to the word at the given index in one of the input sequences.
Args: word_index (:obj:`int`): The index of a word in one of the input sequences. sequence_index (:obj:`int`, defaults to :obj:`0`): The index of the sequence that contains the target word
Returns: :obj:`Tuple[int, int]`: The range of tokens: :obj:`(first, last + 1)` """ pass
@property def words(self): """ The generated word indices.
.. warning:: This is deprecated and will be removed in a future version. Please use :obj:`~tokenizers.Encoding.word_ids` instead.
They represent the index of the word associated to each token. When the input is pre-tokenized, they correspond to the ID of the given input label, otherwise they correspond to the words indices as defined by the :class:`~tokenizers.pre_tokenizers.PreTokenizer` that was used.
For special tokens and such (any token that was generated from something that was not part of the input), the output is :obj:`None`
Returns: A :obj:`List` of :obj:`Optional[int]`: A list of optional word index. """ pass
class NormalizedString: """ NormalizedString
A NormalizedString takes care of modifying an "original" string, to obtain a "normalized" one. While making all the requested modifications, it keeps track of the alignment information between the two versions of the string.
Args: sequence: str: The string sequence used to initialize this NormalizedString """ def append(self, s): """ Append the given sequence to the string """ pass
def clear(self): """ Clears the string """ pass
def filter(self, func): """ Filter each character of the string using the given func """ pass
def for_each(self, func): """ Calls the given function for each character of the string """ pass
def lowercase(self): """ Lowercase the string """ pass
def lstrip(self): """ Strip the left of the string """ pass
def map(self, func): """ Calls the given function for each character of the string
Replaces each character of the string using the returned value. Each returned value **must** be a str of length 1 (ie a character). """ pass
def nfc(self): """ Runs the NFC normalization """ pass
def nfd(self): """ Runs the NFD normalization """ pass
def nfkc(self): """ Runs the NFKC normalization """ pass
def nfkd(self): """ Runs the NFKD normalization """ pass
@property def normalized(self): """ The normalized part of the string """ pass
def prepend(self, s): """ Prepend the given sequence to the string """ pass
def replace(self, pattern, content): """ Replace the content of the given pattern with the provided content
Args: pattern: Pattern: A pattern used to match the string. Usually a string or a Regex
content: str: The content to be used as replacement """ pass
def rstrip(self): """ Strip the right of the string """ pass
def slice(self, range): """ Slice the string using the given range """ pass
def split(self, pattern, behavior): """ Split the NormalizedString using the given pattern and the specified behavior
Args: pattern: Pattern: A pattern used to split the string. Usually a string or a regex built with `tokenizers.Regex`
behavior: SplitDelimiterBehavior: The behavior to use when splitting. Choices: "removed", "isolated", "merged_with_previous", "merged_with_next", "contiguous"
Returns: A list of NormalizedString, representing each split """ pass
def strip(self): """ Strip both ends of the string """ pass
def uppercase(self): """ Uppercase the string """ pass
class PreTokenizedString: """ PreTokenizedString
Wrapper over a string, that provides a way to normalize, pre-tokenize, tokenize the underlying string, while keeping track of the alignment information (offsets).
The PreTokenizedString manages what we call `splits`. Each split represents a substring which is a subpart of the original string, with the relevant offsets and tokens.
When calling one of the methods used to modify the PreTokenizedString (namely one of `split`, `normalize` or `tokenize), only the `splits` that don't have any associated tokens will get modified.
Args: sequence: str: The string sequence used to initialize this PreTokenizedString """ def __init__(self, sequence): pass
def get_splits(self, offset_referential="original", offset_type="char"): """ Get the splits currently managed by the PreTokenizedString
Args: offset_referential: :obj:`str` Whether the returned splits should have offsets expressed relative to the original string, or the normalized one. choices: "original", "normalized".
offset_type: :obj:`str` Whether the returned splits should have offsets expressed in bytes or chars. When slicing an str, we usually want to use chars, which is the default value. Now in some cases it might be interesting to get these offsets expressed in bytes, so it is possible to change this here. choices: "char", "bytes"
Returns A list of splits """ pass
def normalize(self, func): """ Normalize each split of the `PreTokenizedString` using the given `func`
Args: func: Callable[[NormalizedString], None]: The function used to normalize each underlying split. This function does not need to return anything, just calling the methods on the provided NormalizedString allow its modification. """ pass
def split(self, func): """ Split the PreTokenizedString using the given `func`
Args: func: Callable[[index, NormalizedString], List[NormalizedString]]: The function used to split each underlying split. It is expected to return a list of `NormalizedString`, that represent the new splits. If the given `NormalizedString` does not need any splitting, we can just return it directly. In order for the offsets to be tracked accurately, any returned `NormalizedString` should come from calling either `.split` or `.slice` on the received one. """ pass
def to_encoding(self, type_id=0, word_idx=None): """ Return an Encoding generated from this PreTokenizedString
Args: type_id: int = 0: The type_id to be used on the generated Encoding.
word_idx: Optional[int] = None: An optional word index to be used for each token of this Encoding. If provided, all the word indices in the generated Encoding will use this value, instead of the one automatically tracked during pre-tokenization.
Returns: An Encoding """ pass
def tokenize(self, func): """ Tokenize each split of the `PreTokenizedString` using the given `func`
Args: func: Callable[[str], List[Token]]: The function used to tokenize each underlying split. This function must return a list of Token generated from the input str. """ pass
class Regex: """ Instantiate a new Regex with the given pattern """ def __init__(self, pattern): pass
class Token: pass
class Tokenizer: """ A :obj:`Tokenizer` works as a pipeline. It processes some raw text as input and outputs an :class:`~tokenizers.Encoding`.
Args: model (:class:`~tokenizers.models.Model`): The core algorithm that this :obj:`Tokenizer` should be using.
""" def __init__(self, model): pass
def add_special_tokens(self, tokens): """ Add the given special tokens to the Tokenizer.
If these tokens are already part of the vocabulary, it just let the Tokenizer know about them. If they don't exist, the Tokenizer creates them, giving them a new id.
These special tokens will never be processed by the model (ie won't be split into multiple tokens), and they can be removed from the output when decoding.
Args: tokens (A :obj:`List` of :class:`~tokenizers.AddedToken` or :obj:`str`): The list of special tokens we want to add to the vocabulary. Each token can either be a string or an instance of :class:`~tokenizers.AddedToken` for more customization.
Returns: :obj:`int`: The number of tokens that were created in the vocabulary """ pass
def add_tokens(self, tokens): """ Add the given tokens to the vocabulary
The given tokens are added only if they don't already exist in the vocabulary. Each token then gets a new attributed id.
Args: tokens (A :obj:`List` of :class:`~tokenizers.AddedToken` or :obj:`str`): The list of tokens we want to add to the vocabulary. Each token can be either a string or an instance of :class:`~tokenizers.AddedToken` for more customization.
Returns: :obj:`int`: The number of tokens that were created in the vocabulary """ pass
def decode(self, ids, skip_special_tokens=True): """ Decode the given list of ids back to a string
This is used to decode anything coming back from a Language Model
Args: ids (A :obj:`List/Tuple` of :obj:`int`): The list of ids that we want to decode
skip_special_tokens (:obj:`bool`, defaults to :obj:`True`): Whether the special tokens should be removed from the decoded string
Returns: :obj:`str`: The decoded string """ pass
def decode_batch(self, sequences, skip_special_tokens=True): """ Decode a batch of ids back to their corresponding string
Args: sequences (:obj:`List` of :obj:`List[int]`): The batch of sequences we want to decode
skip_special_tokens (:obj:`bool`, defaults to :obj:`True`): Whether the special tokens should be removed from the decoded strings
Returns: :obj:`List[str]`: A list of decoded strings """ pass
@property def decoder(self): """ The `optional` :class:`~tokenizers.decoders.Decoder` in use by the Tokenizer """ pass
def enable_padding( self, direction="right", pad_id=0, pad_type_id=0, pad_token="[PAD]", length=None, pad_to_multiple_of=None ): """ Enable the padding
Args: direction (:obj:`str`, `optional`, defaults to :obj:`right`): The direction in which to pad. Can be either ``right`` or ``left``
pad_to_multiple_of (:obj:`int`, `optional`): If specified, the padding length should always snap to the next multiple of the given value. For example if we were going to pad witha length of 250 but ``pad_to_multiple_of=8`` then we will pad to 256.
pad_id (:obj:`int`, defaults to 0): The id to be used when padding
pad_type_id (:obj:`int`, defaults to 0): The type id to be used when padding
pad_token (:obj:`str`, defaults to :obj:`[PAD]`): The pad token to be used when padding
length (:obj:`int`, `optional`): If specified, the length at which to pad. If not specified we pad using the size of the longest sequence in a batch. """ pass
def enable_truncation(self, max_length, stride=0, strategy="longest_first", direction="right"): """ Enable truncation
Args: max_length (:obj:`int`): The max length at which to truncate
stride (:obj:`int`, `optional`): The length of the previous first sequence to be included in the overflowing sequence
strategy (:obj:`str`, `optional`, defaults to :obj:`longest_first`): The strategy used to truncation. Can be one of ``longest_first``, ``only_first`` or ``only_second``.
direction (:obj:`str`, defaults to :obj:`right`): Truncate direction """ pass
def encode(self, sequence, pair=None, is_pretokenized=False, add_special_tokens=True): """ Encode the given sequence and pair. This method can process raw text sequences as well as already pre-tokenized sequences.
Example: Here are some examples of the inputs that are accepted::
encode("A single sequence")` encode("A sequence", "And its pair")` encode([ "A", "pre", "tokenized", "sequence" ], is_pretokenized=True)` encode( [ "A", "pre", "tokenized", "sequence" ], [ "And", "its", "pair" ], is_pretokenized=True )
Args: sequence (:obj:`~tokenizers.InputSequence`): The main input sequence we want to encode. This sequence can be either raw text or pre-tokenized, according to the ``is_pretokenized`` argument:
- If ``is_pretokenized=False``: :class:`~tokenizers.TextInputSequence` - If ``is_pretokenized=True``: :class:`~tokenizers.PreTokenizedInputSequence`
pair (:obj:`~tokenizers.InputSequence`, `optional`): An optional input sequence. The expected format is the same that for ``sequence``.
is_pretokenized (:obj:`bool`, defaults to :obj:`False`): Whether the input is already pre-tokenized
add_special_tokens (:obj:`bool`, defaults to :obj:`True`): Whether to add the special tokens
Returns: :class:`~tokenizers.Encoding`: The encoded result
""" pass
def encode_batch(self, input, is_pretokenized=False, add_special_tokens=True): """ Encode the given batch of inputs. This method accept both raw text sequences as well as already pre-tokenized sequences. The reason we use `PySequence` is because it allows type checking with zero-cost (according to PyO3) as we don't have to convert to check.
Example: Here are some examples of the inputs that are accepted::
encode_batch([ "A single sequence", ("A tuple with a sequence", "And its pair"), [ "A", "pre", "tokenized", "sequence" ], ([ "A", "pre", "tokenized", "sequence" ], "And its pair") ])
Args: input (A :obj:`List`/:obj:`Tuple` of :obj:`~tokenizers.EncodeInput`): A list of single sequences or pair sequences to encode. Each sequence can be either raw text or pre-tokenized, according to the ``is_pretokenized`` argument:
- If ``is_pretokenized=False``: :class:`~tokenizers.TextEncodeInput` - If ``is_pretokenized=True``: :class:`~tokenizers.PreTokenizedEncodeInput`
is_pretokenized (:obj:`bool`, defaults to :obj:`False`): Whether the input is already pre-tokenized
add_special_tokens (:obj:`bool`, defaults to :obj:`True`): Whether to add the special tokens
Returns: A :obj:`List` of :class:`~tokenizers.Encoding`: The encoded batch
""" pass
def encode_batch_fast(self, input, is_pretokenized=False, add_special_tokens=True): """ Encode the given batch of inputs. This method is faster than `encode_batch` because it doesn't keep track of offsets, they will be all zeros.
Example: Here are some examples of the inputs that are accepted::
encode_batch_fast([ "A single sequence", ("A tuple with a sequence", "And its pair"), [ "A", "pre", "tokenized", "sequence" ], ([ "A", "pre", "tokenized", "sequence" ], "And its pair") ])
Args: input (A :obj:`List`/:obj:`Tuple` of :obj:`~tokenizers.EncodeInput`): A list of single sequences or pair sequences to encode. Each sequence can be either raw text or pre-tokenized, according to the ``is_pretokenized`` argument:
- If ``is_pretokenized=False``: :class:`~tokenizers.TextEncodeInput` - If ``is_pretokenized=True``: :class:`~tokenizers.PreTokenizedEncodeInput`
is_pretokenized (:obj:`bool`, defaults to :obj:`False`): Whether the input is already pre-tokenized
add_special_tokens (:obj:`bool`, defaults to :obj:`True`): Whether to add the special tokens
Returns: A :obj:`List` of :class:`~tokenizers.Encoding`: The encoded batch
""" pass
@property def encode_special_tokens(self): """ Modifies the tokenizer in order to use or not the special tokens during encoding.
Args: value (:obj:`bool`): Whether to use the special tokens or not
""" pass
@staticmethod def from_buffer(buffer): """ Instantiate a new :class:`~tokenizers.Tokenizer` from the given buffer.
Args: buffer (:obj:`bytes`): A buffer containing a previously serialized :class:`~tokenizers.Tokenizer`
Returns: :class:`~tokenizers.Tokenizer`: The new tokenizer """ pass
@staticmethod def from_file(path): """ Instantiate a new :class:`~tokenizers.Tokenizer` from the file at the given path.
Args: path (:obj:`str`): A path to a local JSON file representing a previously serialized :class:`~tokenizers.Tokenizer`
Returns: :class:`~tokenizers.Tokenizer`: The new tokenizer """ pass
@staticmethod def from_pretrained(identifier, revision="main", token=None): """ Instantiate a new :class:`~tokenizers.Tokenizer` from an existing file on the Hugging Face Hub.
Args: identifier (:obj:`str`): The identifier of a Model on the Hugging Face Hub, that contains a tokenizer.json file revision (:obj:`str`, defaults to `main`): A branch or commit id token (:obj:`str`, `optional`, defaults to `None`): An optional auth token used to access private repositories on the Hugging Face Hub
Returns: :class:`~tokenizers.Tokenizer`: The new tokenizer """ pass
@staticmethod def from_str(json): """ Instantiate a new :class:`~tokenizers.Tokenizer` from the given JSON string.
Args: json (:obj:`str`): A valid JSON string representing a previously serialized :class:`~tokenizers.Tokenizer`
Returns: :class:`~tokenizers.Tokenizer`: The new tokenizer """ pass
def get_added_tokens_decoder(self): """ Get the underlying vocabulary
Returns: :obj:`Dict[int, AddedToken]`: The vocabulary """ pass
def get_vocab(self, with_added_tokens=True): """ Get the underlying vocabulary
Args: with_added_tokens (:obj:`bool`, defaults to :obj:`True`): Whether to include the added tokens
Returns: :obj:`Dict[str, int]`: The vocabulary """ pass
def get_vocab_size(self, with_added_tokens=True): """ Get the size of the underlying vocabulary
Args: with_added_tokens (:obj:`bool`, defaults to :obj:`True`): Whether to include the added tokens
Returns: :obj:`int`: The size of the vocabulary """ pass
def id_to_token(self, id): """ Convert the given id to its corresponding token if it exists
Args: id (:obj:`int`): The id to convert
Returns: :obj:`Optional[str]`: An optional token, :obj:`None` if out of vocabulary """ pass
@property def model(self): """ The :class:`~tokenizers.models.Model` in use by the Tokenizer """ pass
def no_padding(self): """ Disable padding """ pass
def no_truncation(self): """ Disable truncation """ pass
@property def normalizer(self): """ The `optional` :class:`~tokenizers.normalizers.Normalizer` in use by the Tokenizer """ pass
def num_special_tokens_to_add(self, is_pair): """ Return the number of special tokens that would be added for single/pair sentences. :param is_pair: Boolean indicating if the input would be a single sentence or a pair :return: """ pass
@property def padding(self): """ Get the current padding parameters
`Cannot be set, use` :meth:`~tokenizers.Tokenizer.enable_padding` `instead`
Returns: (:obj:`dict`, `optional`): A dict with the current padding parameters if padding is enabled """ pass
def post_process(self, encoding, pair=None, add_special_tokens=True): """ Apply all the post-processing steps to the given encodings.
The various steps are:
1. Truncate according to the set truncation params (provided with :meth:`~tokenizers.Tokenizer.enable_truncation`) 2. Apply the :class:`~tokenizers.processors.PostProcessor` 3. Pad according to the set padding params (provided with :meth:`~tokenizers.Tokenizer.enable_padding`)
Args: encoding (:class:`~tokenizers.Encoding`): The :class:`~tokenizers.Encoding` corresponding to the main sequence.
pair (:class:`~tokenizers.Encoding`, `optional`): An optional :class:`~tokenizers.Encoding` corresponding to the pair sequence.
add_special_tokens (:obj:`bool`): Whether to add the special tokens
Returns: :class:`~tokenizers.Encoding`: The final post-processed encoding """ pass
@property def post_processor(self): """ The `optional` :class:`~tokenizers.processors.PostProcessor` in use by the Tokenizer """ pass
@property def pre_tokenizer(self): """ The `optional` :class:`~tokenizers.pre_tokenizers.PreTokenizer` in use by the Tokenizer """ pass
def save(self, path, pretty=True): """ Save the :class:`~tokenizers.Tokenizer` to the file at the given path.
Args: path (:obj:`str`): A path to a file in which to save the serialized tokenizer.
pretty (:obj:`bool`, defaults to :obj:`True`): Whether the JSON file should be pretty formatted. """ pass
def to_str(self, pretty=False): """ Gets a serialized string representing this :class:`~tokenizers.Tokenizer`.
Args: pretty (:obj:`bool`, defaults to :obj:`False`): Whether the JSON string should be pretty formatted.
Returns: :obj:`str`: A string representing the serialized Tokenizer """ pass
def token_to_id(self, token): """ Convert the given token to its corresponding id if it exists
Args: token (:obj:`str`): The token to convert
Returns: :obj:`Optional[int]`: An optional id, :obj:`None` if out of vocabulary """ pass
def train(self, files, trainer=None): """ Train the Tokenizer using the given files.
Reads the files line by line, while keeping all the whitespace, even new lines. If you want to train from data store in-memory, you can check :meth:`~tokenizers.Tokenizer.train_from_iterator`
Args: files (:obj:`List[str]`): A list of path to the files that we should use for training
trainer (:obj:`~tokenizers.trainers.Trainer`, `optional`): An optional trainer that should be used to train our Model """ pass
def train_from_iterator(self, iterator, trainer=None, length=None): """ Train the Tokenizer using the provided iterator.
You can provide anything that is a Python Iterator
* A list of sequences :obj:`List[str]` * A generator that yields :obj:`str` or :obj:`List[str]` * A Numpy array of strings * ...
Args: iterator (:obj:`Iterator`): Any iterator over strings or list of strings
trainer (:obj:`~tokenizers.trainers.Trainer`, `optional`): An optional trainer that should be used to train our Model
length (:obj:`int`, `optional`): The total number of sequences in the iterator. This is used to provide meaningful progress tracking """ pass
@property def truncation(self): """ Get the currently set truncation parameters
`Cannot set, use` :meth:`~tokenizers.Tokenizer.enable_truncation` `instead`
Returns: (:obj:`dict`, `optional`): A dict with the current truncation parameters if truncation is enabled """ pass123456789101112131415from .. import decoders
Decoder = decoders.DecoderByteLevel = decoders.ByteLevelReplace = decoders.ReplaceWordPiece = decoders.WordPieceByteFallback = decoders.ByteFallbackFuse = decoders.FuseStrip = decoders.StripMetaspace = decoders.MetaspaceBPEDecoder = decoders.BPEDecoderCTC = decoders.CTCSequence = decoders.SequenceDecodeStream = decoders.DecodeStream123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279# Generated content DO NOT EDITclass DecodeStream: """ Class needed for streaming decode
""" def __init__(self, skip_special_tokens): pass
class Decoder: """ Base class for all decoders
This class is not supposed to be instantiated directly. Instead, any implementation of a Decoder will return an instance of this class when instantiated. """ def decode(self, tokens): """ Decode the given list of tokens to a final string
Args: tokens (:obj:`List[str]`): The list of tokens to decode
Returns: :obj:`str`: The decoded string """ pass
class BPEDecoder(Decoder): """ BPEDecoder Decoder
Args: suffix (:obj:`str`, `optional`, defaults to :obj:`</w>`): The suffix that was used to characterize an end-of-word. This suffix will be replaced by whitespaces during the decoding """ def __init__(self, suffix="</w>"): pass
def decode(self, tokens): """ Decode the given list of tokens to a final string
Args: tokens (:obj:`List[str]`): The list of tokens to decode
Returns: :obj:`str`: The decoded string """ pass
class ByteFallback(Decoder): """ ByteFallback Decoder ByteFallback is a simple trick which converts tokens looking like `<0x61>` to pure bytes, and attempts to make them into a string. If the tokens cannot be decoded you will get � instead for each inconvertible byte token
""" def __init__(self): pass
def decode(self, tokens): """ Decode the given list of tokens to a final string
Args: tokens (:obj:`List[str]`): The list of tokens to decode
Returns: :obj:`str`: The decoded string """ pass
class ByteLevel(Decoder): """ ByteLevel Decoder
This decoder is to be used in tandem with the :class:`~tokenizers.pre_tokenizers.ByteLevel` :class:`~tokenizers.pre_tokenizers.PreTokenizer`. """ def __init__(self): pass
def decode(self, tokens): """ Decode the given list of tokens to a final string
Args: tokens (:obj:`List[str]`): The list of tokens to decode
Returns: :obj:`str`: The decoded string """ pass
class CTC(Decoder): """ CTC Decoder
Args: pad_token (:obj:`str`, `optional`, defaults to :obj:`<pad>`): The pad token used by CTC to delimit a new token. word_delimiter_token (:obj:`str`, `optional`, defaults to :obj:`|`): The word delimiter token. It will be replaced by a <space> cleanup (:obj:`bool`, `optional`, defaults to :obj:`True`): Whether to cleanup some tokenization artifacts. Mainly spaces before punctuation, and some abbreviated english forms. """ def __init__(self, pad_token="<pad>", word_delimiter_token="|", cleanup=True): pass
def decode(self, tokens): """ Decode the given list of tokens to a final string
Args: tokens (:obj:`List[str]`): The list of tokens to decode
Returns: :obj:`str`: The decoded string """ pass
class Fuse(Decoder): """ Fuse Decoder Fuse simply fuses every token into a single string. This is the last step of decoding, this decoder exists only if there is need to add other decoders *after* the fusion """ def __init__(self): pass
def decode(self, tokens): """ Decode the given list of tokens to a final string
Args: tokens (:obj:`List[str]`): The list of tokens to decode
Returns: :obj:`str`: The decoded string """ pass
class Metaspace(Decoder): """ Metaspace Decoder
Args: replacement (:obj:`str`, `optional`, defaults to :obj:`▁`): The replacement character. Must be exactly one character. By default we use the `▁` (U+2581) meta symbol (Same as in SentencePiece).
prepend_scheme (:obj:`str`, `optional`, defaults to :obj:`"always"`): Whether to add a space to the first word if there isn't already one. This lets us treat `hello` exactly like `say hello`. Choices: "always", "never", "first". First means the space is only added on the first token (relevant when special tokens are used or other pre_tokenizer are used). """ def __init__(self, replacement="▁", prepend_scheme="always", split=True): pass
def decode(self, tokens): """ Decode the given list of tokens to a final string
Args: tokens (:obj:`List[str]`): The list of tokens to decode
Returns: :obj:`str`: The decoded string """ pass
class Replace(Decoder): """ Replace Decoder
This decoder is to be used in tandem with the :class:`~tokenizers.pre_tokenizers.Replace` :class:`~tokenizers.pre_tokenizers.PreTokenizer`. """ def __init__(self, pattern, content): pass
def decode(self, tokens): """ Decode the given list of tokens to a final string
Args: tokens (:obj:`List[str]`): The list of tokens to decode
Returns: :obj:`str`: The decoded string """ pass
class Sequence(Decoder): """ Sequence Decoder
Args: decoders (:obj:`List[Decoder]`) The decoders that need to be chained """ def __init__(self, decoders): pass
def decode(self, tokens): """ Decode the given list of tokens to a final string
Args: tokens (:obj:`List[str]`): The list of tokens to decode
Returns: :obj:`str`: The decoded string """ pass
class Strip(Decoder): """ Strip normalizer Strips n left characters of each token, or n right characters of each token """ def __init__(self, content, left=0, right=0): pass
def decode(self, tokens): """ Decode the given list of tokens to a final string
Args: tokens (:obj:`List[str]`): The list of tokens to decode
Returns: :obj:`str`: The decoded string """ pass
class WordPiece(Decoder): """ WordPiece Decoder
Args: prefix (:obj:`str`, `optional`, defaults to :obj:`##`): The prefix to use for subwords that are not a beginning-of-word
cleanup (:obj:`bool`, `optional`, defaults to :obj:`True`): Whether to cleanup some tokenization artifacts. Mainly spaces before punctuation, and some abbreviated english forms. """ def __init__(self, prefix="##", cleanup=True): pass
def decode(self, tokens): """ Decode the given list of tokens to a final string
Args: tokens (:obj:`List[str]`): The list of tokens to decode
Returns: :obj:`str`: The decoded string """ pass123456from .base_tokenizer import BaseTokenizerfrom .bert_wordpiece import BertWordPieceTokenizerfrom .byte_level_bpe import ByteLevelBPETokenizerfrom .char_level_bpe import CharBPETokenizerfrom .sentencepiece_bpe import SentencePieceBPETokenizerfrom .sentencepiece_unigram import SentencePieceUnigramTokenizer.gitattributes+19
.venv/lib/python3.12/site-packages/sympy-1.14.0.dist-info/INSTALLERAdded+1
.venv/lib/python3.12/site-packages/sympy-1.14.0.dist-info/METADATAAdded+319
.venv/lib/python3.12/site-packages/sympy-1.14.0.dist-info/RECORDAdded
.venv/lib/python3.12/site-packages/sympy-1.14.0.dist-info/REQUESTEDAdded
.venv/lib/python3.12/site-packages/sympy-1.14.0.dist-info/WHEELAdded+5
.venv/lib/python3.12/site-packages/sympy-1.14.0.dist-info/entry_points.txtAdded+2
.venv/lib/python3.12/site-packages/sympy-1.14.0.dist-info/licenses/AUTHORSAdded+1379
.venv/lib/python3.12/site-packages/sympy-1.14.0.dist-info/licenses/LICENSEAdded+153
.venv/lib/python3.12/site-packages/sympy-1.14.0.dist-info/top_level.txtAdded+2
.venv/lib/python3.12/site-packages/sympy/vector/functions.pyAdded+513
.venv/lib/python3.12/site-packages/sympy/vector/implicitregion.pyAdded+506
.venv/lib/python3.12/site-packages/sympy/vector/integrals.pyAdded+206
.venv/lib/python3.12/site-packages/sympy/vector/kind.pyAdded+67
.venv/lib/python3.12/site-packages/sympy/vector/operators.pyAdded+335
.venv/lib/python3.12/site-packages/sympy/vector/orienters.pyAdded+398
.venv/lib/python3.12/site-packages/sympy/vector/parametricregion.pyAdded+189
.venv/lib/python3.12/site-packages/sympy/vector/point.pyAdded+148
.venv/lib/python3.12/site-packages/sympy/vector/scalar.pyAdded+72
.venv/lib/python3.12/site-packages/sympy/vector/tests/__init__.pyAdded
.venv/lib/python3.12/site-packages/sympy/vector/tests/test_coordsysrect.pyAdded+464
.venv/lib/python3.12/site-packages/sympy/vector/tests/test_dyadic.pyAdded+134
.venv/lib/python3.12/site-packages/sympy/vector/tests/test_field_functions.pyAdded+321
.venv/lib/python3.12/site-packages/sympy/vector/tests/test_functions.pyAdded+184
.venv/lib/python3.12/site-packages/sympy/vector/tests/test_implicitregion.pyAdded+90
.venv/lib/python3.12/site-packages/sympy/vector/tests/test_integrals.pyAdded+106
.venv/lib/python3.12/site-packages/sympy/vector/tests/test_operators.pyAdded+43
.venv/lib/python3.12/site-packages/sympy/vector/tests/test_parametricregion.pyAdded+97
.venv/lib/python3.12/site-packages/sympy/vector/tests/test_printing.pyAdded+221
.venv/lib/python3.12/site-packages/sympy/vector/tests/test_vector.pyAdded+342
.venv/lib/python3.12/site-packages/sympy/vector/vector.pyAdded+714
.venv/lib/python3.12/site-packages/tokenizers-0.21.2.dist-info/INSTALLERAdded+1
.venv/lib/python3.12/site-packages/tokenizers-0.21.2.dist-info/METADATAAdded+210
.venv/lib/python3.12/site-packages/tokenizers-0.21.2.dist-info/RECORDAdded+30
.venv/lib/python3.12/site-packages/tokenizers-0.21.2.dist-info/REQUESTEDAdded
.venv/lib/python3.12/site-packages/tokenizers-0.21.2.dist-info/WHEELAdded+4
.venv/lib/python3.12/site-packages/tokenizers/__init__.pyAdded+100
.venv/lib/python3.12/site-packages/tokenizers/__init__.pyiAdded+1238
.venv/lib/python3.12/site-packages/tokenizers/__pycache__/__init__.cpython-312.pycAdded
.venv/lib/python3.12/site-packages/tokenizers/decoders/__init__.pyAdded+15
.venv/lib/python3.12/site-packages/tokenizers/decoders/__init__.pyiAdded+279
.venv/lib/python3.12/site-packages/tokenizers/decoders/__pycache__/__init__.cpython-312.pycAdded
.venv/lib/python3.12/site-packages/tokenizers/implementations/__init__.pyAdded+6
.venv/lib/python3.12/site-packages/tokenizers/implementations/__pycache__/__init__.cpython-312.pycAdded
.venv/lib/python3.12/site-packages/tokenizers/implementations/__pycache__/base_tokenizer.cpython-312.pycAdded
.venv/lib/python3.12/site-packages/tokenizers/implementations/__pycache__/bert_wordpiece.cpython-312.pycAdded
.venv/lib/python3.12/site-packages/tokenizers/implementations/__pycache__/byte_level_bpe.cpython-312.pycAdded
.venv/lib/python3.12/site-packages/tokenizers/implementations/__pycache__/char_level_bpe.cpython-312.pycAdded
.venv/lib/python3.12/site-packages/tokenizers/implementations/__pycache__/sentencepiece_bpe.cpython-312.pycAdded
.venv/lib/python3.12/site-packages/tokenizers/implementations/__pycache__/sentencepiece_unigram.cpython-312.pycAdded