@@ -297,7 +297,7 @@ def _int(i: i64, j: i64, r: Boolean, o: Int, b: Int):
297297 yield rule (eq (Int .NEVER ).to (Int (i ))).then (panic ("Int.NEVER cannot be equal to any real int" ))
298298
299299
300- converter (i64 , Int , lambda x : Int ( x ) )
300+ converter (i64 , Int , Int )
301301
302302IntLike : TypeAlias = Int | i64Like
303303
@@ -377,8 +377,8 @@ def __gt__(self, other: FloatLike) -> Boolean: ...
377377 def __ge__ (self , other : FloatLike ) -> Boolean : ...
378378
379379
380- converter (float , Float , lambda x : Float ( x ) )
381- converter (Int , Float , lambda x : Float .from_int ( x ) )
380+ converter (float , Float , Float )
381+ converter (Int , Float , Float .from_int )
382382
383383
384384FloatLike : TypeAlias = Float | float | IntLike
@@ -521,7 +521,7 @@ def deselect(self, indices: TupleIntLike) -> TupleInt:
521521 return TupleInt .range (self .length ()).filter (lambda i : ~ indices .contains (i )).map (lambda i : self [i ])
522522
523523
524- converter (Vec [Int ], TupleInt , lambda x : TupleInt .from_vec ( x ) )
524+ converter (Vec [Int ], TupleInt , TupleInt .from_vec )
525525
526526TupleIntLike : TypeAlias = TupleInt | VecLike [Int , IntLike ]
527527
@@ -649,7 +649,7 @@ def product(self) -> TupleTupleInt:
649649 )
650650
651651
652- converter (Vec [TupleInt ], TupleTupleInt , lambda x : TupleTupleInt .from_vec ( x ) )
652+ converter (Vec [TupleInt ], TupleTupleInt , TupleTupleInt .from_vec )
653653
654654TupleTupleIntLike : TypeAlias = TupleTupleInt | VecLike [TupleInt , TupleIntLike ]
655655
@@ -755,8 +755,8 @@ def __or__(self, other: IsDtypeKind) -> IsDtypeKind: ...
755755def isdtype (dtype : DType , kind : IsDtypeKind ) -> Boolean : ...
756756
757757
758- converter (DType , IsDtypeKind , lambda x : IsDtypeKind .dtype ( x ) )
759- converter (str , IsDtypeKind , lambda x : IsDtypeKind .string ( x ) )
758+ converter (DType , IsDtypeKind , IsDtypeKind .dtype )
759+ converter (str , IsDtypeKind , IsDtypeKind .string )
760760converter (
761761 tuple , IsDtypeKind , lambda x : convert (x [0 ], IsDtypeKind ) | convert (x [1 :], IsDtypeKind ) if x else IsDtypeKind .NULL
762762)
@@ -922,8 +922,8 @@ def from_tuple_int(cls, ti: TupleIntLike) -> TupleValue:
922922 return TupleValue (ti .length (), lambda i : Value .int (ti [i ]))
923923
924924
925- converter (Vec [Value ], TupleValue , lambda x : TupleValue .from_vec ( x ) )
926- converter (TupleInt , TupleValue , lambda x : TupleValue .from_tuple_int ( x ) )
925+ converter (Vec [Value ], TupleValue , TupleValue .from_vec )
926+ converter (TupleInt , TupleValue , TupleValue .from_tuple_int )
927927
928928TupleValueLike : TypeAlias = TupleValue | VecLike [Value , ValueLike ] | TupleIntLike
929929
@@ -1073,9 +1073,9 @@ def ndarray(cls, key: NDArray) -> IndexKey:
10731073
10741074
10751075converter (type (...), IndexKey , lambda _ : IndexKey .ELLIPSIS )
1076- converter (Int , IndexKey , lambda i : IndexKey .int ( i ) )
1077- converter (Slice , IndexKey , lambda s : IndexKey .slice ( s ) )
1078- converter (MultiAxisIndexKey , IndexKey , lambda m : IndexKey .multi_axis ( m ) )
1076+ converter (Int , IndexKey , IndexKey .int )
1077+ converter (Slice , IndexKey , IndexKey .slice )
1078+ converter (MultiAxisIndexKey , IndexKey , IndexKey .multi_axis )
10791079
10801080
10811081class Device (Expr , ruleset = array_api_ruleset ): ...
@@ -1232,13 +1232,13 @@ def if_(cls, b: BooleanLike, i: NDArrayLike, j: NDArrayLike) -> NDArray: ...
12321232
12331233NDArrayLike : TypeAlias = NDArray | ValueLike | TupleValueLike
12341234
1235- converter (NDArray , IndexKey , lambda v : IndexKey .ndarray ( v ) )
1236- converter (Value , NDArray , lambda v : NDArray .scalar ( v ) )
1235+ converter (NDArray , IndexKey , IndexKey .ndarray )
1236+ converter (Value , NDArray , NDArray .scalar )
12371237# Need this if we want to use ints in slices of arrays coming from 1d arrays, but make it more expensive
12381238# to prefer upcasting in the other direction when we can, which is safer at runtime
12391239converter (NDArray , Value , lambda n : n .to_value (), 100 )
1240- converter (TupleValue , NDArray , lambda v : NDArray .vector ( v ) )
1241- converter (TupleInt , TupleValue , lambda v : TupleValue .from_tuple_int ( v ) )
1240+ converter (TupleValue , NDArray , NDArray .vector )
1241+ converter (TupleInt , TupleValue , TupleValue .from_tuple_int )
12421242
12431243
12441244@array_api_ruleset .register
@@ -1322,7 +1322,7 @@ def eval(self) -> tuple[NDArray, ...]:
13221322 return try_evaling (_get_current_egraph (), array_api_schedule , self , self .to_vec )
13231323
13241324
1325- converter (Vec [NDArray ], TupleNDArray , lambda x : TupleNDArray .from_vec ( x ) )
1325+ converter (Vec [NDArray ], TupleNDArray , TupleNDArray .from_vec )
13261326
13271327TupleNDArrayLike : TypeAlias = TupleNDArray | VecLike [NDArray , NDArrayLike ]
13281328
@@ -1371,7 +1371,7 @@ def some(cls, value: Boolean) -> OptionalBool: ...
13711371
13721372
13731373converter (type (None ), OptionalBool , lambda _ : OptionalBool .none )
1374- converter (Boolean , OptionalBool , lambda x : OptionalBool .some ( x ) )
1374+ converter (Boolean , OptionalBool , OptionalBool .some )
13751375
13761376
13771377class OptionalDType (Expr , ruleset = array_api_ruleset ):
@@ -1382,7 +1382,7 @@ def some(cls, value: DType) -> OptionalDType: ...
13821382
13831383
13841384converter (type (None ), OptionalDType , lambda _ : OptionalDType .none )
1385- converter (DType , OptionalDType , lambda x : OptionalDType .some ( x ) )
1385+ converter (DType , OptionalDType , OptionalDType .some )
13861386
13871387
13881388class OptionalDevice (Expr , ruleset = array_api_ruleset ):
@@ -1393,7 +1393,7 @@ def some(cls, value: Device) -> OptionalDevice: ...
13931393
13941394
13951395converter (type (None ), OptionalDevice , lambda _ : OptionalDevice .none )
1396- converter (Device , OptionalDevice , lambda x : OptionalDevice .some ( x ) )
1396+ converter (Device , OptionalDevice , OptionalDevice .some )
13971397
13981398
13991399class OptionalTupleInt (Expr , ruleset = array_api_ruleset ):
@@ -1404,7 +1404,7 @@ def some(cls, value: TupleIntLike) -> OptionalTupleInt: ...
14041404
14051405
14061406converter (type (None ), OptionalTupleInt , lambda _ : OptionalTupleInt .none )
1407- converter (TupleInt , OptionalTupleInt , lambda x : OptionalTupleInt .some ( x ) )
1407+ converter (TupleInt , OptionalTupleInt , OptionalTupleInt .some )
14081408
14091409
14101410class IntOrTuple (Expr , ruleset = array_api_ruleset ):
@@ -1417,8 +1417,8 @@ def int(cls, value: Int) -> IntOrTuple: ...
14171417 def tuple (cls , value : TupleIntLike ) -> IntOrTuple : ...
14181418
14191419
1420- converter (Int , IntOrTuple , lambda v : IntOrTuple .int ( v ) )
1421- converter (TupleInt , IntOrTuple , lambda v : IntOrTuple .tuple ( v ) )
1420+ converter (Int , IntOrTuple , IntOrTuple .int )
1421+ converter (TupleInt , IntOrTuple , IntOrTuple .tuple )
14221422
14231423
14241424class OptionalIntOrTuple (Expr , ruleset = array_api_ruleset ):
@@ -1429,7 +1429,7 @@ def some(cls, value: IntOrTuple) -> OptionalIntOrTuple: ...
14291429
14301430
14311431converter (type (None ), OptionalIntOrTuple , lambda _ : OptionalIntOrTuple .none )
1432- converter (IntOrTuple , OptionalIntOrTuple , lambda v : OptionalIntOrTuple .some ( v ) )
1432+ converter (IntOrTuple , OptionalIntOrTuple , OptionalIntOrTuple .some )
14331433
14341434
14351435@function
0 commit comments