File tree Expand file tree Collapse file tree 4 files changed +90
-0
lines changed
ivy_tests/test_ivy/test_frontends Expand file tree Collapse file tree 4 files changed +90
-0
lines changed Original file line number Diff line number Diff line change @@ -413,6 +413,9 @@ def var(
413413 def swapaxes (self , axis1 , axis2 ):
414414 return jax_frontend .numpy .swapaxes (self , axis1 = axis1 , axis2 = axis2 )
415415
416+ def tolist (self ):
417+ return ivy .to_list (self .ivy_array )
418+
416419
417420# Jax supports DeviceArray from 0.4.13 and below
418421# Hence aliasing it here
Original file line number Diff line number Diff line change @@ -225,6 +225,9 @@ def __iter__(self):
225225 for i in range (self .shape [0 ]):
226226 yield self [i ]
227227
228+ def tolist (self ):
229+ return ivy .to_list (self .ivy_array )
230+
228231
229232class TensorShape :
230233 # TODO: there are still some methods that may need implementing
Original file line number Diff line number Diff line change @@ -2826,3 +2826,45 @@ def test_jax_swapaxes(
28262826 method_flags = method_flags ,
28272827 on_device = on_device ,
28282828 )
2829+
2830+
2831+ # tolist
2832+ @handle_frontend_method (
2833+ class_tree = CLASS_TREE ,
2834+ init_tree = "jax.numpy.array" ,
2835+ method_name = "tolist" ,
2836+ dtype_and_x = helpers .dtype_and_values (
2837+ available_dtypes = helpers .get_dtypes ("valid" ),
2838+ min_num_dims = 0 ,
2839+ max_num_dims = 5 ,
2840+ min_dim_size = 1 ,
2841+ max_dim_size = 10 ,
2842+ min_value = - 1e05 ,
2843+ max_value = 1e05 ,
2844+ ),
2845+ )
2846+ def test_jax_array_tolist (
2847+ dtype_and_x ,
2848+ frontend_method_data ,
2849+ init_flags ,
2850+ method_flags ,
2851+ frontend ,
2852+ on_device ,
2853+ backend_fw ,
2854+ ):
2855+ input_dtypes , x = dtype_and_x
2856+ helpers .test_frontend_method (
2857+ init_input_dtypes = input_dtypes ,
2858+ backend_to_test = backend_fw ,
2859+ init_all_as_kwargs_np = {
2860+ "object" : x [0 ],
2861+ },
2862+ method_input_dtypes = input_dtypes ,
2863+ method_all_as_kwargs_np = {},
2864+ frontend_method_data = frontend_method_data ,
2865+ init_flags = init_flags ,
2866+ method_flags = method_flags ,
2867+ frontend = frontend ,
2868+ on_device = on_device ,
2869+ test_values = False , # tolist returns Python list, not array
2870+ )
Original file line number Diff line number Diff line change @@ -1607,3 +1607,45 @@ def test_tensorflow_shape(
16071607 x .ivy_array .shape , ivy .Shape (shape ), as_array = False
16081608 )
16091609 ivy .previous_backend ()
1610+
1611+
1612+ # tolist
1613+ @handle_frontend_method (
1614+ class_tree = CLASS_TREE ,
1615+ init_tree = "tensorflow.constant" ,
1616+ method_name = "tolist" ,
1617+ dtype_and_x = helpers .dtype_and_values (
1618+ available_dtypes = helpers .get_dtypes ("valid" ),
1619+ min_num_dims = 0 ,
1620+ max_num_dims = 5 ,
1621+ min_dim_size = 1 ,
1622+ max_dim_size = 10 ,
1623+ min_value = - 1e05 ,
1624+ max_value = 1e05 ,
1625+ ),
1626+ )
1627+ def test_tensorflow_tensor_tolist (
1628+ dtype_and_x ,
1629+ frontend_method_data ,
1630+ init_flags ,
1631+ method_flags ,
1632+ frontend ,
1633+ on_device ,
1634+ backend_fw ,
1635+ ):
1636+ input_dtypes , x = dtype_and_x
1637+ helpers .test_frontend_method (
1638+ init_input_dtypes = input_dtypes ,
1639+ backend_to_test = backend_fw ,
1640+ init_all_as_kwargs_np = {
1641+ "value" : x [0 ],
1642+ },
1643+ method_input_dtypes = input_dtypes ,
1644+ method_all_as_kwargs_np = {},
1645+ frontend_method_data = frontend_method_data ,
1646+ init_flags = init_flags ,
1647+ method_flags = method_flags ,
1648+ frontend = frontend ,
1649+ on_device = on_device ,
1650+ test_values = False , # tolist returns Python list, not array
1651+ )
You can’t perform that action at this time.
0 commit comments