@@ -709,8 +709,43 @@ cdef class IntegerRing_class(PrincipalIdealDomain):
709
709
sage: ZZ. random_element( 11. 0, distribution="gaussian")
710
710
5
711
711
712
+ TESTS:
713
+
714
+ Check that :trac:`32124` is fixed::
715
+
716
+ sage: ZZ. random_element( 5, -5, distribution="1/n") . parent( ) is ZZ
717
+ True
718
+ sage: ZZ. random_element( 5, -5, distribution="gaussian") . parent( ) is ZZ
719
+ True
720
+ sage: ZZ. random_element( 5, -5, distribution="mpz_rrandomb") . parent( ) is ZZ
721
+ True
722
+
723
+ sage: ZZ. random_element( -10, -5, distribution="mpz_rrandomb")
724
+ Traceback ( most recent call last) :
725
+ ...
726
+ TypeError: x must be > 0
727
+ sage: ZZ. random_element( -10, -5, distribution="gaussian")
728
+ Traceback ( most recent call last) :
729
+ ...
730
+ TypeError: x must be > 0
731
+
732
+ Checking error messages::
733
+
734
+ sage: ZZ. random_element( -3)
735
+ Traceback ( most recent call last) :
736
+ ...
737
+ TypeError: x must be > 0
738
+ sage: ZZ. random_element( 4, 2)
739
+ Traceback ( most recent call last) :
740
+ ...
741
+ TypeError: x must be < y
712
742
"""
713
743
cdef Integer z = Integer.__new__ (Integer)
744
+ if distribution == " 1/n" :
745
+ x = None
746
+ y = None
747
+ elif distribution == " mpz_rrandomb" or distribution == " gaussian" :
748
+ y = None
714
749
if x is not None and y is None and x <= 0 :
715
750
raise TypeError (" x must be > 0" )
716
751
if x is not None and y is not None and x >= y:
0 commit comments