Am 16.02.2012 00:55, schrieb Kevin Hunter:
Further, the former is faster:
*In [11]: %timeit a.is_Relational*
*1000 loops, best of 3: 76.3 ns per loop*
*
*
*In [12]: %timeit isinstance(a, Relational)*
*100 loops, best of 3: 289 ns per loop*
Microbenchmark results are, in themselves,
On Sun, Feb 12, 2012 at 11:37 PM, Kevin Hunter hunt...@gmail.com wrote:
:-( Bummer. In this context, I regularly work with expressions with
thousands (sometimes tens of thousands) of variables. They aren't highly
nested, with most terms having less than 5 levels, but there are lots of
Hmm, have there been API changes recently? With your branch, I'm not able
to check an Equality expression for the attribute is_Relational:
* from sympy import **
* from sympy.abc import x, y*
* Eq(x, y).is_Relational*
*Traceback (most recent call last):*
* File stdin, line 1, in module*
Le mercredi 15 février 2012 à 14:25 -0800, Kevin Hunter a écrit :
Hmm, have there been API changes recently? With your branch, I'm not
able to check an Equality expression for the attribute is_Relational:
from sympy import *
from sympy.abc import x, y
Eq(x, y).is_Relational
Traceback
Even so, it works for me, both in master and in Chris's branch. So
either it was a problem and he fixed it, or you're doing something
wrong. Make sure you checkout is clean (git status), refetch his
branch, and try again.
Aaron Meurer
On Wed, Feb 15, 2012 at 4:04 PM, Ronan Lamy
Bah, thank you. I had checked out Chris' repository, but had forgotten to
change branches.
--
You received this message because you are subscribed to the Google Groups
sympy group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sympy/-/C-_1H8aPEDUJ.
To post to this
Can you expand on why? To me the former reads better, and elides the need
to specifically import the Relational class:
* x.is_Relational*
*True*
vs
* from sympy.core.relational import Relational*
* isinstance(x, Relational)' reads better to me than 'isinstance(x,
Relational)*
Further, the
Excellent! For my simple test case, this now no longer goes over the 1000
recursion limit.
As an FYI, with your change, my models using Sympy now only use 45 levels
of recursion. (As tested by the if it broke test binary test.)
I really appreciate your work on this. Cheers!
--
You
Le mercredi 15 février 2012 à 15:55 -0800, Kevin Hunter a écrit :
Can you expand on why? To me the former reads better, and elides the
need to specifically import the Relational class:
There should be one-- and preferably only one --obvious way to do it.
.is_Relational is an ad-hoc
Hullo List,
I have a fairly small expression (~500 variables). When I create a
Relation with it, Python informs me that Sympy has exceeded the max
recursion depth. Is there an intentional limit to expression sizes in
Sympy?
Please find attached a mini-script that highlights the issue I'm
No, this is not intentional. Python sets the recursion limit to 1000,
to prevent infinit recursion from causing a stack overflow (in C).
Since many of our functions are highly recursive, we often run into
this limit.
You can raise it with sys.setrecursionlimit. I set it to 1 in
your script,
:-( Bummer. In this context, I regularly work with expressions with
thousands (sometimes tens of thousands) of variables. They aren't highly
nested, with most terms having less than 5 levels, but there are lots of
them.
Thanks for letting me know.
--
You received this message because you
In this particular case, it's determining if an Add is positive by
peeling off one term at a time (see line 440 of add.py), which I think
should be changed (not only is this needlessly recursive, but it's
also inefficient, because it recomputes Add.flatten each time, making
it a O(n**2)
Oh, so it's not that bad. Still, there's no reason why this has to be
implemented recursively. Not only will it avoid recursion error
problems, but it will be faster if it's written non-recursively, as
function calls in Python are somewhat expensive.
For example, look at the speedup I had
This particular bug should be fixable (see my previous emails). If
this function is rewritten to be non-recursive, it will be one
function call, no matter how big the expression is. As long as you
aren't using the polys, tons of variables shouldn't be a big problem.
Aaron Meurer
On Sun, Feb 12,
15 matches
Mail list logo