Changes between Version 1 and Version 3 of Ticket #14685


Ignore:
Timestamp:
06/07/13 10:23:24 (8 years ago)
Author:
MatthieuDien
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #14685 – Description

    v1 v3  
    14141
    1515}}}
     16The good result should be 3 and not 1 (the order of the series B = x^3 is 3 not 1 )
    1617
    17 Here, a patch :
     18Here, a patch which fix that:
    1819{{{
    19 diff --git a/sage/combinat/species/series.py b/sage/combinat/species/series.py
    20 --- a/sage/combinat/species/series.py
    21 +++ b/sage/combinat/species/series.py
    22 @@ -631,6 +631,7 @@
    23                          self.aorder += 1
    24                          ao += 1
    25                      else:
    26 +                        self.order = ao
    27                          break
     20--- series_old.py       2013-06-08 13:48:40.490566975 +0200
     21+++ series.py   2013-06-08 14:00:41.903399503 +0200
     22@@ -624,17 +624,17 @@
     23             c = self._stream
     24             n = c.number_computed()
     25 
     26+            while ao < n:
     27+                if self._stream[ao] == 0:
     28+                    self.aorder += 1
     29+                    ao += 1
     30+                else:
     31+                    self.order = ao
     32+                    break
     33 
     34-            if ao == 0 and n > 0:
     35-                while ao < n:
     36-                    if self._stream[ao] == 0:
     37-                        self.aorder += 1
     38-                        ao += 1
     39-                    else:
     40-                        break
    2841 
    2942             #Try to recognize the zero series
    30 @@ -643,8 +644,17 @@
     43-            if ao == n:
     44+            if ao == n and n > 0:
     45                 #For non-constant series, we cannot do anything
     46                 if not c.is_constant():
     47                     return
     48@@ -642,11 +642,7 @@
     49                     self.aorder = inf
    3150                     self.order  = inf
    3251                     return
    33                 
     52-               
    3453-            if ao < n:
    3554-                self.order = ao
    36 +            if self.order == unk:
    37 +                while ao < n:
    38 +                    if self._stream[ao] == 0:
    39 +                        self.aorder += 1
    40 +                        ao += 1
    41 +                    else:
    42 +                        self.order = ao
    43 +                        break
     55-           
     56-   
    4457+
    45 +            # if ao < n:
    46 +            #     self.order = ao
    47              
    48      
    4958         if hasattr(self, '_reference') and self._reference is not None:
     59             self._reference._copy(self)
     60}}}
     61The bug is that the aorder is computed one time and never updated. This is because the order was assigned the first time then the condition self.order != unk becomes false and the update never comes.
     62
     63After the patch, we obtain :
     64{{{
     65sage: R = LazyPowerSeriesRing(QQ)
     66sage: B = R([0,0,0,1,0])
     67sage: B.aorder
     680
     69sage: B.coefficients(10)
     70[0, 0, 0, 1, 0, 0, 0, 0, 0, 0]
     71sage: B.aorder
     723
    5073}}}
    5174
    52 I commited it with the number 18037 on the mercurial server
     75What we expected.
    5376
    54 It's my first patch, sorry if i did a mistake.
     77
     78PS : Thanks you for the commment, I tried to answer.
     79