Set_PythonType : sage/schemes and maxima

24 views
Skip to first unread message

vdelecroix

unread,
Jan 18, 2013, 4:22:43 AM1/18/13
to sage-devel
Hi,

I am working on #10962 about pickling of Set_PythonType (in sage/
structure/parent.pyx). I added a fast check in the constructor to
verifies that the argument is a <type 'type'> and not something
else... it causes two errors. The first one occurs in sage/schemes as
in
{{{
sage: P2.<x,y,z> = toric_varieties.P2()
sage: cuspidal_curve = P2.subscheme([y^2*z-x^3])
sage: cuspidal_curve.is_smooth()
Traceback (most recent call last)
...
TypeError: Set_PythonType must be initialized with a type, not
Sequences
}}}
And the second errors occurs with the symbolic ring (example from
doctest)
{{{
sage: t = log(2)
sage: u = t.maxima_methods()
sage: SR(u)
Traceback (most recent call last):
...
TypeError: Set_PythonType must be initialized with a type, not
Expression
}}}

Does anybody have any clue of what's happening ?

Best,
Vincent

Simon King

unread,
Jan 18, 2013, 6:39:57 AM1/18/13
to sage-...@googlegroups.com
Hi,

On 2013-01-18, vdelecroix <20100.d...@gmail.com> wrote:
> And the second errors occurs with the symbolic ring (example from
> doctest)
> {{{
> sage: t = log(2)
> sage: u = t.maxima_methods()
> sage: SR(u)
> Traceback (most recent call last):
> ...
> TypeError: Set_PythonType must be initialized with a type, not
> Expression
> }}}
>
> Does anybody have any clue of what's happening ?

I don't know about the first example, but here, we get:

sage: parent(u)
parent(log(2))
sage: type(parent(u))
<type 'sage.symbolic.expression.Expression'>
sage: issubclass(type(parent(u)),type)
False

Best regards,
Simon

vdelecroix

unread,
Jan 18, 2013, 9:33:48 AM1/18/13
to sage-devel
Hi Simon,

Thanks for your answer.

> > And the second errors occurs with the symbolic ring (example from
> > doctest)
> > {{{
> > sage: t = log(2)
> > sage: u = t.maxima_methods()
> > sage: SR(u)
> > Traceback (most recent call last):
> > ...
> > TypeError: Set_PythonType must be initialized with a type, not
> > Expression
> > }}}
>
> > Does anybody have any clue of what's happening ?
>
> I don't know about the first example, but here, we get:
>
>   sage: parent(u)
>   parent(log(2))
>   sage: type(parent(u))
>   <type 'sage.symbolic.expression.Expression'>
>   sage: issubclass(type(parent(u)),type)
>   False

Actually, the problem starts in the constructor of DefaultConvertMap
where it is written
{{{
if not PY_TYPE_CHECK(domain, Parent):
domain = Set_PythonType(domain)
}}}
and we have
{{{
sage: t = log(2)
sage: isinstance(parent(t), Parent)
True
sage: u = t.maxima_methods()
sage: P = parent(u)
sage: P
parent(log(2))
sage: isinstance(P, Parent)
False
sage: type(P)
<type 'sage.symbolic.expression.Expression'>
}}}
Reply all
Reply to author
Forward
0 new messages