A computer algebra system written in pure Python

Overview

SymPy

pypi version Build status Join the chat at https://gitter.im/sympy/sympy Zenodo Badge codecov Badge

SymPy Banner

See the 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, the Google Highly Open Participation Contest, Google Code-In, wrote and blogged about SymPy...

License: New BSD License (see the LICENSE file for details) covers all files in the sympy repository unless stated otherwise.

Our mailing list is at https://groups.google.com/forum/?fromgroups#!forum/sympy.

We have community chat at Gitter. Feel free to ask us anything there. We have a very welcoming and helpful community.

Download

The recommended installation method is through Anaconda, https://www.anaconda.com/download/

You can also get the latest version of SymPy from https://pypi.python.org/pypi/sympy/

To get the git version do

$ git clone git://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 the documentation, see the SymPy Documentation Style Guide.

Everything is at:

https://docs.sympy.org/

You can generate everything at the above site in your local copy of SymPy by:

$ cd doc
$ make html

Then the docs will be in _build/html. If you don't want to read that, here is a short usage:

From this directory, start Python and:

>>> 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 the classic python console (or IPython when available) that loads the SymPy namespace 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

SymPy has a hard dependency on the mpmath library (version >= 0.19). You should install it first, please refer to the mpmath installation guide:

https://github.com/fredrik-johansson/mpmath#1-download--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:

$ python setup.py install

See https://docs.sympy.org/dev/install.html for more information.

Contributing

We welcome contributions from anyone, even if you are new to open source. Please read our Introduction to Contributing page and the SymPy Documentation Style Guide. If you are new and looking for some way to contribute, a good place to start is to look at the issues tagged Easy to Fix.

Please note that all participants in this project are expected to follow our Code of Conduct. By participating in this project you agree to abide by its terms. See 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 tested by Travis CI.

To test pull requests, use sympy-bot.

Regenerate Experimental LaTeX Parser/Lexer

The parser and lexer generated with the ANTLR4 toolchain in sympy/parsing/latex/_antlr and checked into the repo. Presently, most users should not need to regenerate these files, but if 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.7.2

Alternatively, follow the instructions on the ANTLR website and download the antlr-4.7.2-complete.jar. Then export the CLASSPATH as instructed and instead of creating antlr4 as an alias, make it an executable file with the following contents:

#!/bin/bash
java -jar /usr/local/lib/antlr-4.7.2-complete.jar "[email protected]"

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):

$ ./setup.py clean

You can also clean things with git using:

$ 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 in git 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 git status, git diff, git clean -Xn and git clean -n before doing any of those.

Bugs

Our issue tracker is at https://github.com/sympy/sympy/issues. Please report any bugs that you find. Or, even better, fork the repository on GitHub 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 (just ask on our mailing list or Gitter Channel). If you further have any queries, you can find answers on Stack Overflow using the sympy tag.

Brief History

SymPy was started by Ondřej Čertík in 2005, he wrote some code during the summer, then he wrote some more code during summer 2006. In February 2007, Fabian Pedregosa joined the project and helped fixed many things, contributed documentation and made it alive again. 5 students (Mateusz Paprocki, Brian Jorgensen, Jason Gedge, Robert Schwarz, and Chris Wu) improved SymPy incredibly during summer 2007 as part of the Google Summer of Code. Pearu Peterson joined the development during the summer 2007 and he has made SymPy much more competitive by rewriting the core from scratch, that has made it from 10x to 100x faster. Jurjen N.E. Bos has contributed pretty-printing and other patches. Fredrik Johansson has written mpmath and contributed a lot of patches.

SymPy has participated in every Google Summer of Code since 2007. You can see https://github.com/sympy/sympy/wiki#google-summer-of-code for full details. Each year has improved SymPy by bounds. Most of SymPy's development has come from Google Summer of Code students.

In 2011, Ondřej Čertík stepped down as lead developer, with Aaron Meurer, who also started as a Google Summer of Code student, taking his place. Ondřej Čertík is still active in the community but is too busy with work and family to play a lead development role.

Since then, a lot more people have joined the development and some people 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

@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, be it academic, commercial, creating forks or derivatives, as long as you copy the BSD statement if you redistribute it (see the LICENSE file for details). That said, although not required by the SymPy license, if it is convenient for you, please cite SymPy when using it in your work and also consider contributing all your changes back, so that we can incorporate it and all of us will benefit in the end.

Issues
  • solve has many issues with fractions

    solve has many issues with fractions

    >>> import sympy
    >>> x=sympy.var('x')
    
    Zero is sometimes wrongly reported as a solution.
    
    >>> sympy.solve(-(1 + x)/(2 + x)**2 + 1/(2 + x), x)
    [0]
    
    There is a corresponding "TODO" in the source code, but it would be easy to
    verify if 0 is an effective solution.
    (# TODO: we might have introduced unwanted solutions when multiplied by x**-m)
    
    
    Note that some calculus also lead to infinite recursion.
    
    >>> sympy.solve(1/x,x)
    [...]
    <type 'exceptions.RuntimeError'>: maximum recursion depth exceeded
    
    
    I've patched my own sympy installation ; if I manage to find some time,
    I'll try to deal with all the git stuff to produce a proper sympy patch.
    

    Original issue for #4793: http://code.google.com/p/sympy/issues/detail?id=1694 Original author: https://code.google.com/u/117997262464115802198/ Referenced issues: #4871, #5117, #5016, #5086, #5091, #5226, #5035, #4463, #4464, #5171, #4922, #5098 Original owner: https://code.google.com/u/117997262464115802198/

    imported Bug Needs Review solvers 
    opened by wxgeo 180
  • Introduce rewrite rules

    Introduce rewrite rules

    This introduces basic rewrite rules and strategies to SymPy.

    It also uses these rewrite rules to refactor the MatrixExpressions module

    TODO

    1. ~~Rename as_factor_mul. Merge with as_coeff_mmul~~
    2. ~~rewrite linear_factors (uses a lot of Expr functionality)~~ I've removed this all-together. The definition isn't consistent. I'll work on this in a future PR. Currently only work in other branches of mine uses this sympy.stats.mvnrv
    3. MatMul/MatAdd don't simplify by default (maybe?) (I'm going to wait on this.)
    4. ~~simplification in MatMul/MatAdd doesn't have to traverse entire tree~~
    rr/rl.py         - some fundamental rules
    rr/strat_pure.py - strategies that have nothing to do with SymPy
    rr/traverse.py   - strategies that traverse a SymPy AST
    rr/strat.py      - some conglomerate strategies that do depend on SymPy
    

    matrices/expressions/mat(add/mul).py - Some rules written in normal python language and the use of strategies to combine those rules. Can we replace these by something higher level written in the SymPy language? If so what? These files provide examples of the sorts of rules we'll want to write. The rules are at the bottom matrices/expressions/blockmatrix.py -- I replaced block_collapse (a giant function) with rules. This is a good change but could have been done just as easily by adding methods to existing classes. This is a more aggressive example of using rules to program SymPy. It's rules-for-transformation rather than just rules-for-canonicalization.

    opened by mrocklin 178
  • Gsoc 3

    Gsoc 3

    This is my final pull request of GSOC code. I understand that the gsoc-2 pull request is still being reviewed (which makes this one look quite monstrous, with >80 commits..), but as suggested elsewhere I'm trying to submit all pull requests (i.e. this one) before the soft pencils down deadline. Also submitting this pull request is my pledge not to rebase the branch more often than absolutely necessary.

    The commits in this pull request can be separated roughly into three categories (and in principle I could submit separate pull requests for each of these, although I'm not sure if this is helpful):

    • new special functions (polylog, lerchphi, exponential integrals; with varying degree of support for integration)
    • general improvements to integration (neater output, more clever heurstics)
    • performance improvements

    Over the next few days I will go through and label all the commits (according to a consistent scheme to be come up with...) in order to make reviewing easier (which will of course mean rebasing...)

    opened by ness01 151
  • Added function to calculate Cauchy's principal value in sympy/integrals/integrals.py

    Added function to calculate Cauchy's principal value in sympy/integrals/integrals.py

    Added function cauchy_principal_value in sympy/integrals/integrals.py to implement calculation of Cauchy's principal value

    Took help (code) and reviews by @asmeurer in #14538

    Note : I found this PR (#14538) quite helpful, and since there wasn't any on-going activity for quite some time, I decided to take it up and fix the issues and also add the reviews given by @asmeurer in the original PR.

    Also, If required, I will add more tests and examples for the same.

    Please review this PR and give me a feedback. Thanks

    Release Notes

    • integrals
      • added method principal_value to class Integral to calculate Cauchy's principal value along with tests.
    opened by avishrivastava11 145
  • Unify

    Unify

    Add unification engine to SymPy.

    See http://matthewrocklin.com/blog/work/2012/11/01/Unification/

    opened by mrocklin 139
  • Issue 3275

    Issue 3275

    Application of qapply(Rotation(alpha,beta,gamma)*JzKet(1,1)) [define the symbols alpha beta and gamma](And these are dummy) would ask for the inputs of alpha,beta,gamma.The parameters used in calling the function must be used to in the method and this is not happening so I had to ask for the input.Is there anyway that I could get it working without the use of asking for input.The issue is not completely solved because the same method has to be written for every spin state.

    opened by amitjamadagni 138
  • [GSoC] Add TransferFunction, Series, Parallel and Feedback classes for control package

    [GSoC] Add TransferFunction, Series, Parallel and Feedback classes for control package

    References to other Issues or PRs

    Built upon #18436.

    Brief description of what is fixed or changed

    This PR adds a class for representing LTI systems in transfer function form.

    Other comments

    TODO:

    • [x] adding TransferFunction class along with its functionality.

    • [x] Rewrite unit-tests and make sure they pass.

    • [x] Adding documentation.

    Release Notes

    • physics.control
      • Add TransferFunction, Series, Parallel, and Feedback class for physics.control submodule
    GSoC physics.control 
    opened by namannimmo10 134
  • Solving solvable quintics: First implementation

    Solving solvable quintics: First implementation

    Please see this: http://code.google.com/p/sympy/issues/detail?id=3548

    Also, see this: https://groups.google.com/forum/?fromgroups=#!topic/sympy/xXyiOUWH0SU

    According to the discussions on above links, this PR introduces solving quintics exactly (not numerically) when they are solvable.

    There are a lot of constants involved. So, I created a new file and made a new class for quintics containing required constants. Also note that solving quintics exactly takes( for x5 + 15*x +12 =0 ) ~ 40 secs. The long time is attributed to solving five equations of the form x5 - R =0 somewhere in the middle of the code.

    Also, I have used simplify a few times. It seems that the code became almost 3 times as fast with using simplify, than without it.

    There is an extra flag; quintics. When set to true, the new roots_quintic method is called and if the quintic is solvable, the solution is returned. I am attaching a screenshot : sympy

    Here you can see the solution of x*_5 + 15_x +12 = 0.

    I have not added any tests. @asmeurer Please look at the code. Let me know for changes required.

    opened by prasoon2211 131
  • Proof of concept for the new assumptions

    Proof of concept for the new assumptions

    Here is a proof of concept of how I think the new assumptions should be done, as per https://code.google.com/p/sympy/issues/detail?id=3929. Take a read of the commit messages. The basic idea is that instead of writing handlers that look for expressions like Q.zero(x*y) and return new expressions that it knows are true like Q.zero(x) and Q.zero(y), the handler system returns a set of predicate statements, and everything is done using satisfiable(). This not only makes things cleaner, and gives us a single point of contact to make the assumptions faster (the dpll algorithm), it also allows computing things that are impossible to do under the current handler system. For instance

    >>> from sympy.assumptions.newask import newask
    >>> newask(Q.zero(x) | Q.zero(y), Q.zero(x*y))
    True
    >>> newask(Implies(Q.zero(x), Q.zero(x*y)))
    True
    >>> newask(Q.zero(x) | Q.zero(y), Q.nonzero(x*y))
    False
    >>> ask(Q.zero(x) | Q.zero(y), Q.zero(x*y))
    >>> ask(Implies(Q.zero(x), Q.zero(x*y)))
    >>> ask(Q.zero(x) | Q.zero(y), Q.nonzero(x*y))
    

    It's impossible to write a handler that says "x is zero or y is zero, but we don't know which one".

    I would like some feedback at this point. This code is completely proof of concept. The API is terrible (basically nonexistant). What I've got now is completely unscalable. It already is getting out of hand, and I've only got four assumptions, real, positive, zero, and nonzero.

    I've completely ignored the existing ask() code, because I didn't want to spend a lot of time at this point trying to understand it (it's quite complicated), so I basically wrote the prototype from scratch. Even so, it's quite simple, and I think once you grok how the satisfiable bit works, it is easy to understand the rest.

    So my biggest questions now are, do people like this idea? Do you foresee any major issues with it? Most importantly, what would be a good way to organize the new-style "handlers" (relevant fact extraction) so that it is scalable, extensible, and readable?

    Update: newask has been changed to satask

    assumptions 
    opened by asmeurer 128
  • Ideas to introduce indexed objects (possibly representing tensors)

    Ideas to introduce indexed objects (possibly representing tensors)

    Hi there! I'm currently writing a system of indexed n-dimensional arrays and valued tensors.

    BUGS AND ISSUES:

    • [ ] put more comments about the code.
    • [ ] create TensorIndexType.from_data( ) / TensorIndexType.from_symmetry( ) methods.
    • [x] missing tests for .applyfunc on TensExpr.
    • [x] create .strip( )
    • [x] test .strip( )
    • [ ] repeat all of Pernici's tests on valued tensors as well (or maybe not really all of them).
    • [ ] mark all autodrop points with comments.
    • [x] check that MultiArray never replaces TensorSymmetry in all objects' args.
    • [x] MultiArray shall never autodrop.
    • [ ] test many NumericIndices on the same tensor.
    • [x] create tests with non-diagonal metric.
    • [ ] create tests for MultiArray of rank zero.
    • [ ] correct args in TensMul, and everywhere else
    • [ ] remove @XFAIL from core tests.
    • [x] NumericContravariant and NumericCovariant: only int indices
    • [ ] Decide if NumericContravariant and NumericCovariant are to be subclasses of Basic.
    • [x] direct_sum in MultiArray
    • [x] create tests for direct_sum
    • [ ] direct sum of tensors
    • [ ] tensor product of tensor indices (and method on tensors as well).
    • [ ] check args in TensorIndexType and TensorIndex
    • [ ] check args in valued TensorIndexType
    • [ ] generator MultiArray.create( … ) for rank 0 ?
    • [ ] extend MultiArray to higher rank?
    • [ ] Why in TensorHead isn't comm passed to Basic's constructor?
    • [ ] more control for wrong data in constructors.
    • [ ] test type( … *args ) in NumericContravariant
    • [ ] construct new data from self.args and check equality and hash compatibility with original data.
    • [ ] find all TODO and solve the problems
    • [ ] remove all TODO
    • [ ] should MultiArray be renamed NDArray or something else?
    • [ ] can we inspect numpy's code for their implementation of nDarrays, and import some features here?
    opened by Upabjojr 127
  • evalf unintentionally creates Tuple with None as argument

    evalf unintentionally creates Tuple with None as argument

    In terms.count the terms get converted to Tuple during the comparison with S.ComplexInfinity but it will contain None as arguments https://github.com/sympy/sympy/blob/ed0bfd1e47345c8bd45ef542eef18f6a21c55685/sympy/core/evalf.py#L599-L604 I believe this can be resolved with

    n = sum([term.count(S.ComplexInfinity) for term in terms])
    

    to avoid the creation of Tuples.

    opened by ThePauliPrinciple 0
  • core/containters: fixes typo in Dict that causes non-Basic arguments

    core/containters: fixes typo in Dict that causes non-Basic arguments

    References to other Issues or PRs

    Fixes #22579

    Brief description of what is fixed or changed

    Currently Dict stores its key,value pairs inside a frozenset which is not a Basic, so should not be stored in _args. Note that args already provides the correct interface, so this behaviour might be acceptable.

    Other comments

    Release Notes

    NO ENTRY

    opened by ThePauliPrinciple 1
  • Dict storing key,value pairs as non-Basic

    Dict storing key,value pairs as non-Basic

    Currently, Dict stores its key,value pairs as frozenset. I believe this might be a typo: https://github.com/sympy/sympy/blob/ed0bfd1e47345c8bd45ef542eef18f6a21c55685/sympy/core/containers.py#L227-L238 line 235 should probably read:

            obj = Basic.__new__(cls, *elements)
    

    Although it might be intended for efficiency reasons.

    opened by ThePauliPrinciple 0
  • `Add` is doing term sorting when `evaluate=False`

    `Add` is doing term sorting when `evaluate=False`

    While trying to help on this SO question, I came across a problem. Add rearranges terms and I can't find a way to stop it.

    According to the docs: https://github.com/sympy/sympy/blob/681d5c6431c961cfe3b3a91d7086a3236ba39238/sympy/core/add.py#L100-L113

    But the following all produce x + y + 2 or 2 + x + y:

    from sympy import *
    from sympy.core.add import _unevaluated_Add
    
    x, y = symbols("x y")
    print(Add(y, x, 2))
    print(Add(y, x, 2, evaluate=False))
    with evaluate(False): print(Add(y, x, 2))
    print(_unevaluated_Add(y, x, S(2)))
    print(Add(UnevaluatedExpr(y), UnevaluatedExpr(x), UnevaluatedExpr(2)))
    print(Add(UnevaluatedExpr(y), UnevaluatedExpr(x), UnevaluatedExpr(2), evaluate=False))
    

    Desired output: at least one should print y + x + 2

    core printing 
    opened by Maelstrom6 3
  • Improved time for generating truth tables in simplify_logic

    Improved time for generating truth tables in simplify_logic

    References to other Issues or PRs

    Brief description of what is fixed or changed

    simplify_logic is faster by improving the truth table generation.

    The largest test, test_issue_14700 takes about 2.5 s to execute on my computer. With this it takes about 0.5 s.

    Other comments

    I also added a bit of code from #17330 which replaces e.g. x < 0 and x >= 0 with a single variable (one is not the other). This primarily helps avoiding an issue where one of them may become rewritten to the other under certain circumstances and then the sequential replacement as is done here may miss one of them. This also gives an additional benefit of automatically simplifying expressions like Or(x < 0, x >= 0) without relying on the pattern-based simplification and that the limit of eight variables is enforced a bit more rarely (earlier these were two variables, now one).

    Release Notes

    • logic
      • simplify_logic is faster.
    logic Performance 
    opened by oscargus 3
  • Inner/dot product of N-dim array

    Inner/dot product of N-dim array

    I searched and I found no equivalent for numpy.dot using sp.tensor.ImmutableDenseNDimArray, and I think it could be useful.

    There's already a dot for sympy.matrices.dense.MutableDenseMatrix, but everything is a matrix (rank = 2): vectors are treated as (n, 1) matrix.

    import sympy
    from sympy.abc import x, y, z
    
    def dot(A, B):
        A = sympy.sympify(A)
        B = sympy.sympify(B)
        rankA = A.rank()
        C = sympy.tensorproduct(A, B)
        return sympy.tensorcontraction(C, (rankA-1, rankA))
      
    A = sympy.Array([[1, 2, 3],
                     [4, 5, 6],
                     [7, 8, 9]])
    B = sympy.Array([x, y, z])
    C = dot(A, B)
    
    print(f"type = {type(C)}")
    print(f"rank = {C.rank()}")
    print(C)
    

    gives the output

    type = <class 'sympy.tensor.array.dense_ndim_array.ImmutableDenseNDimArray'>
    rank = 1
    [x + 2*y + 3*z, 4*x + 5*y + 6*z, 7*x + 8*y + 9*z]
    
    opened by carlos-adir 1
  • warning shows through during testing in geometry

    warning shows through during testing in geometry

    test_point() emits a warning even though it is in a with warns(UserWarning); block. Is this right?

    sympy\geometry\tests\test_point.py[12] \sympy\geometry\point.py:148: UserWarning: Dimension of (0, 0) needs to be changed from 2 to 3.
      warnings.warn(message)
    ............                        [OK]
    

    the test line is

        with warns(UserWarning):
            assert Point.is_collinear(p3, Point(p3, dim=4))
    
    opened by smichr 4
  • Min/Max now supports sets as argument

    Min/Max now supports sets as argument

    References to other Issues or PRs

    Closes #22568

    Brief description of what is fixed or changed

    It is now possible to use sets as arguments to Max and Min. I needed a way to write something like

    Max(imageset(Lambda(x, f(x), Range(J))

    and later on replace J with an integer.

    Although this is not yet supported as it doesn't seem possible to convert Range to FiniteSet at will, see #22571, it is a step in the right direction.

    Other comments

    Release Notes

    • functions
      • Max and Min now accept Set arguments.
    sets functions 
    opened by oscargus 4
  • Converting Range to FiniteSet?

    Converting Range to FiniteSet?

    Is it possible to convert a Range to a FiniteSet? If not, what would a suitable way be to do that, i.e., how should it be done?

    For example, an ImageSet will evaluate for a FiniteSet, but not for a (finite) Range.

    In [26]: imageset(Lambda(x, x**2), Range(2))
    Out[26]: 
    ⎧ 2 │           ⎫
    ⎨x  │ x ∊ {0, 1}⎬
    ⎩   │           ⎭
    
    In [27]: imageset(Lambda(x, x**2), FiniteSet(0, 1))
    Out[27]: {0, 1}
    

    Swapping these two if-statements (and making Range identify itself as a FiniteSet if it is iterable) works, but will also lead to that any Set operations with Range will result in a FiniteSet and these do not compare identically (although there may be a better way to do comparisons, but it is also quite convenient to keep a Range as a Range in some situations). https://github.com/sympy/sympy/blob/c551272cdda6220c9fa237fa8b74dc56fd71875a/sympy/sets/fancysets.py#L497-L501

    sets 
    opened by oscargus 6
  • Matrix(1, 1) should be treated as scalar

    Matrix(1, 1) should be treated as scalar

    Expected behavior: Any expression that returns a Matrix(1,1) should automatically return a scalar instead.

    Current behavior: Since a Matrix(1, 1) is not converted into a scalar, some expressions fail, like

    x = Matrix([1, 2, 3])
    
    1 / (x.T * x)
    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    <ipython-input-4-bfd55195e184> in <module>
    ----> 1 1/(x.T * x)
    
    TypeError: unsupported operand type(s) for /: 'int' and 'MutableDenseMatrix'
    
    opened by HDembinski 4
Releases(sympy-1.9)
Owner
SymPy
Symbolic manipulation in Python.
SymPy
Graphic notes on Gilbert Strang's "Linear Algebra for Everyone"

Graphic notes on Gilbert Strang's "Linear Algebra for Everyone"

Kenji Hiranabe 935 Nov 29, 2021
collection of interesting Computer Science resources

collection of interesting Computer Science resources

Kirill Bobyrev 54 Dec 4, 2021
Algorithms covered in the Bioinformatics Course part of the Cambridge Computer Science Tripos

Bioinformatics This is a repository of all the algorithms covered in the Bioinformatics Course part of the Cambridge Computer Science Tripos Algorithm

null 11 Nov 18, 2021
ckan 3.2k Nov 28, 2021
3D visualization of scientific data in Python

Mayavi: 3D visualization of scientific data in Python Mayavi docs: http://docs.enthought.com/mayavi/mayavi/ TVTK docs: http://docs.enthought.com/mayav

Enthought, Inc. 941 Dec 2, 2021
Datamol is a python library to work with molecules

Datamol is a python library to work with molecules. It's a layer built on top of RDKit and aims to be as light as possible.

datamol 101 Nov 16, 2021
Incubator for useful bioinformatics code, primarily in Python and R

Collection of useful code related to biological analysis. Much of this is discussed with examples at Blue collar bioinformatics. All code, images and

Brad Chapman 527 Nov 30, 2021
Karate Club: An API Oriented Open-source Python Framework for Unsupervised Learning on Graphs (CIKM 2020)

Karate Club is an unsupervised machine learning extension library for NetworkX. Please look at the Documentation, relevant Paper, Promo Video, and Ext

Benedek Rozemberczki 1.4k Nov 23, 2021
Probabilistic Programming in Python: Bayesian Modeling and Probabilistic Machine Learning with Aesara

PyMC3 is a Python package for Bayesian statistical modeling and Probabilistic Machine Learning focusing on advanced Markov chain Monte Carlo (MCMC) an

PyMC 6.2k Nov 24, 2021
Statsmodels: statistical modeling and econometrics in Python

About statsmodels statsmodels is a Python package that provides a complement to scipy for statistical computations including descriptive statistics an

statsmodels 6.9k Dec 4, 2021
Kedro is an open-source Python framework for creating reproducible, maintainable and modular data science code

A Python framework for creating reproducible, maintainable and modular data science code.

QuantumBlack Labs 4.7k Dec 3, 2021
PennyLane is a cross-platform Python library for differentiable programming of quantum computers.

PennyLane is a cross-platform Python library for differentiable programming of quantum computers. Train a quantum computer the same way as a neural network.

PennyLaneAI 1.1k Nov 29, 2021
SCICO is a Python package for solving the inverse problems that arise in scientific imaging applications.

Scientific Computational Imaging COde (SCICO) SCICO is a Python package for solving the inverse problems that arise in scientific imaging applications

Los Alamos National Laboratory 7 Nov 25, 2021
Efficient Python Tricks and Tools for Data Scientists

Why efficient Python? Because using Python more efficiently will make your code more readable and run more efficiently.

Khuyen Tran 247 Nov 23, 2021
Float2Binary - A simple python class which finds the binary representation of a floating-point number.

Float2Binary A simple python class which finds the binary representation of a floating-point number. You can find a class in IEEE754.py file with the

Bora Canbula 3 Nov 11, 2021
A computer algebra system written in pure Python

SymPy See the AUTHORS file for the list of authors. And many more people helped on the SymPy mailing list, reported bugs, helped organize SymPy's part

SymPy 8.6k Nov 30, 2021
Mathics is a general-purpose computer algebra system (CAS). It is an open-source alternative to Mathematica

Mathics is a general-purpose computer algebra system (CAS). It is an open-source alternative to Mathematica. It is free both as in "free beer" and as in "freedom".

Mathics 51 Nov 26, 2021
Pure Python bindings for the pure C++11/OpenCL Qrack quantum computer simulator library

pyqrack Pure Python bindings for the pure C++11/OpenCL Qrack quantum computer simulator library (PyQrack is just pure Qrack.) IMPORTANT: You must buil

vm6502q 4 Nov 25, 2021
PyArmadillo: an alternative approach to linear algebra in Python

PyArmadillo is a linear algebra library for the Python language, with an emphasis on ease of use.

Terry Zhuo 60 Nov 17, 2021
The goal of this library is to generate more helpful exception messages for numpy/pytorch matrix algebra expressions.

Tensor Sensor See article Clarifying exceptions and visualizing tensor operations in deep learning code. One of the biggest challenges when writing co

Terence Parr 604 Nov 20, 2021
Visualizations of linear algebra algorithms for people who want a deep understanding

Visualising algorithms on symmetric matrices Examples QR algorithm and LR algorithm Here, we have a GIF animation of an interactive visualisation of t

ogogmad 4 Aug 11, 2021
Graphic notes on Gilbert Strang's "Linear Algebra for Everyone"

Graphic notes on Gilbert Strang's "Linear Algebra for Everyone"

Kenji Hiranabe 935 Nov 29, 2021
Geometric Algebra package for JAX

JAXGA - JAX Geometric Algebra GitHub | Docs JAXGA is a Geometric Algebra package on top of JAX. It can handle high dimensional algebras by storing onl

Robin Kahlow 3 Nov 6, 2021
pure-predict: Machine learning prediction in pure Python

pure-predict speeds up and slims down machine learning prediction applications. It is a foundational tool for serverless inference or small batch prediction with popular machine learning frameworks like scikit-learn and fasttext. It implements the predict methods of these frameworks in pure Python.

Ibotta 60 Nov 15, 2021
Educational python for Neural Networks, written in pure Python/NumPy.

Educational python for Neural Networks, written in pure Python/NumPy.

null 114 Nov 14, 2021
An kind of operating system portal to a variety of apps with pure python

pyos An kind of operating system portal to a variety of apps. Installation Run this on your terminal: git clone https://github.com/arjunj132/pyos.git

null 1 Dec 4, 2021
The free and open-source Download Manager written in pure Python

The free and open-source Download Manager written in pure Python

pyLoad 2.4k Dec 1, 2021
User-friendly, tiny source code searcher written by pure Python.

User-friendly, tiny source code searcher written in pure Python. Example Usages Cat is equivalent in the regular expression as '^Cat$' bor class Cat

Furkan Onder 98 Nov 18, 2021
A very simple Editor.js parser written in pure Python

pyEditor.js A very simple Editor.js parser written in pure Python. Soon-to-be published on PyPI. Features: Automatically convert Editor.js's JSON outp

Kevo 3 Nov 6, 2021