Opened 14 years ago

Closed 14 years ago

# [with patch, positive review] Problem in factor() and roots() for p-adic polynomials

Reported by: Owned by: John Cremona Martin Albrecht major sage-3.2.3 commutative algebra polynomial p-adic wuthrich N/A

### Description

This was reported by Chris Wuthrich while reviewing #3377:

```sage: E = EllipticCurve('37a1')
sage: K =Qp(7,10)
sage: EK = E.base_extend(K)
sage: E = EllipticCurve('37a1')
sage: K = Qp(7,10)
sage: EK = E.base_extend(K)
sage: g = EK.division_polynomial_0(3)
sage: type(g)
sage: g.factor()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/john/sage-3.1.2.alpha3/<ipython console> in <module>()

1009         R = ZpCA(base.prime(), prec = m)
1010         S = PolynomialRing(R, self.parent().variable_name())
-> 1011         F = S(self).factor()
1012         return Factorization([(self.parent()(a), b) for (a, b) in F], base(F.unit()))
1013

133             lval = F[i].leading_coefficient().valuation()
134             if upart != 1:
--> 135                 F[i] = (F[i] // upart, F[i])
136                 u *= upart ** F[i]
137             c -= lval * F[i]

/home/john/sage-3.1.2.alpha3/polynomial_element.pyx in sage.rings.polynomial.polynomial_element.Polynomial_generic_dense.__floordiv__ (sage/rings/polynomial/polynomial_element.c:28101)()

AttributeError: 'Polynomial_padic_flat' object has no attribute '__coeffs'
```

Somewhere in the polynomial hierarchy, this particular type of polynomial is not having its `__coeffs` field set.

### comment:1 Changed 14 years ago by John Cremona

Summary: Problem in factor() and roots() for p-adic polynomials → [with patch, needs review] Problem in factor() and roots() for p-adic polynomials

In 3.2.2 the error message changes to:

```sage: g.factor()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/jec/.sage/temp/host_57_89/5017/_home_jec__sage_init_sage_0.py in <module>()
----> 1
2
3
4
5

1009         R = ZpCA(base.prime(), prec = m)
1010         S = PolynomialRing(R, self.parent().variable_name())
-> 1011         F = S(self).factor()
1012         return Factorization([(self.parent()(a), b) for (a, b) in F], base(F.unit()))
1013

133             lval = F[i].leading_coefficient().valuation()
134             if upart != 1:
--> 135                 F[i] = (F[i] // upart, F[i])
136                 u *= upart ** F[i]
137             c -= lval * F[i]

/home/jec/sage-3.2.2/local/lib/python2.5/site-packages/sage/rings/polynomial/polynomial_element.so in sage.rings.polynomial.polynomial_element.Polynomial_generic_dense.__floordiv__ (sage/rings/polynomial/polynomial_element.c:30443)()
4436
4437
-> 4438
4439
4440

AttributeError: 'Polynomial_padic_flat' object has no attribute '_parent'
```

And the problem goes away if I change "" to "/" on line 135 of sage/rings/polynomial/padics/polynomial_padic_flat.py.

Attached patch applies to 3.2.2.

### comment:2 Changed 14 years ago by Alex Ghitza

Summary: [with patch, needs review] Problem in factor() and roots() for p-adic polynomials → [with patch, positive review] Problem in factor() and roots() for p-adic polynomials

Looks good.

### comment:3 Changed 14 years ago by Michael Abshoff

Milestone: sage-3.4 → sage-3.2.3 → fixed new → closed

Merged in Sage 3.2.3.alpha0

Note: See TracTickets for help on using tickets.