Re: [sage-devel] Re: Errors in an old, massive patch for Skew Polynomials in Sage

2016-07-07 Thread Johan S . H . Rosenkilde
Hi Arpit,

Did you try doctesting other parts of Sage to see whether your
segfaults are related to the ticket or not? It could be related to your
system setup.

If this is not the case, you should, as Travis asked you on an earlier
question, try to find a minimal example which causes the bug from the
Sage shell.

The the signalling behaviour of Cython code changed quite a lot during
the last few years, with ao. cysignals becoming a stand-alone package.
Perhaps the skew polynomial ticket doesn't use sig_on and sig_off
correctly.

Best,
Johan

Arpit Merchant writes:

> Hello,
>
> My apologies for not being able to get back sooner. I was working on a 
> separate ticket this week. And there were some compile errors after Sage 
> upgraded to 7.3beta6. I've fixed those and pushed the changes. Sage now 
> builds and running Sage allows access to the functionalities in the 
> original patch that were already working/fixed. However, before I can move 
> on to fixing the pending ones from last week, I am suddenly getting weird 
> segfault errors while running doctests. i.e. when I do ``./sage -t 
> src/sage/rings/polynomial/skew_polynomial_element.pyx``, I get the 
> following output. What changed in the latest update that has caused this 
> and how can I fix it?
>
> too few successful tests, not using stored timings
>> Running doctests with ID 2016-07-07-14-07-44-39349bdf.
>> Git branch: fix_skew_polynomials_patch
>> Using --optional=mpir,python2,sage
>> Doctesting 1 file.
>> sage -t src/sage/rings/polynomial/skew_polynomial_element.pyx
>> **
>> File "src/sage/rings/polynomial/skew_polynomial_element.pyx", line 100, in 
>> sage.rings.polynomial.skew_polynomial_element
>> Failed example:
>> q,r = c.quo_rem(b,side=Left)
>> Expected:
>> Traceback (most recent call last):
>> ...
>> NotImplementedError
>> Got:
>> 
>> Traceback (most recent call last):
>>   File 
>> "/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/doctest/forker.py",
>>  
>> line 498, in _run
>> self.compile_and_execute(example, compiler, test.globs)
>>   File 
>> "/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/doctest/forker.py",
>>  
>> line 861, in compile_and_execute
>> exec(compiled, globs)
>>   File "", 
>> line 1, in 
>> q,r = c.quo_rem(b,side=Left)
>>   File "sage/rings/polynomial/skew_polynomial_element.pyx", line 1232, 
>> in sage.rings.polynomial.skew_polynomial_element.SkewPolynomial.quo_rem 
>> (/home/arpit/Documents/GSOC_16/sage/src/build/cythonized/sage/rings/polynomial/skew_polynomial_element.c:11397)
>> return self.lquo_rem(other)
>>   File "sage/rings/polynomial/skew_polynomial_element.pyx", line 1092, 
>> in sage.rings.polynomial.skew_polynomial_element.SkewPolynomial.lquo_rem 
>> (/home/arpit/Documents/GSOC_16/sage/src/build/cythonized/sage/rings/polynomial/skew_polynomial_element.c:10375)
>> c = parent.twist_map(-db)(inv*a[i+db])
>>   File 
>> "/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/rings/polynomial/skew_polynomial_ring.py",
>>  
>> line 607, in twist_map
>> map = self._map**n
>>   File "sage/categories/map.pyx", line 1264, in 
>> sage.categories.map.Map.__pow__ 
>> (/home/arpit/Documents/GSOC_16/sage/src/build/cythonized/sage/categories/map.c:9103)
>> return generic_power(self, n)
>>   File "sage/structure/element.pyx", line 3496, in 
>> sage.structure.element.generic_power 
>> (/home/arpit/Documents/GSOC_16/sage/src/build/cythonized/sage/structure/element.c:27116)
>> return generic_power_c(a,n,one)
>>   File "sage/structure/element.pyx", line 3529, in 
>> sage.structure.element.generic_power_c 
>> (/home/arpit/Documents/GSOC_16/sage/src/build/cythonized/sage/structure/element.c:27789)
>> a = ~a
>> TypeError: bad operand type for unary ~: 
>> 'sage.rings.morphism.RingHomomorphism_im_gens'
>> Killed due to segmentation fault
>> **
>> Tests run before process (pid=13179) failed:
>> sage: R. = ZZ[] ## line 19 ##
>> sage: sigma = R.hom([t+1]) ## line 20 ##
>> sage: S. = R['x',sigma]; S ## line 21 ##
>> Skew Polynomial Ring in x over Univariate Polynomial Ring in t over 
>> Integer Ring twisted by t |--> t + 1
>> sage: a = t + x + 1; a ## line 26 ##
>> x + t + 1
>> sage: b = S([t^2,t+1,1]); b ## line 28 ##
>> x^2 + (t + 1)*x + t^2
>> sage: c = S.random_element(degree=3,monic=True); c ## line 30 ##
>> x^3 + (-95*t^2 + t + 2)*x^2 + (-t^2 + t)*x + 2*t - 8
>> sage: a + b ## line 35 ##
>> x^2 + (t + 2)*x + t^2 + t + 1
>> sage: a - b ## line 37 ##
>> -x^2 - t*x - t^2 + t + 1
>> sage: a * b ## line 40 ##
>> x^3 + (2*t + 3)*x^2 + (2*t^2 + 4*t + 2)*x + t^3 + t^2
>> sage: b * a ## line 42 ##
>> x^3 + (2*t + 4)*x^2 + (2*t^2 + 3*t + 2)*x + t^3 + t^2
>> sage: a * b == b * a ## line 44 ##
>> 

[sage-devel] Re: Errors in an old, massive patch for Skew Polynomials in Sage

2016-07-07 Thread Arpit Merchant
Hello,

My apologies for not being able to get back sooner. I was working on a 
separate ticket this week. And there were some compile errors after Sage 
upgraded to 7.3beta6. I've fixed those and pushed the changes. Sage now 
builds and running Sage allows access to the functionalities in the 
original patch that were already working/fixed. However, before I can move 
on to fixing the pending ones from last week, I am suddenly getting weird 
segfault errors while running doctests. i.e. when I do ``./sage -t 
src/sage/rings/polynomial/skew_polynomial_element.pyx``, I get the 
following output. What changed in the latest update that has caused this 
and how can I fix it?

too few successful tests, not using stored timings
> Running doctests with ID 2016-07-07-14-07-44-39349bdf.
> Git branch: fix_skew_polynomials_patch
> Using --optional=mpir,python2,sage
> Doctesting 1 file.
> sage -t src/sage/rings/polynomial/skew_polynomial_element.pyx
> **
> File "src/sage/rings/polynomial/skew_polynomial_element.pyx", line 100, in 
> sage.rings.polynomial.skew_polynomial_element
> Failed example:
> q,r = c.quo_rem(b,side=Left)
> Expected:
> Traceback (most recent call last):
> ...
> NotImplementedError
> Got:
> 
> Traceback (most recent call last):
>   File 
> "/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/doctest/forker.py",
>  
> line 498, in _run
> self.compile_and_execute(example, compiler, test.globs)
>   File 
> "/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/doctest/forker.py",
>  
> line 861, in compile_and_execute
> exec(compiled, globs)
>   File "", 
> line 1, in 
> q,r = c.quo_rem(b,side=Left)
>   File "sage/rings/polynomial/skew_polynomial_element.pyx", line 1232, 
> in sage.rings.polynomial.skew_polynomial_element.SkewPolynomial.quo_rem 
> (/home/arpit/Documents/GSOC_16/sage/src/build/cythonized/sage/rings/polynomial/skew_polynomial_element.c:11397)
> return self.lquo_rem(other)
>   File "sage/rings/polynomial/skew_polynomial_element.pyx", line 1092, 
> in sage.rings.polynomial.skew_polynomial_element.SkewPolynomial.lquo_rem 
> (/home/arpit/Documents/GSOC_16/sage/src/build/cythonized/sage/rings/polynomial/skew_polynomial_element.c:10375)
> c = parent.twist_map(-db)(inv*a[i+db])
>   File 
> "/home/arpit/Documents/GSOC_16/sage/local/lib/python2.7/site-packages/sage/rings/polynomial/skew_polynomial_ring.py",
>  
> line 607, in twist_map
> map = self._map**n
>   File "sage/categories/map.pyx", line 1264, in 
> sage.categories.map.Map.__pow__ 
> (/home/arpit/Documents/GSOC_16/sage/src/build/cythonized/sage/categories/map.c:9103)
> return generic_power(self, n)
>   File "sage/structure/element.pyx", line 3496, in 
> sage.structure.element.generic_power 
> (/home/arpit/Documents/GSOC_16/sage/src/build/cythonized/sage/structure/element.c:27116)
> return generic_power_c(a,n,one)
>   File "sage/structure/element.pyx", line 3529, in 
> sage.structure.element.generic_power_c 
> (/home/arpit/Documents/GSOC_16/sage/src/build/cythonized/sage/structure/element.c:27789)
> a = ~a
> TypeError: bad operand type for unary ~: 
> 'sage.rings.morphism.RingHomomorphism_im_gens'
> Killed due to segmentation fault
> **
> Tests run before process (pid=13179) failed:
> sage: R. = ZZ[] ## line 19 ##
> sage: sigma = R.hom([t+1]) ## line 20 ##
> sage: S. = R['x',sigma]; S ## line 21 ##
> Skew Polynomial Ring in x over Univariate Polynomial Ring in t over 
> Integer Ring twisted by t |--> t + 1
> sage: a = t + x + 1; a ## line 26 ##
> x + t + 1
> sage: b = S([t^2,t+1,1]); b ## line 28 ##
> x^2 + (t + 1)*x + t^2
> sage: c = S.random_element(degree=3,monic=True); c ## line 30 ##
> x^3 + (-95*t^2 + t + 2)*x^2 + (-t^2 + t)*x + 2*t - 8
> sage: a + b ## line 35 ##
> x^2 + (t + 2)*x + t^2 + t + 1
> sage: a - b ## line 37 ##
> -x^2 - t*x - t^2 + t + 1
> sage: a * b ## line 40 ##
> x^3 + (2*t + 3)*x^2 + (2*t^2 + 4*t + 2)*x + t^3 + t^2
> sage: b * a ## line 42 ##
> x^3 + (2*t + 4)*x^2 + (2*t^2 + 3*t + 2)*x + t^3 + t^2
> sage: a * b == b * a ## line 44 ##
> False
> sage: b^2 ## line 47 ##
> x^4 + (2*t + 4)*x^3 + (3*t^2 + 7*t + 6)*x^2 + (2*t^3 + 4*t^2 + 3*t + 1)*x 
> + t^4
> sage: b^2 == b*b ## line 49 ##
> True
> sage: q,r = c.quo_rem(b)   # default side is right ## line 80 ##
> sage: q ## line 81 ##
> x - 95*t^2
> sage: r ## line 83 ##
> (95*t^3 + 93*t^2 - t - 1)*x + 95*t^4 + 2*t - 8
> sage: c == q*b + r ## line 85 ##
> True
> sage: q == c // b ## line 91 ##
> True
> sage: r == c % b ## line 93 ##
> True
> sage: q,r = c.quo_rem(b,side=Left) ## line 100 ##
> sage: k. = GF(5^3) ## line 107 ##
> sage: Frob = k.frobenius_endomorphism() ## line 108 ##
> sage: S. = k['x',Frob] ## line 109 ##
> sage: a = x^4 + (4*t + 1)*x^3 + (t^2 

[sage-devel] Re: Errors in an old, massive patch for Skew Polynomials in Sage

2016-07-01 Thread Travis Scrimshaw
Hey Aprit,

The errors (there's numerous instances of each of these errors occurring. 
> Please find below one of each type):
> (1) 
> sage: R. = QQ[]
> sage: sigma = R.hom([t+1])
> sage: S. = R['x', sigma]
> sage: S.twist_map(-1)
>
>
>
> *Got - TypeError: bad operand type for unary ~: 
> 'sage.rings.morphism.RingHomomorphism_im_gens'Expected - 
> NotImplementedError*
>
This looks like you are trying to invert a morphism which does not have a 
defined __invert__ method. If you are expecting it to, then you likely are 
creating objects (morphisms) different than what you are expecting.
 

> (2) 
> sage: k. = GF(5^3)
> sage: Frob = k.Frobenius_endomorphism()
> sage: S. = k.['x', Frob]
> sage: a = x^3 + (t^2 + 1)*x^2 + (2*t + 3)*x + t^2 + t + 2
>
>
>
> *Got - Exception raised:... (traceback) TypeError: Cannot convert int to 
> sage.structure.element.Element*
>
>>
>>
Somewhere in the computation, you are creating/returning a python int, 
which is getting passed/returned by a _cmp_, _call_, etc, instead.

Also, as a more generic comment from browsing through the code, I don't 
really like having objects for Right and Left, and in particular, I 
strongly think they should not be included in the global namespace.

Best,
Travis

 

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: Errors in an old, massive patch for Skew Polynomials in Sage

2016-07-01 Thread Arpit Merchant
Hello,

Here is the latest branch and the last commit was by David Lucas. 
https://git.sagemath.org/sage.git/diff?id=32feb35840fab0ebd5a8957aed78d4c05d7e751c

The errors (there's numerous instances of each of these errors occurring. 
Please find below one of each type):
(1) 
sage: R. = QQ[]
sage: sigma = R.hom([t+1])
sage: S. = R['x', sigma]
sage: S.twist_map(-1)



*Got - TypeError: bad operand type for unary ~: 
'sage.rings.morphism.RingHomomorphism_im_gens'Expected - 
NotImplementedError*
(2) 
sage: k. = GF(5^3)
sage: Frob = k.Frobenius_endomorphism()
sage: S. = k.['x', Frob]
sage: a = x^3 + (t^2 + 1)*x^2 + (2*t + 3)*x + t^2 + t + 2




*Got - Exception raised:... (traceback) TypeError: Cannot convert int to 
sage.structure.element.Element*

On Thursday, 30 June 2016 14:47:55 UTC+5:30, Dima Pasechnik wrote:
>
> it's quite not clear from your post how to reproduce this. The log 
> mentions some git branch; where is this branch?
> It might also be easier to parse if you take the failing doctest out and 
> produce few lines of Sage code that
> need to get the error interactively, at Sage prompt (on the git branch in 
> question)
>
>
>
> On Thursday, June 30, 2016 at 7:11:36 AM UTC+1, Arpit Merchant wrote:
>>
>> Hello,
>>
>> My GSoC project is to implement Gabidulin codes which require the Skew 
>> Polynomial ticket #13215. While, a lot of the errors have been eliminated, 
>> we are stuck with a couple of nasty ones that are hampering the progress on 
>> the project. I'm attaching a file that has the tracebacks for them. Can 
>> someone please explain what is going wrong and help arrive at a way to 
>> resolve these?
>>
>> Thanks in advance.
>>
>> Sincerely,
>> Arpit.
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: Errors in an old, massive patch for Skew Polynomials in Sage

2016-06-30 Thread Dima Pasechnik
it's quite not clear from your post how to reproduce this. The log mentions 
some git branch; where is this branch?
It might also be easier to parse if you take the failing doctest out and 
produce few lines of Sage code that
need to get the error interactively, at Sage prompt (on the git branch in 
question)



On Thursday, June 30, 2016 at 7:11:36 AM UTC+1, Arpit Merchant wrote:
>
> Hello,
>
> My GSoC project is to implement Gabidulin codes which require the Skew 
> Polynomial ticket #13215. While, a lot of the errors have been eliminated, 
> we are stuck with a couple of nasty ones that are hampering the progress on 
> the project. I'm attaching a file that has the tracebacks for them. Can 
> someone please explain what is going wrong and help arrive at a way to 
> resolve these?
>
> Thanks in advance.
>
> Sincerely,
> Arpit.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: Errors in an old, massive patch for Skew Polynomials in Sage

2016-06-30 Thread Arpit Merchant
Hello,

My GSoC project is to implement Gabidulin codes which require the Skew 
Polynomial ticket #13215. While, a lot of the errors have been eliminated, 
we are stuck with a couple of nasty ones that are hampering the progress on 
the project. I'm attaching a file that has the tracebacks for them. Can 
someone please explain what is going wrong and help arrive at a way to 
resolve these?

Thanks in advance.

Sincerely,
Arpit.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.
too few successful tests, not using stored timings
Running doctests with ID 2016-06-20-00-59-25-8e75afbe.
Git branch: apply_skew_polynomials_patch
Using --optional=mpir,python2,sage
Doctesting 1 file.
sage -t src/sage/rings/polynomial/skew_polynomial_ring.py
**
File "src/sage/rings/polynomial/skew_polynomial_ring.py", line 589, in 
sage.rings.polynomial.skew_polynomial_ring.SkewPolynomialRing_general.twist_map
Failed example:
S.twist_map(-1)
Expected:
Traceback (most recent call last):
...
NotImplementedError
Got:

Traceback (most recent call last):
  File 
"/home/arpit/Documents/GSOC_16/sage-7.2/local/lib/python2.7/site-packages/sage/doctest/forker.py",
 line 496, in _run
self.compile_and_execute(example, compiler, test.globs)
  File 
"/home/arpit/Documents/GSOC_16/sage-7.2/local/lib/python2.7/site-packages/sage/doctest/forker.py",
 line 858, in compile_and_execute
exec(compiled, globs)
  File "",
 line 1, in 
S.twist_map(-Integer(1))
  File 
"/home/arpit/Documents/GSOC_16/sage-7.2/local/lib/python2.7/site-packages/sage/rings/polynomial/skew_polynomial_ring.py",
 line 605, in twist_map
map = self._map**n
  File "sage/categories/map.pyx", line 1264, in 
sage.categories.map.Map.__pow__ 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/categories/map.c:8985)
return generic_power(self, n)
  File "sage/structure/element.pyx", line 3671, in 
sage.structure.element.generic_power 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/structure/element.c:28593)
return generic_power_c(a,n,one)
  File "sage/structure/element.pyx", line 3704, in 
sage.structure.element.generic_power_c 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/structure/element.c:29266)
a = ~a
TypeError: bad operand type for unary ~: 
'sage.rings.morphism.RingHomomorphism_im_gens'
**
**
File "src/sage/rings/polynomial/skew_polynomial_finite_field.pyx", line 2419, 
in sage.rings.polynomial.skew_polynomial_finite_field.factorizations
Failed example:
a = x^3 + (t^2 + 1)*x^2 + (2*t + 3)*x + t^2 + t + 2
Exception raised:
Traceback (most recent call last):
  File 
"/home/arpit/Documents/GSOC_16/sage-7.2/local/lib/python2.7/site-packages/sage/doctest/forker.py",
 line 496, in _run
self.compile_and_execute(example, compiler, test.globs)
  File 
"/home/arpit/Documents/GSOC_16/sage-7.2/local/lib/python2.7/site-packages/sage/doctest/forker.py",
 line 858, in compile_and_execute
exec(compiled, globs)
  File "", line 1, 
in 
a = x**Integer(3) + (t**Integer(2) + Integer(1))*x**Integer(2) + 
(Integer(2)*t + Integer(3))*x + t**Integer(2) + t + Integer(2)
  File "sage/structure/element.pyx", line 1798, in 
sage.structure.element.RingElement.__mul__ 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/structure/element.c:16351)
return coercion_model.bin_op(left, right, mul)
  File "sage/structure/coerce.pyx", line 1020, in 
sage.structure.coerce.CoercionModel_cache_maps.bin_op 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/structure/coerce.c:8743)
action = self.get_action(xp, yp, op, x, y)
  File "sage/structure/coerce.pyx", line 1557, in 
sage.structure.coerce.CoercionModel_cache_maps.get_action 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/structure/coerce.c:15560)
action = self.discover_action(R, S, op, r, s)
  File "sage/structure/coerce.pyx", line 1697, in 
sage.structure.coerce.CoercionModel_cache_maps.discover_action 
(/home/arpit/Documents/GSOC_16/sage-7.2/src/build/cythonized/sage/structure/coerce.c:17010)
action = (R).get_action(S, op, True, r, s)
  File "sage/structure/parent.pyx", line 2742, in 
sage.structure.parent.Parent.get_action 

[sage-devel] Re: Errors in an old, massive patch for Skew Polynomials in Sage

2016-06-21 Thread Arpit Merchant
Hello,

One other set of errors I'm facing is, I think already reported in Ticket #
19553  which is an open ticket. Any 
suggestions on how to resolve this?

Thanks.

-Arpit.

On Monday, 20 June 2016 14:06:51 UTC+5:30, Simon King wrote:
>
> Hi Arpit, 
>
> On 2016-06-19, Arpit Merchant  wrote: 
> > What does MyElement represent in your example? What is its connection to 
> > MyParent? 
> > And since Element is itself a class, won't writing Element = MyElement 
> give 
> > a syntax error? 
>
> I think that's all answered in the thematic tutorial "How to implement new 
> algebraic structure in Sage", see 
>
> http://doc.sagemath.org/html/en/thematic_tutorials/coercion_and_categories.html#coercion-and-categories
>  
>
> Best regards, 
> Simon 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: Errors in an old, massive patch for Skew Polynomials in Sage

2016-06-20 Thread Simon King
Hi Arpit,

On 2016-06-19, Arpit Merchant  wrote:
> What does MyElement represent in your example? What is its connection to
> MyParent?
> And since Element is itself a class, won't writing Element = MyElement give
> a syntax error?

I think that's all answered in the thematic tutorial "How to implement new
algebraic structure in Sage", see
http://doc.sagemath.org/html/en/thematic_tutorials/coercion_and_categories.html#coercion-and-categories

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.