2323 (ul .arange , (5 ,), {"step" : 2 }, [0 , 2 , 4 ],),
2424 (ul .arange , (0 ,), {"stop" : 5 , "step" : 2 }, [0 , 2 , 4 ],),
2525
26- (ul .repeat , (0 , 3 ), {}, [0 , 0 , 0 ],),
27- (ul .repeat , (1.0 , 3 ), {}, [1.0 , 1.0 , 1.0 ],),
28- (ul .repeat , (False , 3 ), {}, [False , False , False ],),
29- (ul .repeat , ('foo' , 3 ), {}, ['foo' , 'foo' , 'foo' ],),
30-
31- (ul .from_seq , (range (3 ), "float" ), {}, [0.0 , 1.0 , 2.0 ],),
32- (ul .from_seq , (range (3 ), "int" ), {}, [0 , 1 , 2 ],),
33- (ul .from_seq , (range (3 ), "int32" ), {}, [0 , 1 , 2 ],),
34- (ul .from_seq , (range (3 ), "int64" ), {}, [0 , 1 , 2 ],),
35-
36- (ul .from_seq , ([False , True ], "bool" ), {}, [False , True ],),
37- (ul .from_seq , ([0.0 , 1.0 , 2.0 ], "float" ), {}, [0.0 , 1.0 , 2.0 ],),
38- (ul .from_seq , ([0 , 1 , 2 ], "int" ), {}, [0 , 1 , 2 ],),
39- (ul .from_seq , (['foo' , 'bar' ], "string" ), {}, ['foo' , 'bar' ],),
40-
41- (ul .from_seq , ((False , True ), "bool" ), {}, [False , True ],),
42- (ul .from_seq , ((0.0 , 1.0 , 2.0 ), "float" ), {}, [0.0 , 1.0 , 2.0 ],),
43- (ul .from_seq , ((0 , 1 , 2 ), "int" ), {}, [0 , 1 , 2 ],),
44- (ul .from_seq , (('foo' , 'bar' ), "string" ), {}, ['foo' , 'bar' ],),
45- (ul .from_seq , (('foo' , 'bar' , None ), "string" ),
46- {}, ['foo' , 'bar' , None ],),
47-
4826 (ul .cycle , (range (3 ), 1 , 'float' ), {}, [0.0 ],),
4927 (ul .cycle , (range (3 ), 1 , 'int32' ), {}, [0 ],),
5028 (ul .cycle , (range (3 ), 1 , 'int64' ), {}, [0 ],),
6442 (ul .cycle , ((0.0 , 1.0 ), 3 , 'float' ), {}, [0.0 , 1.0 , 0.0 ],),
6543 (ul .cycle , ((0 , 1 ), 3 , 'int' ), {}, [0 , 1 , 0 ],),
6644 (ul .cycle , (('foo' , 'bar' ), 3 , 'string' ), {}, ['foo' , 'bar' , 'foo' ],),
45+
46+
47+ (ul .from_seq , (range (3 ), "float" ), {}, [0.0 , 1.0 , 2.0 ],),
48+ (ul .from_seq , (range (3 ), "int" ), {}, [0 , 1 , 2 ],),
49+ (ul .from_seq , (range (3 ), "int32" ), {}, [0 , 1 , 2 ],),
50+ (ul .from_seq , (range (3 ), "int64" ), {}, [0 , 1 , 2 ],),
51+
52+ (ul .from_seq , ([False , True ], "bool" ), {}, [False , True ],),
53+ (ul .from_seq , ([0.0 , 1.0 , 2.0 ], "float" ), {}, [0.0 , 1.0 , 2.0 ],),
54+ (ul .from_seq , ([0 , 1 , 2 ], "int" ), {}, [0 , 1 , 2 ],),
55+ (ul .from_seq , (['foo' , 'bar' ], "string" ), {}, ['foo' , 'bar' ],),
56+
57+ (ul .from_seq , ((False , True ), "bool" ), {}, [False , True ],),
58+ (ul .from_seq , ((0.0 , 1.0 , 2.0 ), "float" ), {}, [0.0 , 1.0 , 2.0 ],),
59+ (ul .from_seq , ((0 , 1 , 2 ), "int" ), {}, [0 , 1 , 2 ],),
60+ (ul .from_seq , (('foo' , 'bar' ), "string" ), {}, ['foo' , 'bar' ],),
61+ (ul .from_seq , (('foo' , 'bar' , None ), "string" ),
62+ {}, ['foo' , 'bar' , None ],),
63+
64+ (ul .repeat , (0 , 3 ), {}, [0 , 0 , 0 ],),
65+ (ul .repeat , (1.0 , 3 ), {}, [1.0 , 1.0 , 1.0 ],),
66+ (ul .repeat , (False , 3 ), {}, [False , False , False ],),
67+ (ul .repeat , ('foo' , 3 ), {}, ['foo' , 'foo' , 'foo' ],),
6768 ],
6869)
6970def test_constructors (
@@ -84,3 +85,21 @@ def test_constructors(
8485 else :
8586 raise TypeError (f"Unexpected type { type (expected_value [0 ])} !" )
8687 check_test_result (dtype , test_method , result , expected_value )
88+
89+
90+ @pytest .mark .parametrize (
91+ "test_method, args, kwargs" ,
92+ [
93+ (ul .random , (), {"size" : 3 , "dtype" : "float32" },),
94+ ],
95+ )
96+ def test_rand (
97+ test_method : Callable ,
98+ args : tuple ,
99+ kwargs : dict ,
100+ ) -> None :
101+ arr1 = test_method (* args , ** kwargs )
102+ arr2 = test_method (* args , ** kwargs )
103+ assert arr1 .not_equal (arr2 ).all ()
104+ assert len (arr1 ) == len (arr2 )
105+ assert len (arr1 ) == kwargs ["size" ]
0 commit comments