Skip to content

Commit 6d8b1df

Browse files
GiacomoPopegrhkm21
andauthored
Apply suggestions from code review
Co-authored-by: grhkm21 <[email protected]>
1 parent 72a9f16 commit 6d8b1df

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/sage/rings/finite_rings/element_base.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ cdef class FiniteRingElement(CommutativeRingElement):
145145
def to_bytes(self, byteorder="big"):
146146
"""
147147
Return an array of bytes representing an integer. Internally relies
148-
on the python ``int.to_bytes()`` method. Length of byte array is
149-
determined from the field's order.
148+
on the Python ``int.to_bytes()`` method. The length of the byte array
149+
is fixed by the parent field's order.
150150
151151
INPUT:
152152
@@ -1112,8 +1112,8 @@ cdef class FinitePolyExtElement(FiniteRingElement):
11121112
def to_bytes(self, byteorder="big"):
11131113
"""
11141114
Return an array of bytes representing an integer. Internally relies
1115-
on the python ``int.to_bytes()`` method. Length of byte array is
1116-
determined from the field's order.
1115+
on the Python ``int.to_bytes()`` method. The length of the byte array
1116+
is fixed by the parent field's order.
11171117
11181118
INPUT:
11191119

src/sage/rings/finite_rings/finite_field_base.pyx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,7 +2120,7 @@ cdef class FiniteField(Field):
21202120
def from_bytes(self, input_bytes, byteorder="big"):
21212121
"""
21222122
Return the integer represented by the given array of bytes. Internally relies
2123-
on the python ``int.from_bytes()`` method.
2123+
on the Python ``int.from_bytes()`` method.
21242124
21252125
INPUT:
21262126
@@ -2159,7 +2159,9 @@ cdef class FiniteField(Field):
21592159
sage: for F in fields:
21602160
....: for _ in range(1000):
21612161
....: a = F.random_element()
2162-
....: assert F.from_bytes(a.to_bytes()) == a
2162+
....: order = choice(["little", "big"])
2163+
....: a_bytes = a.to_bytes(byteorder=order)
2164+
....: assert F.from_bytes(a_bytes, byteorder=order) == a
21632165
"""
21642166
python_int = int.from_bytes(input_bytes, byteorder=byteorder)
21652167
return self.from_integer(python_int)

src/sage/rings/integer.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7166,7 +7166,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
71667166
def to_bytes(self, length=1, byteorder="big", is_signed=False):
71677167
"""
71687168
Return an array of bytes representing an integer. Internally relies
7169-
on the python ``int.to_bytes()`` method.
7169+
on the Python ``int.to_bytes()`` method.
71707170
71717171
INPUT:
71727172

0 commit comments

Comments
 (0)