Re: [sympy] RFC: Context manager for new assumptions

2013-02-04 Thread Anton Loukianov
Hi, I think I found an elegant and relevant solution in Werkzeug ( http://werkzeug.pocoo.org/) sources. Specifically look here: https://github.com/mitsuhiko/werkzeug/blob/master/werkzeug/local.py They have a stack object that represents context. When something is placed on this stack and then a

Re: [sympy] RFC: Context manager for new assumptions

2013-02-04 Thread Aaron Meurer
Don't worry, we always test everything in python 2.5. So far the only issue I've noticed is that with statements can't be in doctests. And if it becomes a burden, that will be the perfect excuse to drop 2.5 support. Aaron Meurer On Feb 4, 2013, at 11:51 AM, Joachim Durchholz wrote: > Am 04.02.

Re: [sympy] RFC: Context manager for new assumptions

2013-02-04 Thread Sergiu Ivanov
On Mon, Feb 04, 2013 at 10:54:53AM -0700, Aaron Meurer wrote: > On Feb 4, 2013, at 8:29 AM, Sergiu Ivanov wrote: > > > Also, thank you for the blog post: I have finally got the clear idea > > of the difference between old and new assumption systems. > > The blog post omitted a key difference bet

Re: [sympy] RFC: Context manager for new assumptions

2013-02-04 Thread Joachim Durchholz
Am 04.02.2013 01:28, schrieb Matthew Rocklin: I would like to introduce a context managerfor new assumptions. Just a heads-up: Make sure it works with Python 2.5 before coding up too much. Context managers were introduced in 2.5 I think, and I

Re: [sympy] RFC: Context manager for new assumptions

2013-02-04 Thread Matthew Rocklin
In the SO question `z` is an assumptions context. I want to take the assumptions context from the caller, potentially modify it, use it, and then forget the changes when I give back control. On Mon, Feb 4, 2013 at 10:36 AM, Ronan Lamy wrote: > Le 04/02/2013 17:44, Matthew Rocklin a écrit : > >

Re: [sympy] RFC: Context manager for new assumptions

2013-02-04 Thread Ronan Lamy
Le 04/02/2013 17:44, Matthew Rocklin a écrit : I've asked a simpler version of the problem on stack overflow http://stackoverflow.com/questions/14692071/sharing-scope-in-python-between-called-and-calling-functions I don't understand the relevance of your question. As I see it, the problem here

Re: [sympy] RFC: Context manager for new assumptions

2013-02-04 Thread Aaron Meurer
On Feb 4, 2013, at 8:29 AM, Sergiu Ivanov wrote: > Hello, > > On Sun, Feb 03, 2013 at 04:28:17PM -0800, Matthew Rocklin wrote: >> >> I would like to introduce a context >> managerfor new >> assumptions. I suggest the following syntax >> > fac

Re: [sympy] RFC: Context manager for new assumptions

2013-02-04 Thread Matthew Rocklin
I've asked a simpler version of the problem on stack overflow http://stackoverflow.com/questions/14692071/sharing-scope-in-python-between-called-and-calling-functions On Mon, Feb 4, 2013 at 8:57 AM, Matthew Rocklin wrote: > > > True. In the common case global_assumptions is empty but this woul

Re: [sympy] RFC: Context manager for new assumptions

2013-02-04 Thread Matthew Rocklin
> > True. In the common case global_assumptions is empty but this would > become > > more complex if we choose to inject assumptions on symbol creation. I > > suppose the context manager solution also wouldn't work in a nested setup > > with negations. > > I didn't even think about symbol creatio

Re: [sympy] RFC: Context manager for new assumptions

2013-02-04 Thread Sergiu Ivanov
Hello, On Sun, Feb 03, 2013 at 04:28:17PM -0800, Matthew Rocklin wrote: > > I would like to introduce a context > managerfor new > assumptions. I suggest the following syntax > > >>> facts = Q.positive(x), Q.positive(y) > > >>> with assuming(*fa

Re: [sympy] RFC: Context manager for new assumptions

2013-02-04 Thread Sergiu Ivanov
Hello, On Sun, Feb 03, 2013 at 04:28:17PM -0800, Matthew Rocklin wrote: > > I would like to introduce a context > managerfor new > assumptions. I suggest the following syntax > > >>> facts = Q.positive(x), Q.positive(y) > > >>> with assuming(*fa

Re: [sympy] RFC: Context manager for new assumptions

2013-02-04 Thread Aaron Meurer
On Mon, Feb 4, 2013 at 1:09 AM, Matthew Rocklin wrote: > > On Sun, Feb 3, 2013 at 9:32 PM, Aaron Meurer wrote: >> >> One limitation of your context manager the way it is now is that it >> only lets you add assumptions in the context, not remove them. So if >> you wanted to assume globally that x

Re: [sympy] RFC: Context manager for new assumptions

2013-02-04 Thread Matthew Rocklin
On Sun, Feb 3, 2013 at 9:32 PM, Aaron Meurer wrote: > One limitation of your context manager the way it is now is that it > only lets you add assumptions in the context, not remove them. So if > you wanted to assume globally that x is positive, but then forget it > for a little bit, you can't ve