# HG changeset patch
# User William Stein <wstein@gmail.com>
# Date 1209157761 25200
# Node ID fa5fee03ab8df704612457c7a47cfb6c1982f6e6
# Parent 5322170885081281bdd7b95b309058cffd0477c6
Fix a bug in setting entries of a SPARSE free module element.
diff -r 532217088508 -r fa5fee03ab8d sage/modules/free_module_element.pyx
|
a
|
b
|
cdef class FreeModuleElement_generic_spa |
| 1694 | 1694 | |
| 1695 | 1695 | def __setitem__(self, i, value): |
| 1696 | 1696 | """ |
| | 1697 | Set the ith entry of self to value. |
| | 1698 | |
| | 1699 | EXAMPLES: |
| | 1700 | sage: V = VectorSpace(GF(17), 10000000, sparse=True) |
| | 1701 | sage: w = V(0) |
| | 1702 | sage: w[39893] = 20 |
| | 1703 | sage: w[39893] |
| | 1704 | 3 |
| | 1705 | sage: parent(w[39893]) |
| | 1706 | Finite Field of size 17 |
| | 1707 | sage: w[39893] = sqrt(2) |
| | 1708 | Traceback (most recent call last): |
| | 1709 | ... |
| | 1710 | TypeError: unable to convert x (=sqrt(2)) to an integer |
| 1697 | 1711 | """ |
| 1698 | 1712 | if not self._is_mutable: |
| 1699 | 1713 | raise ValueError, "vector is immutable; please change a copy instead (use self.copy())" |
| … |
… |
cdef class FreeModuleElement_generic_spa |
| 1703 | 1717 | if i < 0 or i >= self.degree(): |
| 1704 | 1718 | raise IndexError, "index (i=%s) must be between 0 and %s"%(i, |
| 1705 | 1719 | self.degree()-1) |
| 1706 | | self.set(i, value) |
| | 1720 | self.set(i, self._parent.base_ring()(value)) |
| 1707 | 1721 | |
| 1708 | 1722 | def denominator(self): |
| 1709 | 1723 | R = self.base_ring() |