inverse_real use

44 views
Skip to first unread message

Gaurav Dhingra

unread,
Jun 24, 2015, 4:33:34 AM6/24/15
to sy...@googlegroups.com
Hi all

My first question is:
I was looking at the code base of solveset.py and test_solveset.py. I found that on lines https://github.com/sympy/sympy/blob/master/sympy/solvers/tests/test_solveset.py#L39-L40 
. Here why do we have consecutive declaration of `x`. I am not sure if that make any difference to use both of these lines.

I think first line can be removed without affecting the other ?

Second question is:

On the line https://github.com/sympy/sympy/blob/master/sympy/solvers/tests/test_solveset.py#L60 . Why have we allowed the inversion, i mean
here `y` is just a `Symbol` with no assumptions like `positive=True, real=True` 

>>> x = Symbol('x', real=True)
>>> y = Symbol('y', real=True)
>>> inverse_real(Abs(x), y, x)
(x, FiniteSet(-y, y)) # this is what it returns currently
# i think it should be returned as it is.

>>> y = Symbol('y', real=True, positive=True)
>>> inverse_real(Abs(x), y, x)
(x, FiniteSet(-y, y ))          # currently this is returned which i think is correct


Correct me if am wrong in my thinking at this point.


Gaurav

Aaron Meurer

unread,
Jun 24, 2015, 12:18:48 PM6/24/15
to sy...@googlegroups.com
On Wed, Jun 24, 2015 at 3:33 AM, Gaurav Dhingra <axyd...@gmail.com> wrote:
> Hi all
>
> My first question is:
> I was looking at the code base of solveset.py and test_solveset.py. I found
> that on lines
> https://github.com/sympy/sympy/blob/master/sympy/solvers/tests/test_solveset.py#L39-L40
> . Here why do we have consecutive declaration of `x`. I am not sure if that
> make any difference to use both of these lines.

Looks like a bug.

I see another definition of x at the bottom of the function too. You
might try to figure out from the git history whether the first line
was intended or the second.

Aaron Meurer

>
> I think first line can be removed without affecting the other ?
>
> Second question is:
>
> On the line
> https://github.com/sympy/sympy/blob/master/sympy/solvers/tests/test_solveset.py#L60
> . Why have we allowed the inversion, i mean
> here `y` is just a `Symbol` with no assumptions like `positive=True,
> real=True`
>
>>>> x = Symbol('x', real=True)
>>>> y = Symbol('y', real=True)
>>>> inverse_real(Abs(x), y, x)
> (x, FiniteSet(-y, y)) # this is what it returns currently
> # i think it should be returned as it is.
>
>>>> y = Symbol('y', real=True, positive=True)
>>>> inverse_real(Abs(x), y, x)
> (x, FiniteSet(-y, y )) # currently this is returned which i think
> is correct
>
>
> Correct me if am wrong in my thinking at this point.
>
>
> Gaurav
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/69b79a09-bb4d-4f28-814f-3bd09a6864d6%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Harsh Gupta

unread,
Jun 24, 2015, 6:35:07 PM6/24/15
to sy...@googlegroups.com
Good catch, the first line (L39) is redundant, it should be removed.
The second question you raised is also valid and this is a bug. Also
please @mention me on the PRs on solveset, because the volume of
activity on sympy's github I've unwatched the repo and I don't get
notified for all the PR's.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAKgW%3D6L_%2B-Vj0MwbUwz6jfaFAZ-rFfu%2B%3DhtQEdY9kmNmA8iOtA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



--
Harsh

Gaurav Dhingra

unread,
Jun 25, 2015, 12:16:35 AM6/25/15
to sy...@googlegroups.com
Probably i also come to one more question i am having from a long time.(which is related to this)
How can i create symbols with assumptions like 
y = Symbol('y', where y > 3)    ? How is this done ?
though i can create `y = Symbol('y', positive=True)` (i.e. y > 0)

This is related to the invert_real as `invert_real(exp(x) + 3, y, x)` so unless we have such like `y > 3` defining, this bug will be difficult to solve, i guess.  
Though since i was working on some other PR on https://github.com/sympy/sympy/pull/9570  . I probably hope to try to fix that in that PR commit's. 

Gaurav Dhingra

unread,
Jun 25, 2015, 12:29:28 AM6/25/15
to sy...@googlegroups.com
Now i think more about it. It's better to have a new PR for that.  This is the issue link (https://github.com/sympy/sympy/issues/9571) it will be better if you could answer the new third question on the issue itself.

Thanks 
Gaurav

On Thursday, June 25, 2015 at 4:05:07 AM UTC+5:30, Harsh Gupta wrote:
Reply all
Reply to author
Forward
0 new messages