Changes between Version 1 and Version 3 of Ticket #14685
- Timestamp:
- 06/07/13 10:23:24 (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #14685 – Description
v1 v3 14 14 1 15 15 }}} 16 The good result should be 3 and not 1 (the order of the series B = x^3 is 3 not 1 ) 16 17 17 Here, a patch :18 Here, a patch which fix that: 18 19 {{{ 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 28 41 29 42 #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 31 50 self.order = inf 32 51 return 33 52 - 34 53 - if ao < n: 35 54 - 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 - 44 57 + 45 + # if ao < n:46 + # self.order = ao47 48 49 58 if hasattr(self, '_reference') and self._reference is not None: 59 self._reference._copy(self) 60 }}} 61 The 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 63 After the patch, we obtain : 64 {{{ 65 sage: R = LazyPowerSeriesRing(QQ) 66 sage: B = R([0,0,0,1,0]) 67 sage: B.aorder 68 0 69 sage: B.coefficients(10) 70 [0, 0, 0, 1, 0, 0, 0, 0, 0, 0] 71 sage: B.aorder 72 3 50 73 }}} 51 74 52 I commited it with the number 18037 on the mercurial server 75 What we expected. 53 76 54 It's my first patch, sorry if i did a mistake. 77 78 PS : Thanks you for the commment, I tried to answer. 79