Re: [sympy] sympy on Jython?

189 views
Skip to first unread message

Ronan Lamy

unread,
Feb 5, 2013, 7:10:51 PM2/5/13
to sy...@googlegroups.com
Le 05/02/2013 21:08, Bill Janssen a �crit :
> Any hope for this? I just tried sympy (both 0.7.2 and the git trunk)
> with Jython 2.5.3 (the latest stable release), and I still get the
> "multiple bases" error, even though the dialog in the issues seems to
> indicate that fixes for this have been checked in...

AFAIK, all the problems mentioned in
http://code.google.com/p/sympy/issues/detail?id=1233 are still current,
sorry.

Aaron Meurer

unread,
Feb 5, 2013, 8:14:30 PM2/5/13
to sy...@googlegroups.com
For what it's worth, I wouldn't hold out much hope. Even if we can
make our classes agreeable to Jython (I guess it has something to do
with the way we use __slots__), there have already been two Jython
bugs that have come up, http://bugs.jython.org/issue1676 and
http://bugs.jython.org/issue1777. Both cause the Jython interpreter
to crash. One is from 2011 and the other from 2010. That and the
fact that Jython clearly doesn't support the same class semantics as
CPython leave me a bit cynical about it.

To contrast, we've found a handful of bugs in PyPy, and even a bug in
CPython from SymPy test failures, and in each case the bugs were fixed
right away after they were reported.

Of course, that isn't to say that we won't try, or that we don't
really want to bother getting Jython support. It's just that I don't
see much help coming from the Jython end, at least so far.

Aaron Meurer

On Tue, Feb 5, 2013 at 5:10 PM, Ronan Lamy <ronan...@gmail.com> wrote:
> --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Bill Janssen

unread,
Feb 6, 2013, 12:30:52 PM2/6/13
to sy...@googlegroups.com
Aaron, if your "branch is merged now" (as per Jython bug 1777, on 9/28/2011), why do I get the same "multiple bases" error?  I'm just trying to figure out what the truth of the progress is...

Bill

Aaron Meurer

unread,
Feb 6, 2013, 8:09:42 PM2/6/13
to sy...@googlegroups.com
You're right, it did work. I had only checked the releases, and they
were still broken. But it imports in commit
8abc1caf5eba6273e6b802aa73acd68284960a08. I bisected it not working
again to

commit 9a11265af013bff83f469aa62407267c6d148457
Author: Ronan Lamy <Ronan...@normalesup.org>
Date: Mon Mar 19 03:42:16 2012 +0000

Remove AssumeMixin.

This allows us to get rid of some tricky magic in
ManagedProperties.

Note that AssumeMixin was the original class that we conditionally
didn't define __slots__ in Jython with.

That doesn't really show me an obvious path to make it work again.
Maybe Ronan has an idea.

Aaron Meurer

Ronan Lamy

unread,
Feb 6, 2013, 8:21:55 PM2/6/13
to sy...@googlegroups.com
Le 07/02/2013 01:09, Aaron Meurer a �crit :
> You're right, it did work. I had only checked the releases, and they
> were still broken. But it imports in commit
> 8abc1caf5eba6273e6b802aa73acd68284960a08. I bisected it not working
> again to
>
> commit 9a11265af013bff83f469aa62407267c6d148457
> Author: Ronan Lamy <Ronan...@normalesup.org>
> Date: Mon Mar 19 03:42:16 2012 +0000
>
> Remove AssumeMixin.
>
> This allows us to get rid of some tricky magic in
> ManagedProperties.
>
> Note that AssumeMixin was the original class that we conditionally
> didn't define __slots__ in Jython with.
>
> That doesn't really show me an obvious path to make it work again.
> Maybe Ronan has an idea.

Removing the __slots__ declaration in Basic gets rid of the metaclass
thing, but then it dies with:
...
File "sympy/core/compatibility.py", line 740, in ordered
d.pop(k)
java.lang.NullPointerException
...

which is caused by Jython bug 1676, if I'm not mistaken.
I see it has just been fixed though, so maybe there's some hope after all?

Aaron Meurer

unread,
Feb 6, 2013, 9:07:24 PM2/6/13
to sy...@googlegroups.com
What version of Jython are you using? I get in 2.7a2

Traceback (most recent call last):
File "bin/isympy", line 345, in <module>
main()
File "bin/isympy", line 338, in main
from sympy.utilities.exceptions import SymPyDeprecationWarning
File "/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/__init__.py",
line 50, in <module>
from sympy.core import *
File "/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/__init__.py",
line 25, in <module>
from sets import (Set, Interval, Union, EmptySet, FiniteSet, ProductSet,
File "/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/sets.py",
line 10, in <module>
from sympy.assumptions import ask
File "/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/assumptions/__init__.py",
line 2, in <module>
from ask import Q, ask, register_handler, remove_handler
File "/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/assumptions/ask.py",
line 275, in <module>
known_facts = And(
File "/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/logic/boolalg.py",
line 18, in __and__
return And(self, other)
File "/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/operations.py",
line 429, in __new__
obj = super(AssocOp, cls).__new__(cls, _args)
File "/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/cache.py",
line 92, in wrapper
func_cache_it_cache[k] = r = func(*args, **kw_args)
File "/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/function.py",
line 122, in __new__
args = map(sympify, args)
File "/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/sympify.py",
line 218, in sympify
return sympify(coerce(a))
File "/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/sympify.py",
line 218, in sympify
return sympify(coerce(a))
File "/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/basic.py",
line 447, in __repr__
from sympy.printing import sstr
File "/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/printing/__init__.py",
line 3, in <module>
from pretty import pager_print, pretty, pretty_print, pprint, \
File "/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/printing/pretty/__init__.py",
line 3, in <module>
from pretty import (pretty, pretty_print, pprint, pprint_use_unicode,
File "/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/printing/pretty/pretty.py",
line 7, in <module>
from sympy.printing.printer import Printer
File "/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/printing/printer.py",
line 70, in <module>
from sympy import Basic, Add
ImportError: cannot import name Basic

I probably should have mentioned that before, but I figured this was
probably a manifestation of the same error somehow.

I'll see if I can build from source.

Aaron Meurer

On Wed, Feb 6, 2013 at 6:21 PM, Ronan Lamy <ronan...@gmail.com> wrote:

Ronan Lamy

unread,
Feb 6, 2013, 9:27:49 PM2/6/13
to sy...@googlegroups.com
Le 07/02/2013 02:07, Aaron Meurer a �crit :
> What version of Jython are you using?

2.5.2

> I get in 2.7a2
>
> Traceback (most recent call last):

> File "/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/sets.py",
> line 10, in <module>
> from sympy.assumptions import ask

Importing sympy.assumptions from inside the core looks rather dodgy.

> line 218, in sympify
> return sympify(coerce(a))
> File "/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/basic.py",
> line 447, in __repr__
> from sympy.printing import sstr

This is odd. It looks like float(a) (or perhaps int(a)) calls repr().
Jython bug?

> I probably should have mentioned that before, but I figured this was
> probably a manifestation of the same error somehow.

It doesn't look like the same thing to me.

> I'll see if I can build from source.
>
> Aaron Meurer
>
> On Wed, Feb 6, 2013 at 6:21 PM, Ronan Lamy <ronan...@gmail.com> wrote:
>> Le 07/02/2013 01:09, Aaron Meurer a �crit :

Aaron Meurer

unread,
Feb 6, 2013, 9:40:20 PM2/6/13
to sy...@googlegroups.com
On Wed, Feb 6, 2013 at 7:27 PM, Ronan Lamy <ronan...@gmail.com> wrote:
> Le 07/02/2013 02:07, Aaron Meurer a écrit :
>
>> What version of Jython are you using?
>
>
> 2.5.2
>
>
>> I get in 2.7a2
>>
>> Traceback (most recent call last):
>
>
>> File
>> "/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/sets.py",
>> line 10, in <module>
>> from sympy.assumptions import ask
>
>
> Importing sympy.assumptions from inside the core looks rather dodgy.
>
>
>> line 218, in sympify
>> return sympify(coerce(a))
>> File
>> "/Users/aaronmeurer/Documents/Python/sympy/sympy/sympy/core/basic.py",
>> line 447, in __repr__
>> from sympy.printing import sstr
>
>
> This is odd. It looks like float(a) (or perhaps int(a)) calls repr(). Jython
> bug?
>
>
>> I probably should have mentioned that before, but I figured this was
>> probably a manifestation of the same error somehow.
>
>
> It doesn't look like the same thing to me.

I vaguely remember such strange import errors (not being able to
import a class that should already be created) being related to this.

Anyway, I just built mercurial Jython, and it's the same traceback
(after removing Basic.__slots__; the metaclass thing is still there
too). I tried it on 8abc1caf5eba6273e6b802aa73acd68284960a08 to see
what would happen, and it imports. I'll run the tests to see what
fails, and also do a bisection to see what intermediate commit breaks
it.

Aaron Meurer

Aaron Meurer

unread,
Feb 6, 2013, 10:38:07 PM2/6/13
to sy...@googlegroups.com
If you're interested in technical details, we've been continuing the
discussion over at
http://code.google.com/p/sympy/issues/detail?id=1233. It looks like
every time we change the core class structure, it breaks Jython
(assuming it otherwise worked already). So even if we can get things
to a state where they work, it will likely break again the next time
we slightly refactor the core, or if we require Jython tests to pass,
it will make refactoring the core a pita.

Also, it looks like http://bugs.jython.org/issue1676 was fixed, but
http://bugs.jython.org/issue1777 is still reproducible in the latest
Jython hg. I can't say for sure if that will be a direct issue for us
still or not, though. We are still trying to get Jython to import the
git master sympy.

Aaron Meurer

Bill Janssen

unread,
Feb 8, 2013, 1:49:03 PM2/8/13
to sy...@googlegroups.com
Looks like you're making some progress.  Yay!
Reply all
Reply to author
Forward
0 new messages