@@ -39,6 +39,7 @@ def sh(x):
3939
4040class TestHypothesisArraysApis (ExtTestCase ):
4141MAX_ARRAY_SIZE = 10000
42+ SQRT_MAX_ARRAY_SIZE = int (10000 ** 0.5 )
4243VERSION = "2021.12"
4344
4445@classmethod
@@ -138,9 +139,80 @@ def fctonx(x, kw):
138139fctonx ()
139140self .assertEqual (len (args_onxp ),len (args_np ))
140141
142+ def test_square_sizes_strategies (self ):
143+ dtypes = dict (
144+ integer_dtypes = self .xps .integer_dtypes (),
145+ uinteger_dtypes = self .xps .unsigned_integer_dtypes (),
146+ floating_dtypes = self .xps .floating_dtypes (),
147+ numeric_dtypes = self .xps .numeric_dtypes (),
148+ boolean_dtypes = self .xps .boolean_dtypes (),
149+ scalar_dtypes = self .xps .scalar_dtypes (),
150+ )
151+
152+ dtypes_onnx = dict (
153+ integer_dtypes = self .onxps .integer_dtypes (),
154+ uinteger_dtypes = self .onxps .unsigned_integer_dtypes (),
155+ floating_dtypes = self .onxps .floating_dtypes (),
156+ numeric_dtypes = self .onxps .numeric_dtypes (),
157+ boolean_dtypes = self .onxps .boolean_dtypes (),
158+ scalar_dtypes = self .onxps .scalar_dtypes (),
159+ )
160+
161+ for k ,vnp in dtypes .items ():
162+ vonxp = dtypes_onnx [k ]
163+ anp = self .xps .arrays (dtype = vnp ,shape = shapes (self .xps ))
164+ aonxp = self .onxps .arrays (dtype = vonxp ,shape = shapes (self .onxps ))
165+ self .assertNotEmpty (anp )
166+ self .assertNotEmpty (aonxp )
167+
168+ args_np = []
169+
170+ kws = array_api_kwargs (k = strategies .integers (),dtype = self .xps .numeric_dtypes ())
171+ sqrt_sizes = strategies .integers (0 ,self .SQRT_MAX_ARRAY_SIZE )
172+ ncs = strategies .none ()| sqrt_sizes
173+
174+ @given (n_rows = sqrt_sizes ,n_cols = ncs ,kw = kws )
175+ def fctnp (n_rows ,n_cols ,kw ):
176+ base = np .asarray (0 )
177+ e = np .eye (n_rows ,n_cols )
178+ self .assertNotEmpty (e .dtype )
179+ self .assertIsInstance (e ,base .__class__ )
180+ e = np .eye (n_rows ,n_cols ,** kw )
181+ self .assertNotEmpty (e .dtype )
182+ self .assertIsInstance (e ,base .__class__ )
183+ args_np .append ((n_rows ,n_cols ,kw ))
184+
185+ fctnp ()
186+ self .assertEqual (len (args_np ),100 )
187+
188+ args_onxp = []
189+
190+ kws = array_api_kwargs (
191+ k = strategies .integers (),dtype = self .onxps .numeric_dtypes ()
192+ )
193+ sqrt_sizes = strategies .integers (0 ,self .SQRT_MAX_ARRAY_SIZE )
194+ ncs = strategies .none ()| sqrt_sizes
195+
196+ @given (n_rows = sqrt_sizes ,n_cols = ncs ,kw = kws )
197+ def fctonx (n_rows ,n_cols ,kw ):
198+ base = onxp .asarray (0 )
199+ e = onxp .eye (n_rows ,n_cols )
200+ self .assertIsInstance (e ,base .__class__ )
201+ self .assertNotEmpty (e .dtype )
202+ e = onxp .eye (n_rows ,n_cols ,** kw )
203+ self .assertNotEmpty (e .dtype )
204+ self .assertIsInstance (e ,base .__class__ )
205+ args_onxp .append ((n_rows ,n_cols ,kw ))
206+
207+ fctonx ()
208+ self .assertEqual (len (args_onxp ),len (args_np ))
209+
141210
142211if __name__ == "__main__" :
143212# cl = TestHypothesisArraysApis()
144213# cl.setUpClass()
145214# cl.test_scalar_strategies()
215+ # import logging
216+
217+ # logging.basicConfig(level=logging.DEBUG)
146218unittest .main (verbosity = 2 )