Quantcast
Channel: Keep the gradient flowing
Viewing all articles
Browse latest Browse all 195

Query module - finally in trunk

$
0
0

The query module is finally in the main SymPy repository. I made substantial changes since last post, most of them at the user interface level (thanks to Vinzent and Mateusz for many insightful comments). Main function is ask(), which replaces the old expression.is_* syntax. You can ask many things. For example, you can ask if a given expression is integer, prime or real: [cc lang="python"] >>> ask(2, Q.integer) True >>> ask(x**2, Q.integer) None >>> ask(x**2, Q.integer, Assume(x, Q.integer)) True >>> ask(sqrt(2)*x, Q.integer, Assume(x, Q.integer)) >>> ask(I*x, Q.real, Assume(x, Q.imaginary)) True >>> ask(x*y, Q.prime, Assume(x, Q.prime) & Assume(y, Q.prime)) False [/cc] as you see, it returns True when it is sure that the expression is an integer, None if it does not know, and False if it is certainly not an integer. The second argument, which we will call 'key' specifies what we want to ask about. For example, Q.integer ask wether expression is an integer, Q.negative wether it's a negative, etc. For a complete list of all the keys available, see doc/src/modules/queries.txt in sympy codebase. It also accepts an optional third argument where you can specify assumptions that symbols in expr satisfy. That can be any kind of boolean expression involving assumptions, for example: Assume(x, Q.positive) & Assume(x, Q.integer) or Assume(x, Q.positive) | Assume(x, Q.negative), or even NAnd(Assume(x, Q.positive), Assume(x, Q.integer)


Viewing all articles
Browse latest Browse all 195

Trending Articles


Girasoles para colorear


mayabang Quotes, Torpe Quotes, tanga Quotes


Tagalog Quotes About Crush – Tagalog Love Quotes


OFW quotes : Pinoy Tagalog Quotes


Long Distance Relationship Tagalog Love Quotes


Tagalog Quotes To Move on and More Love Love Love Quotes


5 Tagalog Relationship Rules


Best Crush Tagalog Quotes And Sayings 2017


Re:Mutton Pies (lleechef)


FORECLOSURE OF REAL ESTATE MORTGAGE


Sapos para colorear


tagalog love Quotes – Tiwala Quotes


Break up Quotes Tagalog Love Quote – Broken Hearted Quotes Tagalog


Patama Quotes : Tagalog Inspirational Quotes


Pamatay na Banat and Mga Patama Love Quotes


Tagalog Long Distance Relationship Love Quotes


BARKADA TAGALOG QUOTES


“BAHAY KUBO HUGOT”


Vimeo 10.7.0 by Vimeo.com, Inc.


Vimeo 10.7.1 by Vimeo.com, Inc.