Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8e204dd

Browse files
author
Release Manager
committed
sagemathgh-39479: Fixed crash when exp(0) of p-adic numbers is called Fixes sagemath#38037. Fixes crash when exp(0) is called when using p-adic numbers. Since the unit part of 0 does not exist it was causing a crash. Therefore, to fix this bug we check if our exponent is exactly 0 and if it is return 1 immediately. Also added a doctest to verify that the issue has been fixed. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [X] The title is concise and informative. - [X] The description explains in detail what this PR is about. - [X] I have linked a relevant issue or discussion. - [X] I have created tests covering the changes. - [X] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies URL: sagemath#39479 Reported by: Noel-Roemmele Reviewer(s):
2 parents 11ee7ca + 56b0fc4 commit 8e204dd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/sage/rings/padics/padic_generic_element.pyx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2959,6 +2959,14 @@ cdef class pAdicGenericElement(LocalGenericElement):
29592959
sage: x.exp(algorithm='generic') # indirect doctest # needs sage.libs.ntl
29602960
1 + w*7 + (4*w + 2)*7^2 + (w + 6)*7^3 + 5*7^4 + O(7^5)
29612961
2962+
TESTS:
2963+
2964+
Verify that :issue:`38037` is fixed::
2965+
2966+
sage: R.<a> = Zq(9)
2967+
sage: exp(R.zero())
2968+
1 + O(3^20)
2969+
29622970
AUTHORS:
29632971
29642972
- Genya Zaytman (2007-02-15)
@@ -2973,6 +2981,8 @@ cdef class pAdicGenericElement(LocalGenericElement):
29732981
R=self.parent()
29742982
p=self.parent().prime()
29752983
e=self.parent().absolute_e()
2984+
if self._is_exact_zero():
2985+
return R.one()
29762986
x_unit=self.unit_part()
29772987
p_unit=R(p).unit_part().lift_to_precision()
29782988
x_val=self.valuation()

0 commit comments

Comments
 (0)